61 if ((retval = nc_def_dim(ncid,
"nrows", m.
nrows(), &ncdims[0])))
63 if ((retval = nc_def_dim(ncid,
"ncols", m.
ncols(), &ncdims[1])))
65 if ((retval = nc_def_var(ncid,
"Matrix", NC_DOUBLE, 2, &ncdims[0], &varid)))
67 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
68 if ((retval = nc_put_var_double(ncid, varid, m.
get_c_array())))
80 Index npages, nrows, ncols;
85 t.
resize(npages, nrows, ncols);
97 if ((retval = nc_def_dim(ncid,
"npages", t.
npages(), &ncdims[0])))
99 if ((retval = nc_def_dim(ncid,
"nrows", t.
nrows(), &ncdims[1])))
101 if ((retval = nc_def_dim(ncid,
"ncols", t.
ncols(), &ncdims[2])))
103 if ((retval = nc_def_var(ncid,
"Tensor3", NC_DOUBLE, 3, &ncdims[0], &varid)))
105 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
106 if ((retval = nc_put_var_double(ncid, varid, t.
get_c_array())))
118 Index nbooks, npages, nrows, ncols;
124 t.
resize(nbooks, npages, nrows, ncols);
135 int ncdims[4], varid;
136 if ((retval = nc_def_dim(ncid,
"nbooks", t.
nbooks(), &ncdims[0])))
138 if ((retval = nc_def_dim(ncid,
"npages", t.
npages(), &ncdims[1])))
140 if ((retval = nc_def_dim(ncid,
"nrows", t.
nrows(), &ncdims[2])))
142 if ((retval = nc_def_dim(ncid,
"ncols", t.
ncols(), &ncdims[3])))
144 if ((retval = nc_def_var(ncid,
"Tensor4", NC_DOUBLE, 4, &ncdims[0], &varid)))
146 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
147 if ((retval = nc_put_var_double(ncid, varid, t.
get_c_array())))
159 Index nshelves, nbooks, npages, nrows, ncols;
166 t.
resize(nshelves, nbooks, npages, nrows, ncols);
177 int ncdims[5], varid;
178 if ((retval = nc_def_dim(ncid,
"nshelves", t.
nshelves(), &ncdims[0])))
180 if ((retval = nc_def_dim(ncid,
"nbooks", t.
nbooks(), &ncdims[1])))
182 if ((retval = nc_def_dim(ncid,
"npages", t.
npages(), &ncdims[2])))
184 if ((retval = nc_def_dim(ncid,
"nrows", t.
nrows(), &ncdims[3])))
186 if ((retval = nc_def_dim(ncid,
"ncols", t.
ncols(), &ncdims[4])))
188 if ((retval = nc_def_var(ncid,
"Tensor5", NC_DOUBLE, 5, &ncdims[0], &varid)))
190 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
191 if ((retval = nc_put_var_double(ncid, varid, t.
get_c_array())))
218 if ((retval = nc_def_dim(ncid,
"nelem",
v.nelem(), &ncdim)))
220 if ((retval = nc_def_var(ncid,
"Vector", NC_DOUBLE, 1, &ncdim, &varid)))
222 if ((retval = nc_enddef(ncid)))
nca_error(retval,
"nc_enddef");
223 if ((retval = nc_put_var_double(ncid, varid,
v.get_c_array())))
232#define TMPL_NC_READ_WRITE_FILE_DUMMY(what) \
233 void nca_write_to_file(const int, const what &, const Verbosity &) { \
234 ARTS_USER_ERROR("NetCDF support not yet implemented for this type!"); \
236 void nca_read_from_file(const int, what &, const Verbosity &) { \
237 ARTS_USER_ERROR("NetCDF support not yet implemented for this type!"); \
243#undef TMPL_NC_READ_WRITE_FILE_DUMMY
The global header file for ARTS.
Numeric * get_c_array() const noexcept
Index nrows() const noexcept
Index ncols() const noexcept
Index npages() const
Returns the number of pages.
Index nrows() const
Returns the number of rows.
Index ncols() const
Returns the number of columns.
Index ncols() const noexcept
Index nrows() const noexcept
Index nbooks() const noexcept
Index npages() const noexcept
Index nrows() const noexcept
Index ncols() const noexcept
Index npages() const noexcept
Index nbooks() const noexcept
Index nshelves() const noexcept
void resize(Index r, Index c)
Resize function.
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
void resize(Index p, Index r, Index c)
Resize function.
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
void resize(Index b, Index p, Index r, Index c)
Resize function.
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
void resize(Index s, Index b, Index p, Index r, Index c)
Resize function.
INDEX Index
The type to use for all integer numbers and indices.
Index nca_get_dim(const int ncid, const String &name, const bool noerror)
Read a dimension from NetCDF file.
void nca_error(const int e, const std::string_view s)
Throws a runtime error for the given NetCDF error code.
void nca_get_data(const int ncid, const String &name, int *data)
Read variable of type int from NetCDF file.
This file contains basic functions to handle NetCDF data files.
void nca_read_from_file(const int ncid, Matrix &m, const Verbosity &)
Reads a Matrix from a NetCDF file.
void nca_write_to_file(const int ncid, const Matrix &m, const Verbosity &)
Writes a Matrix to a NetCDF file.
This file contains private function declarations and template instantiation to handle NetCDF data fil...