[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 19991021: linking netCDF library
- Subject: Re: 19991021: linking netCDF library
- Date: Fri, 22 Oct 1999 10:30:38 -0600
>To: address@hidden
>From: "Chul Chung (Eddy)" <address@hidden>
>Subject: linking netCDF library
>Organization: Florida State University
>Keywords: 199910212021.OAA10448 HANDLE_ERR, error handling
Hi,
> I am a new user of netCDF. Recently, I made the first FORTRAN code that
>
> creates a netCDF file. When I compiled the program, it couldn't link the
>
> subroutine "handle_err", while other subroutines were linked fine.
>
> I got the netCDF package from http://www.unidata.ucar.edu/packages/netcdf.
The handle_error() function used in the examples in the documentation is
just to make the examples simpler. Error handling can differ greatly in
applications, depending on whether the program is trying to hide the
netCDF layer from the user.
But there is a simple example of a handle_error() function in the User's
Guide section 5.2, documenting the NF_STRERROR() function:
INCLUDE 'netcdf.inc'
...
SUBROUTINE HANDLE_ERR(STATUS)
INTEGER STATUS
IF (STATUS .NE. NF_NOERR) THEN
PRINT *, NF_STRERROR(STATUS)
STOP 'Stopped'
ENDIF
END
You could just use this, if you want something simple.
I usually would like to know where the error came from (source file
and line number in the FORTRAN source), and for this you would need
something a bit more complicated, to identify exactly where the error
was detected.
The way errors are handled is left up to the application, since there is
such a wide variety of ways to do this (much like other Unix I/O
libraries, in which you must check the returned error status and handle
it). So the only netCDF library support for error handling is the error
status returned by each function and the error strings returned by
nf_strerror().
--Russ
_____________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu