REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
ncutils::NCFile Class Reference

#include <REMORA_NCInterface.H>

Collaboration diagram for ncutils::NCFile:

Public Member Functions

 ~NCFile ()
 
void close ()
 Close file object.
 
int num_dimensions () const
 Number of dimensions.
 
int num_variables () const
 Number of variables.
 
int num_attributes () const
 Number of attributes.
 
bool has_dim (const std::string &) const
 Check if a dimension exists by name.
 
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 dim (const std::string &) const
 Get the dimension instance by name.
 
NCVar var (const std::string &) const
 Get the variable instance by name.
 
NCDim def_dim (const std::string &, const size_t len) const
 Define new dimension.
 
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.
 
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.
 
NCVar def_var (const std::string &name, const nc_type dtype, const std::vector< std::string > &dnames) const
 Define a variable (wrapper for def_array)
 
NCVar def_var_fill (const std::string &name, const nc_type dtype, const std::vector< std::string > &dnames, const void *fill_val) const
 Define a variable (wrapper for def_array)
 
void put_attr (const std::string &name, const std::string &value) const
 Set file attribute to value.
 
void put_attr (const std::string &name, const std::vector< double > &value) const
 Set file attribute to value.
 
void put_attr (const std::string &name, const std::vector< float > &value) const
 Set file attribute to value.
 
void put_attr (const std::string &name, const std::vector< int > &value) const
 Set file attribute to value.
 
std::string get_attr (const std::string &name) const
 Read file attribute from file.
 
void get_attr (const std::string &name, std::vector< double > &value) const
 Read file attribute from file.
 
void get_attr (const std::string &name, std::vector< float > &value) const
 Read file attribute from file.
 
void get_attr (const std::string &name, std::vector< int > &value) const
 Read file attribute from file.
 
void wait_all (int num_requests, int *requests)
 wait for non-blocking calls to finish
 
std::vector< NCDimall_dims () const
 Return a list of all dimensions defined in this group.
 
std::vector< NCVarall_vars () const
 Return a list of all variables defined in this group.
 
void enter_def_mode () const
 Enter definition mode (not needed for NetCDF4 format)
 
void exit_def_mode () const
 Exit definition mode.
 
 NCFile (const int id)
 

Static Public Member Functions

static NCFile create (const std::string &name, const int cmode=NC_CLOBBER|NC_MPIIO, MPI_Comm comm=MPI_COMM_WORLD, MPI_Info info=MPI_INFO_NULL)
 Create a file.
 
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.
 

Public Attributes

const int ncid {-1}
 
bool is_open {false}
 

Detailed Description

Representation of a NetCDF file

Provide wrappers to create and open file

Definition at line 267 of file REMORA_NCInterface.H.

Constructor & Destructor Documentation

◆ ~NCFile()

ncutils::NCFile::~NCFile ( )

Definition at line 452 of file REMORA_NCInterface.cpp.

◆ NCFile()

ncutils::NCFile::NCFile ( const int  id)
inline

Definition at line 385 of file REMORA_NCInterface.H.

Member Function Documentation

◆ all_dims()

std::vector< NCDim > ncutils::NCFile::all_dims ( ) const

Return a list of all dimensions defined in this group.

Definition at line 400 of file REMORA_NCInterface.cpp.

Here is the call graph for this function:

◆ all_vars()

std::vector< NCVar > ncutils::NCFile::all_vars ( ) const

Return a list of all variables defined in this group.

Definition at line 410 of file REMORA_NCInterface.cpp.

Here is the call graph for this function:

◆ close()

void ncutils::NCFile::close ( )

Close file object.

Definition at line 457 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the caller graph for this function:

◆ create()

NCFile ncutils::NCFile::create ( const std::string &  name,
const int  cmode = NC_CLOBBER | NC_MPIIO,
MPI_Comm  comm = MPI_COMM_WORLD,
MPI_Info  info = MPI_INFO_NULL 
)
static

Create a file.

Definition at line 435 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile().

Here is the caller graph for this function:

◆ def_array()

NCVar ncutils::NCFile::def_array ( const std::string &  name,
const nc_type  dtype,
const std::vector< std::string > &  dnames 
) const

Define an array.

Definition at line 287 of file REMORA_NCInterface.cpp.

Referenced by def_var().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ def_array_fill()

NCVar ncutils::NCFile::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.

Definition at line 299 of file REMORA_NCInterface.cpp.

Referenced by def_var_fill().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ def_dim()

NCDim ncutils::NCFile::def_dim ( const std::string &  name,
const size_t  len 
) const

Define new dimension.

Definition at line 275 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the caller graph for this function:

◆ def_scalar()

NCVar ncutils::NCFile::def_scalar ( const std::string &  name,
const nc_type  dtype 
) const

Define a scalar variable, i.e., 0-dimensional array.

Definition at line 281 of file REMORA_NCInterface.cpp.

◆ def_var()

NCVar ncutils::NCFile::def_var ( const std::string &  name,
const nc_type  dtype,
const std::vector< std::string > &  dnames 
) const
inline

Define a variable (wrapper for def_array)

Definition at line 334 of file REMORA_NCInterface.H.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ def_var_fill()

