VsCode Fortran开发环境配置

VsCode Fortran Settings

Modern Fortran [Miguel Carvajal]

Fortran highlight plugin.

C/C++ for Visual Studio Code [Microsoft]

C/C++ debug plugin also supports fortran.

Toggle debug and modify the example launch.json and tasks.json files.

Makefile Tools [Microsoft, optional]

You can set make command in tasks.json or use this plugin to compile make project.

// vscode settings
{
	"makefile.launchConfigurations": [
		{
			"cwd": "/home/user/project",
			"binaryPath": "/home/user/project/bin/program",
			"binaryArgs": []
		}
	]
}

Here is a example for C/C++ make project.

Directory tree

- bin
-- main
- src
-- main.cpp
-- module.cpp
-- header.h
- Makefile

Makefile

LINK    = @echo linking $@ && g++
GCC     = @echo compiling $@ && g++
GC      = @echo compiling $@ && gcc
AR      = @echo generating static library $@ && ar crv
FLAGS   = -g -DDEBUG -W -Wall -fPIC
GCCFLAGS =
DEFINES =
HEADER  = -I./
LIBS    =
LINKFLAGS =

BIN_PATH = bin
SRC = $(wildcard src/*.cpp)
INCLUDES = include
TARGET = main
OBJECT = $(SRC:%.cpp=%.o)

.SUFFIXES: .cpp .c
.cpp.o:
	$(GCC) -c $(HEADER) $(FLAGS) $(GCCFLAGS) -fpermissive -o $@ $<

.c.o:
	$(GC) -c $(HEADER) $(FLAGS) -fpermissive -o $@ $<

$(TARGET) : $(OBJECT)
	@echo "============开始编译============"
	$(LINK) $(FLAGS) $(LINKFLAGS) -o $@ $^ $(LIBS)
	mv $(TARGET) $(BIN_PATH)
	@echo "============编译结束============"

clean:
	rm -rf $(OBJECT) $(TARGET)

FORTRAN IntelliSense (Chris Hansen)

Install fortran-language-server and create .fortls file if you need to modify the default configuration.

pip install fortran-language-server

An example of .fortls to add external source of hdf5 libs.

{
	"ext_source_dirs": ["/home/user/hdf5/fortran/src"],
	"debug_log": true
}

fprettify (Blamsoft)

Fortran code formatter.

pip install --upgrade fprettify

Integrating with VsCode, modify in your need:

// VsCode settings
{
	"fprettify.arguments": "-i 4 --case 1 1 1 2"
}

作者:PorYoung
原文地址:https://blog.poryoung.cn/?p=1190
发布时间:2021年3月22

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值