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

(Fwd) Re: 970923: netcdf 3.3.1 fortran interface: HP-UX probs



    >> To: address@hidden From: Holger Wenzel
    >> <address@hidden> Subject: netcdf 3.3.1 fortran
    >> interface: HP-UX probs Organization: .  Keywords:
    >> 199709231518.JAA15329
    >>
    >> Hi,
    >>
    >> I'm using a program that uses your netcdf-package to perform
    >> input/output.
    >>
    >> On a SGI-workstation and on a Cray J-90 everything works o.k.,
    >> but when I try to use it on a HP-workstation using either HPUX
    >> 9.07 or HPUX 10.20 I have some problems reading netcdf files
    >> in, that were written on another system.
    >>
    >> I've boild the problem down to the following program that
    >> calculates the value of pi and writes it out to a netcdf file
    >> called nc.test.
    >>
    >> test_nc.f:
    >>
    >> program test_nc
    >>
    >> implicit none
    >>
    >> include 'netcdf.inc'
    >>
    >> real x
    >>
    >> integer rcode, cdfid
    >>
    >> x=4*atan(1.)
    >>
    >> cdfid = NCCRE("nc.test", NCCLOB, rcode)
    >>
    >> call NCAPT(cdfid, NCGLOBAL, 'x', NCDOUBLE, 1, x, rcode)
    >>
    >> call NCCLOS(cdfid, rcode)
    >>
    >> stop 'test_nc end'
    >>
    >> end
    >>
    >>
    >>
    >> If I compile it e.g. on HPUX 10.20 with the command line, using
    >> the -R8 switch to get double precison as default:
    >>
    >> fort77 -R8 -o test_nc -I$HOME/executables/H8000/include
    >> -L$HOME/executables/H8000/lib test_nc.f -lnetcdf a call to this
    >> program and a subsequent call to ncdump gives:
    >>
    >> loredana:ugg[68]$ ./test_nc;ncdump -h nc.test STOP test_nc end
    >> netcdf nc {
    >>
    >> // global attributes: :x = 50.1238708496094 ; }
    >>
    >> where the value of x should be pi.
    >>
    >>
    >>
    >>
    >>
    >> Doing the same procedure on a sgi gives:
    >>
    >> f77 -r8 -o test_nc -I/disk2/people/hw/include
    >> -L/disk2/people/hw/lib
    Glenn> test_nc.f -lnetcdf
    >>  ctr-sgi1:ugg[262]$ ./test_nc; ncdump -h nc.test STOP test_nc
    >> end statement executed netcdf nc {
    >>
    >> // global attributes: :x = 3.14159265358979 ; }
    >>
    >>
    >>
    >> On the Cray J90 everything is o.k. as well.
    >>
    >>
    >>
    >> I've compiled the netcdf-library on the HP with no problems and
    >> the tests ran through smoothly.
    >>
    >>
    >>
    >> Changing the statement where I declare the variable x into
    >>
    >> real*8 x
    >>
    >> solves the problem with this testprogram, but I don't really
    >> want to do that in the program I do my calculations with.
    >>
    >>
    >>
    >> I can produce a netcdf file on a HP and read it back in with no
    >> problems, the problem I'm facing is, that I can't use the
    >> netcdf file from the Cray or a SGI to use it on a HP or vice
    >> versa.
    >>
    >> If I miss something obvious here, I'd apreciate a RTFM with a
    >> pointer, otherwise I'd be glad to provide you with more
    >> information if needed.
    >>
    >> Thanks for your effort.
    >>
    >> Holger - -- Holger Wenzel Institut fuer Technische Mechanik
    >> RWTH Aachen phone: +49/(0)241/80-4624 Templergraben 64 email:
    >> address@hidden D-52064 Aachen

    Glenn> Holger:

    Glenn> Your problem is inconsistant use of the -R8 flag to fort77.

    Glenn> The configuration script used to build the netcdf library
    Glenn> figures out what C type matches a FORTRAN REAL, and sticks
    Glenn> that into an include file used to build the FORTRAN
    Glenn> interface.  I'll wager the netcdf library was configured
    Glenn> without using '-R8', so the C type matching FORTRAN REAL in
    Glenn> the library is 'float'.

    Glenn> If you are going to use -R8 to your FORTRAN compiles, you
    Glenn> have to reconfigure and rebuild the netcdf library with
    Glenn> that assumption. Set the environment variable FFLAGS to
    Glenn> include -R8 before running configure.

    Glenn> As a matter of style, if your program depends on 8 byte
    Glenn> REALs or you want to compare results between machines 8
    Glenn> byte and 4 byte REALs, you should probably just say in your
    Glenn> program that you want REAL*8. That way it will be more
    Glenn> consistant across machines an you won't have to worry about
    Glenn> keeping track of multiple versions of the netcdf library.

    Glenn> -glenn

Glen:

Thanks a lot for the prompt answer.

I've tried to compile the netcdf library with the -R8 switch like this



export CPPFLAGS=-DNDEBUG
export CC=/bin/c89
export CFLAGS=-O
export FC=/usr/bin/fort77
export FFLAGS='-O -w -R8'
export CXX=/usr/bin/CC

./configure --prefix=$HOME/executables >configure.sout

make

make test

make install



But the behaviour I mentioned in my first mail didn't change. And now
the tests give an error while checking the fortran interface:



Making `test' in directory /sally/users/hw/executables/netcdf-3.3.1/src/fortran

        ar cru   ../libsrc/libnetcdf.a fort-attio.o      fort-control.o
 fort-dim.o      fort-genatt.o   fort-geninq.o   fort-genvar.o   fort-lib.o
 fort-misc.o     fort-v2compat.o         fort-vario.o    fort-var1io.o
 fort-varaio.o   fort-varmio.o   fort-varsio.o
        ranlib ../libsrc/libnetcdf.a
ranlib: ar already did it for you, see ar(1).
        /usr/bin/fort77 -o ftest -O -w -R8  ftest.o ../libsrc/libnetcdf.a
        ./ftest
*** Testing nccre ...
*** Testing ncddef ...
*** Testing ncvdef ...
*** Testing ncapt, ncaptc ...
*** Testing ncclos ...
*** Testing ncvpt1 ...
*** Testing ncvgt1 ...
 error in ncvgt 1 float: 2.1427 not close to 3.14159
*** Testing ncvpt ...
*** Testing ncopn, ncinq, ncdinq, ncvinq, ncanam, ncainq ...
*** Testing ncvgt, ncvgtc ...
*** Testing ncagt, ncagtc ...
*** Testing ncredf, ncdren, ncvren, ncaren, ncendf ...
*** Testing ncacpy ...
*** Testing ncadel ...
*** Testing fill values ...



Anyway, I'm going to declare my real variables as real*8 as you
proposed, so I don't have to solve that problem now. I'm just curious
why it works on a Silicon Graphics and not on a HP.

Thanks again for your help.

Holger


--
Holger Wenzel                        Institut fuer Technische Mechanik
                                                           RWTH Aachen
phone:  +49/(0)241/80-4624                            Templergraben 64
email:  address@hidden                     D-52064 Aachen