Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28579 Discussions

Visual Studio Code support with Modern Fortran

Ron_Green
Moderator
11,383 Views

A Note About This Article

This article describes interesting technologies from the larger Fortran community. We have to note that the tools described below are not officially supported by Intel. We are providing this information for those who are interested in third-party tools available online that support the Intel Fortran compiler but are not produced or supported by Intel.

 

What Is This?

Visual studio code is an editor and integrated development environment (IDE). It is available for Windows, Linux, and macOS. This tool supports extensions to add capabilites. Extensions are available from the Microsoft Visual Studio Code Marketplace and can be added directly from the within the GUI. Extensions include support for multiple languages along with other editing, linting, and source analysis tools useful for programmers.

 

 

Modern Fortran is an extension to provide modern Fortran language support in VS Code. You can read about Modern Fortran's v3.1.0 release here.

In addition to Modern Fortran, other extensions add additional Fortran aware capabilities to VS Code:
fortls - Native Language Server integration
FORTRAN Intellisense - similar capabilities to IntelliSense in Visual Studio
Fortran Breakpoint Support - debugger breakpoint support

The Intel Fortran compilers for oneAPI, both ifort and ifx, are supported in this environment.   Other features:

Key Features

For my macBook Pro I used a handy guide to installation videos:
VS Code on macOS for C, C++, and Fortran Part 1
VS Code on macOS for C, C++, and Fortran Part 2

These are helpful since macOS requires manually installing  xcode command line tools, Homebrew, gcc, gfortran, python3, and the fortls mentioned above. Windows and Linux I think are much easier to setup. Perhaps others can contribute links for each of Windows and Linux.

 

References

Here is a link to the Modern Fortran homepage.

You can find Modern Fortran in the Microsoft Marketplace for Visual Studio Code

 

Intel has some support for Intel(R) oneAPI with VS Code.  This includes a sample browser for code samples in Sycl or Data Parallel C++.  Nothing specifically for Fortran.  Here is the link

7 Replies
FortranFan
Honored Contributor II
11,343 Views

@Ron_Green,

Kudos for this post.

Visual Studio Code continues to be more and more important to the development of computational technologies and solutions in the industry with each passing quarter.

Extensions such as the Modern Fortran tooling for VS Code are extremely valuable.  We would like to find the Modern Fortran tooling continuing to advance and evolve with VS Code and be maintained well.   Formal support of some kind to such tooling from Intel will be most welcome and it can be a win-win for the Community as well as Intel as it can prove a strategically beneficial move to further boost the Fortran toolkit in Intel oneAPI.

Can you suggest if there are any options to convince Intel to officially support Modern Fortran tooling in VS Code, say dedicate some stuff and funding to enhance the effort?

Muneer
Novice
11,111 Views

Language Server integration

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.

van_der_merwe__ben
New Contributor I
10,220 Views

I have also used Visual Studio code. What is nice about it, is that it can handle massive solutions with intellisense while remaining fully responsive. Using a project compiled using Visual C++ and Intel Fortran Classic, I am using the Fortran Intellisense and Modern Fortran extensions.  Modern Fortran is definitely a good product. A couple of issues to be aware of:

- The CALL STACK does not show any Fortran methods. It does show the Fortran file and line number in the file.

- The WATCH window only sometimes works. But you can see variables if you expand the VARIABLES section and scroll down to the variable.

van_der_merwe__ben_0-1665078695530.png

- No data breakpoints! ARG! Not even for Microsoft's C/C++ extension. Sometimes you seriously need data breakpoints...

 

thomasx
Beginner
9,919 Views

I'm learning VB. I'm manually trying to change the colors of functions to improve readability according to my requirements. It's working fine but when I open new file then settings goes back to default settings. Please suggest me the exact solution.  

FireShot Capture 030 - How to Change Text Color in Visual Studio Code in 2022 - VSCode Synta_ - www.youtube.com.png

jimdempseyatthecove
Honored Contributor III
9,915 Views

>> No data breakpoints! ARG!

 

Data breakpoints are made using Fortran.

 

1) place a code breakpoint prior to when you wish to observe the data breakpoint. For example at the start of the procedure.

2) Run up to break point

3) Open the breakpoints window:  Debug | Windows | Breakpoints

4) Pulldown New, click on data breakpoint

5) Enter: loc(yourVariableNameNere)

6) Continue

 

Jim Dempsey

JohnNichols
Valued Contributor III
9,908 Views

Screenshot 2022-10-19 104942.png

You might want to add error checking to the allocates. 

jimdempseyatthecove
Honored Contributor III
9,908 Views

Additional notes on data breakpoints.

This should be obvious ...

 

Should you place a data breakpoint on a local variable (iow stack), and exit the procedure with that/those breakpoints active, those addresses are still live breakpoints. IOW remember to disable those breakpoints. This is a similar behavior to having a watch window referencing a variable that is out of scope.

 

Jim Dempsey

0 Kudos
Reply