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

[netCDF #FTD-335729]: netcdf F90 - trouble linking



> Hi Ed,
>
> Thanks for your help, and sorry for the delayed response.  I had to turn my
attention to other things for a few days.  I have installed and built the daily
snapshot distribution, and make check reports that all is well.  I built with
the following environment variables set, then ran make check and make install.
>
> ===========
> [twh142@kernighan ~]$ export CC=/usr/bin/gcc
> [twh142@kernighan ~]$ export CXX=/usr/bin/g++
> [twh142@kernighan ~]$ export F77=/usr/bin/gfortran
> [twh142@kernighan ~]$ export F90=/usr/bin/gfortran
> [twh142@kernighan ~]$ export FC=/usr/bin/gfortran
> [twh142@kernighan ~]$ cd netcdf-3.6.2-snapshot2007111702/
> [twh142@kernighan netcdf-3.6.2-snapshot2007111702]$ mkdir ../netcdf_install
> [twh142@kernighan netcdf-3.6.2-snapshot2007111702]$ pwd
> /home3/twh142/netcdf-3.6.2-snapshot2007111702
> [twh142@kernighan netcdf-3.6.2-snapshot2007111702]$ ./configure
--prefix=/home3/
> twh142/netcdf_install
> ===========
>
> One of the example programs compiles, links, and runs without problems:
> ===========
> [twh142@backus F90]$ pwd
> /home3/twh142/netcdf-3.6.2-snapshot2007111702/examples/F90
> [twh142@backus F90]$ gfortran -I../../f90 -g -O2 -c pres_temp_4D_rd.f90
> [twh142@backus F90]$ gfortran -g -O2 pres_temp_4D_rd.o
../../libsrc/.libs/libnetcdf.a -o pres_temp_4D_rd
> [twh142@backus F90]$  ls -l pres_temp_4D_rd.o pres_temp_4D_rd
> -rwxr-xr-x  1 twh142 dice 1577424 Nov 18 08:01 pres_temp_4D_rd
> -rw-r--r--  1 twh142 dice   11984 Nov 18 08:01 pres_temp_4D_rd.o
> [twh142@backus F90]$ ./pres_temp_4D_rd
> *** SUCCESS reading example file pres_temp_4D.nc!
> ===========
>
> When I try to build my model, everything compiles but will not link (same as
before):
>
> ===========
> [twh142@backus sib3]$ make -f Makefile.tim remake
> rm -f SiBD3 sibmerge *.o *.mod *.stb
> gfortran  -I/home3/twh142/netcdf-3.6.2-snapshot2007111702/f90 -g -O2 -c
kinds.F90 -o kinds.o
>
> gfortran  -I/home3/twh142/netcdf-3.6.2-snapshot2007111702/f90 -g -O2 -c
physical_parameters.F90 -o physical_parameters.o
>
> gfortran  -I/home3/twh142/netcdf-3.6.2-snapshot2007111702/f90 -g -O2 -c
eau_params.F90 -o eau_params.o
>
> <SNIP>
>
> gfortran -g -O2 kinds.o physical_parameters.o eau_params.o sib_const_module.o
sib_io_module.o sib_bc_module.o sibtype.o timetype.o addinc.o balan.o
dtess_eau.o begtem.o cfrax.o clm_combo.o combine_snow.o compact_snow.o cycalc.o
delef.o delhf.o dellwf.o hydro_canopy.o hydro_snow.o hydro_soil.o qsat_eau.o
ess_eau.o netrad.o phosib.o rada2.o rbrd.o respsib.o rnload.o soilwater.o
sortin.o subdivide_snow.o tridiag_solver.o vmfcalz.o vmfcalzo.o vntlat.o
sibslv.o update.o resp_control.o sib.o handle_err.o init_grid.o init_var.o
zenith.o init_sibdrv.o time_init.o time_manager.o sibdrv_read_single.o
sibdrv_read_ecmwf.o sibdrv_read_ncep2.o sibdrv_read_geos4.o read_ti.o mapper.o
calculate_td.o read_ndvi.o previous_bc.o rtape_sib.o diagnostic_output.o
pbpwrite.o qpwrite.o output_control.o sibdrv_interp.o bc_interp.o SiBDRV.o
/home3/twh142/netcdf-3.6.2-snapshot2007111702/libsrc/.libs/libnetcdf.a
-L/usr/global/lapackpp/lib -llapack -lblas    -o  SiBD3
> handle_err.o(.text+0x7a): In function `handle_err_':
> /home3/twh142/wlef/sib3/handle_err.F90:19: undefined reference to
`nf90_strerror_'
> init_grid.o(.text+0xe35): In function `init_grid_':
> /home3/twh142/wlef/sib3/init_grid.F90:178: undefined reference to
`nf90_open_'
> init_grid.o(.text+0xe77):/home3/twh142/wlef/sib3/init_grid.F90:180: undefined
reference to `nf90_inq_dimid_'
> ===========
>
> There are then a whole bunch more undefined references.  Given that the
example code seems to work just fine, and I am compiling and linking with the
same syntax, could there be something in the model code that is causing this?
It seems strange to me that such a problem would manifest itself as a bunch of
undefined references in the linker.
>
> Thanks for your help,
> Tim
>

Howdy Tim!

Hmmm, this is a bit of a stumper...

I am assuming that you ran "make check" on netCDF, and that it was successful.
That is, netCDF passed all tests.

And since you say that you can build one of the F90 example programs, we know
that the netCDF library works, and includes the proper F90 API calls for
gfortran...

Try using the "nm" command to list the functions in the netCDF library (i.e.
the libnetcdf.a file). Make sure the functions you are trying to call are
listed, and that their names are exactly the same as what your linker is
complaining about (that is, same number of underscores in the same places). If
the names are not the same, then perhaps you are using different versions of
gfortran for the netCDF build and the program you are trying to compile.

Are some of the other libraries that you are calling also trying to call the
netCDF library? THat would also cause the problem you are seeing. Try moving
the netCDF library to the very end of the list in the link command and see what
that does.

Please let me know if neither of these suggestions help...

Thanks,

Ed


Ticket Details
===================
Ticket ID: FTD-335729
Department: Support netCDF
Priority: Normal
Status: Closed