28#include <BESInternalError.h>
30#include <libdap/UInt16.h>
32#include "FONcUShort.h"
34#include "FONcAttributes.h"
47 UInt16 *u16 =
dynamic_cast<UInt16 *
>(b) ;
50 string s = (string)
"File out netcdf-4, FONcUShort was passed a "
51 +
"variable that is not a DAP UInt16" ;
84 D4Attributes *d4_attrs = _bt->attributes();
85 updateD4AttrType(d4_attrs,NC_USHORT);
88 AttrTable &attrs = _bt->get_attr_table();
89 updateAttrType(attrs,NC_USHORT);
94 _varname, _orig_varname ) ;
112 BESDEBUG(
"fonc",
"FONcUShort::write for var " << _varname << endl ) ;
113 size_t var_index[] = {0} ;
114 unsigned short *data =
new unsigned short ;
119 _bt->intern_data(*get_eval(), *get_dds());
121 _bt->buf2val( (
void**)&data ) ;
122 int stax = nc_put_var1_ushort( ncid, _varid, var_index, data ) ;
123 if( stax != NC_NOERR )
125 string err = (string)
"fileout.netcdf-4 - "
126 +
"Failed to write short data for "
131 BESDEBUG(
"fonc",
"FONcUShort::done write for var " << _varname << endl ) ;
163 strm << BESIndent::LMarg <<
"FONcUShort::dump - ("
164 << (
void *)
this <<
")" << endl ;
165 BESIndent::Indent() ;
166 strm << BESIndent::LMarg <<
"name = " << _bt->name() << endl ;
167 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 Int16 or UInt16 in the netcdf file
virtual nc_type type()
returns the netcdf type of the DAP object
virtual void dump(ostream &strm) const
dumps information about this object for debugging purposes
virtual string name()
returns the name of the DAP Int16 or UInt16
FONcUShort(libdap::BaseType *b)
Constructor for FOncShort that takes a DAP UInt16.
virtual ~FONcUShort()
Destructor that cleans up the short.
virtual void write(int ncid)
Write the ushort out to the netcdf file.
static void handle_error(int stax, const string &err, const string &file, int line)
handle any netcdf errors