1 gfortran hello.f90
2 ./a
1 将代码编译为可执行文件,不特别设置一般为a.exe
2 运行a.exe
1 gfortran -o hello hello.f90 hello1.f90
2 ./hello
1 将hello.f90文件和hello1.f90文件编译为名为hello.exe的可执行文件,也可只编译一个文件
2 运行hello.exe
PS:
launch.json文件和tasks.json文件内容如下,参数意义可参考视频:VS Code for Fortran Ep.3: Automated Build Process
launch.json文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Fortran",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
"args": [], // Possible input args for a.out
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Fortran: gfortran.exe 生成活动文件"
}
]
}
tasks.json文件
{
"version": "2.0.0",
"tasks": [
{
//"type": "cppbuild",
"label": "Fortran: gfortran.exe 生成活动文件",
"command": "gfortran.exe",
"args": [
"-g",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "编译器: gfortran.exe"
}
]
}






"editor.rulers": [132],
"workbench.colorCustomizations": {
"editorRuler.foreground": "#458cff"

