REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_NCFile.cpp
Go to the documentation of this file.
1#include <string>
2
3#include "REMORA_NCFile.H"
5
6
7/**
8 * @param fname Name of NetCDF file
9 * @param var_name Name of variable
10 * @param attr_name Name of attribute to read
11 * @returns attribute value
12 */
13std::string ReadNetCDFVarAttrStr (const std::string& fname,
14 const std::string& var_name,
15 const std::string& attr_name)
16{
17 std::string attr_val;
18 auto ncf = ncutils::NCFile::open(fname, NC_NOCLOBBER);
19 ncmpi_begin_indep_data(ncf.ncid);
20 if (amrex::ParallelDescriptor::IOProcessor())
21 {
22 attr_val = ncf.var(var_name).get_attr(attr_name);
23 }
24 ncf.close();
25 return attr_val;
26}
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.