This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Hi Peter, I'm not able to reproduce the problem you are seeing, but maybe you are trying to link with a netCDF library that was not compiled with the same compiler flags you are using, in particular -r8 and -i8. If so, that might explain the problem. Before compiling your program and running it, I added the following at the end of the program: ! need to close file before exit CALL NCCLOS(NCID, RCODE) if(RCODE.ne.0) then print *,'NCCLOS, RCODE=',RCODE end if because the file must be closed to flush buffers and finish writing the file. Then I compiled and ran the program, and it produced the expected results: test$ f95 -g -I/upc/netcdf/include -c peterf.f -L/upc/netcdf/lib -lnetcdf test$ f95 -g peterf.o -L/upc/netcdf/lib -lnetcdf -o peterf test$ ./peterf NCID= 4 , RCODE= 0 test$ ncdump foo.nc netcdf foo { dimensions: lat = 5 ; lon = 10 ; time = UNLIMITED ; // (0 currently) variables: double rh(time, lat, lon) ; data: } In answer to your questions: > Can someone explain why I get the message coming from the libraries rather than a > non-zero result code returned? That's because the program is using the version 2 (1996) Fortran interface, for which the default error behavior, as explained here: http://www.unidata.ucar.edu/software/netcdf/guide_6.html#SEC37 was: ... by default all netCDF library routines just print an error message and exit when an error occurs. If this (admittedly drastic) error behavior is acceptable, you never need to check return values, since any condition that would result in an error will print an explanatory message and exit. ... If you want error messages, but do not wish errors to be fatal, turn off the fatal error flag with: CALL NCPOPT(NCVERBOS) If you want neither error messages nor fatal errors, turn off both flags with: CALL NCPOPT(0) > What is the invalid dimension ID or name in this example? The names and IDs in the program are all valid, so I can only speculate this is an artifact of compiling with options incompatible with the way the installed library was built. Incidentally the newer version 3 Fortran-77 and Fortran-90 interfaces have the error behavior you were expecting, returning an error code by default instead of exiting with a message. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: ZTO-391659 Department: Support netCDF Priority: Normal Status: Closed