Hi Russ:
I have the snapshot of netcdf4 as of 2008031112. I am using the F90
interface (Intel Macbook pro, the gcc hat comes with Xcode and
gfortran), and other than changing my prefix, I have done everything
by default, except for including the szlib library in hdf5.. So
given that, I have found:
1. A number of the examples for F90, in terms of the modules, only have
use netcdf
I found that this produces an error in my own code (the module was
found, so that is not the error), and programs would only compile if
both modules were used and in this order only:
use typesizes
use netcdf
2. In linking, I had to explicitly list netcdf, hdf_hl, hdf, z and sz
as the libraries to link in, otherwise I would get an undefined
reference.
I have already sent an email that how to do Vlen's in fortran is very
unclear - somehow the data needs to be stuffed into a character
buffer (what HDF fortran has done for awhile) but it is very unclear
how to map data into the given calls. Groups and subgroups, and
straightforward data puts so far are working fine.
HTH,
-Roy
On Apr 2, 2008, at 9:31 AM, Russ Rew wrote:
Hi Roy,
I am finally getting a chance to look at the f90 interface to
netcdf-4. I will use gfortran for compatibility. I am reading the
Makefile correctly that I should use:
gfortran -g -O2
and that libnetcdf libnetcdff and both hdf libs need to be linked in,
or are the hdflibs already linked to libnetcdf? Is there a preferred
order to the links?
By default, you don't need libnetcdff, which is a separate Fortran
library required only when you specify --enable-separate-fortran or
--enable-shared flags to the configure script.
The --enable-separate-fortran flag will cause the Fortran 77 and
Fortran
90 APIs to be built into a separate library, instead of being included
in the C library. This is useful for supporting more than one Fortran
compiler with the same netCDF C library. This is turned on by default
for shared library builds.
The --enable-shared flag will build shared libraries (as well as
static)
on platforms that support them.
If you have enabled shared libraries or specified a separate Fortran
library, you should link with the Fortran library first, since it
calls
functions in the C library, as in
-L/usr/local/netcdf -lnetcdff -lnetcdf
Because the netCDF-4 library calls HDF5 functions, HDF5 libraries need
to be specified after the netCDF library, as in
-L/usr/local/netcdf -lnetcdff -lnetcdf -L/usr/local/hdf -lhdf5_hl
-lhdf5
This finds functions in both the HDF5 high-level library and the HDF5
core library, and the libraries should be mentioned in that order.
It would be simpler if you define an environment variable or macro for
the needed libraries, as you would do in a Makefile.
Another approach is to define a customized compiler command (which
might
be an alias or a simple shell script) so you only have to get the
location of the include files and libraries right once and can change
them in one place. We may eventually provide such a convenience
command
if we can figure out how to make it flexible enough, analogous to the
h5cc script included in HDF5 software.
Eventually we would like to bundle the software to make linking
simpler,
but that will have to wait for a future release.
--Russ
**********************
"The contents of this message do not reflect any position of the U.S.
Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097
e-mail: Roy.Mendelssohn@xxxxxxxx (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/
"Old age and treachery will overcome youth and skill."