40 static char rcsid[]
not_used = {
"$Id$" };
43 #include <InternalErr.h>
67 dynamic_cast<NCInt32&
> (*this) = rhs;
85 errstat = nc_open(dataset().c_str(), NC_NOWRITE, &ncid);
86 if (errstat != NC_NOERR) {
87 string err =
"Could not open the dataset's file (" + dataset() +
")";
88 throw Error(errstat, err);
92 errstat = nc_inq_varid(ncid, name().c_str(), &varid);
93 if (errstat != NC_NOERR)
94 throw Error(errstat,
"Could not get variable ID.");
97 #if NETCDF_VERSION >= 4
98 errstat = nc_get_var(ncid, varid, &lht);
101 size_t cor[MAX_NC_DIMS];
104 errstat = nc_inq_var(ncid, varid, (
char *)0, &datatype, &num_dim, (
int *)0,
106 if( errstat != NC_NOERR )
108 throw Error(errstat,
string(
"Could not read information about the variable `") + name() +
string(
"'."));
110 if( datatype != NC_LONG )
112 throw InternalErr(__FILE__, __LINE__,
"Entered NCInt32::read() with non-Int32 variable!");
115 for(
int id = 0;
id <= num_dim &&
id < MAX_NC_DIMS;
id++ )
120 errstat = nc_get_var1_long( ncid, varid, cor, &lht ) ;
122 if (errstat != NC_NOERR)
123 throw Error(errstat,
string(
"Could not read the variable `") + name() +
string(
"'."));
127 dods_int32 intg32 = (dods_int32) lht;
130 if (nc_close(ncid) != NC_NOERR)
131 throw InternalErr(__FILE__, __LINE__,
"Could not close the dataset!");
virtual BaseType * ptr_duplicate()
NCInt32(const string &n, const string &d)
NCInt32 & operator=(const NCInt32 &rhs)