Fortran support in Code::Blocks

From CodeBlocks
Revision as of 06:23, 4 April 2015 by Briedis (Talk | contribs) (Setting up Fortran projects)

Jump to: navigation, search

Presently Code::Blocks IDE has support not only for C/C++ but for Fortran also. Features of Code::Blocks useful for Fortran:

  • Editor with syntax highlighting for fixed and free Fortran source code
  • Support for GFortran and PGI Fortran compilers. Other Fortran compilers can be added by users too. “Support for compiler” means: (a) the graphical interface for the options of the compiler and (b) catching of compilation errors and warnings and jumping to the corresponding code line
  • During the compilation Code::Blocks cares about the dependencies between Fortran files in the project (it is important when Fortran modules are used)
  • Symbol browser with program units and variables defined in Fortran files
  • Code-completion
  • Call-tips
  • and some more.

Most of the functionality useful for Fortran is implemented through FortranProject plugin. More information about the use of Code::Blocks with Fortran can be found here here.


For troubleshooting enable the "Full command line" Under menu "Settings" -> "Compiler" -> "Other" tab, "Compiler logging". If you see that still the gcc compiler is invoked, make sure you setup the right compiler in the build options for your project AND your target (e.g. "default").

Using gfortran instead of g77

The preceding steps can also be used to set up Code::Blocks to use the GNU gfortran Fortran '95 compiler, albeit with the following changes:

  • Setup the compiler as follows:

1.) The "Compiler's installation directory" should point to the location of the root directory of the gfortran installation, for example if gfortran.exe is located in C:\gfortran\bin the path should read "C:\gfortran" (minus quotes).

2.) Under the "Programs" tab, select "gfortran.exe" as both the C compiler and the linker for dynamic libs instead of "g77.exe"

3.) DO NOT add the linker commands as given previously; leave these fields blank.

  • Adding new Fortran file type

Proceed as above, but add "*.f95" as a file type instead of "*.f77".

Follow the rest of the steps above and gfortran should work.

See also