fortls
gfortran
, Intel's ifort
, ifx
, NAG's nagfor
The Fortran Language Server fortls
is responsible for providing a lot of the higher level, IDE functionality. By default, Modern Fortran
will attempt to use it for hover, autocompletion, symbols and Go to & Peeking into definitions.
Allow for fortls
to be automatically installed with pip
or Anaconda
and if the location where fortls
is installed is not in your PATH
point VS Code to the fortls
location by setting
{ "fortran.fortls.path": "/custom/path/to/fortls" }
For more about the Language Server's capabilities please refer to the documentation of fortls
.
Linting allows for compiler error and warning detection while coding without the user having to compile.
Vendor Compiler GNUgfortran
Intel ifort
, ifx
NAG nagfor
Using an invalid if expression
Using incorrect type and rank as function argument
📝️ Note Save your file to generate linting resultsLinting results can be improved by providing additional options to the compiler.
You can control the include paths to be used by the linter with the fortran.linter.includePaths
option.
linter.includePaths
should match the included paths for your project's compilation.
{ "fortran.linter.includePaths": ["/usr/include/**", "${workspaceFolder}/include/**"] }❗️ Important If a glob pattern is used only directories matching the pattern will be included Additional linting options
More options can be passed to the linter via
{ "fortran.linter.extraArgs": [ "-fdefault-real-8", "-fdefault-double-8", "-Wunused-variable", "-Wunused-dummy-argument" ] }
Default value is -Wall
(or -warn all
for ifort).
By default, the linter used is gfortran
, Intel's ifort
and Intel's LLVM based compiler ifx
are also supported. One can use a different linter compiler via the option
The linter executable is assumed to be found in the PATH
. In order to use a different executable or if the executable can't be found in the PATH
you can point the extension to another linter with the fortran.linter.compilerPath
option.
{ "fortran.linter.compilerPath": "/opt/oneapi/compiler/2022.0.2/linux/bin/intel64/ifort" }
The extension uses the debugger from Microsoft's C/C++ extension for Visual Studio Code. This allows this extension to use the full functionality of the C/C++ extension for debugging applications: (un)conditional breaking points, expression evaluation, multithreaded debugging, call stack, stepping, watch window.
A minimal launch.json
script, responsible for controlling the debugger, is provided below. However, Visual Studio Code is also capable of autogenerating a launch.json
file and the configurations inside the file.
More details about how to set up the debugger can be found in Microsoft's website:
Two formatters are supported findent
and fprettify
. Both of them can be installed with pip
automatically through the extension.
The formatter is controlled by the user option
Additional arguments to the formatter can be input using
{ "fortran.formatting.findentArgs": ["-Cn", "-Rr"], "fortran.formatting.fprettifyArgs": ["--whitespace-comma", "--enable-decl"] }
To check all available arguments to formatters try findent -h
or fprettify -h
in a terminal.
If the formatter is not present in the PATH
its location can be input with
{ "fortran.formatting.path": "./custom/path/venv/bin" }📝️ Note
findent
can also be used to generate dependency files for a project.
Autocompletion and options validation for fpm.toml
files are provided by the installing the Even Better TOML Visual Studio Code extension.
Snippets are included by both fortls
Language Server and the Modern Fortran VS Code extension. Some available snippets can be seen below. Users can define their own snippets by following these VS Code instructions.
If you think a snippet should be shipped by with the extension feel free to submit a feature request
Demo: snippets in actionTo show the symbols in the file outline enable provide.symbols
. Symbols can be served by the fortls, the built-in, both or none. By default fortls
is used.
You can also configure the case for fortran intrinsics auto-complete by using
For debugging you need to have one of the following debuggers installed:
You can support further development of the extension by fiscal donations:
to our LFortan project on NumFOCUS
Or
directly sponsoring developers through GitHub Sponsors
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4