- 1 Overview
- 2 Debugging tips
- 2.1 Check the GEOS-Chem and HEMCO log files
- 2.2 Make sure you did not max out your allotted time or memory
- 2.3 Check if someone else has already reported the bug
- 2.4 Recompile GEOS-Chem with debug options turned on
- 2.5 Identify whether the error happens consistently
- 2.6 Run GEOS-Chem in a debugger to find the source of error
- 2.7 Isolate the error to a particular operation
- 2.8 Check any code modifications that you have added
- 2.9 Check for math errors
- 2.10 When in doubt, print it out!
- 2.11 When all else fails, use the brute force method
- 3 Using profiling tools to determine the source of computational bottlenecks
- 4 Using the GEOS-Chem Unit Tester
- 5 Reporting GEOS-Chem bugs to the GEOS-Chem Support Team
If your GEOS-Chem simulation dies unexpectedly with an error or takes much longer to execute than it should, the most important thing is to try to isolate the source of the error or bottleneck right away. Below are some of debugging tips that you can use.
Also see the Common GEOS-Chem error messages wiki page for detailed information on common errors and how to resolve them.
Check the GEOS-Chem and HEMCO log files
If your GEOS-Chem simulation stopped with an error, but you cannot tell where, turn on the ND70 diagnostic (debug output) in input.geos and rerun your simulation. The ND70 diagnostic will print debug output at several locations in the code (after transport, chemistry, emissions, dry deposition, etc.). This should let you pinpoint the location of the error.
If the log file indicates your run stopped in emissions, you can check the HEMCO.log file for additional information (GEOS-Chem v10-01 and later versions only). We recommend setting both the Verbose and Warnings options in HEMCO_Config.rc to 3 to print all debug statements and warning messages to your HEMCO.log file.
If your run stopped with an erorr, see the Common GEOS-Chem error messages wiki page for detailed information on common errors and how to resolve them.
Make sure you did not max out your allotted time or memory
If you are running GEOS-Chem in on a shared computer system, chances are you will have used a scheduler (such as LSF, PBS, Grid Engine, or SLURM) to submit your GEOS-Chem job to a computational queue. You should be aware of the run time and memory limits for each of the queues on your system.
If your GEOS-Chem job uses more memory or run time than the computational queue allows, your job can be cancelled by the scheduler. You will usually get an error message printed out to the stderr stream. Be sure to check all of the log files created by your GEOS-Chem jobs for such error messages.
The solution will usually be to submit your GEOS-Chem simulation to a queue with a longer run-time limit, or larger memory limit. You can also split up your GEOS-Chem simulation into several smaller stages that take less time to complete.
Check if someone else has already reported the bug
Before trying to debug your code, we recommend that you check our Bugs and fixes wiki page to see if your error is a known issue, and if someone has already submitted a fix.
Recompile GEOS-Chem with debug options turned on
Check for common problems like array-out-of-bounds errors, floating-point exceptions, and parallelization issues by turning on debug compiler switches:
|DEBUG=yes||This option turns off all optimization. It also prepares GEOS-Chem so that it can be run in a debugger like TotalView.|
|BOUNDS=yes||This option turns on runtime array-out-of-bounds checking, which looks for instances of invalid array indices (i.e. If the A array only has 10 elements but you try to reference A(11).)|
|TRACEBACK=yes|| This option turns on the -traceback option (ifort only) and will print a list of routines that were called when the error occurred.|
NOTE: This option will always be turned on by default in GEOS-Chem v11-01 and newer versions.
|This option turns on error checking for floating-point exceptions (i.e. div-by-zero, NaN, floating-invalid, and similar errors).|
|OMP=no||This option turns off OpenMP parallelization (which is turned on by default). This will check for parallelization issues.|
Identify whether the error happens consistently
If the error happens at the same model date & time, it could indicate bad input data. Check our List of reprocessed met fields to make sure there is not a known issue with the met fields or emissions for that date. This is a list of met field data files that had to be regenerated due to known issues (i.e. incomplete data or other such problems). You might be able to fix your problem by simply re-downloading the affected file or files.
If the error happened only once, it could be caused by a network problem or other such transient condition.
Run GEOS-Chem in a debugger to find the source of error
If you have access to a debugger (e.g. GDB, IDB, DBX, Totalview), you can save a lot of time and hassle by learning the basic commands such as how to:
- Examine data when a program stops
- Navigate the stack when a program stops
- Set break points
To run GEOS-Chem in a debugger, you should add the DEBUG=yes option to the make command. This will compile GEOS-Chem with the -g flag that tells the compiler to generate symbolic debug information. The DEBUG=yes option also uses the -O flag, which switches off compiler optimization that can modify the sequence in which individual instructions occur. To apply these options, type:
make -j4 DEBUG=yes OMP=no # Without parallelization make -j4 DEBUG=yes # With parallelization
Isolate the error to a particular operation
Can you tell if the error happens in transport, chemistry, emissions, dry dep, etc? Try turning off these operations one at a time in input.geos to see if you get past the error.
Also try turning on the ND70 diagnostic, which will add additional debug print statements to the output. This will help you to see the last subroutine that was exited before the error occurred.
Check any code modifications that you have added
If you have made modifications to a "fresh out-of-the-box" GEOS-Chem version, then you should look over your changes to search for the source of error.
You can also use Git to revert to the last known error-free state of GEOS-Chem, and use that as a reference.
Check for math errors
If you suspect that a floating-point math error, such as:
- Division by zero
- Logarithm of a negative number
- Numerical overflow or underflow
Then make clean and recompile with the FPEX=yes flag. This will turn on additional error checking that will stop your GEOS-Chem run if a floating-point error is encountered.
You can often detect numerical errors by adding debugging print statements into your source code:
- Check the minimum and maximum values of an array with the MINVAL and MAXVAL intrinsic functions:
PRINT*, '### Min, Max: ', MINVAL( ARRAY ), MAXVAL( ARRAY ) CALL FLUSH( 6 )
- Check the sum of an array with the SUM intrinsic function:
PRINT*, '### Sum of X : ', SUM( ARRAY ) CALL FLUSH( 6 )
See our Floating point math issues wiki page for information on how to avoid some common pitfalls.
When in doubt, print it out!
Print out the values of variables in the area where you suspect the error lies. You can also add call flush(6) to flush the output buffer after writing. Maybe you will see something wrong in the output.
When all else fails, use the brute force method
If the bug is difficult to locate, then comment out a large section of code and run GEOS-Chem. If the error does not occur, then uncomment some more code and run GEOS-Chem again. Repeat the process until you find the location of the error. The brute force method may be tedious, but it will usually lead you to the source of the problem.
Using profiling tools to determine the source of computational bottlenecks
If you think your GEOS-Chem simulation is taking too long to run, consider using profiling tools to generate a list of the time that is spent in each routine. This can help you identify badly written or parallelized code that is causing GEOS-Chem to slow down. For more information, please see our Profiling GEOS-Chem wiki page.
Using the GEOS-Chem Unit Tester
The GEOS-Chem Unit Tester is an external package that can run several test GEOS-Chem simulations with a set of very strict debugging options. The debugging options are designed to detect issues such as floating-point math errors, array-out-of-bounds errors, inefficient subroutine calls, and parallelization errors. You can use this tool to find many common numerical errors and programming issues in your GEOS-Chem code.
For complete instructions on how the GEOS-Chem Unit Tester can assist your debugging efforts, please see our Debugging with the GEOS-Chem unit tester wiki page.
Reporting GEOS-Chem bugs to the GEOS-Chem Support Team
If you have tried to solve your code problem but cannot, then please report it to the GEOS-Chem Support Team. We will be happy to assist you. In order for us to diagnose your issue, we request that you send us the folloiwng output files from your run directory:
The lastbuild file
The GEOS-Chem "Classic" compilation sequence generates a file that contains all of the options that were used to build the executable file. This file is named either lastbuild.mp<tt> (if OpenMP parallelization is turned on) or <tt>lastbuild.sp (if OpenMp parallelization is turned off).
Here is a sample lastbuild.mp file from a recent 1-month benchmark simulation:
LAST BUILD INFORMATION: CODE_DIR : /n/home05/msulprizio/GC/Code.Dev CODE_BRANCH : dev/12.1.0 LAST_COMMIT : Revert to reading I3 met fields each hour instead of once per day COMMIT_DATE : Wed Nov 21 09:07:51 2018 -0500 VERSION : 12.1.0 VERSION_TAG : GC_12.1.0 MET : geosfp GRID : 4x5 SIM : benchmark NEST : n TRACEBACK : y BOUNDS : n DEBUG : n FPE : n NO_ISO : n NO_REDUCED : y CHEM : Standard TOMAS12 : n TOMAS15 : n TOMAS30 : n TOMAS40 : n RRTMG : n MASSCONS : n TIMERS : 1 TAU_PROF : n BPCH_DIAG : y NC_DIAG : y COMPILER : ifort 17.0.4 Datetime : 2018/11/21 10:33
Of particular importance are the following items:
|LAST_COMMIT||The location (aka "commit") of your source code in the Git version history. (You can use the gitk browser to view the Git version history.)|
|VERSION||The GEOS-Chem version number.|
|MET/span></tt>||The type of meteorology that is being used to drive GEOS-Chem (e.g. geosfp, merra2)|
|<tt>GRID</tt>||The horizontal grid (e.g. 4x5, 2x25, 025x03125, 05x0625) that is being used for your simulation|
|<tt>SIM</tt>||The name of your GEOS-Chem simulation (e.g. Standard, Benchmark, CH4, Rn-Pb-Be, Hg, etc.)|
|<tt>NEST</tt>||If you are running a nested-grid simulation, <tt>NEST</tt> specifies the nested region that you are using (e.g. as, af, ch, na, eu, etc.)|
|<tt>COMPILER</tt>||The compiler version that you used to build the GEOS-Chem executable.|
The GEOS-Chem log file
The HEMCO log file
The <tt>lastbuild.mp</tt> file contains all of the options that were used to compile the GEOS-Chem executable. A new <tt>lastbuild
|GEOS-Chem Version Number||(e.g. GEOS-Chem 12.0.0)|
|Met field type||(e.g. GEOS-FP, MERRA2)|
|Horizontal Resolution||(e.g. 4° x 5°, 2° x 2.5°, 0.5° x 0.625°, 0.25° x 0.3125°)|
|Type of Simulation||
|Platform & OS||(e.g. CentOS, MacOS, etc.)|
|CPU type||Type <tt>cat /proc/cpuinfo</tt> at the Unix prompt and look for the "model name" field, e.g.
model name : Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
|Compiler and version||Use the <tt>--version</tt> option to your compiler. For example, type:
which will print
ifort (IFORT) 15.0.0 20140723 Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
and similarly for the <tt>gfortran</tt> and <tt>pgfortran</tt> compilers.
|Number of Processors|
|Diagnostics Requested||(e.g. ND28, ND43, ND45, etc.)|
|Description of problem|
|The commands that are required to produce/reproduce the problem|
|GEOS-Chem logfile output|
|HEMCO logfile output|