NCVar ncutils::NCFile::def_var_fill ( const std::string &  name,
const nc_type  dtype,
const std::vector< std::string > &  dnames,
const void *  fill_val 
) const
inline

Define a variable (wrapper for def_array)

Definition at line 343 of file REMORA_NCInterface.H.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dim()

NCDim ncutils::NCFile::dim ( const std::string &  name) const

Get the dimension instance by name.

Definition at line 269 of file REMORA_NCInterface.cpp.

Referenced by def_array(), and def_array_fill().

Here is the caller graph for this function:

◆ enter_def_mode()

void ncutils::NCFile::enter_def_mode ( ) const

Enter definition mode (not needed for NetCDF4 format)

Definition at line 420 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the caller graph for this function:

◆ exit_def_mode()

void ncutils::NCFile::exit_def_mode ( ) const

Exit definition mode.

Definition at line 431 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the caller graph for this function:

◆ get_attr() [1/4]

std::string ncutils::NCFile::get_attr ( const std::string &  name) const

Read file attribute from file.

Definition at line 370 of file REMORA_NCInterface.cpp.

◆ get_attr() [2/4]

void ncutils::NCFile::get_attr ( const std::string &  name,
std::vector< double > &  value 
) const

Read file attribute from file.

Definition at line 379 of file REMORA_NCInterface.cpp.

◆ get_attr() [3/4]

void ncutils::NCFile::get_attr ( const std::string &  name,
std::vector< float > &  value 
) const

Read file attribute from file.

Definition at line 386 of file REMORA_NCInterface.cpp.

◆ get_attr() [4/4]

void ncutils::NCFile::get_attr ( const std::string &  name,
std::vector< int > &  value 
) const

Read file attribute from file.

Definition at line 393 of file REMORA_NCInterface.cpp.

◆ has_attr()

bool ncutils::NCFile::has_attr ( const std::string &  name) const

Check if an attribute exists.

Definition at line 347 of file REMORA_NCInterface.cpp.

◆ has_dim()

bool ncutils::NCFile::has_dim ( const std::string &  name) const

Check if a dimension exists by name.

Definition at line 337 of file REMORA_NCInterface.cpp.

◆ has_var()

bool ncutils::NCFile::has_var ( const std::string &  name) const

Check if a variable exists by name.

Definition at line 342 of file REMORA_NCInterface.cpp.

◆ num_attributes()

int ncutils::NCFile::num_attributes ( ) const

Number of attributes.

Definition at line 325 of file REMORA_NCInterface.cpp.

◆ num_dimensions()

int ncutils::NCFile::num_dimensions ( ) const

Number of dimensions.

Definition at line 319 of file REMORA_NCInterface.cpp.

Referenced by all_dims().

Here is the caller graph for this function:

◆ num_variables()

int ncutils::NCFile::num_variables ( ) const

Number of variables.

Definition at line 331 of file REMORA_NCInterface.cpp.

Referenced by all_vars().

Here is the caller graph for this function:

◆ open()

NCFile ncutils::NCFile::open ( const std::string &  name,
const int  cmode = NC_NOWRITE,
MPI_Comm  comm = MPI_COMM_WORLD,
MPI_Info  info = MPI_INFO_NULL 
)
static

Open an existing file.

Definition at line 441 of file REMORA_NCInterface.cpp.

Referenced by NCTimeSeriesRiver::Initialize(), ReadNetCDFFile(), ReadNetCDFVarAttrStr(), and REMORA::WriteNCPlotFile().

Here is the caller graph for this function:

◆ put_attr() [1/4]

void ncutils::NCFile::put_attr ( const std::string &  name,
const std::string &  value 
) const

Set file attribute to value.

Definition at line 354 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the caller graph for this function:

◆ put_attr() [2/4]

void ncutils::NCFile::put_attr ( const std::string &  name,
const std::vector< double > &  value 
) const

Set file attribute to value.

Definition at line 358 of file REMORA_NCInterface.cpp.

◆ put_attr() [3/4]

void ncutils::NCFile::put_attr ( const std::string &  name,
const std::vector< float > &  value 
) const

Set file attribute to value.

Definition at line 362 of file REMORA_NCInterface.cpp.

◆ put_attr() [4/4]

void ncutils::NCFile::put_attr ( const std::string &  name,
const std::vector< int > &  value 
) const

Set file attribute to value.

Definition at line 366 of file REMORA_NCInterface.cpp.

◆ var()

NCVar ncutils::NCFile::var ( const std::string &  name) const

Get the variable instance by name.

Definition at line 313 of file REMORA_NCInterface.cpp.

Referenced by REMORA::WriteNCPlotFile_which().

Here is the caller graph for this function:

◆ wait_all()

void ncutils::NCFile::wait_all ( int  num_requests,
int *  requests 
)

wait for non-blocking calls to finish

Definition at line 447 of file REMORA_NCInterface.cpp.

Member Data Documentation

◆ is_open

bool ncutils::NCFile::is_open {false}

Definition at line 388 of file REMORA_NCInterface.H.

Referenced by close(), and ~NCFile().

◆ ncid


The documentation for this class was generated from the following files: