Checking ability of compilers to detect uninitialised variables

April 8, 2025 ยท View on GitHub

The program uninit_test.f90 contains a number of simple subroutines that check for various fortran compilers ability to detect uninitialised variables.

With gfortran use -ffpe-trap=zero,overflow,invalid -finit-real=snan -finit-derived

With Intel compilers (ifort and ifx) use -check all -init=snan -init=array

Derived types with allocation in subroutines match the style of CABLE code in the UM. ACCESS ESM1.5/6 uses pointers (case 14) while ACCESS-AM3 uses a mixture of pointers and allocatable components (cases 14 & 16).

In the table an X indicates that an error was raised.

Casegfortran 14.2ifort 2021.10.0ifx 2025.0.4
1: Scalar in mainXXX
2: Static array in mainXXX
3: Allocatable array in main_XX
4: Pointer array in main_X_
5: Local scalar in a subroutineXXX
6: Module scalarXXX
7: Automatic array in subroutineXXX
8: Array in subroutine with dimension from module parameterXXX
9: Static module arrayXXX
10: Allocatable module array_XX
11: Pointer module array_X_
12: Scalar component of a derived typeX__
13: Pointer array component of derived type_X_
14: Pointer array component of derived type (alloc in subroutine)___
15: Allocatable array component of derived type_XX
16: Allocatable array component of derived type (alloc in subroutine)__X