geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
168 stars 165 forks source link

[BUG/ISSUE] GEOS-Chem 12.6.0 with CMake encounters seg fault when compiling ocean_mercury_mod.F #64

Closed yantosca closed 5 years ago

yantosca commented 5 years ago

Describe the bug

GEOS-Chem in the dev/12.6.0 branch (commit https://github.com/geoschem/geos-chem/commit/8ab5a66eb789ad02801977baef1009a7e1d40477) dies with an internal compiler error when trying to compile ocean_mercury_mod.F.

This is known behavior and also occurs when you compile GEOS-Chem with GNU Make. But in the GNU Makefiles, we have to add a special rule to compile ocean_mercury_mod.F as -O1 in order to avoid the error:

ocean_mercury_mod.o         : ocean_mercury_mod.F                            \
                              dao_mod.o               depo_mercury_mod.o     \
                              diag03_mod.o            toms_mod.o             \
                              hco_interface_mod.o
##############################################################################
# NOTE: For some reason gfortran 8.x.x throws an internal compiler error
# in this routine.  The error does not happen when optimization is turned
# off.  For now, lower the optimization level to get around this issue.
# The ocean mercury module might eventually be replaced later on.
#   -- Bob Yantosca, 17 Aug 2018
ifeq ($(IS_GNU_8),1)
    $(F90) -c -O1 $<
endif
##############################################################################

This appears to be present in gfortran 8 and higher. I think it is because gfortran 8+ cannot handle and/or optimize some old-timey legacy code in ocean_mercury_mod.F.

To Reproduce

Steps to reproduce the behavior:

  1. Create a rundir geosfp_4x5_TransportTracers from the UT branch dev/12.6.0
  2. cd geosfp_4x5_TransportTracers
  3. mkdir build
  4. cd build
  5. cmake ../CodeDir
  6. make -j8

Expected behavior

The executable should be built.

Error message:

[ 88%] Building Fortran object GeosCore/CMakeFiles/GeosCore.dir/ocean_mercury_mod.F.o
[ 88%] Building Fortran object GeosCore/CMakeFiles/GeosCore.dir/land_mercury_mod.F.o
[ 89%] Building Fortran object GeosCore/CMakeFiles/GeosCore.dir/wetscav_mod.F.o
during GIMPLE pass: ccp
/local/ryantosca/GC/rundirs/12.6.0/geosfp_4x5_TransportTracers/CodeDir/GeosCore/ocean_mercury_mod.F:404:0:

       USE CMN_SIZE_MOD

internal compiler error: Segmentation fault
0xad755f crash_signal
        ../.././gcc/toplev.c:325
0xbaeb0c gimple_code
        ../.././gcc/gimple.h:1679
0xbaeb0c gimple_nop_p
        ../.././gcc/gimple.h:6346
0xbaeb0c get_default_value
        ../.././gcc/tree-ssa-ccp.c:279
0xbb04bc get_value
        ../.././gcc/tree-ssa-ccp.c:354
0xbb04bc ccp_finalize
        ../.././gcc/tree-ssa-ccp.c:962
0xbb04bc do_ssa_ccp
        ../.././gcc/tree-ssa-ccp.c:2475
0xbb04bc execute
        ../.././gcc/tree-ssa-ccp.c:2518
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
make[2]: *** [GeosCore/CMakeFiles/GeosCore.dir/ocean_mercury_mod.F.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [GeosCore/CMakeFiles/GeosCore.dir/all] Error 2
make: *** [all] Error 2

Required information

Out of the box" GEOS-Chem dev/12.6.0 running on CentOS7:

Linux holyjacob01.rc.fas.harvard.edu 3.10.0-957.12.1.el7.x86_64 #1 SMP Mon Apr 29 14:59:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

with these modules

Currently Loaded Modules:
  1) git/2.17.0-fasrc01    7) mpc/1.0.3-fasrc06      13) netcdf/4.1.3-fasrc02
  2) perl/5.26.1-fasrc01   8) gcc/8.2.0-fasrc01      14) libtiff/4.0.9-fasrc01
  3) IDL/8.4.1-fasrc01     9) openmpi/3.1.1-fasrc01  15) emacs/26.1-fasrc01
  4) flex/2.6.4-fasrc01   10) zlib/1.2.8-fasrc07     16) cmake/3.12.1-fasrc01
  5) gmp/6.1.2-fasrc01    11) szip/2.1-fasrc02       17) jdk/1.8.0_172-fasrc01
  6) mpfr/3.1.5-fasrc01   12) hdf5/1.8.12-fasrc12    18) tau-2.28.2-gcc-8.2.0-ofp23hs

Other info:

The gfortran 8.2.0 compiler was built by our Research Computing staff. There might be some issues with it. If time allows I will try to build a fresh version of gfortran 8.2.0 (and maybe also gfortran 9.3) cleanly with Spack and see if we still get the error.

The ocean_mercury_mod.F90 is not used for fullchem simulations, but it is compiled into the executable. It is a bit of a mess, so there must be some kind of construct that the newer gfortran (which skews to the newer Fortran standards like F2003, F2008) cannot parse. Or perhaps could parse but doesn't want to.

LiamBindle commented 5 years ago

Hi @yantosca, thanks for writing this up. I'm on it right now. I'll follow up in an hour or so.

yantosca commented 5 years ago

This is now resolved by https://github.com/geoschem/geos-chem/pull/65. We can close this issue now.