32#include <BESInternalError.h>
34#include <libdap/Int32.h>
35#include <libdap/UInt16.h>
39#include "FONcAttributes.h"
49FONcInt::FONcInt( BaseType *b )
55 string s = (string)
"File out netcdf, FONcInt was passed a "
56 +
"variable that is not a DAP Int32 or UInt32" ;
59 _unsigned_short =
false;
62FONcInt::FONcInt( BaseType *b ,
bool unsigned_short)
63 :
FONcBaseType(), _bt( b ), _unsigned_short(unsigned_short)
66 if(!_unsigned_short) {
70 string s = (string)
"File out netcdf, FONcInt was passed a "
71 +
"variable that is not a DAP Int32 " ;
79 string s = (string)
"File out netcdf, FONcInt was passed a "
80 +
"variable that is not a DAP UInt16" ;
113 D4Attributes *d4_attrs = _bt->attributes();
114 updateD4AttrType(d4_attrs,NC_INT);
117 AttrTable &attrs = _bt->get_attr_table();
118 updateAttrType(attrs,NC_INT);
124 _varname, _orig_varname ) ;
140 BESDEBUG(
"fonc",
"FONcInt::write for var " << _varname << endl ) ;
141 size_t var_index[] = {0} ;
147 _bt->intern_data(*get_eval(), *get_dds());
149 if(_unsigned_short) {
150 unsigned short * sdata =
new unsigned short;
151 _bt->buf2val( (
void**)&sdata ) ;
152 BESDEBUG(
"fonc",
"FONcInt::write for short value " << *sdata << endl ) ;
153 int temps = (
int)(*sdata);
154 stax = nc_put_var1_int( ncid, _varid, var_index, &temps ) ;
158 int *data =
new int ;
159 _bt->buf2val( (
void**)&data ) ;
160 stax = nc_put_var1_int( ncid, _varid, var_index, data ) ;
163 if( stax != NC_NOERR )
165 string err = (string)
"fileout.netcdf - "
166 +
"Failed to write int data for "
171 BESDEBUG(
"fonc",
"FONcInt::done write for var " << _varname << endl ) ;
203 strm << BESIndent::LMarg <<
"FONcInt::dump - ("
204 << (
void *)
this <<
")" << endl ;
205 BESIndent::Indent() ;
206 strm << BESIndent::LMarg <<
"name = " << _bt->name() << endl ;
207 BESIndent::UnIndent() ;
exception thrown if internal error encountered
static void add_original_name(int ncid, int varid, const string &var_name, const string &orig)
Adds an attribute for the variable if the variable name had to be modified in any way.
static void add_variable_attributes(int ncid, int varid, BaseType *b, bool is_netCDF_enhanced, bool is_dap4)
Add the attributes for an OPeNDAP variable to the netcdf file.
A DAP BaseType with file out netcdf information included.
virtual void define(int ncid)
Define the variable in the netcdf file.
virtual void define(int ncid)
define the DAP Int32 or UInt32 in the netcdf file
virtual ~FONcInt()
Destructor that cleans up the instance.
virtual string name()
returns the name of the DAP Int32 or UInt32
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
virtual nc_type type()
returns the netcdf type of the DAP object
virtual void write(int ncid)
Write the int out to the netcdf file.
static void handle_error(int stax, const string &err, const string &file, int line)
handle any netcdf errors