48 long* vnrows =
new long[
nelem];
49 long* vncols =
new long[
nelem];
55 aom[i].resize(vnrows[i], vncols[i]);
59 vnrows[i] * vncols[i],
60 aom[i].get_c_array());
61 pos += vnrows[i] * vncols[i];
77 int ncdim, varid_nrows, varid_ncols;
78 int ncdim_total, varid;
80 long* vncols =
new long[aom.
nelem()];
81 long* vnrows =
new long[aom.
nelem()];
83 vnrows[i] = aom[i].nrows();
84 vncols[i] = aom[i].ncols();
85 nelem_total += vnrows[i] * vncols[i];
88 if ((retval = nc_def_dim(ncid,
"nelem", aom.
nelem(), &ncdim)))
90 if ((retval = nc_def_dim(ncid,
"nelem_total", nelem_total, &ncdim_total)))
94 nc_def_var(ncid,
"Matrix_nrows", NC_LONG, 1, &ncdim, &varid_nrows)))
97 nc_def_var(ncid,
"Matrix_ncols", NC_LONG, 1, &ncdim, &varid_ncols)))
99 if ((retval = nc_def_var(
100 ncid,
"ArrayOfMatrix", NC_DOUBLE, 1, &ncdim_total, &varid)))
103 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
105 if ((retval = nc_put_var_long(ncid, varid_nrows, vnrows)))
107 if ((retval = nc_put_var_long(ncid, varid_ncols, vncols)))
112 size_t count = aom[i].nrows() * aom[i].ncols();
113 if ((retval = nc_put_vara_double(
114 ncid, varid, &pos, &count, aom[i].get_c_array())))
134 long* vnelem =
new long[
nelem];
139 aov[i].resize(vnelem[i]);
141 ncid,
"ArrayOfVector", pos, vnelem[i], aov[i].get_c_array());
157 int ncdim, varid_nelem;
158 int ncdim_total, varid;
159 long nelem_total = 0;
160 long* velems =
new long[aov.
nelem()];
162 velems[i] = aov[i].
nelem();
163 nelem_total += velems[i];
166 if ((retval = nc_def_dim(ncid,
"nelem", aov.
nelem(), &ncdim)))
168 if ((retval = nc_def_dim(ncid,
"nelem_total", nelem_total, &ncdim_total)))
172 nc_def_var(ncid,
"Vector_nelem", NC_LONG, 1, &ncdim, &varid_nelem)))
174 if ((retval = nc_def_var(
175 ncid,
"ArrayOfVector", NC_DOUBLE, 1, &ncdim_total, &varid)))
178 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
180 if ((retval = nc_put_var_long(ncid, varid_nelem, velems)))
185 size_t count = aov[i].
nelem();
186 if ((retval = nc_put_vara_double(
187 ncid, varid, &pos, &count, aov[i].get_c_array())))
200 #define TMPL_NC_READ_WRITE_FILE_DUMMY(what) \
201 void nca_write_to_file(const int, const what&, const Verbosity&) { \
202 throw runtime_error("NetCDF support not yet implemented for this type!"); \
204 void nca_read_from_file(const int, what&, const Verbosity&) { \
205 throw runtime_error("NetCDF support not yet implemented for this type!"); \
211 #undef TMPL_NC_READ_WRITE_FILE_DUMMY