Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fortran language support for Visual Studio Code

License

NotificationsYou must be signed in to change notification settings

fortran-lang/vscode-fortran-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Visual Studio Marketplace DownloadsVisual Studio Marketplace InstallsGitHub Workflow StatusVisual Studio Marketplace Version (including pre-releases)GitHub

Key Features

Get Started & Seek Support

Useful Tools

Language Server integration

The Fortran Language Serverfortls is responsiblefor 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 forfortls to be automatically installed withpip orAnaconda andif the location wherefortls is installed is not in yourPATH point VS Codeto thefortls location by setting

{"fortran.fortls.path":"/custom/path/to/fortls"}

For more about the Language Server's capabilities please refer to thedocumentation offortls.

Linting

Linting allows for compiler error and warning detection while codingwithout the user having to compile.

VendorCompiler
GNUgfortran
Intelifort,ifx
NAGnagfor

Using an invalid if expression

alt

Using incorrect type and rank as function argument

alt

📝️ NoteSave your file to generate linting results

Linting results can be improved by providing additional options to the compiler.

Including directories

You can control the include paths to be used by the linter with thefortran.linter.includePaths option.

❗️ ImportantFor the best linting resultslinter.includePaths should match the included paths for your project's compilation.
{"fortran.linter.includePaths": ["/usr/include/**","${workspaceFolder}/include/**"]}
❗️ ImportantIf 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).

Changing linting compiler

By default, the linter used isgfortran, Intel'sifort and Intel's LLVM based compilerifx are also supported.One can use a different linter compiler via the option

{"fortran.linter.compiler":"ifort"|"gfortran"|"ifx"|"Disabled"}

The linter executable is assumed to be found in thePATH.In order to use a different executable or if the executable can't be found in thePATHyou can point the extension to another linter with thefortran.linter.compilerPath option.

{"fortran.linter.compilerPath":"/opt/oneapi/compiler/2022.0.2/linux/bin/intel64/ifort"}

Debugging

alt

The extension uses the debugger from Microsoft'sC/C++ extensionfor Visual Studio Code. This allows this extension to use the full functionalityof the C/C++ extension for debugging applications:(un)conditional breaking points, expression evaluation, multithreaded debugging,call stack, stepping, watch window.

A minimallaunch.json script, responsible for controlling the debugger, isprovided below. However, Visual Studio Code is also capable of autogeneratingalaunch.json file and the configurations inside the file.

More details about how to set up the debugger can be found in Microsoft's website:

Example: 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}/a.out","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,        },      ],    },  ],}

Formatting

Two formatters are supportedfindentandfprettify. Both of them can beinstalled withpip automatically through the extension.

Demo: formatters in action
findentfprettify
altalt

The formatter is controlled by the user option

{"fortran.formatting.formatter":"findent"|"fprettify"|"Disabled"}

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 tryfindent -h orfprettify -hin a terminal.

If the formatter is not present in thePATH its location can be input with

{"fortran.formatting.path":"./custom/path/venv/bin"}
📝️ Notefindent can also be used to generate dependency files for a project.

Fortran Package Manager

Validation offpm.toml

Autocompletion and options validation forfpm.toml files are provided by theinstalling theEven Better TOML Visual Studio Code extension.

fpm-validation

Snippets

Snippets are included by bothfortls Language Server and the Modern Fortran VS Code extension.Some available snippets can be seen below. Users can define their own snippetsby following these VS Codeinstructions.

If you think a snippet should be shipped by with the extension feel free tosubmit afeature request

Demo: snippets in action

program snippetmodule snippet

Advanced options

To show the symbols in the file outline enableprovide.symbols. Symbols can beserved by the fortls, the built-in, both or none. By defaultfortls is used.

{"fortran.provide.symbols":"fortls"|"Built-in"|"Both"|"Disable"}

You can also configure the case for fortran intrinsics auto-complete by using

{"fortran.preferredCase":"lowercase"|"uppercase"}

Requirements

For debugging you need to have one of the following debuggers installed:

  • Linux: GDB
  • macOS: GDB or LLDB
  • Windows: GDB or Visual Studio Windows Debugger

Contributing

Support Us

You can support further development of the extension by fiscal donations:

to ourLFortan project on NumFOCUS

Or

directly sponsoring developers throughGitHub Sponsors

Sponsor this project

    Packages

    No packages published

    Contributors18


    [8]ページ先頭

    ©2009-2025 Movatter.jp