Difference between revisions of "Specifying compilers for GEOS-Chem"

From Geos-chem
Jump to: navigation, search
(Using spack)
(Defining the proper environment variables)
Line 56: Line 56:
 
== Defining the proper environment variables ==
 
== Defining the proper environment variables ==
  
TBD
+
After you have specified a compiler to use with GEOS-Chem, you must set a few [https://www.networkworld.com/article/3215965/all-you-need-to-know-about-unix-environment-variables.html Unix environment variables].  These definitions can be placed in the same startup script (usually <tt>.bashrc</tt> or <tt>.bash-aliases</tt>) 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:
 +
 
 +
{| border=1 cellspacing=0 cellpadding=5
 +
|-valign="top" bgcolor="#CCCCCC"
 +
!width="100px"|Variable
 +
!width="600px"|Description
 +
 
 +
|-valign="top"
 +
|<tt>FC</tt> || Name of the Fortran compiler
 +
 
 +
|-valign="top"
 +
|<tt>CC</tt> || Name of the C compiler.<br>''Not needed for GEOS-Chem "Classic", but is needed for GCHP.''
 +
 
 +
|-valign="top"
 +
|<tt>CXX</tt> || Name of the C++ compiler.<br>''Not needed for GEOS-Chem "Classic", but is needed for GCHP.''
 +
 
 +
|}
 +
 
 +
In most cases, the Fortran, C, and C++ compilers come as a integrated package.  Often, using the <tt>module load</tt> command will load all three compilers into your Unix environment together.
 +
 
 +
=== Check if compiler environment variables have been automatically set ===
 +
 
 +
On many systems (espcially those using the Lmod module system), <tt>FC</tt>, <tt>CC</tt>, and <tt>CXX</tt> will be set automatically for you when you use the  <tt>module load</tt> 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 are not blank, then you are all set and can skip the next section.
 +
 
 +
=== Manually defining compiler environment variables ===
 +
 
 +
If the <tt>FC</tt>, <tt>CC</tt>, and <tt>CXX</tt> environment variables are all undefined, then you will have to manually set them in your startup script as described below:
 +
 
 +
{| border=1 cellspacing=0 cellpadding=5
 +
|-valign="top" bgcolor="#CCCCCC"
 +
!width="125px"|If your<br>shell is
 +
!width="125px"|and your<br>compiler is
 +
!width="125px"|add to<br>this file
 +
!width="300px"|the following lines of code
 +
 
 +
|-valign="top"
 +
|<tt>/bin/bash</tt>
 +
|<tt>ifort</tt>
 +
|<tt>.bashrc</tt>
 +
|<tt>export FC=ifort<br>export CC=icc<br>export CXX=icpc</tt>
 +
 
 +
|-valign="top" bgcolor="#CCFFFF"
 +
|<tt>/bin/bash</tt>
 +
|<tt>gfortran</tt>
 +
|<tt>.bashrc</tt>
 +
|<tt>export FC=gfortran<br>export CC=gcc<br>export CXX=g++</tt>
 +
 +
|-valign="top"
 +
|<tt>/bin/csh</tt> or<br><tt>/bin/tcsh</tt>
 +
|<tt>ifort</tt>
 +
|<tt>.cshrc</tt>
 +
|<tt>setenv FC ifort<br>setenv CC icc<br>setenv CXX icpc</tt>
 +
 +
|-valign="top" bgcolor="#CCFFFF"
 +
|<tt>/bin/csh</tt> or<br><tt>/bin/tcsh</tt>
 +
|<tt>gfortran</tt>
 +
|<tt>.cshrc</tt>
 +
|<tt>setenv FC gfortran<br>setenv CC gcc<br>setenv CXX g++</tt>
 +
 
 +
|}
 +
 
 +
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.
 +
 
 +
--[[User:Bmy|Bob Yantosca]] ([[User talk:Bmy|talk]]) 18:47, 9 January 2019 (UTC)
 +
 
  
 
----
 
----
 
'''''[[Configuring your computational environment|Previous]] | [[Specifying software libraries for GEOS-Chem|Next]] | [[Getting Started with GEOS-Chem]]'''''
 
'''''[[Configuring your computational environment|Previous]] | [[Specifying software libraries for GEOS-Chem|Next]] | [[Getting Started with GEOS-Chem]]'''''

Revision as of 21:36, 17 December 2019

Previous | Next | Getting Started with GEOS-Chem

  1. Minimum system requirements
  2. Configuring your computational environment
  3. Downloading source code
  4. Downloading data directories
  5. Creating run directories
  6. Configuring runs
  7. Compiling
  8. Running
  9. Output files
  10. Visualizing and processing output
  11. Coding and debugging
  12. Further reading


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 specifics

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

or

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:

  1. The path to the compiler executable is added to your Unix $PATH variable.
  2. The path to the compiler library files is added to your $LD_LIBRARY_PATH environment variable.
  3. One or more environment variables (e.g. $INTEL_HOME, $GCC_HOME) are added to your Unix environment.

Using spack

TBD

Direct specification

TBD

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:

Variable Description
FC Name of the Fortran compiler
CC Name of the C compiler.
Not needed for GEOS-Chem "Classic", but is needed for GCHP.
CXX Name of the C++ compiler.
Not needed for GEOS-Chem "Classic", but is needed for GCHP.

In most cases, the Fortran, C, and C++ compilers come as a integrated package. Often, using the module load command will load all three compilers into your Unix environment together.

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 are not blank, then you are all set and can skip the next section.

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:

If your
shell is
and your
compiler is
add to
this file
the following lines of code
/bin/bash ifort .bashrc export FC=ifort
export CC=icc
export CXX=icpc
/bin/bash gfortran .bashrc export FC=gfortran
export CC=gcc
export CXX=g++
/bin/csh or
/bin/tcsh
ifort .cshrc setenv FC ifort
setenv CC icc
setenv CXX icpc
/bin/csh or
/bin/tcsh
gfortran .cshrc 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) 18:47, 9 January 2019 (UTC)



Previous | Next | Getting Started with GEOS-Chem