E3SM-Project / E3SM

Energy Exascale Earth System Model source code. NOTE: use "maint" branches for your work. Head of master is not validated.
https://docs.e3sm.org/E3SM
Other
355 stars 368 forks source link

Explicit interface error message in ODEmod.F90 when using gfortran-10 #4151

Closed mpaiao closed 3 years ago

mpaiao commented 3 years ago

I am a new user of E3SM-FATES, and currently I am trying to install the model on my computer (MacBook) to familiarize with the code and run initial simulation. I am currently using version 10.2.0_4 of gfortran, gcc, and g++, installed with HomeBrew. When I try to compile the model using IELMFATES, it fails due to multiple messages similar to the one below:

Error: Explicit interface required for polymorphic argument at (1)
/path/to/E3SM/components/elm/src/external_models/sbetr/src/betr/betr_math/ODEMod.F90:57:16:

   57 |     call odefun(extra, y0, dt, t, nprimeq, neq, f)
      |                1
Error: Explicit interface required for polymorphic argument at (1)

Is there any fortran compilation flag that I should turn on to ignore these errors without modifying the code?

For reference, I managed to compile this file, but I had to edit it. I added two abstract interfaces at the beginning of the file (right before interface get_rerr).

  abstract interface
     subroutine odebbks(extra,y0,dt,t,nprimeq,neq,f)
        use bshr_kind_mod , only : r8 => shr_kind_r8
        use gbetrType     , only : gbetr_type
        implicit none
        class(gbetr_type), intent(inout) :: extra
        real(r8)         , intent(in)    :: y0(neq)
        real(r8)         , intent(in)    :: t
        real(r8)         , intent(in)    :: dt
        integer          , intent(in)    :: nprimeq
        integer          , intent(in)    :: neq
        real(r8)         , intent(out)   :: f(neq)
     end subroutine odebbks
  end interface

  abstract interface
     subroutine oderkx(extra,y0,dt,t,neq,f)
        use bshr_kind_mod , only : r8 => shr_kind_r8
        use gbetrType     , only : gbetr_type
        implicit none
        class(gbetr_type), target        :: extra
        real(r8)         , intent(in)    :: y0(neq)
        real(r8)         , intent(in)    :: t
        real(r8)         , intent(in)    :: dt
        integer          , intent(in)    :: neq
        real(r8)         , intent(out)   :: f(neq)
     end subroutine oderkx
  end interface

and replaced the declaration external :: odefun with either procedure(odebbks) :: odefun or procedure(oderkx) :: odefun in every subroutine in ODEmod.F90. I'm still working on the compilation flags and options to build the executables, so I am not sure these changes work fine.

jinyuntang commented 3 years ago

@mpaiao I think the fix you tried is legitimate. I tested a similar fix at https://github.com/BeTR-biogeochemistry-modeling/sbetr/commit/eba045e8e223979ad9014cd86b6b95528e90443e, and it worked just fine. So for you to proceed, you may just grab ODEMod.F90 from https://github.com/BeTR-biogeochemistry-modeling/sbetr/blob/jinyuntang/v1eca.r/src/betr/betr_math/ODEMod.F90, and integrate into your branch as a fix. Likely you then need to create a new branch at https://github.com/BeTR-biogeochemistry-modeling/sbetr, and create a PR for the change to be integrated as part of the repo. Thanks

jinyuntang commented 3 years ago

@mpaiao If you need me to fix it for you, please advise me your procedures (like which tag) so that I can reproduce your issue and apply the fix properly. Thanks.

mpaiao commented 3 years ago

@jinyuntang Thanks for the suggestion and sorry it took me long to come back to this. I was able to compile and run the code fine, so I will create a PR at BeTR-biogeochemistry-modeling/sbetr.

rljacob commented 3 years ago

@jinyuntang and @bishtgautam do you have a plan for getting the version of betr with this fix on master soon?

amametjanov commented 3 years ago

@jinyuntang and @bishtgautam An error with submodule update to 61cc9beb comes up during setup of SMS_D_Ln5.ne4_ne4.FC5AV1C-L with gcc/10.3.0:

   Calling /autofs/nccs-svm1_home1/azamat/repos/E3SM-spock/components/elm//cime_config/buildnml
