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
"
4
#include "
REMORA_NCInterface.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
*/
13
std::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
}
REMORA_NCFile.H
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.
Definition
REMORA_NCFile.cpp:13
REMORA_NCInterface.H
ncutils::NCFile::open
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.
Definition
REMORA_NCInterface.cpp:441
Source
IO
REMORA_NCFile.cpp
Generated by
1.9.8