CLion 2022.1 Help

Fortran

CLion supports Fortran via the Fortran plugin. The plugin provides language support and debugger for FORTRAN 77/90/95/2003/2008. Application support is provided by CMake.

Start a Fortran project in CLion

  1. Install the Fortran compiler. You can use GNU Fortran compiler included in the GCC installation or another Fortran compilers of your choice.

  2. Install the Fortran plugin either directly from the Plugin Repository page or from CLion: go to Settings / Preferences | Plugins, switch to Marketplace and type Fortran in the search field, then click Install in the plugin description dialog.

  3. Create a new Fortran executable project (File | New Project) or open an existing CMake-based Fortran project.

Working with Fortran code

In addition to parsing and highlighting your Fortran code, the plugin provides other code insight features, for example:

  • Code editing: Add Line Comment Ctrl+/, Code folding, Brace matching, and Formatting (currently available only for free source form files)

    Code styles for Fortran
  • Navigation actions: Go to Definition, Structure view, and Find Usages

    Find Usages for Fortran
  • Code analysis: a set of useful code inspections to catch potential errors

    Code inspections for Fortran

Running and debugging

  1. To run and debug Fortran code, create a CMake Application configuration (go to Run | Edit Configurations, press plus and select CMake Application).

    CMake run/debug configuration for Fortran
  2. In the toolchain settings (Settings / Preferences | Build, Execution, Deployment | Toolchain), switch to GDB in the Debugger field.

  3. RunApp actions execute or DebugApp actions start debugger the newly created configuration:

    Debugging Fortran
Last modified: 25 July 2022