Compiling Geos-Chem

Geos-Chem 8.3.1 and newer

For the new Geos-Chem versions starting with v8-03-01, directory structures have changed quite a bit along with placement of certain files we need to edit. Also, the build command is no longer used as "make" replaces it. This document will describe how to change the compiler options on the newer versions.

Code.v8-03-01 (code directory)
...bin (Directory, Executable location after compilation)
...doc (Directory, Geos-Chem information)
...GeosCore (Directory, Geos-Chem main code files)
...GeosTomas (Directory, Specific routines for TOMAS)
...GeosUtil (Directory, Format modules)
...Headers (Directory, All Header files) (Directory, help information)
...ISOROPIA (Directory, Routines for ISOROPIA)
...KPP (Directory, Routines created by KPP)
...lib (Directory, Contains object files after compilation)
...Makefile (Geos-Chem main make file) (Makefile header information)
...mod (Directory, Contains module files after compilation)
...obsolete (Directory, Subroutines/Module files that are obsolete)
...REVISIONS (Revision information)

Note: A script is being worked on that will completely automate the whole compilation and run process of geoschem. For the time being, this is the process to follow.

First things First

The very first thing you will need to do is edit your ~/.cshrc file to use version 11.1 of the Intel Compiler. Open up this file (nano ~/.cshrc) and edit the following lines.

Instead of this:

# Set variables for Intel Fortran compiler version 11.1
#source /opt/intel/Compiler/11.1/072/bin/ifortvars.csh intel64

# Set variables for Intel Fortran compiler version 10.1
source /opt/intel/fce/10.1.025/bin/ifortvars.csh
# Set variables for Intel Fortran compiler version 11.1
source /opt/intel/Compiler/11.1/072/bin/ifortvars.csh intel64

# Set variables for Intel Fortran compiler version 10.1
#source /opt/intel/fce/10.1.025/bin/ifortvars.csh

As you can see, the only change we are making is to swap the "#" mark from one source line to the other.

NOTE: If you have not yet added the appropriate lines to your ~/.cshrc file from the "Setting Up Your Account for IDL/GEOS-Chem" guide, please go here now to do that.

Source Code Directory

You will need to copy over the appropriate code directory from ctm_tools to get started. I recommend putting the code in its own directory within your run directory (which can also be copied from ctm_tools). We assume you are in your code directory for the rest of this guide.

Changing Geos-Chem Options

The file 'Headers/define.h' contains all of the C-preprocessor "switches" used to configure the compilation process. Open this file using your favorite text editor (type gedit at the command line to open a very nice, easy to use text editor). The key sections that may require editing are:

As an example, let's edit 'define.h' to reconfigure Geos-Chem for a GEOS5 model type and for a 4x5 grid size. First, find 'define.h' in the 'Headers' subdirectory and open it in a text editor. Go to Line 123 and make the following changes for the Model Type. Note that the ! character (exclamation point) in the first position indicates that the line is a comment and is not processed by the compiler.

file: Headers/define.h
   123:  !----- Model types -----
   124:  !#define GCAP        'GCAP'
   125:  !#define GEOS_3      'GEOS_3'
   126:  !#define GEOS_4      'GEOS_4'
   127:  #define GEOS_5      'GEOS_5'

Next, go to Line 129 and make the following changes to the Grid Size.

file: Headers/define.h
   129:  !----- Grid sizes -----
   130:  !#define NESTED_CH   'NESTED_CH'
   131:  !#define NESTED_NA   'NESTED_NA'
   132:  !#define NESTED_EU   'NESTED_EU'
   133:  !#define GRID05x0666 'GRID05x0666'
   134:  !#define GRID1x1     'GRID1x1'
   135:  !#define GRID1x125   'GRID1x125'
   136:  !#define GRID2x25    'GRID2x25'
   137:  #define GRID4x5     'GRID4x5'

It is usually not necessary to change the Fortran compiler since the default is fine for our setup. Next we will change the name of our output executable. This is optional.

Open the file 'GeosCore/Makefile', which contains the compiler flags for Intel Professional Fortran. Unless it is necessary to change compiler options (for advanced users only!), the only line that might need to be changed is Line 103. Here, you can change the name of the compiled executable file.

file: GeosCore/Makefile
   98:  # Define variables
   99:  ROOTDIR = ..
   100: BIN     = $(ROOTDIR)/bin
   101: BPCH    = $(ROOTDIR)/GeosBpch
   102: DOC     = $(ROOTDIR)/doc
   103: EXE     = geos

After making the change, save the file and close the editor. Make sure you are in your code directory.

The next step is to clean up the old .obj and .o files with the command:

> make clean

Then, to recompile the Geos-Chem code and build a new executable, type the command:

> make

The build process will likely take several minutes. Once complete, the final step is to copy the new executable to your model/run directory (where 'input.geos' resides). Notice how the executable was put into the bin directory within the code directory. This can be done by typing the following command (actual format will depend on how your model directory is structured):

> cp bin/geos ../

Now, go to your model directory and verify that the new executable file is there. If so, edit the 'input.geos' file and get modeling!