Fortran
Fortran has played a central role in meteorology for decades due to its efficiency in numerical computation and array handling. Many legacy and modern weather models, data assimilation systems, and climate simulations are written in Fortran, making it a foundational language for scientific computing in atmospheric sciences. Its performance and portability continue to make it a preferred choice for high-performance computing tasks in meteorology.
Coding
Most often codes are written in Python or Fortran. Here some information is given on Fortran.
Have a look at Debugging
Fortran
Fortran is quite popular in Meteorology and Geophysics. Please find some help on solving common problems.
Get some information on Fortran: - Fortran Language, Learning, Compilers
Compilers
There are a few compilers, but most commonly GNU (Gfortran) and INTEL (ifort) are used on our servers.
GNU Fortran | INTEL Fortran | |
---|---|---|
double Fprecision real | -fdefault-real-8 |
-r8 |
check array bounds | -fbounds-check |
-check |
call chain traceback | -fbacktrace |
-traceback |
convert little/big endian | -fconvert=big-endian/little-endian |
-convert big_endian/little_endian |
default optimisation | -O0 |
-O2 |
highest recommended optimisation | -O3 |
-O2 maybe -O3 or -fast |
position independent code (shared) | -fPIC |
-fPIC |
Please take a look into the compiler options guidelines from AMD or Intel, which might be very helpful for finding the right compiler flags for certain CPUs
- Servers such as Aurora AMD EPYC ZEN3 compiler quick reference
- Servers such as VSC5, LUMI, ... AMD EPYC ZEN4 compiler quick reference
- Servers such as SRVX1, JET, VSC4 Intel compiler quick reference
more information on how to find good options can be found on the PRACE (Partnership for advanced computing in Europe) website
Generating optimized code for a certain processor
All compiler providers have special options that have optimizations for certain processors, especially intel.
Processor Type | System | Flag (intel) | Flag (gcc) |
---|---|---|---|
Cascade Lake | VSC5 | -xCORE-AVX512 |
-march=cascadelake |
Skylake | JET, SRVX1, VSC4 | -xCORE-AVX512 |
-march=skylake |
Broadwell | SRVX8 | -xCORE-AVX2 |
-march=broadwell |
Sandy Bridge | DEVx1 | -xAVX |
-march=sandybridge |
Milan | VSC5, Aurora | -xCORE-AVX2 |
-march=znver3 |
Generic x64 | containers | -xCORE-AVX2 |
-march=x86-64-v4 |
GCC/GFortran processor compiler flags
Intel Compiler
from P. Seibert using ifort for the fastest code (srvx1):
Makefile | |
---|---|
1 2 3 4 5 6 |
|
Remark: The above flags and libraries (such as grib_api
, jasper
, and mcmodel=medium
) are specifically needed when compiling FLEXPART, an atmospheric particle dispersion model. For other Fortran projects, these may not be required.
Learn more about FLEXPART here.
Tricky Issues
record markers
On 64-bit machines, some Fortran compilers will insert record markers that are 64-bit integers instead of the standard 32-bit integers.
gfortran man page says:
Text Only | |
---|---|
1 2 |
|
Code Testing
pFUnit - Python Parallel Fortran Unit Testing Framework GitHub