Visual Studio Code作为微软出品的轻量级编辑器,用来写写算法和有限元作业是再合适不过的了
安装 MINGW-W64
在windows下安装完成后需要设置环境变量
C:\mingw64\bin
安装 Visual Studio Code 扩展
查看>扩展,搜索安装以下扩展
-
Gimly81.fortran
fortran 语言支持及 fortran 文件代码高亮
![](https://img.haomeiwen.com/i11246265/b8e802e72774daff.png)
-
ms-vscode.cpptools
微软官方的C/C++的gdb debugger,也可以用来调试fortran
![](https://img.haomeiwen.com/i11246265/9223f6759872858d.png)
-
ekibun.fortranbreaker
为 fortran 文件增加调试断点支持
![](https://img.haomeiwen.com/i11246265/56afcee9dc0e37bf.png)
配置 Fortran 调试环境
- 文件>打开文件夹,选择项目路径
- 新建
.vscode
文件夹 - 创建
launch.json
启动配置文件
{
"version": "0.0.1",
"configurations": [
{
"name": "Fortran Launch (GDB)",
"type": "cppdbg",
"request": "launch",
"targetArchitecture": "x86",
"program": "${workspaceRoot}\\${fileBasenameNoExtension}.exe",
"miDebuggerPath": "gdb.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": true,
"preLaunchTask": "gfortran"
}
]
}
- 创建
tasks.json
配置文件
{
"version": "0.0.1",
"command": "gfortran",
"args": [
"-g",
"${file}",
"-o",
"${workspaceRoot}\\${fileBasenameNoExtension}.exe"
]
}
- 在项目根目录新建
.for
文件,至此文件目录如下
![](https://img.haomeiwen.com/i11246265/9ff8e4cbc876ed96.png)
- 编写代码,调试>启动调试
![](https://img.haomeiwen.com/i11246265/1420da357c519c1b.png)
以上
网友评论
{
"version": "2.0.0",
"configurations": [
和
"type": "cppdbg",
"request": "launch",
这两段代码没有显示高亮,请问如何解决