William.Hatheway
Active member
The recent releases of Ubuntu 22 and Ubuntu 23 by Canonical introduced several changes to their base operating system, including significant updates to the GNU Compiler Collection (GCC). Specifically, these versions have been upgraded to GCC 11 and GCC 12, respectively.
A noteworthy aspect of this update is its impact on legacy Fortran code compatibility. GCC versions greater than 9 have deprecated certain antiquated Fortran commands, resulting in compatibility issues during the installation of the Weather Research and Forecasting (WRF) model. This is due to the default disabling of older code syntaxes in these newer GCC versions, which leads to errors.
To address this and ensure compatibility with legacy Fortran code while compiling libraries for WRF, WPS, and other related software, it is necessary to set specific environment variables before the compilation process. These variables enable the older Fortran code syntaxes. The required environment variables and their values are as follows:
These commands enable the compiler to accept argument mismatches and invalid BOZ literal constants, which are common in older Fortran codes. Detailed documentation and explanations of these compiler options can be found in the GCC online documentation, particularly in the section dedicated to Fortran Dialect Options: Fortran Dialect Options (The GNU Fortran Compiler)
It is important to note that while the
flag in GCC can also be used to enable legacy Fortran code compatibility, its usage might lead to additional complications. This flag sets the compiler to accept all legacy Fortran code, but it might inadvertently allow code practices that are incompatible with modern Fortran standards, potentially leading to unforeseen issues.
By following these guidelines and carefully setting the environment variables, developers and researchers can ensure smooth compilation and execution of WRF and other Fortran-based applications on the latest Ubuntu releases. This approach maintains compatibility with legacy codes while leveraging the advancements of the newer GCC versions.
A noteworthy aspect of this update is its impact on legacy Fortran code compatibility. GCC versions greater than 9 have deprecated certain antiquated Fortran commands, resulting in compatibility issues during the installation of the Weather Research and Forecasting (WRF) model. This is due to the default disabling of older code syntaxes in these newer GCC versions, which leads to errors.
To address this and ensure compatibility with legacy Fortran code while compiling libraries for WRF, WPS, and other related software, it is necessary to set specific environment variables before the compilation process. These variables enable the older Fortran code syntaxes. The required environment variables and their values are as follows:
Bash:
export fallow_argument=-fallow-argument-mismatch
export boz_argument=-fallow-invalid-boz
export FFLAGS="$fallow_argument $boz_argument -m64"
export FCFLAGS="$fallow_argument $boz_argument -m64"
These commands enable the compiler to accept argument mismatches and invalid BOZ literal constants, which are common in older Fortran codes. Detailed documentation and explanations of these compiler options can be found in the GCC online documentation, particularly in the section dedicated to Fortran Dialect Options: Fortran Dialect Options (The GNU Fortran Compiler)
It is important to note that while the
Bash:
-std=legacy
By following these guidelines and carefully setting the environment variables, developers and researchers can ensure smooth compilation and execution of WRF and other Fortran-based applications on the latest Ubuntu releases. This approach maintains compatibility with legacy codes while leveraging the advancements of the newer GCC versions.