[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #RSG-712199]: Problems linking to NetCDF f90 interface



Craig,

> I wasn't able to solve my Intel compiler linking problems on this cluster, so 
> I switched to the PGI compilers and made it work:
> 
> module add pgi
> module add mpich2/pgi
> module add netcdf-4.1.1/pgi
> setenv LD_LIBRARY_PATH /share/apps/hdf5/1.8.6/pgi/lib:${LD_LIBRARY_PATH}
> setenv FC pgf90
> pgf90 `nc-config --fflags` pres_temp_4D_wr.f90 -o wr.exe `nc-config --flibs`
> wr.exe
> ncdump -v pres -f fortran pres_temp_4D.nc
> 
> data:
> 
> pres =
> 900,   // pres(1,1,1,1)
> 901,   // pres(2,1,1,1)
> 902,   // pres(3,1,1,1)
> 903,   // pres(4,1,1,1)
> . . .
> 1053,   // pres(10,6,2,3)
> 1054,   // pres(11,6,2,3)
> 1055;  // pres(12,6,2,3)
> }
> 
> Not the greatest solution, but at least I can build and run NetCDF apps now .

I'm glad you found a solution.  We don't have a cluster with ifort on which
to test, so I'm still not sure what the problem was with linking the Fortran
and C libraries to an application.

--Russ

