Specifying compilers for GEOS-Chem
Previous | Next | Getting Started with GEOS-Chem
- Minimum system requirements
- Configuring your computational environment
- Specifying the compiler
- Specifying libraries
- Specifying parallelization settings
- A sample initialization script
- Downloading source code
- Downloading data directories
- Creating run directories
- Configuring runs
- Output files
- Visualizing and processing output
- Coding and debugging
- Further reading
- 1 Selecting the compiler
- 2 Defining the proper environment variables
Selecting the compiler
There are typically several ways in which you can select the compiler that you wish to use with GEOS-Chem. Not all of these may be present on your system, so it is always best to ask your IT staff about the method that your system uses.
Using Lmod modules
Many computational clusters use the Lmod module system to allow you to pick and choose different pre-compiled software programs and libraries. Lmod makes it easy to switch between different compiler versions, if more than compiler has been installed. Check with your IT staff if your system uses the Lmod module command.
If your system uses Lmod, then you can load the compiler with commands such as:
module load intel/19.0
module load gcc/9.2.0
... etc ...
(Actual commands will vary from system to system.)
You can typically place these module load commands in your .bashrc or .bash_aliases startup scripts. Ask your IT staff where they would prefer them to be placed.
When a module is "loaded", the following things typically happen:
- The path to the compiler executable is added to your Unix $PATH variable.
- The path to the compiler library files is added to your $LD_LIBRARY_PATH environment variable.
- One or more environment variables (e.g. $INTEL_HOME, $GCC_HOME) are added to your Unix environment.
If you are using a compiler that was built with the Spack package manager, then you can use the spack load command in a manner similar to that of the Lmod module load command described above.
For example, if you have built the gcc/gfortran compilers version 9.2.0 with Spack, then this may be loaded into your environment with:
spack load firstname.lastname@example.org
where the @9.2.0 describes the version number.
--Bob Yantosca (talk) 22:06, 17 December 2019 (UTC)
Defining the proper environment variables
After you have specified a compiler to use with GEOS-Chem, you must set a few Unix environment variables. These definitions can be placed in the same startup script (usually .bashrc or .bash-aliases) as the commands that load the compiler.
Unix environment variables for compilers
It is a Unix convention to use the following environment variable names for compilers:
|FC||Name of the Fortran compiler|
|CC||Name of the C compiler|
|CXX||Name of the C++ compiler|
In most cases, the Fortran, C, and C++ compilers are installed together as a integrated package. Often, using the module load command will load all three compilers into your Unix environment together. If you are using GEOS-Chem "Classic" then you really only need the Fortran compiler. But other software packages on your system will use the C and/or C++ compilers.
--Bob Yantosca (talk) 21:41, 17 December 2019 (UTC)
Check if compiler environment variables have been automatically set
On many systems (espcially those using the Lmod module system), FC, CC, and CXX will be set automatically for you when you use the module load command. The easiest way to check if these variables have been automatically set for you is to print them to the screen. Type at the Unix prompt:
echo $FC echo $CC echo $CXX
If these variables are all blank, then you must define these manually (see next section). If they are NOT blank, then you are all set!
--Bob Yantosca (talk) 21:42, 17 December 2019 (UTC)
Manually defining compiler environment variables
If the FC, CC, and CXX environment variables are all undefined, then you will have to manually set them in your startup script as described below:
|use these definitions|
|ifort||setenv FC ifort|
setenv CC icc
setenv CXX icpc
|gfortran||setenv FC gfortran|
setenv CC gcc
setenv CXX g++
Then make sure to type:
source ~/.bashrc # if you are using bash source ~/.cshrc # if you are using csh or tcsh
to apply the changes.
--Bob Yantosca (talk) 21:38, 17 December 2019 (UTC)