Notes on gfortran

-C

Almost every Fortran compiler has a debugging option for run-time array-bounds checking, which does useful checks at the expense of often considerable performance loss, so it should not be used in production versions of code. Almost every Fortran compiler enables this with the option -C. With gfortran, -C affects how the preprocessor treats certain comments. The option for array bounds checking is -fcheck=bounds.

Module File Versioning

gfortran is an increasingly mature and useful member of the Gnu Compiler Collection. Like most other compilers, it is fairly conservative about changing its ABI: object files and libraries compiled with one version of gfortran generally work fine with any newer version.

However, it is far from conservative about changing the format of the module files it produces. It changes them on every major release. An imcomplete list of compiler version numbers against modulr file version numbers is:

4.3.2unversioned
4.5.14
4.6.36
4.7.0pre8
4.7.19
4.8.110

This becomes an issue if one attempts to have a central installation of a library and associated module files used by a selection of clients using different versions of gfortran. The C or C++ analogue of library with associated header file will work fine, as the header file may depend on the library version, but not on the compiler version. With gfortran one is liable to see errors such as:

hello.mpi.f90:3.6:

  use mpi
      1
Fatal Error: Cannot read module file 'mpi.mod' opened at (1),
because it was created by a different version of GNU Fortran

One needs to ensure that the module file is created with the same version of the compiler that is being used for the compilation which includes it.


Back to MJR's software page.