From Gary.Hodges at noaa.gov Thu Feb 1 15:20:14 2007 From: Gary.Hodges at noaa.gov (Gary Hodges) Date: Thu, 01 Feb 2007 15:20:14 -0700 Subject: varid return value Message-ID: <45C2679E.8010608@noaa.gov> The netcdf man page indicates that ncvarid will return a value of -1 if an error occurs. I have the following code and I know that "head_temp2" does not exist in the netcdf file. my $vid = NetCDF::varid($ncid, "head_temp2"); print("$vid\n); I get the error "ncvarid: ncid 5: Variable not found" when this is run. Ultimately what I want to do is test if a variable exists and set a flag based on the result so I'm not necessarily tied to varid. Gary ============================================================================== To unsubscribe netcdf-perl, visit: http://www.unidata.ucar.edu/mailing-list-delete-form.html ============================================================================== From steve at unidata.ucar.edu Thu Feb 1 15:32:03 2007 From: steve at unidata.ucar.edu (Steve Emmerson) Date: Thu, 01 Feb 2007 15:32:03 -0700 Subject: varid return value In-Reply-To: <45C2679E.8010608@noaa.gov> References: <45C2679E.8010608@noaa.gov> Message-ID: <45C26A63.4020309@unidata.ucar.edu> Gary, Does the perl script exit after the error occurs? Are you using the NetCDF::opts() function to tell the netCDF library not to terminate when an error occurs? Regards, Steve Emmerson Gary Hodges wrote: > The netcdf man page indicates that ncvarid will return a value of -1 if > an error occurs. I have the following code and I know that "head_temp2" > does not exist in the netcdf file. > > my $vid = NetCDF::varid($ncid, "head_temp2"); > print("$vid\n); > > I get the error "ncvarid: ncid 5: Variable not found" when this is run. > Ultimately what I want to do is test if a variable exists and set a > flag based on the result so I'm not necessarily tied to varid. > > Gary > > =============================================================================== > > To unsubscribe netcdf-perl, visit: > http://www.unidata.ucar.edu/mailing-list-delete-form.html > =============================================================================== > ============================================================================== To unsubscribe netcdf-perl, visit: http://www.unidata.ucar.edu/mailing-list-delete-form.html ==============================================================================