Compiling error with NETCDF and HDF

876 views
Skip to first unread message

Wei-Wei

unread,
Jan 9, 2012, 12:17:18 PM1/9/12
to COSP users group
Dear all,

When I was compiling COSP, it has become stuck at:

-L/opt/clout/udunits-2-2.1.22-gnu-4.1.2/lib -ludunits2 -lexpat
-o cosp_test
/opt/clout/netcdf-4-4.1.2-gnu-4.1.2/lib/libnetcdf.a(libnetcdf4_la-
nc4file.o): In function `sync_netcdf4_file':
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/
libsrc4/nc4file.c:2625: undefined reference to `H5Fflush'
/opt/clout/netcdf-4-4.1.2-gnu-4.1.2/lib/libnetcdf.a(libnetcdf4_la-
nc4file.o): In function `close_netcdf4_file':
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/
libsrc4/nc4file.c:2705: undefined reference to `H5Fclose'
/opt/clout/netcdf-4-4.1.2-gnu-4.1.2/lib/libnetcdf.a(libnetcdf4_la-
nc4file.o): In function `nc4_iterate_link':
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/
libsrc4/nc4file.c:1790: undefined reference to `H5Eauto_is_v2'
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/
libsrc4/nc4file.c:1790: undefined reference to `H5Eget_auto2'
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/
libsrc4/nc4file.c:1790: undefined reference to `H5Eset_auto2'
...

I think this means there is something wrong with the link between hdf5
and netcdf? I can't seem to find any info on the web regarding this
error with COSP.

Any help will be greatly appreciated!

Thank you very much indeed!

Wei-Wei

Bodas-Salcedo, Alejandro

unread,
Jan 10, 2012, 6:17:04 AM1/10/12
to cosp...@googlegroups.com
Dear Wei-Wei,

I'm not sure if this will help, but can you try with the following lines
in your Makefile, instead of the ones in your current Makefile?

$(PROG): $(OBJS)
$(F90) $(F90FLAGS) $(PROG).F90 $(OBJS) \
-I$(INC) -L${LIB} -lz \
-I$(CMOR_INC) -L${CMOR_LIB} -lcmor \
-I$(NCDF_INC) -L${NCDF_LIB} -lnetcdff -lnetcdf \
-I$(UUID_INC) -L${UUID_LIB} -luuid \
-L${UDUNITS_LIB} -ludunits2 \
-o $(PROG)

Also, it may be worth checking that the path to your hdf library is in
your LD_LIBRARY_PATH environment variable.

Regards,

Alejandro

Wei-Wei

unread,
Jan 10, 2012, 9:52:25 AM1/10/12
to COSP users group
Hi Alejandro,

Thanks a lot for your kind reply! However, it still appeared the same
error after I changed the Makefile as you suggested. BTW, it actually
has linking problem with libcurl, which I forgot to mention last time.
The error is similar as:
---------------------------
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/oc/
ocinternal.c:140: undefined reference to `curl_version_info'
/opt/clout/netcdf-4-4.1.2-gnu-4.1.2/lib/libnetcdf.a(libnetcdf4_la-
nc4type.o): In function `NC4_inq_type_equal':
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/
libsrc4/nc4type.c:77: undefined reference to `H5Tequal'
/opt/clout/netcdf-4-4.1.2-gnu-4.1.2/lib/libnetcdf.a(liboc_la-
curlfunctions.o): In function `ocset_ssl':
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/oc/
curlfunctions.c:100: undefined reference to `curl_easy_setopt'
/opt/clout/clout/software/netcdf/netcdf-4/netcdf-4-4.1.2-gnu-4.1.2/oc/
curlfunctions.c:103: undefined reference to `curl_easy_setopt'
----------------------------

-------------------My Makefile is as follows:------------------------
F90 = gfortran

NCDF_INC = /opt/clout/netcdf-4-4.1.2-gnu-4.1.2/include
NCDF_LIB = /opt/clout/netcdf-4-4.1.2-gnu-4.1.2/lib

CMOR_INC = /Usershome/project/COSP/CMOR2/include
CMOR_LIB = /Usershome/project/COSP/CMOR2/lib

UDUNITS_LIB = /opt/clout/udunits-2-2.1.22-gnu-4.1.2/lib

