Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

CESM cannot see netcdf

I'm trying to get CESM 1.0.2 working on a linux cluster with Intel Compiler Suite 13 and OpenMPI 1.6.3 compiled with (and so accessing) Intel. I've been following this guide.

Everything goes smoothly, and I can run $CASE.$MACH.build until the final step where the executable cesm.exe is being built. At this point, the build fails. Viewing the error file, there is no specific compiler error (the final line is "Error" but with no reason), but there are very many (hundreds of) lines which talk about "undefined reference to" and then refer to something which is evidently related to NetCDF. I assume this means that either the compiler can't see NetCDF or the NetCDF library has not been compiled correctly. All of my environmental variables are set correctly.

I've tried this with NetCDF compiled with Intel as in the above guide, and also compiled via the official Intel NetCDF compilation guide. Both compile, but the result is the same in both cases. I've also tried compiling NetCDF with the OpenMPI compiler wrappers, but I couldn't make this work.

I've tried using CESM 1.0.5 as well, but I can't get to the cesm.exe compilation stage because of other problems that I can't resolve.

Does anyone have any suggestions?
 
OK, answered my own question. In the Makefile in $CESM/scripts/ccsm_utils/Build, you need to add the Fortran netcdf library flag "-lnetcdff" in addition to the existing flag "-lnetcdf".
 
Hi
I've been having exactly this problem for the last two weeks, and have not been able to resolve it. I tried adding the library tag like you suggested, but that didn't work. Where exactly did you add it? Do you have any other details that might be helpful?
Thanks a lot!!
 

jedwards

CSEG and Liaisons
Staff member
Hi Molly,

Can you tell us what cesm version you are using, what netcdf library you are trying to link to and the error you are getting.
 
Hi

Right, sorry. I am using cesm 1.0.4, trying to link to netcdf4211. Everything builds properly up to the ccsm component, but then it fails. I am attaching the buildlog for that component, but I really don't know how to make heads or tails of it.

Thanks!
 

jedwards

CSEG and Liaisons
Staff member


mpif90 -o /localdisk/scratch/mbs244/test1/run/ccsm.exe ccsm_comp_mod.o ccsm_driver.o map_atmatm_mct.o map_atmice_mct.o map_atmlnd_mct.o map_atmocn_mct.o
map_glcglc_mct.o map_iceice_mct.o map_iceocn_mct.o map_lndlnd_mct.o map_ocnocn_mct.o map_rofocn_mct.o map_rofrof_mct.o map_snoglc_mct.o map_snosno_mct.o
mrg_x2a_mct.o mrg_x2g_mct.o mrg_x2i_mct.o mrg_x2l_mct.o mrg_x2o_mct.o mrg_x2s_mct.o seq_avdata_mod.o seq_diag_mct.o seq_domain_mct.o seq_flux_mct.o
seq_frac_mct.o seq_hist_mod.o seq_rearr_mod.o seq_rest_mod.o -L/localdisk/scratch/mbs244/test1/lib -latm -llnd -lice -locn -lglc -L/localdisk/scratch/mbs244/test1/lib
-lcsm_share -lmct -lmpeu -lpio -L/usr/local/netcdf4211/lib -lnetcdf -L/usr/lib64/openmpi/lib -lmpi
This is your link line. For netcdf 4.2.1.1 there is an additional library that you need to link so you need to add -lnetcdff. For cesm1_0_4 you would add this flag in the Macros file in your case directory. Look for the -lnetcdf and change it to -lnetcdff -lnetcdf
 

jedwards

CSEG and Liaisons
Staff member
Sorry, it's in scripts/ccsm_utils/Build/Makefile. Look for the lines below and add -lnetcdff


Code:
# System libraryies (netcdf, mpi, pnetcdf, esmf) 
ifeq ($(strip $(SLIBS)),)
   SLIBS := -L$(LIB_NETCDF) -lnetcdf 
else
   SLIBS += -L$(LIB_NETCDF) -lnetcdf 
endif
 
Hi
Sorry I've taken so long to respond; I had an extremely busy few days.
I made the modifications in the Makefile script, but the same error still occured. What I find extremely interesting is that even though Makefile was modified in the way you suggested (and I went and checked, it definetly was the modified version), the newest error log didn't change. It still says -L/usr/local/netcdf4211/lib -lnetcdf -L/usr/lib64/openmpi/lib -lmpi without acknowledging the new flag at all. What could be causing this?
Thank you so much for your patience! I've attached the Makefile script and new error log.
 

jedwards

CSEG and Liaisons
Staff member

Code:
Actually it did work, this is a different error.   You need to figure out what version of these commands your system supports and add the proper -D flags to your Macros.   

mpif90 -o /localdisk/scratch/mbs244/test3/run/ccsm.exe ccsm_comp_mod.o ccsm_driver.o map_atmatm_mct.o map_atmice_mct.o map_atmlnd_mct.o map_atmocn_mct.o map_glcglc_mct.o map_iceice_mct.o map_iceocn_mct.o map_lndlnd_mct.o map_ocnocn_mct.o map_rofocn_mct.o map_rofrof_mct.o map_snoglc_mct.o map_snosno_mct.o mrg_x2a_mct.o mrg_x2g_mct.o mrg_x2i_mct.o mrg_x2l_mct.o mrg_x2o_mct.o mrg_x2s_mct.o seq_avdata_mod.o seq_diag_mct.o seq_domain_mct.o seq_flux_mct.o seq_frac_mct.o seq_hist_mod.o seq_rearr_mod.o seq_rest_mod.o -L/localdisk/scratch/mbs244/test3/lib -latm -llnd -lice -locn -lglc -L/localdisk/scratch/mbs244/test3/lib -lcsm_share -lmct -lmpeu -lpio  -L/usr/local/netcdf4211/lib -lnetcdff -lnetcdf  -L/usr/lib64/openmpi/lib -lmpi  
/localdisk/scratch/mbs244/test3/lib/libcsm_share.a(shr_sys_mod.o): In function `__shr_sys_mod_MOD_shr_sys_chdir':
/localdisk/cesm1_0_4/models/csm_share/shr/shr_sys_mod.F90:152: undefined reference to `chdir_'
/localdisk/scratch/mbs244/test3/lib/libcsm_share.a(shr_sys_mod.o): In function `__shr_sys_mod_MOD_shr_sys_system':
/localdisk/cesm1_0_4/models/csm_share/shr/shr_sys_mod.F90:83: undefined reference to `system_'
 

jedwards

CSEG and Liaisons
Staff member

Code:
This line:<br /><br /><br /># Note that CPPDEFS is set in Macros.cppdefs
CPPDEFS += -DLINUX -DSEQ_$(FRAMEWORK) -DFORTRANUNDERSCORE -DNO_R16 -DNO_SHR_VMATH
 
Top