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

20000928: Testing for exisiting dimensions (fwd)



Matt,

> Date:    Thu, 28 Sep 2000 11:22:53 -0700
> From:    "Matt D'Ortenzio" <address@hidden>
> To:      address@hidden
> Subject: Testing for exisiting dimensions

The above message contained the following:

> I ran into a problem while trying to test whether certain dimension names 
> exist in one of my datasets.  I wrote the following, where "dummy" is not 
> a name of a dimension in the set:
> 
> $dimIdentifier = NetCDF::dimid($ncID, "dummy");
> if ($dimIdentifier  ==  -1)
> {
>      print "Dimension doesn't exist..\n\n";
> }
> 
> I was hoping that the "dimid" function would simply set the $dimIdentifier 
> variable to -1 and execution would continue, however right after the 
> "dimid" function is called, the program stops and the following netCDF 
> error message is printed:
> 
> ncdimid: ncid 3: Invalid dimension id or name
> 
> How can you cleanly catch this error?  Thanks for the help.

Your program halts because the default error-handling action of the
netCDF library is to abort on error.  To override, call the following
first:

    NetCDF::ncopts(NetCDF::VERBOSE);

This will cause the netCDF library to print a message to standard error
and then continue.

> -Matt
> *************************************************************
> Matt D'Ortenzio
> NASA Ames Research Center
> MS 269-1
> Moffett Field, CA   94035
> Phone: (650)604-1715
> Email: address@hidden
> *************************************************************

Regards,
Steve Emmerson   <http://www.unidata.ucar.edu>