UUID_INC = /Usershome/project/COSP/uuid/include
UUID_LIB = /Usershome/project/COSP/uuid/lib

LD_LIBRARY_PATH=/usr/local/lib:/opt/clout/hdf-5-1.8.6-gnu-4.1.2/lib:/
usr/local/netcdf-4-4.1.2-gnu-4.1.2/lib

RS_PATH = /Usershome/project/COSP/COSP_code/quickbeam
CS_PATH = /Usershome/project/COSP/COSP_code/actsim
LLNL_PATH = /Usershome/project/COSP/COSP_code/llnl
ISCCP_PATH =/Usershome/project/COSP/COSP_code/icarus-scops-4.1-bsd
MISR_PATH = /Usershome/project/COSP/COSP_code/MISR_simulator
MODIS_PATH = /Usershome/project/COSP/COSP_code/MODIS_simulator

RTTOV_PATH = /Usershome/project/COSP/rttov93/
RTTOV_LIB_PATH = $(RTTOV_PATH)/lib
RTTOV_INC_PATH = $(RTTOV_PATH)/include
RTTOV_MOD_PATH = $(RTTOV_PATH)/mod

########################################################################
# End of modifications
########################################################################

PROG = cosp_test
OBJS = cosp_radar.o cosp_types.o cosp_constants.o cosp_simulator.o \
cosp_utils.o scops.o prec_scops.o cosp.o cosp_stats.o \
pf_to_mr.o \
cosp_lidar.o radar_simulator_types.o zeff.o \
array_lib.o atmos_lib.o dsd.o format_input.o \
gases.o load_hydrometeor_classes.o \
math_lib.o mrgrnk.o optics_lib.o radar_simulator.o \
lidar_simulator.o cosp_io.o llnl_stats.o lmd_ipsl_stats.o \
cosp_isccp_simulator.o icarus.o \
cosp_misr_simulator.o MISR_simulator.o \
cosp_modis_simulator.o modis_simulator.o \
cosp_rttov_simulator.o

all: $(PROG)
$(PROG): $(OBJS)
$(F90) $(F90FLAGS) $(PROG).F90 $(OBJS) \
-I$(INC) -L${LIB} -lz \
-I$(CMOR_INC) -L${CMOR_LIB} -lcmor \
-I$(NCDF_INC) -L${NCDF_LIB} -lnetcdff -lnetcdf \
-I$(UUID_INC) -L${UUID_LIB} -luuid \
-L${UDUNITS_LIB} -ludunits2 \
-o $(PROG)
------------------------------------------------

Hoping for kind replies:) Thank you all!

Wei-Wei

On Jan 10, 5:17 am, "Bodas-Salcedo, Alejandro"

Bodas-Salcedo, Alejandro

unread,
Jan 10, 2012, 11:31:49 AM1/10/12
to cosp...@googlegroups.com
Hi,

Have you run the CMOR tests? This could help you find what the problem is. Also, at the end of the CMOR installation process, you should get information on the libraries that you you will need to use to build fortran programs.
I've also found in the past that working with NetCDF4/HDF5 is more problematic than NetCDF3, so building CMOR against Netcdf 3.6.3 may also help.

Wei-Wei

unread,
Jan 10, 2012, 12:22:36 PM1/10/12
to COSP users group
Hi Alejandro,

We have found the problem. We change the Makefile as:

$(PROG): $(OBJS)
$(F90) $(F90FLAGS) $(PROG).F90 $(OBJS) \
-I$(NCDF_INC) -L${NCDF_LIB} -lnetcdff -lnetcdf -lcurl \
-I$(INC) -L${LIB} -lsz \
-I$(CMOR_INC) -L${CMOR_LIB} -lcmor \
-I$(UUID_INC) -L${UUID_LIB} -luuid \
-L${UDUNITS_LIB} -ludunits2 -lexpat \
-L/opt/clout/hdf-5-1.8.6-gnu-4.1.2/lib -lhdf5_hl -lhdf5 -o $
(PROG)

It works now. You are right, working with NetCDF4 and HDF5 often bring
more problems. Here, we found the order of linkers are also crucial to
this problem.

Anyway, thank you so much for solving this problem!

Best!

Wei-Wei

On Jan 10, 10:31 am, "Bodas-Salcedo, Alejandro"
Reply all
Reply to author
Forward
0 new messages