ERROR: Command: '/autofs/nccs-svm1_home1/azamat/repos/E3SM-spock/components/elm/bld/configure    -comp_intf mct -phys elm -phys elm -cppdefs -DMODAL_AER -usr_src /gpfs/alpine/cli133/proj-shared/azamat/e3sm_scratch/spock/tests/integration/20210916/SMS_D_Ln5.ne4_ne4.FC5AV1C-L.spock_gnu.20210916/SourceMods/src.elm' failed with error '** source directory does not exist: /autofs/nccs-svm1_home1/azamat/repos/E3SM-spock/components/elm/src/external_models/sbetr/src/Applications/soil-farm/CENT_ECACNP' from dir '/gpfs/alpine/cli133/proj-shared/azamat/e3sm_scratch/spock/tests/integration/20210916/SMS_D_Ln5.ne4_ne4.FC5AV1C-L.spock_gnu.20210916/Buildconf/elmconf'
amametjanov commented 3 years ago

This can be reproduced on cori-knl with latest master (which uses gcc/8.3.0) and checkout of any recent sbetr merge-commit hash (61cc9beb, 7a195176, 79f33196)

./cime/scripts/create_test SMS_D_Ln5.ne4_oQU240.F2010 --compiler gnu
bishtgautam commented 3 years ago

@amametjanov I used the latest master (without any modifications to the sbetr submodule) and ran the following tests

[ 98%] Linking Fortran executable /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/e3sm.exe
cd /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/cmake-bld/cmake/cpl && /global/common/sw/cray/cnl7/haswell/cmake/3.20.2/bin/cmake -E cmake_link_script CMakeFiles/e3sm.exe.dir/link.txt --verbose=1
python3 /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/Tools/e3sm_compile_wrap.py  /opt/cray/pe/craype/2.6.2/bin/ftn   -fopenmp CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/cime_comp_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/cime_driver.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/component_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/component_type_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/cplcomp_exchange_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/map_glc2lnd_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/map_lnd2glc_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/map_lnd2rof_irrig_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/mrg_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_aoflux_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_atm_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_glc_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_iac_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_ice_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_lnd_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_ocn_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_rof_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/prep_wav_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_diag_mct.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_domain_mct.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_flux_mct.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_frac_mct.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_hist_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_io_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_map_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_map_type_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/seq_rest_mod.F90.o CMakeFiles/e3sm.exe.dir/global/cfs/cdirs/e3sm/gbisht/Projects/e3sm-after-cime-submodule/driver-mct/main/t_driver_timers_mod.F90.o -o /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/e3sm.exe  ../atm/libatm.a ../lnd/liblnd.a ../../mpas-framework/src/libice.a ../ocn/libocn.a ../rof/librof.a ../glc/libglc.a ../wav/libwav.a ../iac/libiac.a ../esp/libesp.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/mct/noesmf/c1a1l1i1o1r1g1w1i1e1/lib/libcsm_share.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib/libmct.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib/libmpeu.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib/libpiof.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib/libpioc.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib/libgptl.a -L/opt/cray/pe/parallel-netcdf/1.11.1.1/GNU/8.2/lib -lpnetcdf -L/opt/cray/pe/mpt/7.7.10/gni/mpich-gnu/8.2/lib -lmpich -lstdc++ /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscontainers.a /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/gnu/mpt/debug/threads/mct/lib64/libkokkoscore.a /usr/lib64/libdl.so -lmvec -lnetcdf_c++4 -lmpichcxx_gnu_82 -lmvec -lstdc++
/usr/bin/ld: attempted static link of dynamic object `/usr/lib64/libdl.so'
collect2: error: ld returned 1 exit status
Target /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/e3sm.exe built in 0.840837 seconds
gmake[2]: *** [cmake/cpl/CMakeFiles/e3sm.exe.dir/build.make:543: /global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/e3sm.exe] Error 1
gmake[2]: Leaving directory '/global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/cmake-bld'
gmake[1]: *** [CMakeFiles/Makefile2:661: cmake/cpl/CMakeFiles/e3sm.exe.dir/all] Error 2
gmake[1]: Leaving directory '/global/cscratch1/sd/gbisht/e3sm_scratch/cori-knl/SMS_D_Ln5.ne4_oQU240.F2010.cori-knl_gnu.20210917_100734_66omst/bld/cmake-bld'
gmake: *** [Makefile:94: all] Error 2
real 3.69
user 1.62
sys 1.25

Since the first test built successfully, I'm not sure if sbetr is causing the build failure. What do you think?

amametjanov commented 3 years ago

I'm not getting any build errors with master (and no mods to sbetr): e.g. the test is passing on CDash.

We need a more recent gcc/10.3.0 for E3SM on OLCF machine Spock. There, E3SM's sbetr needs updates to src/betr/betr_math/ODEMod.F90 as in BeTR-biogeochemistry-modeling/sbetr#54. Updating sbetr in E3SM is leading to "CENT_ECACNP does not exist" error with a sample test SMS_D_Ln5.ne4_oQU240.F2010 and any gnu version.

If you're getting errors on Cori, can you try with gnu on Chrysalis or Anvil?