40static char rcsid[] not_used = {
"$Id$" };
44#include <libdap/InternalErr.h>
45#include <libdap/util.h>
65NCByte::NCByte(
const string &n,
const string &d) :
70NCByte::NCByte(
const NCByte &rhs) :
80NCByte::operator=(
const NCByte &rhs)
85 dynamic_cast<NCByte&
> (*this) = rhs;
91NCByte::ptr_duplicate()
93 return new NCByte(*
this);
101 errstat = nc_open(dataset().c_str(), NC_NOWRITE, &ncid);
102 if (errstat != NC_NOERR) {
103 string err =
"Could not open the dataset's file (" + dataset() +
")";
104 throw Error(errstat, err);
108 errstat = nc_inq_varid(ncid, name().c_str(), &varid);
109 if (errstat != NC_NOERR)
110 throw InternalErr(__FILE__, __LINE__,
111 "Could not get variable ID for: " + name() +
". (error: " + long_to_string(errstat) +
").");
114#if NETCDF_VERSION >= 4
115 errstat = nc_get_var(ncid, varid, &Dbyte);
117 size_t cor[MAX_NC_DIMS];
120 errstat = nc_inq_var(ncid, varid, (
char *) 0, &datatype, &num_dim, (
int *) 0, (
int *) 0);
121 if (errstat != NC_NOERR) {
122 throw Error(errstat,
string(
"Could not read information about the variable `") + name() +
string(
"'."));
124 if (datatype != NC_BYTE) {
125 throw InternalErr(__FILE__, __LINE__,
"Entered NCByte::read() with non-byte variable!");
128 for (
int id = 0;
id <= num_dim &&
id < MAX_NC_DIMS;
id++) {
132 errstat = nc_get_var1_uchar(ncid, varid, cor, &Dbyte);
135 if (errstat != NC_NOERR)
136 throw Error(errstat,
string(
"Could not read the variable '") + name() +
string(
"'."));
142 if (nc_close(ncid) != NC_NOERR)
143 throw InternalErr(__FILE__, __LINE__,
"Could not close the dataset!");