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

[netCDF #CXR-134834]: linking netCDF library with program written in Fortran



Hi Ana,

Sorry to have taken so long to respond to your question ...
> I have installed the following libraries on my MacBook Pro (OS X 10.8.2) 
> using MacPorts:
> 
> - netcdf @4.2.1.1
> - netcdf-cxx @4.2
> - netcdf-fortran @4.2
> 
> I need to pass the information about the netcdf interface to JULES
> program written in Fortran and in the user manual the following option
> is suggested:
> 
> make COMPILER=gfortran BUILD=run CDF_LIB_PATH=/opt/local/lib \
> CDF_MOD_PATH=/opt/local/include
>
> The values for these options are the directories in which the pre-compiled
> netCDF library (libnc.a) and Fortran 90 module files (those with .mod
> extension) are located respectively. However, in my lib directory I don't
> have libnc.a library, only libnetcdf_c++.a and libnetcdf.a libraries. 

NetCDF doesn't install any library named "libnc.a", only libnetcdff.a (for 
Fortran),
libnetcdf.a (for C), and libnetcdf_c++.a, for C++.  You generally don't need the
C++ library, unless JULES requires it for some reason.  The Fortran netCDF 
library
calls the C library, so you generally need to link Fortran applications with 
both,
as your output from nc-config --flibs shows.  The Makefile also must know where 
the
netcdf.h, netcdf.inc, and netcdf.MOD files are, usually all in the same 
include/ 
directory

> ... In
> my include directory I have NETCDF.mod and TYPESIZES.mod files. Now, when
> I run the above given command in my Terminal, I get the following error:
> â.
> â.
> gfortran -c -fbounds-check rwerr_mod.f90 -J/Users/Nana/JULES/jules_v2.2/MODS 
> -I/Users/Nana/JULES/jules_v2.2/MODS -I/Users/Nana/netcdf/include 
> -I/Users/Nana/JULES/jules_v2.2/UTILS/drhook_dummy
> Fatal Error: Reading module netcdf at line 25 column 2: Expected string
> make[1]: *** [/Users/Nana/JULES/jules_v2.2/libjules.a(rwerr_mod.o)] Error 1
> make: *** [make_SOURCE/MODULES/CONTROL] Error 2

The format of .mod module files is compiler-specific, so if you used a 
different Fortran
compiler than gfortran (or even an earlier version) when you built the netCDF 
Fortran-90
library from source, it might generate such an error.  Also if you just copied 
the .MOD
file into the /Users/Nana/netcdf/include directory from a different directory 
where it was
built for a different platform or compiler, you would see such an error.

Otherwise, I don't know what would cause this.

> When I run nc-config --flibs, I get the following information:
> 
> -L/opt/local/lib -lnetcdff -L/opt/local/lib -lnetcdf -lnetcdf
> 
> and for nc-config --includedir
> 
> /opt/local/include
> 
> Do you have an idea what I could do to fix this?

I suspect you would might better advice asking the JULES help-desk or 
support about this problem, since it may be related to something in
the JULES Makefile.

--Russ

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



Ticket Details
===================
Ticket ID: CXR-134834
Department: Support netCDF
Priority: High
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.