YAKL
Classes | Public Member Functions | List of all members
yakl::SimpleNetCDF Class Reference

Simple way to write yakl::Array objects to NetCDF files. More...

#include <YAKL_netcdf.h>

Public Member Functions

 SimpleNetCDF ()
 
 ~SimpleNetCDF ()
 Files are automatically closed when SimpleNetCDF objects are destroyed. More...
 
void close ()
 Close the netcdf file. More...
 
void create (std::string fname, int mode=NC_CLOBBER)
 Create a netcdf file. More...
 
void createDim (std::string dimName)
 Create an unlimited dimension. More...
 
void createDim (std::string dimName, size_t len)
 Create a dimension of the given length. More...
 
bool dimExists (std::string dimName) const
 Determine if a dimension name exists. More...
 
size_t getDimSize (std::string dimName) const
 Determine the size of a dimension name. More...
 
void open (std::string fname, int mode=NETCDF_MODE_READ)
 Open a netcdf file. More...
 
template<class T , int rank, int myMem, int myStyle>
void read (Array< T, rank, myMem, myStyle > &arr, std::string varName)
 Read an entire Array. More...
 
template<class T >
void read (T &arr, std::string varName)
 Read a single scalar value. More...
 
bool varExists (std::string varName) const
 Determine if a variable name exists. More...
 
template<class T , int rank, int myMem, int myStyle>
void write (Array< T, rank, myMem, myStyle > const &arr, std::string varName, std::vector< std::string > dimNames)
 Write an entire Array at once. More...
 
template<class T >
void write (T arr, std::string varName)
 Write a single scalar value. More...
 
template<class T , int rank, int myMem, int myStyle>
void write1 (Array< T, rank, myMem, myStyle > const &arr, std::string varName, std::vector< std::string > dimNames, int ind, std::string ulDimName="unlim")
 Write one entry of an Array into the unlimited index. More...
 
template<class T , typename std::enable_if< std::is_arithmetic< T >::value, int >::type = 0>
void write1 (T val, std::string varName, int ind, std::string ulDimName="unlim")
 Write one entry of a scalar into the unlimited index. More...
 

Detailed Description

Simple way to write yakl::Array objects to NetCDF files.

Constructor & Destructor Documentation

◆ SimpleNetCDF()

yakl::SimpleNetCDF::SimpleNetCDF ( )
inline

◆ ~SimpleNetCDF()

yakl::SimpleNetCDF::~SimpleNetCDF ( )
inline

Files are automatically closed when SimpleNetCDF objects are destroyed.

Member Function Documentation

◆ close()

void yakl::SimpleNetCDF::close ( )
inline

Close the netcdf file.

◆ create()

void yakl::SimpleNetCDF::create ( std::string  fname,
int  mode = NC_CLOBBER 
)
inline

Create a netcdf file.

Parameters
modeCan be NETCDF_MODE_CLOBBER or NETCDF_MODE_NOCLOBBER

◆ createDim() [1/2]

void yakl::SimpleNetCDF::createDim ( std::string  dimName)
inline

Create an unlimited dimension.

◆ createDim() [2/2]

void yakl::SimpleNetCDF::createDim ( std::string  dimName,
size_t  len 
)
inline

Create a dimension of the given length.

◆ dimExists()

bool yakl::SimpleNetCDF::dimExists ( std::string  dimName) const
inline

Determine if a dimension name exists.

◆ getDimSize()

size_t yakl::SimpleNetCDF::getDimSize ( std::string  dimName) const
inline

Determine the size of a dimension name.

◆ open()

void yakl::SimpleNetCDF::open ( std::string  fname,
int  mode = NETCDF_MODE_READ 
)
inline

Open a netcdf file.

Parameters
modeCan be NETCDF_MODE_READ or NETCDF_MODE_WRITE

◆ read() [1/2]

template<class T , int rank, int myMem, int myStyle>
void yakl::SimpleNetCDF::read ( Array< T, rank, myMem, myStyle > &  arr,
std::string  varName 
)
inline

Read an entire Array.

◆ read() [2/2]

template<class T >
void yakl::SimpleNetCDF::read ( T &  arr,
std::string  varName 
)
inline

Read a single scalar value.

◆ varExists()

bool yakl::SimpleNetCDF::varExists ( std::string  varName) const
inline

Determine if a variable name exists.

◆ write() [1/2]

template<class T , int rank, int myMem, int myStyle>
void yakl::SimpleNetCDF::write ( Array< T, rank, myMem, myStyle > const &  arr,
std::string  varName,
std::vector< std::string >  dimNames 
)
inline

Write an entire Array at once.

◆ write() [2/2]

template<class T >
void yakl::SimpleNetCDF::write ( arr,
std::string  varName 
)
inline

Write a single scalar value.

◆ write1() [1/2]

template<class T , int rank, int myMem, int myStyle>
void yakl::SimpleNetCDF::write1 ( Array< T, rank, myMem, myStyle > const &  arr,
std::string  varName,
std::vector< std::string >  dimNames,
int  ind,
std::string  ulDimName = "unlim" 
)
inline

Write one entry of an Array into the unlimited index.

◆ write1() [2/2]

template<class T , typename std::enable_if< std::is_arithmetic< T >::value, int >::type = 0>
void yakl::SimpleNetCDF::write1 ( val,
std::string  varName,
int  ind,
std::string  ulDimName = "unlim" 
)
inline

Write one entry of a scalar into the unlimited index.


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