REMORA
Energy Research and Forecasting: An Atmospheric Modeling Code
NCFile.cpp File Reference
#include <string>
#include "NCFile.H"
#include "NCInterface.H"
Include dependency graph for NCFile.cpp:

Functions

std::string ReadNetCDFVarAttrStr (const std::string &fname, const std::string &var_name, const std::string &attr_name)
 

Function Documentation

◆ ReadNetCDFVarAttrStr()

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

Parameters
fnameName of NetCDF file
var_nameName of variable
attr_nameName of attribute to read
Returns
attribute value
10 {
11  std::string attr_val;
12  if (amrex::ParallelDescriptor::IOProcessor())
13  {
14  auto ncf = ncutils::NCFile::open(fname, NC_CLOBBER | NC_NETCDF4);
15  attr_val = ncf.var(var_name).get_attr(attr_name);
16  ncf.close();
17  }
18  return attr_val;
19 }
static NCFile open(const std::string &name, const int cmode=NC_NOWRITE)
Definition: NCInterface.cpp:577
Here is the call graph for this function: