ESMCI / cime

Common Infrastructure for Modeling the Earth
http://esmci.github.io/cime
Other
161 stars 206 forks source link

INCLDIR being added to before it's set. #3142

Closed ekluzek closed 5 years ago

ekluzek commented 5 years ago

This is in cime5.8.3 in scripts/Tools/Makefile INCLDIR is being added to with a variable that isn't set yet before INCLDIR is initially defined. This seems to work on cheyenne, but fail on hobart.

The following change gets it to work:

diff --git a/scripts/Tools/Makefile b/scripts/Tools/Makefile
index d5c86a68e..a9de3ebb8 100644
--- a/scripts/Tools/Makefile
+++ b/scripts/Tools/Makefile
@@ -376,7 +376,6 @@ ifeq ($(ULIBDEP),$(null))
     endif
     ifeq ($(LND_PRESENT),TRUE)
       ULIBDEP += $(LNDLIBDIR)/$(LNDLIB)
-      INCLDIR += -I$(LNDOBJDIR)
       CPPDEFS += -DLND_PRESENT
     endif
     ifeq ($(OCN_PRESENT),TRUE)
@@ -849,6 +848,7 @@ else
     INCLUDE_DIR = $(INSTALL_SHAREDPATH)/$(COMP_INTERFACE)/$(ESMFDIR)/include
   endif
 endif
+INCLDIR += -I$(LNDOBJDIR)

 ifeq ($(COMP_GLC), cism)
   ULIBDEP += $(CISM_LIBDIR)/libglimmercismfortran.a

Without the above change, I get the following since it doesn't know where to find the CLM modules. Notice one of the first "-I" is empty without anything after it. I'm not sure why this works on cheyenne...

Time(Code Output): User 0.05, System 0.00
[NAG Fortran Compiler normal termination, 3 warnings]
mpif90  -c -I. -I -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/nag/mvapich2/debug/nothreads/mct/include -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/nag/mvapich2/debug/nothreads/mct/mct/noesmf/c1a1l1i1o1r1g1w1i1e1/include -I/usr/local/netcdf-c-4.6.1-f-4.4.4-gcc-g++-8.1.0-nag-6.2/include -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/atm/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/ice/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/ocn/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/glc/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/rof/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/wav/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/esp/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/iac/obj -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/nag/mvapich2/debug/nothreads/mct/include -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/nag/mvapich2/debug/nothreads/mct/mct/noesmf/include -I. -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/SourceMods/src.drv -I/fs/cgd/data0/erik/ctsm_buildlib/cime/src/drivers/mct/main -I/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/bld/lib/include -Wp,-macro=no_com -convert=BIG_ENDIAN -indirect /fs/cgd/data0/erik/ctsm_buildlib/cime/config/cesm/machines/nag_mpi_argument.txt  -C=all -g -time -f2003 -ieee=stop   -gline   -DLINUX  -DCESMCOUPLED   -DFORTRANUNDERSCORE -DNO_CRAY_POINTERS -DNO_SHR_VMATH -DCPRNAG  -DDEBUG -DMCT_INTERFACE -DHAVE_MPI -DPIO1 -DHAVE_SLASHPROC -DATM_PRESENT -DICE_PRESENT -DLND_PRESENT -DOCN_PRESENT -DROF_PRESENT -DGLC_PRESENT -DWAV_PRESENT -DESP_PRESENT -free  -DUSE_CONTIGUOUS= /fs/cgd/data0/erik/ctsm_buildlib/cime/src/drivers/mct/main/cime_comp_mod.F90
NAG Fortran Compiler Release 6.2(Chiyoda) Build 6207
Fatal Error: /fs/cgd/data0/erik/ctsm_buildlib/cime/src/drivers/mct/main/cime_comp_mod.F90, line 50: Cannot find module LND_IMPORT_EXPORT
             detected at :@LND_INIT
/scratch/cluster/erik/tests_rtm1__67_ctsm1d42r/SMS_D_Ld5.f10_f10_musgs.I2000Clm50BgcCropRtm.hobart_nag.rtm-default.GC.rtm1__67_ctsm1d42r_nag/Tools/Makefile:930: recipe for target 'cime_comp_mod.o' failed
gmake: *** [cime_comp_mod.o] Error 2
billsacks commented 5 years ago

@ekluzek thanks for the catch and the suggested fix. I see that your fix appends LNDOBJDIR in all cases, rather than just in select cases as was done before. Have you checked to confirm that this is a safe / desirable thing to do? If so, can you please open a PR with your suggested fix?

ekluzek commented 5 years ago

I've only tested with I compsets. For other compsets it probably still works it just would add an extra unneeded include directory (but that would still be undesirable). I'd really like someone to look at it and suggest the best thing to do and then I can implement and test that solution. I could check for LND_PRESENT or other settings before doing the add to INCLDIR. I could also do some reordering moving the CLM section above the LND_PRESENT section, but that sounds like a bigger change. Could @jedwards4b or @fischer-ncar give advice?

jedwards4b commented 5 years ago

I'll have a fix shortly.