14 const std::string& var_name,
15 const std::string& attr_name)
19 ncmpi_begin_indep_data(ncf.ncid);
20 if (amrex::ParallelDescriptor::IOProcessor())
22 if (!ncf.has_var(var_name)) {
23 amrex::Print() <<
"Trying to read attribute " << attr_name <<
" from variable " << var_name <<
" that does not exist!" << std::endl;
25 if (!ncf.var(var_name).has_attr(attr_name)) {
26 amrex::Print() <<
"Trying to read attribute " << attr_name <<
" that does not exist from variable " << var_name <<
"!" << std::endl;
28 attr_val = ncf.var(var_name).get_attr(attr_name);
41 const std::string& var_name,
42 const std::string& attr_name)
46 ncmpi_begin_indep_data(ncf.ncid);
47 if (amrex::ParallelDescriptor::IOProcessor())
49 has_var = ncf.var(var_name).has_attr(attr_name);
bool QueryNetCDFVarAttrStr(const std::string &fname, const std::string &var_name, const std::string &attr_name)
Helper function for testing for the presence of a single variable attribute.
std::string ReadNetCDFVarAttrStr(const std::string &fname, const std::string &var_name, const std::string &attr_name)
Helper function for reading a single variable attribute.
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.