Go to the documentation of this file.
77 const Index& file_index,
84 os <<
out_basename <<
"." << varname <<
"." << file_index <<
".nc";
90 os << filename <<
"." << file_index <<
".nc";
113 out2 <<
" Reading " << efilename <<
'\n';
115 #pragma omp critical(netcdf__critical_region)
118 if (nc_open(efilename.c_str(), NC_NOWRITE, &ncid))
121 os <<
"Error reading file: " << efilename << endl;
122 throw runtime_error(os.str());
129 catch (runtime_error e)
132 os <<
"Error reading file: " << efilename << endl;
133 os << e.what() << endl;
134 throw runtime_error(os.str());
159 out2 <<
" Writing " << efilename <<
'\n';
161 #pragma omp critical(netcdf__critical_region)
164 if (nc_create(efilename.c_str(), NC_CLOBBER, &ncid))
167 os <<
"Error writing file: " << efilename << endl;
168 throw runtime_error(os.str());
175 catch (runtime_error e)
178 os <<
"Error writing file: " << efilename << endl;
179 os << e.what() << endl;
180 throw runtime_error(os.str());
200 if ((retval = nc_def_dim(ncid, name.c_str(), nelem, ncdim)))
217 const int* dims,
int* varid)
220 if ((retval = nc_def_var(ncid, name.c_str(), type, ndims, dims, varid)))
236 int ncdims[1], varid;
240 nca_def_var(ncid, name, NC_INT, 1, &ncdims[0], &varid);
260 int ncdims[1], varid;
264 nca_def_var(ncid, name, NC_DOUBLE, 1, &ncdims[0], &varid);
284 int ncdims[2], varid;
289 nca_def_var(ncid, name, NC_DOUBLE, 2, &ncdims[0], &varid);
309 int ncdims[4], varid;
316 nca_def_var(ncid, name, NC_DOUBLE, 4, &ncdims[0], &varid);
338 if ((retval = nc_inq_dimid(ncid, name.c_str(), &dimid)))
340 if (!noerror)
nca_error(retval,
"nc_inq_ndims("+name+
")");
343 if ((retval = nc_inq_dimlen(ncid, dimid, &ndim)))
345 if (!noerror)
nca_error(retval,
"nc_inq_dimlen("+name+
")");
364 if ((retval = nc_inq_varid(ncid, name.c_str(), &varid)))
365 nca_error(retval,
"nc_inq_varid("+name+
")");
366 if ((retval = nc_get_var_int(ncid, varid, data)))
367 nca_error(retval,
"nc_get_var("+name+
")");
382 if ((retval = nc_inq_varid(ncid, name.c_str(), &varid)))
383 nca_error(retval,
"nc_inq_varid("+name+
")");
384 if ((retval = nc_get_var_long(ncid, varid, data)))
385 nca_error(retval,
"nc_get_var("+name+
")");
400 if ((retval = nc_inq_varid(ncid, name.c_str(), &varid)))
401 nca_error(retval,
"nc_inq_varid("+name+
")");
402 if ((retval = nc_get_var_double(ncid, varid, data)))
403 nca_error(retval,
"nc_get_var("+name+
")");
416 size_t start,
size_t count,
Numeric* data)
419 if ((retval = nc_inq_varid(ncid, name.c_str(), &varid)))
420 nca_error(retval,
"nc_inq_varid("+name+
")");
421 if ((retval = nc_get_vara_double(ncid, varid, &start, &count, data)))
422 nca_error(retval,
"nc_get_var("+name+
")");
437 if ((retval = nc_inq_varid(ncid, name.c_str(), &varid)))
438 nca_error(retval,
"nc_inq_varid("+name+
")");
439 if ((retval = nc_get_var_text(ncid, varid, data)))
440 nca_error(retval,
"nc_get_var("+name+
")");
464 for (ArrayOfIndex::iterator it = aoi.begin(); it != aoi.end(); it++, i++)
487 aast.resize(species_count.
nelem());
488 if (species_count.
nelem())
490 Index species_strings_nelem =
nc_get_dim(ncid, name+
"_strings_nelem", noerror);
491 Index species_strings_length =
nc_get_dim(ncid, name+
"_strings_length", noerror);
492 char* species_strings =
new char[species_strings_nelem*species_strings_length];
496 for (
Index i = 0; i < species_count.
nelem(); i++)
499 for (
Index j = 0; j < species_count[i]; j++)
501 aast[i].push_back(
SpeciesTag(&species_strings[si]));
502 si += species_strings_length;
506 delete[] species_strings;
564 t.
resize(nbooks, npages, nrows, ncols);
588 if ((retval = nc_put_var_long(ncid, varid, ind_arr)))
613 if ((retval = nc_put_var_double(ncid, varid, v.
get_c_array())))
635 if ((retval = nc_put_var_double(ncid, varid, m.
get_c_array())))
657 if ((retval = nc_put_var_double(ncid, varid, t.
get_c_array())))
674 os <<
"NetCDF error: " << s <<
", " << e;
675 throw runtime_error(os.str());
void nca_get_data_Matrix(const int ncid, const String &name, Matrix &m, const bool noerror)
Read variable of type Matrix from NetCDF file.
void resize(Index b, Index p, Index r, Index c)
Resize function.
The declarations of all the exception classes.
void nca_get_data_double(const int ncid, const String &name, Numeric *data)
Read variable of type double from NetCDF file.
void nca_get_data_int(const int ncid, const String &name, int *data)
Read variable of type int from NetCDF file.
void nca_get_data_ArrayOfIndex(const int ncid, const String &name, ArrayOfIndex &aoi, const bool noerror)
Read variable of type ArrayOfIndex from NetCDF file.
Index nc_get_dim(const int ncid, const String &name, const bool noerror)
Read a dimension from NetCDF file.
This file contains basic functions to handle NetCDF data files.
void nca_get_data_text(const int ncid, const String &name, char *data)
Read variable of type array of char from NetCDF file.
void nca_write_to_file(const String &filename, const T &type, const Verbosity &verbosity)
Writes a variable to a NetCDF file.
bool nca_put_var_Matrix(const int ncid, const int varid, const Matrix &m)
Write variable of type Matrix to NetCDF file.
void resize(Index n)
Resize function.
Index nrows() const
Returns the number of rows.
void nca_get_data_Tensor4(const int ncid, const String &name, Tensor4 &t, const bool noerror)
Read variable of type Tensor4 from NetCDF file.
void nca_filename(String &filename, const String &varname)
Gives the default filename for the NetCDF formats.
This file contains private function declarations and template instantiation to handle NetCDF data fil...
void nca_filename_with_index(String &filename, const Index &file_index, const String &varname)
Gives the default filename, with file index, for the NetCDF formats.
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.
A tag group can consist of the sum of several of these.
bool nca_put_var_ArrayOfIndex(const int ncid, const int varid, const ArrayOfIndex &a)
Write variable of type ArrayOfIndex to NetCDF file.
int nca_def_Vector(const int ncid, const String &name, const Vector &v)
Define NetCDF dimensions and variable for a Vector.
Declarations having to do with the four output streams.
Index ncols() const
Returns the number of columns.
The implementation for String, the ARTS string class.
int nca_def_Tensor4(const int ncid, const String &name, const Tensor4 &t)
Define NetCDF dimensions and variable for a Tensor4.
bool nca_put_var_Tensor4(const int ncid, const int varid, const Tensor4 &t)
Write variable of type Tensor4 to NetCDF file.
Index nelem() const
Returns the number of elements.
Index ncols() const
Returns the number of columns.
NUMERIC Numeric
The type to use for all floating point numbers.
Index npages() const
Returns the number of pages.
void nca_get_data_long(const int ncid, const String &name, long *data)
Read variable of type long from NetCDF file.
void nca_read_from_file(const String &filename, T &type, const Verbosity &verbosity)
Reads a variable from a NetCDF file.
int nca_def_Matrix(const int ncid, const String &name, const Matrix &m)
Define NetCDF dimensions and variable for a Matrix.
Index nbooks() const
Returns the number of books.
int nca_def_ArrayOfIndex(const int ncid, const String &name, const ArrayOfIndex &a)
Define NetCDF dimensions and variable for an ArrayOfIndex.
void resize(Index r, Index c)
Resize function.
String out_basename
The basename for the report file and for all other output files.
void nca_def_var(const int ncid, const String &name, const nc_type type, const int ndims, const int *dims, int *varid)
Define NetCDF variable.
Index nrows() const
Returns the number of rows.
String expand_path(const String &path)
String add_basedir(const String &path)
void nca_def_dim(const int ncid, const String &name, const Index nelem, int *ncdim)
Define NetCDF dimension.
This file contains basic functions to handle ASCII files.
INDEX Index
The type to use for all integer numbers and indices.
void nca_get_data_Vector(const int ncid, const String &name, Vector &v, const bool noerror)
Read variable of type Vector from NetCDF file.
const Numeric * get_c_array() const
Conversion to plain C-array.
void nca_error(const int e, const String s)
Throws a runtime error for the given NetCDF error code.
const Numeric * get_c_array() const
Conversion to plain C-array.
Index nelem() const
Number of elements.
const Numeric * get_c_array() const
Conversion to plain C-array.
The global header file for ARTS.
void nca_get_data_ArrayOfArrayOfSpeciesTag(const int ncid, const String &name, ArrayOfArrayOfSpeciesTag &aast, const bool noerror)
Read variable of type ArrayOfArrayOfSpeciesTag from NetCDF file.
bool nca_put_var_Vector(const int ncid, const int varid, const Vector &v)
Write variable of type Vector to NetCDF file.