Interfacing GEOS-Chem with KPP

From Geos-chem
Revision as of 17:18, 20 November 2009 by Plesager (Talk | contribs) (Generating KPP input files from GEOS-Chem globchem.dat)

Jump to: navigation, search

This page describes how to install and run KPP, and how to interface it with GEOS-Chem.

Installing KPP and Running the examples

The source code, examples and the documentation to install and run KPP are available directly from A. Sandu web page.

For version 2.2.1 of KPP to work with GEOS-Chem, you must modify the source code so duplicate and proportional reactions in the input files will trigger a warning instead of an error. (Thanks to Paul Eller.)

In the file kpp/src/scanner.c , search for the following line of code around line 665 (may be slightly different):

ScanError( "Duplicate equation: "
           " (eqn<%d> = eqn<%d> )", i+1, EqnNr+1 );

and change it to the following:

ScanWarning( "Duplicate equation: "
             " (eqn<%d> = eqn<%d> )", i+1, EqnNr+1 );

Then replace :

       ScanError( "Linearly dependent equations: "
                  "( %.0f eqn<%d> = %.0f eqn<%d> )",
                  r1, i+1, r2, EqnNr+1 );


       ScanWarning( "Linearly dependent equations: "
                    "( %.0f eqn<%d> = %.0f eqn<%d> )",
                    r1, i+1, r2, EqnNr+1 );

This should allow you to create the KPP model. Having duplicate and proportional equations should not be a problem for KPP.

(1) Installation of KPP is simple. You need to double check the location of the flex library. Ask your system administrator, or just use the "find" command.

(2) Running examples should not be a problem either. The kpp executable being on the $path, you just need to be in the directory were the model file (*.kpp) is to run kpp on it. (Some examples names are different between the distribution and the manual, but it is straightforward to figure it out.)

Generating KPP input files from GEOS-Chem globchem.dat

"" is a Perl script from Paul Eller that automatically generates the three input files for KPP from globchem.dat:

> globchem.dat

the script is available in two versions, one for the original globchem.dat format (, one for the new format used by Fabien Paulot for the alternate isoprene chemistry (

this will create 3 files (globchem.def, globchem.eqn, globchem.spc). Then you must use "globchem" for the MODEL flag in the *.kpp file. So create a "gckpp.kpp", with a rosenbrock solver, like that:

#MODEL      globchem
#INTEGRATOR rosenbrock
#LANGUAGE   Fortran90
#DRIVER     none
#HESSIAN    on

The "none" driver is enough to get the files needed for GEOS-Chem. We are not generating a standalone code.

Running KPP

Put the gckpp.kpp file and the globchem* files in the same directory, and call kpp there:

> kpp gckpp.kpp

this will generate all the necessary files:


Interfacing the generated Code into GEOS-Chem

(coming soon)

--phs 14:23, 16 October 2009 (EDT)