43static char rcsid[] not_used ={
"$Id$"};
47#include <libdap/InternalErr.h>
52NCFloat32::NCFloat32(
const string &n,
const string &d) :
Float32(n, d)
60NCFloat32::~NCFloat32()
70 dynamic_cast<NCFloat32&
>(*this) = rhs;
77NCFloat32::ptr_duplicate()
79 return new NCFloat32(*
this);
87 size_t cor[MAX_NC_DIMS];
96 errstat = nc_open(dataset().c_str(), NC_NOWRITE, &ncid);
97 if (errstat != NC_NOERR) {
98 string err =
"Could not open the dataset's file (" + dataset() +
")";
99 throw Error(errstat, err);
102 errstat = nc_inq_varid(ncid, name().c_str(), &varid);
103 if (errstat != NC_NOERR)
104 throw Error(errstat,
"Could not get variable ID for '" + name() +
"'.");
106 errstat = nc_inq_var(ncid, varid, (
char *) 0, &datatype, &num_dim, (
int *) 0, (
int *) 0);
107 if (errstat != NC_NOERR)
108 throw Error(errstat,
string(
"Could not read information about the variable `") + name() +
string(
"'."));
110 for (
id = 0;
id <= num_dim &&
id < MAX_NC_DIMS;
id++)
113 if (datatype == NC_FLOAT) {
116 errstat = nc_get_var1_float(ncid, varid, cor, &flt);
117 if (errstat != NC_NOERR)
118 throw Error(errstat,
string(
"Could not read the variable `") + name() +
string(
"'."));
122 flt32 = (dods_float32) flt;
125 if (nc_close(ncid) != NC_NOERR)
126 throw InternalErr(__FILE__, __LINE__,
"Could not close the dataset!");
129 throw InternalErr(__FILE__, __LINE__,
"Entered NCFloat32::read() with non-float variable!");