34static char rcsid[] not_used = {
"$Id$" };
37#include <libdap/InternalErr.h>
41NCUInt32::NCUInt32(
const string &n,
const string &d) :
46NCUInt32::NCUInt32(
const NCUInt32 &rhs) :
56NCUInt32::operator=(
const NCUInt32 &rhs)
61 dynamic_cast<NCUInt32&
> (*this) = rhs;
67NCUInt32::ptr_duplicate()
70 return new NCUInt32(*
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 during read.");
90#if NETCDF_VERSION >= 4
92 errstat = nc_get_var(ncid, varid, &lng);
95 size_t cor[MAX_NC_DIMS];
98 errstat = nc_inq_var(ncid, varid, (
char *)0, &datatype, &num_dim, (
int *)0,
100 if( errstat != NC_NOERR )
102 throw Error(errstat,
string(
"Could not read information about the variable `") + name() +
string(
"'."));
104 if( datatype != NC_LONG )
106 throw InternalErr(__FILE__, __LINE__,
"Entered NCUInt32::read() with non-Int32 variable!");
109 for(
int id = 0;
id <= num_dim &&
id < MAX_NC_DIMS;
id++ )
114 errstat = nc_get_var1_long( ncid, varid, cor, &lng ) ;
116 if (errstat != NC_NOERR)
117 throw Error(errstat,
string(
"Could not read the variable `") + name() +
string(
"'."));
121 dods_uint32 uintg32 = (dods_uint32) lng;
124 if (nc_close(ncid) != NC_NOERR)
125 throw InternalErr(__FILE__, __LINE__,
"Could not close the dataset!");