27static const int NLAT = 6;
 
   28static const int NLON = 12;
 
   31static const float SAMPLE_PRESSURE = 900;
 
   32static const float SAMPLE_TEMP = 9.0;
 
   33static const float START_LAT = 25.0;
 
   34static const float START_LON = -125.0;
 
   37static const int NC_ERR = 2;
 
   42   float presIn[NLAT][NLON];
 
   43   float tempIn[NLAT][NLON];
 
   52   NcFile dataFile(
"sfc_pres_temp.nc", NcFile::read);
 
   67   latVar = dataFile.
getVar(
"latitude");
 
   68   if(latVar.
isNull()) 
return NC_ERR;
 
   69   lonVar = dataFile.
getVar(
"longitude");
 
   70   if(lonVar.
isNull()) 
return NC_ERR;
 
   75   for(
int lat = 0; lat < NLAT; lat++)
 
   76      if (latsIn[lat] != START_LAT + 5. * lat)
 
   80   for (
int lon = 0; lon < NLON; lon++)
 
   81      if (lonsIn[lon] != START_LON + 5. * lon)
 
   85   NcVar presVar, tempVar;
 
   86   presVar = dataFile.
getVar(
"pressure");
 
   87   if(presVar.
isNull()) 
return NC_ERR;
 
   88   tempVar = dataFile.
getVar(
"temperature");
 
   89   if(tempVar.
isNull()) 
return NC_ERR;
 
   94   for (
int lat = 0; lat < NLAT; lat++)
 
   95      for (
int lon = 0; lon < NLON; lon++)
 
   96     if (presIn[lat][lon] != SAMPLE_PRESSURE + (lon * NLAT + lat)
 
   97         || tempIn[lat][lon] != SAMPLE_TEMP + .25 * (lon * NLAT + lat))
 
  105   att = latVar.
getAtt(
"units");
 
  106   if(att.
isNull()) 
return NC_ERR;
 
  109   if (units != 
"degrees_north")
 
  111       cout<<
"getValue returned "<<units<<endl;
 
  116   att = lonVar.
getAtt(
"units");
 
  117   if(att.
isNull()) 
return NC_ERR;
 
  120   if (units != 
"degrees_east")
 
  122       cout<<
"getValue returned "<<units<<endl;
 
  126   att = presVar.
getAtt(
"units");
 
  127   if(att.
isNull()) 
return NC_ERR;
 
  132       cout<<
"getValue returned "<<units<<endl;
 
  136   att = tempVar.
getAtt(
"units");
 
  137   if(att.
isNull()) 
return NC_ERR;
 
  140   if (units != 
"celsius")
 
  142       cout<<
"getValue returned "<<units<<endl;
 
  155     cout<<
"FAILURE********************************8"<<endl;
 
bool isNull() const
Returns true if this object is null (i.e.
void getValues(char *dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Class represents a netCDF root group.
Class represents a netCDF attribute local to a netCDF variable.
Class represents a netCDF variable.
void getVar(void *dataValues) const
This is an overloaded member function, provided for convenience.
NcVarAtt getAtt(const std::string &name) const
Gets attribute by name.
bool isNull() const
Returns true if this object variable is not defined.
Base object is thrown if a netCDF exception is encountered.