> On Aug 6, 2012, at 5:14 PM, Unidata netCDF Support wrote:
> 
> > Hi Craig,
> >
> >> I just built and installed version 4.4-beta1 of the Fortran 90 interface 
> >> for NetCDF on multiple systems.
> >>
> >> My builds pass all built-in NetCDF tests on all 3 systems (make check | & 
> >> tee check.log).
> >>
> >> An example program (pres_temp_4D_wr.f90) provided by NCAR (attached) 
> >> builds and runs fine on both my Mac laptop (OS X 10.7) and the SDSC Gordon 
> >> linux cluster.
> >>
> >> However, the build fails on our local university linux cluster with errors 
> >> like the following:
> >>
> >> ifort ${FFLAGS} -I${NETCDF}/include -L${NETCDF}/lib -lnetcdf -lnetcdff 
> >> pres_temp_4D_wr.f90 -o wr.exe
> >
> > I think you need to have -lnetcdf *after* -lnetcdff, because the Fortran 
> > library calls
> > functions in the C library.
> >
> > --Russ
> >
> >> /tmp/ifortgqaUzq.o: In function `pres_temp_4d_wr_IP_writenetcdf_':
> >> pres_temp_4D_wr.f90:(.text+0x1292): undefined reference to 
> >> `netcdf_mp_nf90_create_'
> >> pres_temp_4D_wr.f90:(.text+0x131a): undefined reference to 
> >> `netcdf_mp_nf90_def_dim_'
> >> pres_temp_4D_wr.f90:(.text+0x1352): undefined reference to 
> >> `netcdf_mp_nf90_def_dim_'
> >> pres_temp_4D_wr.f90:(.text+0x1387): undefined reference to 
> >> `netcdf_mp_nf90_def_dim_'
> >> pres_temp_4D_wr.f90:(.text+0x13bc): undefined reference to 
> >> `netcdf_mp_nf90_def_dim_'
> >> pres_temp_4D_wr.f90:(.text+0x13f5): undefined reference to 
> >> `netcdf_mp_nf90_def_dim_'
> >> pres_temp_4D_wr.f90:(.text+0x151d): undefined reference to 
> >> `netcdf_mp_nf90_def_var_onedim_'
> >> pres_temp_4D_wr.f90:(.text+0x155d): undefined reference to 
> >> `netcdf_mp_nf90_def_var_onedim_'
> >> pres_temp_4D_wr.f90:(.text+0x1655): undefined reference to 
> >> `netcdf_mp_nf90_def_var_manydims_'
> >> pres_temp_4D_wr.f90:(.text+0x16d1): undefined reference to 
> >> `netcdf_mp_nf90_def_var_manydims_'
> >> pres_temp_4D_wr.f90:(.text+0x174d): undefined reference to 
> >> `netcdf_mp_nf90_def_var_manydims_'
> >> pres_temp_4D_wr.f90:(.text+0x178c): undefined reference to 
> >> `netcdf_mp_nf90_put_att_text_'
> >> pres_temp_4D_wr.f90:(.text+0x17cb): undefined reference to 
> >> `netcdf_mp_nf90_put_att_text_'
> >> pres_temp_4D_wr.f90:(.text+0x180a): undefined reference to 
> >> `netcdf_mp_nf90_put_att_text_'
> >> pres_temp_4D_wr.f90:(.text+0x1849): undefined reference to 
> >> `netcdf_mp_nf90_put_att_text_'
> >> pres_temp_4D_wr.f90:(.text+0x1888): undefined reference to 
> >> `netcdf_mp_nf90_put_att_text_'
> >> pres_temp_4D_wr.f90:(.text+0x18fe): undefined reference to 
> >> `netcdf_mp_nf90_enddef_'
> >> pres_temp_4D_wr.f90:(.text+0x198a): undefined reference to 
> >> `netcdf_mp_nf90_put_var_1d_fourbytereal_'
> >> pres_temp_4D_wr.f90:(.text+0x19cb): undefined reference to 
> >> `netcdf_mp_nf90_put_var_1d_fourbytereal_'
> >> pres_temp_4D_wr.f90:(.text+0x1cb3): undefined reference to 
> >> `netcdf_mp_nf90_put_var_text_'
> >> pres_temp_4D_wr.f90:(.text+0x1e02): undefined reference to 
> >> `netcdf_mp_nf90_put_var_3d_fourbytereal_'
> >> pres_temp_4D_wr.f90:(.text+0x1f47): undefined reference to 
> >> `netcdf_mp_nf90_put_var_3d_fourbytereal_'
> >> pres_temp_4D_wr.f90:(.text+0x2011): undefined reference to 
> >> `netcdf_mp_nf90_close_'
> >> pres_temp_4D_wr.f90:(.text+0x217c): undefined reference to 
> >> `netcdf_mp_nf90_strerror_'
> >> pres_temp_4D_wr.f90:(.text+0x2290): undefined reference to 
> >> `netcdf_mp_nf90_strerror_'
> >> pres_temp_4D_wr.f90:(.text+0x23a4): undefined reference to 
> >> `netcdf_mp_nf90_strerror_'
> >> pres_temp_4D_wr.f90:(.text+0x24b8): undefined reference to 
> >> `netcdf_mp_nf90_strerror_'
> >> pres_temp_4D_wr.f90:(.text+0x25cc): undefined reference to 
> >> `netcdf_mp_nf90_strerror_'
> >> /tmp/ifortgqaUzq.o:pres_temp_4D_wr.f90:(.text+0x26e0): more undefined 
> >> references to `netcdf_mp_nf90_strerror_' follow
> >>
> >> The objects seem to be in the appropriate NetCDF library:
> >>
> >> nm -A -g $NETCDF/lib/libnetcdff.a | grep netcdf_mp_nf90_create_
> >> /nethome/cmattock/usr/local/netcdf4/lib/libnetcdff.a:netcdf.o:00000000000002c0
> >>  T netcdf_mp_nf90_create_
> >> /nethome/cmattock/usr/local/netcdf4/lib/libnetcdff.a:netcdf.o:00000000000000a0
> >>  T netcdf_mp_nf90_create_mp_
> >>
> >> nm -A -g $NETCDF/lib/libnetcdff.a | grep netcdf_mp_nf90_def_dim_
> >> /nethome/cmattock/usr/local/netcdf4/lib/libnetcdff.a:netcdf.o:0000000000000340
> >>  T netcdf_mp_nf90_def_dim_
> >>
> >> etc.
> >>
> >> I can compile the program:
> >> ifort -c ${FFLAGS} -I${NETCDF}/include pres_temp_4D_wr.f90
> >>
> >> ls -l
> >> -rw-r--r-- 1 cmattock soden 15886 Aug  3 14:02 pres_temp_4D_wr.f90
> >> -rw-r--r-- 1 cmattock soden 38992 Aug  3 17:49 pres_temp_4D_wr.o
> >>
> >> but I can't seem to link the object to the Fortran libraries.
> >>
> >> What am I doing wrong? Any hints or suggestions?
> >>
> >> Thank you!
> >> Craig
> >>
> >> ---------------------------------------------------
> >> Dr. Craig A. Mattocks
> >> Atmospheric Research Scientist
> >> Meteorology and Physical Oceanography, MSC 339
> >> Rosenstiel School of Marine and Atmospheric Science
> >> University of Miami
> >> 4600 Rickenbacker Causeway
> >> Miami, FL 33149-1301
> >> phone: (305) 421-4287
> >> e-mail: address@hidden
> >> address@hidden
> >> http://www.rsmas.miami.edu/about-rsmas/
> >> ---------------------------------------------------
> >>
> >>
> >
> > Russ Rew                                         UCAR Unidata Program
> > address@hidden                      http://www.unidata.ucar.edu
> >
> >
> >
> > Ticket Details
> > ===================
> > Ticket ID: RSG-712199
> > Department: Support netCDF
> > Priority: Normal
> > Status: Closed
> >
> 
> 

Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: RSG-712199
Department: Support netCDF
Priority: Normal
Status: Closed


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.