NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi all, trying to compile netCDF-3.5.1 under CYGWIN with the NAG f95 compiler and with the Intel Fortran compilers under Linux compiler exhibited a few problems with the current netCDF release. I am new to netCDF, so maybe some issues mentioned are old and well known. 1) The file cfortran.h coming with netCDF is quite ancient, it should be replaced by a more recent one or patched suitably. By googling one can certainly find most necessary but scattered information. However, for compiling with NAG f95 I had to use another patch, since NAG f95 does not do the same name mangling as f2c (note: this may or may not be the correct place to fix the symptoms, but it did serve to compile and link the stuff): --- fortran/cfortran-netcdf.h 2004-02-18 18:27:40.000000000 +0100 +++ fortran/cfortran-netcdf-cygwin-nagf95.h 2004-04-06 14:33:13.000000000 +0200 @@ -74,7 +74,7 @@ /* Remainder of cfortran.h depends on the Fortran compiler. */ -#if defined(CLIPPERFortran) || defined(__CYGWIN32__) +#if (defined(CLIPPERFortran)||defined(__CYGWIN32__)) && !defined(NAGf90Fortran) #ifndef f2cFortran #define f2cFortran #endif If somebody knows how to correctly auto-detect the type of the Fortran 95 compiler, he or she might also set suitable defaults for the compiler options, such as "-mismatch -w=unused" for the NAG compiler. 2) The following patch should be applied to the source distribution --- ./nf_test/nf_test.F.orig 1997-06-11 18:20:48.000000000 +0200 +++ ./nf_test/nf_test.F. 2004-04-06 14:41:37.375000000 +0200 @@ -81,6 +81,9 @@ ! DIGITAL Visual Fortran needs DFPORT for iargc USE DFPORT implicit none +#elif defined(NAGf90Fortran) + USE F90_UNIX_ENV, only : iargc, getarg + implicit none #else implicit none integer iargc 3) In the file ncx.c there is a bug which throws an floating point exception with NAG f95. Running the Fortran 90 tests after compiling yields a core dump: [...] 00400000:D:/cygwin/usr/local/src/packages/netcdf-3.5.1/src/nf_test/nf_test.e xe ( symbols previously loaded) #0 0x00450bad in ncx_put_short_double ( xp=0xa0484ac, ip=0x22edb8) at ncx.c:408 408 ix_short xx = *ip; (gdb) l 408 403 } 404 405 int 406 ncx_put_short_double(void *xp, const double *ip) 407 { 408 ix_short xx = *ip; 409 put_ix_short(xp, &xx); 410 if(*ip > X_SHORT_MAX || *ip < X_SHORT_MIN) 411 return NC_ERANGE; 412 return ENOERR; (gdb) print *ip $1 = -32769 (gdb) Clearly, the assignment to the short xx should be made _after_ the range check, not before! I do not know what should happen when *ip is outside the range for shorts, so this is something for the maintainers to look into and to fix. -- Harald Anlauf Deutscher Wetterdienst (DWD) | Phone: +49-(0)69/678667-41 FE1/AP03 - Assimilation & Modelle | Fax: +49-(0)69/678667-54 63067 Offenbach | e-Mail: harald.anlauf@xxxxxx
netcdfgroup
archives: