[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 20020403: netCDF on MacOS X
- Subject: Re: 20020403: netCDF on MacOS X
- Date: Thu, 04 Apr 2002 13:48:39 -0700
>To: address@hidden
>From: Neil Banas <address@hidden>
>Subject: netCDF on MacOS X
>Organization: U Washington
>Keywords: 200204032115.g33LF4a29111 netCDF MacOS-X
Hi Neil,
> I've tried installing netCDF 3.5.0--the fortran interface--on my Mac (OS
> 10.1) a few different ways and am having major problems with all of them.
> Hope you can help.
>
> I've given a fair bit of detail below.
>
> --------------
> method 1: starting with the netCDF source
> I follow the instructions given on the website for OS X with Fortran, set
> the env variables CC, CPPFLAGS, FC, FFLAGS.
> ./compile runs with no errors.
I assume you mean "./configure" runs with no errors.
> make gives this error:
> error.c: In function `strerror':
> error.c:24: conflicting types for `sys_errlist'
> /usr/include/stdio.h:265: previous declaration of `sys_errlist'
> This is a standard C library, right? I reinstalled the Apple Developer
> Tools (which includes gcc) right before doing this, so I don't know why
> this should fail.
I just tried this with netCDF 3.5.0 on Mac OS X 10.1.3 and I couldn't
reproduce the problem. I'm not sure how to find the version of the
Developer Tools I'm using, but I wouldn't think it would matter much.
Here's the version of gcc I'm using, if that's any help:
$ /usr/bin/cc --version
2.95.2
And "uname -a" gives:
$ uname -a
Darwin mort.unidata.ucar.edu 5.3 Darwin Kernel Version 5.3: Thu Jan 24
22:06:02 PST 2002; root:xnu/xnu-201.19.obj~1/RELEASE_PPC Power Macintosh
powerpc
And here's the full info on /usr/include/stdio.h:
$ ls -l /usr/include/stdio.h
-r--r--r-- 1 root wheel 13954 Sep 9 2001 /usr/include/stdio.h
You might check to make sure you've set CC, CPPFLAGS, FC, FFLAGS as
environment variables rather than regular shell variables. For
shell-specific details, see the section "Setting Environment
Variables" in the INSTALL document (sorry if this is insulting, but
I'm just trying to cover all possibilities). Anyway with these
environment variable settings:
CC=/usr/bin/cc
CPPFLAGS=-Df2cFortran
FC=/usr/bin/g77
FFLAGS=-w
the .configure script succeeds with warnings about
configure: warning: CC failed on test program
configure: warning: Could not find working Fortran-90 compiler
configure: warning: The Fortran-90 interface will not be built
but it finds "c++" works and "make all" and "make test" succeed:
Making `all' in directory /home/russ/netcdf/build/mort0/src/libsrc
/usr/bin/cc -c -O -I. -Df2cFortran attr.c
/usr/bin/cc -c -O -I. -Df2cFortran dim.c
/usr/bin/cc -c -O -I. -Df2cFortran error.c
/usr/bin/cc -c -O -I. -Df2cFortran -DVERSION=`cat ../VERSION` libvers.c
MEMORY:1: warning: malformed floating constant
/usr/bin/cc -c -O -I. -Df2cFortran nc.c
...
Making `test' in directory /home/russ/netcdf/build/mort0/src/libsrc
/usr/bin/cc -c -O -I. -Df2cFortran t_nc.c
ar cru libnetcdf.a attr.o dim.o error.o libvers.o nc.o ncio.o ncx.o putget.o
string.o v1hpg.o v2i.o var.o
ranlib libnetcdf.a
...
./nctst > test.out
*** C++ test successful ***
Returning to directory /home/russ/netcdf/build/mort0/src
> --------------
> method 2: netCDF binary from FINK
> The netCDF package installs fine, and I get much farther this way. I can
> compile the Fortran code written by ncgen, but can't link it to
> libnetcdf.a.
> Here's my test program.
> program netcdftest
> include 'netcdf.inc'
> integer ncid, err
> err = nf_open('samp.nc',nf_nowrite,ncid)
> print *, nf_strerror(err)
> end
> Whether I compile this with Absoft Fortran 7.0 (f77), or with g77...
> f77 -w -f -I/sw/include -L/sw/lib -lnetcdf netcdftest.f
> ...I get the error
> /usr/bin/ld: Undefined symbols:
> _nf_open
> _nf_strerror
> When I split up the fortran-compilation and linking steps, the source
> compiles fine, and the .inc file is included fine (no error on the
> parameter nf_nowrite)--it's just a problem linking to the library.
>
> The odd thing is that the back-compatibility routines link, but run with
> errors, in Absoft Fortran. When I change nf_open and nf_strerror to
> nc_open and nc_strerror, the program runs, but gives the error
> 246676
> When I change nc_open to ncopen, it gives the error
> ncopen: filename "samp.nc(B??No such file or directory
> as if the filename is getting passed to ncopen incorrectly. (By the way, I
> know the file is good because I can open it with netCDF for Matlab.)
We don't have access to an Absoft f77 compiler for Mac OS X, but have
a report of success building with it on Mac OS X:
http://www.unidata.ucar.edu/glimpse/netcdfgroup-list/1497
You might use the "nm" utility on your libnetcdf.a to see if the
Fortran routines _nf_open etc. are actually there:
$ nm -a libnetcdf.a | grep _nf_open
00000494 T _nf_open__
Note that if "make test" ran OK in the ncgen directory, then it did
successfully compile an ncgen-generated Fortran 77 program that called
some of the Fortran interface routines, such as nf_create() and that
linked and ran successfully. That's what the "ncgen -f" test does. You
could rerun that test and look carefully at the flags that the
makefile used for linking to make sure you're using similar flags.
You might have to modify the ncgen/Makefile to take out some of the
leading "@" characters so those lines get printed out when you run
"make test" or "make f-test" in the ncgen directory.
> so: I feel like the FINK binary method is closer to working, but I can't
> fathom how the library can be present and located and the routines inside
> mostly _but not entirely_ inaccessible. I have the same problem when I use
> the binary you provide at
> ftp://ftp.unidata.ucar.edu/pub/binary/macosx_10.1-powerpc/
> (with the .inc file from the FINK download).
>
> any ideas?
No, but I'd be interested in anything you find out. Were you letting
fink build from source or just getting the fink-built binaries? In
the latter case, you would probably have to be using the same
C/Fortran compiler combination fink used in building the libraries ...
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu