Windows
Windows is the most complicated option, and needs some extra work. You can select either one of the methods shown below:
One: Cygwin
Installing the Cygwin shell gives most of the Linux tools for Windows, and with a careful setup it is possible to run our models on Windows, too. A real Windows expert might be able to set up our models even without the Cygwin environment, but this has not been tried so far.
1. Download the resource file for 32-bit (setup-x86.exe) or 64-bit (setup-x86_64.exe) Windows in: http://www.cygwin.com/install.html.
2. Double click setup-x86.exe or setup-x86_64.exe.
3. Install cygwin:
--> (1) Install from Internet
--> (2) select a root directory, I recommend to use the default one; All Users.
--> (3) Select where to store the installation files, which is not the root directory. I recommend to use the default one. If the directory does not exist, click 'yes' to create it.
--> (4) Direct Connection
--> (5) Select a site, the speed depends on your location. Using the first one is a good option.
--> (6) Select packages to install, leave it as default now and click 'Next'.
--> (7) 'Next'
--> (8) Wait installation.
--> (9) At least select 'Create icon on Desktop' to make life easier.
--> (10) Finish.
4. Install Fortran compiler:
--> (1) Click the setup file again.
--> (2) Follow the steps shown in 3 until (5).
--> (3) In 'Select package' window, search gcc-fortran, click 'Devel', then click 'Skip' before 'gcc-fortran: GNU Compiler Collection (Fortran).
--> (4) Next --> Next --> Finish.
5. Install make.
--> (1) Similar to 4, now search 'make', and 'Devel', then click 'Skip' before "make: The GNU version of the 'make' utility".
--> (2) Next --> Next --> Finish.
6. Install other packages you need. For example, the text editor 'vim'.
7. Double click 'Cygwin.bat' in the root directory, you will get a command line window. Try to type 'gfortran.exe' and return to make sure the command is installed. You should know that here you are in the directory of 'root directory/home/Administrator/'. Put all the Fortran files here to compile and run.
Two: Eclipse
Go to here to download current version of Eclipse IDE: https://www.eclipse.org/downloads/ according to your system. Run the Eclipse installer, select "Eclipse for Scientific Computing" and follow the instructions.
Mac
If you use Mac, we recommend first installing the Homebrew package manager. After that things will mostly be almost as easy as with Ubuntu. (Ubuntu package selection is wider, so in some cases Homebrew may not have a package, so a manual install is then the only option.)
Usually 'make' is already installed as a default. If you do not have 'make' installed, you can install 'Command Line Tools' in terminal by:
$ xcode-select --install
More detailed instruction can be found here: http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/.
Then you can select either one of the methods shown below:
One: Gfortran binaries
Download the Apple-style installer *.dmg for your Mac OS version from github (https://github.com/fxcoudert/gfortran-for-macOS/releases). Double click to install it.
Two: Eclipse
Go to here to download current version of Eclipse IDE: https://www.eclipse.org/downloads/ according to your system. Run the Eclipse installer, select "Eclipse for Scientific Computing" and follow the instructions.
Three: Other
You can also find other ways here (https://gcc.gnu.org/wiki/GFortranBinaries) to install gfortran compiler.
Linux
Usually you already have everything.
TIPs to debug kpp
1. All the lines read in from input files to KPP can be checked by printing out yyvsp before switch (yyn) in src/y.tab.c. Then you can know which line has problem.
2. If you want to deal with very long reaction coefficient rate, change in src/scan.y:
%union{
char str[80];
};
to:
%union{
char str[500];
};
or other numbers you want instead of 500.
Then
$ make distclean
$ make
This will define YYTYPE as a union with str[500] in the generated file src/y.tab.c.
3. Always check if those kpp files contain illegal special characters, e.g. '^M'.
4. Sometimes you need to change some parameters and then make again to get kpp to work properly.
Filename | Variables | Meaning |
Recommended value |
---|---|---|---|
gdata.h | MAX_EQN | maximum equation number | 50000 |
gdata.h | MAX_SPECIES | maximum species number | 10000 |
gdata.h |
MAX_SPNAME |
Maximum length of the specie names |
50 |
scan.h | MAX_INLINE | maximum inline characters | 50000 |
5. How to use kpp to calculate reactions created by MCM.
(1) Download the kpp file (e.g., mcm.def) in MCM website (http://mcm.leeds.ac.uk/MCMv3.3.1/) with selected compounds.
(2) In mcm.def, there is one line showing ' = IGNORED', modify it to 'dummy = IGNORED'. And add this dummy to some equations below where should be O2, N2, H2O, M2 or something else.
O + O3 = dummy
OH + HO2 = dummy
(3) Create a mcm.kpp to specify general settings like:
#MODEL mcm
#LANGUAGE Fortran90
#DOUBLE ON
#INTEGRATOR rosenbrock
#DRIVER general
#JACOBIAN SPARSE_LU_ROW
#HESSIAN OFF
#STOICMAT OFF
(4) Generate f90 files.
$ kpp mcm.kpp
(5) Modify mcm_Global.f90, mcm_Main.f90.
(6) Modify the make file.
(7) Compile Fortran code.
(8) Run the code.