目录架构
--.vscode
-launch.json
-tasks.json
--hello_fort.for
--f_print.for
hello_fort.for
program main
integer(8):: i,num
call print('hello, world!')
num = 10
do i=1,num
write(*,*) i
enddo
call print('end')
end program
f_print.for
subroutine print(msg)
character(*) msg
write(*,*) msg
end subroutine
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) debug hello_fort",
"preLaunchTask": "make build", //在launch之前运行的任务,对应tasks.json中的任务
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/hello_fort", //需要运行的可执行文件
"args": [], //命令行参数
"stopAtEntry": false, // 选为true则会在打开控制台后停滞,暂时不执行程序
"cwd": "${workspaceFolder}", // 当前工作路径
"environment": [],
"externalConsole": false, // 是否使用外部控制台
"MIMode": "gdb",
"miDebuggerPath": "D:\\softwares\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json
{
"version": "2.0.0",
"tasks": [
{ // 可以通过ctrl+shift+P, Tasks:Run Task 调用任务
"label": "build",
"type": "shell",
"command": "gfortran",
"args": [
"-g",
"f_print.for",
"hello_fort.for",
"-o",
"hello_fort"
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": false
}
},
{
"label": "clean",
"type": "shell",
"command": "rm -f *.o hello_fort",
"problemMatcher": []
},
{
"label": "make build",
"type": "shell",
"command": "mingw32-make ",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true // 可以用ctrl+shift+B快捷调用默认的构建任务
}
}
]
}