Fortran module file format
The Fortran standard does not define a specific Fortran module file format. Each compiler vendor has a unique incompatible Fortran module file format. Fortran module files are not portable between different compilers or even different versions of the same compiler.
LLVM Flang
The LLVM Flang .mod files generated are legal Fortran syntax – they are text files. The .mod format gives the version number, which may be seen like:
head -n1 <moduleName>.modThe output starts like:
!mod$ v1
GNU Fortran (GFortran)
The GFortran header version is defined in module.cc as variable “MOD_VERSION”. GNU Fortran “gfortran” .mod files are GZIP and is not documented
| GCC version | module file version |
|---|---|
| 15.x | 16 |
| 8.x - 14.x | 15 |
| 5.1.0 | 14 |
| 4.9.2 | 12 |
| 4.8.1 | 10 |
| 4.7.1 | 9 |
Examine Gfortran .mod file header like:
gunzip -c <moduleName>.mod | head -n1The output starts like:
GFORTRAN module version ‘15’ created from …
Intel oneAPI (ifx)
Intel oneAPI .mod files are a proprietary binary format. It is possible to determine the version of the .mod file by using od to look at the first 2 bytes of the .mod file.
od -An -N4 -d <moduleName>.modThe first number is like “13” and is the module format version. This version may change over time as oneAPI internals change. The second number is the update version, which is fixed at “1”.
There is an undocumented “ifx” compiler option -switch:fe_module_dump that outputs the module and submodule data in text format.
NVHPC and AOCC
NVIDIA HPC SDK (NVHPC) and AOCC compilers generate .mod files that are text files. The format for legacy Flang module files is distinct from LLVMFlang Fortran module files.
The .mod file is a text file, beginning with the version number.
head -n1 <moduleName>.modThe output is like:
V34 :0x24 dummy
Cray Fortran
By default, Cray Fortran stores uppercase DUMMY.mod filenames.
This can be made lowercase with the ftn -ef flag.
The
Cray Fortran .mod format
is proprietary, but the version number might be seen like:
head -n2 <moduleName>.modRelated: Fortran submodule file naming