8#include <AMReX_Print.H>
10#define abort_func amrex::Abort
21 abort_func(
"Encountered NetCDF error; aborting");
27 [](
unsigned char c) { return static_cast<char>(std::tolower(c)); });
57 abort_func(
"Ambiguous case-insensitive NetCDF variable lookup for " + name);
136 const std::vector<MPI_Offset> &
stride)
const {
141 const std::vector<MPI_Offset> &
stride)
const {
154 const std::vector<MPI_Offset> &
stride)
const {
159 const std::vector<MPI_Offset> &
stride)
const {
172 const std::vector<MPI_Offset> &
stride)
const {
177 const std::vector<MPI_Offset> &
stride)
const {
186 const std::vector<MPI_Offset> &
stride)
const {
211 const std::vector<MPI_Offset> &
stride)
const {
216 const std::vector<MPI_Offset> &
stride)
const {
229 const std::vector<MPI_Offset> &
stride)
const {
234 const std::vector<MPI_Offset> &
stride)
const {
247 const std::vector<MPI_Offset> &
stride)
const {
252 const std::vector<MPI_Offset> &
stride)
const {
261 const std::vector<MPI_Offset> &
stride)
const {
290 std::vector<char>
aval;
294 return std::string {
aval.begin(),
aval.end() };
422 std::vector<char>
aval;
426 return std::string {
aval.begin(),
aval.end() };
451 std::vector<NCDim>
adims;
461 std::vector<NCVar>
avars;
mf_h setVal(geomdata.ProbHi(2))
void put_attr(const std::string &name, const std::string &value) const
Set file attribute to value.
std::vector< NCDim > all_dims() const
Return a list of all dimensions defined in this group.
NCVar def_scalar(const std::string &name, const nc_type dtype) const
Define a scalar variable, i.e., 0-dimensional array.
NCVar def_array(const std::string &name, const nc_type dtype, const std::vector< std::string > &) const
Define an array.
std::vector< NCVar > all_vars() const
Return a list of all variables defined in this group.
NCDim dim(const std::string &) const
Get the dimension instance by name.
void enter_def_mode() const
Enter definition mode (not needed for NetCDF4 format)
bool has_var(const std::string &) const
Check if a variable exists by name.
bool has_attr(const std::string &) const
Check if an attribute exists.
NCDim def_dim(const std::string &, const size_t len) const
Define new dimension.
void exit_def_mode() const
Exit definition mode.
std::string get_attr(const std::string &name) const
Read file attribute from file.
int num_dimensions() const
Number of dimensions.
void wait_all(int num_requests, int *requests)
wait for non-blocking calls to finish
bool has_dim(const std::string &) const
Check if a dimension exists by name.
int num_attributes() const
Number of attributes.
static NCFile create(const std::string &name, const int cmode=NC_CLOBBER|NC_64BIT_DATA, MPI_Comm comm=MPI_COMM_WORLD, MPI_Info info=MPI_INFO_NULL)
Create a file. Defaults to CDF-5; classic CDF-1 has a 2GB limit.
int num_variables() const
Number of variables.
static NCFile open(const std::string &name, const int cmode=NC_NOWRITE, MPI_Comm comm=MPI_COMM_WORLD, MPI_Info info=MPI_INFO_NULL)
Open an existing file.
void close()
Close file object.
NCVar var(const std::string &) const
Get the variable instance by name.
NCVar def_array_fill(const std::string &name, const nc_type dtype, const std::vector< std::string > &dnames, const void *fill_val) const
Define an array with a fill value.
Representation of NetCDF dimension.
const int dimid
Dimension ID used with NetCDF API.
const int ncid
File/Group Identifier.
MPI_Offset len() const
Length of this dimension.
std::string name() const
Name of this dimension.
Representation of a NetCDF variable.
bool has_attr(const std::string &name) const
Whether a variable has an attribute with name.
const int ncid
File/Group identifier.
const int varid
Variable ID used with NetCDF API.
void iput(const double *dptr, const std::vector< MPI_Offset > &start, const std::vector< MPI_Offset > &count, int *request) const
Write out a slice of data with with strides (see hyperslab definition in NetCDF)
std::string name() const
Name of this variable.
void put_varn_all(int num, MPI_Offset *const *starts, MPI_Offset *const *counts, const double *dptr) const
void put(const double *ptr) const
Write out the entire double variable.
void get(double *ptr) const
Read the entire variable from file.
std::string get_attr(const std::string &name) const
Read attribute from file.
void put_all(const double *dptr, const std::vector< MPI_Offset > &start, const std::vector< MPI_Offset > &count) const
Write out a slice of data, collective.
void put_attr(const std::string &name, const std::string &value) const
Set attribute "name" to "value".
std::vector< MPI_Offset > shape() const
Shape of the array (size in each array dimension)
void get_all(double *dptr, const std::vector< MPI_Offset > &start, const std::vector< MPI_Offset > &count) const
Read a chunk of data from the file, collective.
int ndim() const
Number of array dimensions for this variable.