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

[netCDF #QGV-335526]: Problem with netcdf and fortran 90



Hi Delphine ,

> I'm trying to compile a fortran code but it seems my netcdf library is
> not referenced correctly. However, I can't find the reason why. I hope
> you could help me finding the source of the problem.
> 
> My environment is Mac OS X 10.6.6.
> Fortran compiler is ifort 12.0.0
> 
> I have installed the netcdf 4.1.1 library. See below the results of the
> command 'nc-config --all'
> 
> I'm trying to compile a simple code requiring netcdf library. However,
> I'm getting this error message:
> 
> Undefined symbols:
> "_nf_open_", referenced from:
> _wr4dnc_ in netcdf4d.o
> ld: symbol(s) not found
> make: *** [main] Error 1

First, please check that the library was compiled for the same architecture
as your application program.  A common error on Mac's is to build a library
for a 64-bit x86_64 architecture and try to link a program compiled for a
32-bit i386 architecture with that library (or vice versa).  The result is
that netCDF library functions won't be found.  You can check what 
architectures your program and library are compiled for with the "file"
command, as in 

  $ file /opt/local/lib/netcdff.dylib
  /opt/local/lib/netcdff.dylib:  Mach-O 64-bit dynamically linked shared 
library x86_64

If your Fortran and C compilers have different defaults for arcitectures, 
you may have to use -m64 or -m32 CFLAGS or FCFLAGS explicitly to make sure 
they match.

That may not be the problem, because I see another possible symptom of
a problem in the nc-config output you sent:

> --libs -> -L/opt/local/lib -lnetcdf -L/opt/local//lib -lhdf5_hl -lhdf5 
> -L/opt/local//lib -lz -lm -L/opt/local//lib -lsz -L/opt/local/lib -lcurl 
> -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -lidn -lssl -lcrypto -lssl 
> -lcrypto -lz -lz
 ...
> --flibs -> -L/opt/local/lib -lnetcdf -L/opt/local//lib -lhdf5_hl -lhdf5 
> -L/opt/local//lib -lz -lm -L/opt/local//lib -lsz -L/opt/local/lib -lcurl 
> -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -lidn -lssl -lcrypto -lssl 
> -lcrypto -lz -lz

Both of these have a double slash "//" in some -L options, as in 
"-L/opt/local//lib".  That seems wrong, and may be the result of a typo
when the library was configured and built, or may be a bug in nc-config,
but I don't see such a double slash in the --libs or --flibs output of
the 4.1.1 nc-config here.

Can you check if things work if you change this "//" to "/" in your link
command?

--Russ

> nc-config --all
> 
> This netCDF 4.1.1 has been built with the following features:
> 
> --cc        -> icc
> --cflags    ->  -I/opt/local/include
> --libs      -> -L/opt/local/lib -lnetcdf -L/opt/local//lib -lhdf5_hl -lhdf5  
> -L/opt/local//lib -lz -lm  -L/opt/local//lib -lsz  -L/opt/local/lib -lcurl 
> -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -lidn -lssl -lcrypto -lssl 
> -lcrypto -lz -lz
> 
> --cxx       -> icpc
> --has-c++   -> yes
> 
> --fc        -> ifort
> --fflags    -> -g -I/opt/local/include
> --flibs     -> -L/opt/local/lib -lnetcdf -L/opt/local//lib -lhdf5_hl -lhdf5  
> -L/opt/local//lib -lz -lm  -L/opt/local//lib -lsz  -L/opt/local/lib -lcurl 
> -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -lidn -lssl -lcrypto -lssl 
> -lcrypto -lz -lz
> --has-f77   -> yes
> --has-f90   -> yes
> 
> --has-dap   -> yes
> --has-nc2   -> yes
> --has-nc4   -> yes
> --has-hdf5  -> yes
> --has-hdf4  -> no
> --has-szlib -> yes
> 
> --prefix    -> /opt/local
> --includedir-> /opt/local/include
> --version   -> netCDF 4.1.1
> 
> 

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



Ticket Details
===================
Ticket ID: QGV-335526
Department: Support netCDF
Priority: Normal
Status: Closed