34 #include <BESInternalError.h>
38 #include "FONcUtils.h"
39 #include "FONcAttributes.h"
54 _str =
dynamic_cast<Str *
>(b);
56 throw BESInternalError(
"File out netcdf, FONcStr was passed a variable that is not a DAP Str", __FILE__, __LINE__);
82 BESDEBUG(
"fonc",
"FONcStr::define - defining " << _varname << endl);
86 _str->buf2val((
void**) &_data);
87 int size = _data->size() + 1;
89 string dimname = _varname +
"_len";
90 int stax = nc_def_dim(ncid, dimname.c_str(), size, &_dimid);
91 if (stax != NC_NOERR) {
92 string err = (string)
"fileout.netcdf - " +
"Failed to define dim " + dimname +
" for " + _varname;
98 stax = nc_def_var(ncid, _varname.c_str(), NC_CHAR, 1, var_dims, &_varid);
99 if (stax != NC_NOERR) {
100 string err = (string)
"fileout.netcdf - " +
"Failed to define var " + _varname;
109 BESDEBUG(
"fonc",
"FONcStr::define - done defining " << _varname << endl);
124 BESDEBUG(
"fonc",
"FONcStr::write for var " << _varname << endl);
129 var_count[0] = _data->size() + 1;
131 int stax = nc_put_vara_text(ncid, _varid, var_start, var_count, _data->c_str());
132 if (stax != NC_NOERR) {
133 string err = (string)
"fileout.netcdf - " +
"Failed to write string data " + *_data +
" for " + _varname;
141 BESDEBUG(
"fonc",
"FONcStr::done write for var " << _varname << endl);
170 strm << BESIndent::LMarg <<
"FONcStr::dump - (" << (
void *)
this <<
")" << endl;
172 strm << BESIndent::LMarg <<
"name = " << _str->name() << endl;
173 BESIndent::UnIndent();