50 long* vnrows =
new long[nelem];
51 long* vncols =
new long[nelem];
56 for (
Index i = 0; i < nelem; i++)
58 aom[i].resize(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()];
84 vnrows[i] = aom[i].nrows();
85 vncols[i] = aom[i].ncols();
86 nelem_total += vnrows[i] * vncols[i];
89 if ((retval = nc_def_dim(ncid,
"nelem", aom.
nelem(), &ncdim)))
91 if ((retval = nc_def_dim(ncid,
"nelem_total", nelem_total, &ncdim_total)))
94 if ((retval = nc_def_var(ncid,
"Matrix_nrows", NC_LONG, 1,
95 &ncdim, &varid_nrows)))
97 if ((retval = nc_def_var(ncid,
"Matrix_ncols", NC_LONG, 1,
98 &ncdim, &varid_ncols)))
100 if ((retval = nc_def_var(ncid,
"ArrayOfMatrix", NC_DOUBLE, 1,
101 &ncdim_total, &varid)))
104 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
106 if ((retval = nc_put_var_long(ncid, varid_nrows, vnrows)))
108 if ((retval = nc_put_var_long(ncid, varid_ncols, vncols)))
114 size_t count = aom[i].nrows() * aom[i].ncols();
115 if ((retval = nc_put_vara_double(ncid, varid, &pos, &count,
116 aom[i].get_c_array())))
138 long* vnelem =
new long[nelem];
142 for (
Index i = 0; i < nelem; i++)
144 aov[i].resize(vnelem[i]);
146 aov[i].get_c_array());
162 int ncdim, varid_nelem;
163 int ncdim_total, varid;
164 long nelem_total = 0;
165 long* velems =
new long[aov.
nelem()];
168 velems[i] = aov[i].
nelem();
169 nelem_total += velems[i];
172 if ((retval = nc_def_dim(ncid,
"nelem", aov.
nelem(), &ncdim)))
174 if ((retval = nc_def_dim(ncid,
"nelem_total", nelem_total, &ncdim_total)))
177 if ((retval = nc_def_var(ncid,
"Vector_nelem", NC_LONG, 1,
178 &ncdim, &varid_nelem)))
180 if ((retval = nc_def_var(ncid,
"ArrayOfVector", NC_DOUBLE, 1,
181 &ncdim_total, &varid)))
184 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
186 if ((retval = nc_put_var_long(ncid, varid_nelem, velems)))
192 size_t count = aov[i].
nelem();
193 if ((retval = nc_put_vara_double(ncid, varid, &pos, &count,
194 aov[i].get_c_array())))
208 #define TMPL_NC_READ_WRITE_FILE_DUMMY(what) \ 209 void nca_write_to_file(const int, const what&, const Verbosity&) \ 211 throw runtime_error("NetCDF support not yet implemented for this type!"); \ 213 void nca_read_from_file(const int, what&, const Verbosity&) \ 215 throw runtime_error("NetCDF support not yet implemented for this type!"); \ 221 #undef TMPL_NC_READ_WRITE_FILE_DUMMY INDEX Index
The type to use for all integer numbers and indices.
void nca_write_to_file(const int ncid, const ArrayOfMatrix &aom, const Verbosity &)
Writes an ArrayOfMatrix to a NetCDF file.
This file contains basic functions to handle NetCDF data files.
Index nelem() const
Number of elements.
void nca_error(const int e, const String s)
Throws a runtime error for the given NetCDF error code.
The global header file for ARTS.
void nca_read_from_file(const int ncid, ArrayOfMatrix &aom, const Verbosity &)
Reads an ArrayOfMatrix from a NetCDF file.
void nca_get_dataa_double(const int ncid, const String &name, size_t start, size_t count, Numeric *data)
Read variable of type array of double from NetCDF file.
This file contains private function declarations and template instantiation to handle NetCDF data fil...
This can be used to make arrays out of anything.
void nca_get_data_long(const int ncid, const String &name, long *data)
Read variable of type long from NetCDF file.
Index nc_get_dim(const int ncid, const String &name, const bool noerror)
Read a dimension from NetCDF file.