comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Is_netCDF Function
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Is_netCDF Function [message #38737] Fri, 26 March 2004 07:42 Go to previous message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Kenneth P. Bowman wrote:
> In article <MPG.1acd1c3c46279728989715@news.frii.com>,
> David Fanning <david@dfanning.com> wrote:
>
>
>> Isn't there a function to tell if a file is a netCDF file or not?
>> I've looked everywhere but the right place. :-(
>
>
> There's the function NCDF_EXITS, which sounds like it ought to do what
> you want, but it doesn't.
>
> To tell if a file is a netCDF file, try opening it and be prepared to
> handle the error.
>
> IDL> id = ncdf_open('.tcshrc')
> % NCDF_OPEN: Unable to open the file ".tcshrc". (NC_ERROR=-51)
> % Execution halted at: $MAIN$

That's what I do. I wrapped the above in an is_ncdf() function. The error value, -51,
indicates that the file is not an netCDF format file. Here's the complete list, with a
short description, from the netcdf.h file supplied with the netcdf library:

/*
* The netcdf version 3 functions all return integer error status.
* These are the possible values, in addition to certain
* values from the system errno.h.
*/

#define NC_ISSYSERR(err) ((err) > 0)

#define NC_NOERR 0 /* No Error */

#define NC_EBADID (-33) /* Not a netcdf id */
#define NC_ENFILE (-34) /* Too many netcdfs open */
#define NC_EEXIST (-35) /* netcdf file exists && NC_NOCLOBBER */
#define NC_EINVAL (-36) /* Invalid Argument */
#define NC_EPERM (-37) /* Write to read only */
#define NC_ENOTINDEFINE (-38) /* Operation not allowed in data mode */
#define NC_EINDEFINE (-39) /* Operation not allowed in define mode */
#define NC_EINVALCOORDS (-40) /* Index exceeds dimension bound */
#define NC_EMAXDIMS (-41) /* NC_MAX_DIMS exceeded */
#define NC_ENAMEINUSE (-42) /* String match to name in use */
#define NC_ENOTATT (-43) /* Attribute not found */
#define NC_EMAXATTS (-44) /* NC_MAX_ATTRS exceeded */
#define NC_EBADTYPE (-45) /* Not a netcdf data type */
#define NC_EBADDIM (-46) /* Invalid dimension id or name */
#define NC_EUNLIMPOS (-47) /* NC_UNLIMITED in the wrong index */
#define NC_EMAXVARS (-48) /* NC_MAX_VARS exceeded */
#define NC_ENOTVAR (-49) /* Variable not found */
#define NC_EGLOBAL (-50) /* Action prohibited on NC_GLOBAL varid */
#define NC_ENOTNC (-51) /* Not a netcdf file */
#define NC_ESTS (-52) /* In Fortran, string too short */
#define NC_EMAXNAME (-53) /* NC_MAX_NAME exceeded */
#define NC_EUNLIMIT (-54) /* NC_UNLIMITED size already in use */
#define NC_ENORECVARS (-55) /* nc_rec op when there are no record vars */
#define NC_ECHAR (-56) /* Attempt to convert between text & numbers */
#define NC_EEDGE (-57) /* Edge+start exceeds dimension bound */
#define NC_ESTRIDE (-58) /* Illegal stride */
#define NC_EBADNAME (-59) /* Attribute or variable name
contains illegal characters */
/* N.B. following must match value in ncx.h */
#define NC_ERANGE (-60) /* Math result not representable */
#define NC_ENOMEM (-61) /* Memory allocation (malloc) failure */


Of course, one should really define these in a netcdf.pro include file since I'm sure the
actual value associated with NC_ENOTNC, -51, could possibly chane in future releases (of
netcdf or IDL... or both!)

paulv
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Changing the Colour Table for RGB images on Linux/Solaris
Next Topic: Re: X and tvrd color scaling problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:52:26 PDT 2025

Total time taken to generate the page: 0.00428 seconds