34static char rcsid[] not_used = {
"$Id$" };
37#include <libdap/InternalErr.h>
41NCUInt16::NCUInt16(
const string &n,
const string &d) :
46NCUInt16::NCUInt16(
const NCUInt16 &rhs) :
56NCUInt16::operator=(
const NCUInt16 &rhs)
61 dynamic_cast<NCUInt16&
> (*this) = rhs;
67NCUInt16::ptr_duplicate()
70 return new NCUInt16(*
this);
79 errstat = nc_open(dataset().c_str(), NC_NOWRITE, &ncid);
80 if (errstat != NC_NOERR) {
81 string err =
"Could not open the dataset's file (" + dataset() +
")";
82 throw Error(errstat, err);
86 errstat = nc_inq_varid(ncid, name().c_str(), &varid);
87 if (errstat != NC_NOERR)
88 throw Error(errstat,
"Could not get variable ID.");
91#if NETCDF_VERSION >= 4
92 errstat = nc_get_var(ncid, varid, &sht);
94 size_t cor[MAX_NC_DIMS];
97 errstat = nc_inq_var(ncid, varid, (
char *)0, &datatype, &num_dim, (
int *)0,
99 if( errstat != NC_NOERR )
101 throw Error(errstat,
string(
"Could not read information about the variable `") + name() +
string(
"'."));
103 if( datatype != NC_SHORT )
105 throw InternalErr(__FILE__, __LINE__,
"Entered NCUInt16::read() with non-UInt16 variable!");
108 for(
int id = 0;
id <= num_dim &&
id < MAX_NC_DIMS;
id++ )
113 errstat = nc_get_var1_short( ncid, varid, cor, &sht ) ;
115 if (errstat != NC_NOERR)
116 throw Error(errstat,
string(
"Could not read the variable `") + name() +
string(
"'."));
120 dods_uint16 uintg16 = (dods_uint16) sht;
123 if (nc_close(ncid) != NC_NOERR)
124 throw InternalErr(__FILE__, __LINE__,
"Could not close the dataset!");