Extension: Json and NetCDF utilities
#include "dg/file/file.h" (includes both Json and NetCDF utilities)
NetCDF utilities

Classes

struct  dg::file::NC_Error
 Class thrown by the NC_Error_Handle. More...
 
struct  dg::file::NC_Error_Handle
 Empty utitlity class that handles return values of netcdf functions and throws NC_Error(status) if( status != NC_NOERR) More...
 

Functions

template<class host_vector >
void dg::file::put_var_double (int ncid, int varid, const dg::aTopology2d &grid, const host_vector &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_vara_double (int ncid, int varid, unsigned slice, const dg::aTopology2d &grid, const host_vector &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_var_double (int ncid, int varid, const dg::aTopology3d &grid, const host_vector &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_vara_double (int ncid, int varid, unsigned slice, const dg::aTopology3d &grid, const host_vector &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_var_double (int ncid, int varid, const dg::aMPITopology2d &grid, const dg::MPI_Vector< host_vector > &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_vara_double (int ncid, int varid, unsigned slice, const dg::aMPITopology2d &grid, const dg::MPI_Vector< host_vector > &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_var_double (int ncid, int varid, const dg::aMPITopology3d &grid, const dg::MPI_Vector< host_vector > &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class host_vector >
void dg::file::put_vara_double (int ncid, int varid, unsigned slice, const dg::aMPITopology3d &grid, const dg::MPI_Vector< host_vector > &data, bool parallel=false)
 Convenience wrapper around nc_put_vara_double() More...
 
template<class T >
int dg::file::define_real_time (int ncid, const char *name, int *dimID, int *tvarID)
 Define an unlimited time dimension and coordinate variable. More...
 
static int dg::file::define_time (int ncid, const char *name, int *dimID, int *tvarID)
 Define an unlimited time dimension and coordinate variable. More...
 
static int dg::file::define_limited_time (int ncid, const char *name, int size, int *dimID, int *tvarID)
 Define a limited time dimension and coordinate variable. More...
 
template<class T >
int dg::file::define_dimension (int ncid, int *dimID, const dg::RealGrid1d< T > &g, std::string name_dim="x", std::string axis="X")
 Define a 1d dimension and associated coordinate variable. More...
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, int *tvarID, const dg::RealGrid1d< T > &g, std::array< std::string, 2 > name_dims={"time","x"})
 Define an unlimited time and a dimension together with their coordinate variables. More...
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, const dg::aRealTopology2d< T > &g, std::array< std::string, 2 > name_dims={"y", "x"})
 Define 2 dimensions and associated coordiante variables. More...
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, int *tvarID, const dg::aRealTopology2d< T > &g, std::array< std::string, 3 > name_dims={"time", "y", "x"})
 Define an unlimited time and 2 dimensions and associated coordinate variables. More...
 
template<class T >
int dg::file::define_limtime_xy (int ncid, int *dimsIDs, int size, int *tvarID, const dg::aRealTopology2d< T > &g, std::array< std::string, 3 > name_dims={"time", "y", "x"})
 Define a limited time and 2 dimensions and associated coordinate variables. More...
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, const dg::aRealTopology3d< T > &g, std::array< std::string, 3 > name_dims={"z", "y", "x"})
 Define 3 dimensions and associated coordinate variables. More...
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, int *tvarID, const dg::aRealTopology3d< T > &g, std::array< std::string, 4 > name_dims={"time", "z", "y", "x"})
 Define an unlimited time and 3 dimensions together with their coordinate varariables. More...
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, const dg::aRealMPITopology2d< T > &g, std::array< std::string, 2 > name_dims={"y", "x"})
 Only master process should call this!! Convenience function that just calls the corresponding serial version with the global grid.
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, int *tvarID, const dg::aRealMPITopology2d< T > &g, std::array< std::string, 3 > name_dims={"time", "y", "x"})
 Only master process should call this!! Convenience function that just calls the corresponding serial version with the global grid.
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, const dg::aRealMPITopology3d< T > &g, std::array< std::string, 3 > name_dims={"z", "y", "x"})
 Only master process should call this!! Convenience function that just calls the corresponding serial version with the global grid.
 
template<class T >
int dg::file::define_dimensions (int ncid, int *dimsIDs, int *tvarID, const dg::aRealMPITopology3d< T > &g, std::array< std::string, 4 > name_dims={"time", "z", "y", "x"})
 Only master process should call this!! Convenience function that just calls the corresponding serial version with the global grid.
 

Detailed Description

#include "dg/file/nc_utilities.h" (link -lnetcdf -lhdf5[_serial] -lhdf5[_serial]_hl)

Function Documentation

◆ define_dimension()

template<class T >
int dg::file::define_dimension ( int  ncid,
int *  dimID,
const dg::RealGrid1d< T > &  g,
std::string  name_dim = "x",
std::string  axis = "X" 
)
inline

Define a 1d dimension and associated coordinate variable.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.
Parameters
ncidfile ID
dimIDdimension ID (output)
gThe 1d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g)
name_dimName of dimension and coordinate variable (input)
axisThe axis attribute (input), ("X", "Y" or "Z")
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
NetCDF error code if any

◆ define_dimensions() [1/5]

template<class T >
int dg::file::define_dimensions ( int  ncid,
int *  dimsIDs,
const dg::aRealTopology2d< T > &  g,
std::array< std::string, 2 >  name_dims = {"y", "x"} 
)
inline

Define 2 dimensions and associated coordiante variables.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.

Dimensions have attributes of (Y, X)

Parameters
ncidfile ID
dimsIDs(write - only) 2D array of dimension IDs (Y,X)
gThe 2d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g) in each dimension
name_dimsNames for the dimension variables
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
if anything goes wrong it returns the netCDF code, else SUCCESS
Note
File stays in define mode

◆ define_dimensions() [2/5]

template<class T >
int dg::file::define_dimensions ( int  ncid,
int *  dimsIDs,
const dg::aRealTopology3d< T > &  g,
std::array< std::string, 3 >  name_dims = {"z", "y", "x"} 
)
inline

Define 3 dimensions and associated coordinate variables.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.

Dimensions have attributes ( Z, Y, X)

Parameters
ncidfile ID
dimsIDs(write - only) 3D array of dimension IDs (Z,Y,X)
gThe 3d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g) in each dimension
name_dimsNames for the dimension variables ( Z, Y, X)
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
if anything goes wrong it returns the netCDF code, else SUCCESS
Note
File stays in define mode

◆ define_dimensions() [3/5]

template<class T >
int dg::file::define_dimensions ( int  ncid,
int *  dimsIDs,
int *  tvarID,
const dg::aRealTopology2d< T > &  g,
std::array< std::string, 3 >  name_dims = {"time", "y", "x"} 
)
inline

Define an unlimited time and 2 dimensions and associated coordinate variables.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.

Semantically equivalent to the following:

define_time( ncid, name_dims[0], &dimsIDs[0], tvarID);
define_dimensions( ncid, &dimsIDs[1], g, {name_dims[1], name_dims[2]});
int define_dimensions(int ncid, int *dimsIDs, int *tvarID, const dg::RealGrid1d< T > &g, std::array< std::string, 2 > name_dims={"time","x"})
Define an unlimited time and a dimension together with their coordinate variables.
Definition: nc_utilities.h:172
static int define_time(int ncid, const char *name, int *dimID, int *tvarID)
Define an unlimited time dimension and coordinate variable.
Definition: nc_utilities.h:87

Dimensions have attributes of (time, Y, X)

Parameters
ncidfile ID
dimsIDs(write - only) 3D array of dimension IDs (time, Y,X)
tvarID(write - only) The ID of the time variable ( unlimited)
gThe 2d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g) in each dimension
name_dimsNames for the dimension variables ( time, Y, X)
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
if anything goes wrong it returns the netCDF code, else SUCCESS
Note
File stays in define mode

◆ define_dimensions() [4/5]

template<class T >
int dg::file::define_dimensions ( int  ncid,
int *  dimsIDs,
int *  tvarID,
const dg::aRealTopology3d< T > &  g,
std::array< std::string, 4 >  name_dims = {"time", "z", "y", "x"} 
)
inline

Define an unlimited time and 3 dimensions together with their coordinate varariables.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.

Semantically equivalent to the following:

define_time( ncid, name_dims[0], &dimsIDs[0], tvarID);
define_dimensions( ncid, &dimsIDs[1], g, {name_dims[1], name_dims[2], name_dims[3]});

Dimensions have attributes ( time, Z, Y, X)

Parameters
ncidfile ID
dimsIDs(write - only) 4D array of dimension IDs (time, Z,Y,X)
tvarID(write - only) The ID of the time variable ( unlimited)
gThe 3d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g) in each dimension
name_dimsNames for the dimension variables ( time, Z, Y, X)
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
if anything goes wrong it returns the netCDF code, else SUCCESS
Note
File stays in define mode

◆ define_dimensions() [5/5]

template<class T >
int dg::file::define_dimensions ( int  ncid,
int *  dimsIDs,
int *  tvarID,
const dg::RealGrid1d< T > &  g,
std::array< std::string, 2 >  name_dims = {"time","x"} 
)
inline

Define an unlimited time and a dimension together with their coordinate variables.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.

Semantically equivalent to the following:

define_time( ncid, name_dims[0], &dimsIDs[0], tvarID);
define_dimension( ncid, &dimsIDs[1], g, name_dims[1]);
int define_dimension(int ncid, int *dimID, const dg::RealGrid1d< T > &g, std::string name_dim="x", std::string axis="X")
Define a 1d dimension and associated coordinate variable.
Definition: nc_utilities.h:135

Dimensions have attribute of (time, X)

Parameters
ncidfile ID
dimsIDsdimension IDs (time, X)
tvarIDtime coordinate variable ID (unlimited)
gThe 1d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g)
name_dimsNames for the dimension and coordinate variables
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
NetCDF error code if any

◆ define_limited_time()

static int dg::file::define_limited_time ( int  ncid,
const char *  name,
int  size,
int *  dimID,
int *  tvarID 
)
inlinestatic

Define a limited time dimension and coordinate variable.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable. The CF conventions dictate that the units attribute must be defined for a time variable: we give it the value "time since start"
Parameters
ncidfile ID
nameName of the time variable (usually "time")
sizeThe number of timesteps
dimIDtime-dimension ID
tvarIDtime-variable ID (for a time variable of type NC_DOUBLE)
Returns
NetCDF error code if any

◆ define_limtime_xy()

template<class T >
int dg::file::define_limtime_xy ( int  ncid,
int *  dimsIDs,
int  size,
int *  tvarID,
const dg::aRealTopology2d< T > &  g,
std::array< std::string, 3 >  name_dims = {"time", "y", "x"} 
)
inline

Define a limited time and 2 dimensions and associated coordinate variables.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable.

Semantically equivalent to the following:

define_limited_time( ncid, name_dims[0], size, &dimsIDs[0], tvarID);
define_dimensions( ncid, &dimsIDs[1], g, {name_dims[1], name_dims[2]});
static int define_limited_time(int ncid, const char *name, int size, int *dimID, int *tvarID)
Define a limited time dimension and coordinate variable.
Definition: nc_utilities.h:109

Dimensions have attributes of (time, Y, X)

Parameters
ncidfile ID
dimsIDs(write - only) 3D array of dimension IDs (time, Y,X)
sizeThe size of the time variable
tvarID(write - only) The ID of the time variable (limited)
gThe 2d DG grid from which data points for coordinate variable are generated using dg::create::abscissas(g)
name_dimsNames for the dimension variables (time, Y, X)
Template Parameters
Tdetermines the datatype of the dimension variables
Returns
if anything goes wrong it returns the netCDF code, else SUCCESS
Note
File stays in define mode

◆ define_real_time()

template<class T >
int dg::file::define_real_time ( int  ncid,
const char *  name,
int *  dimID,
int *  tvarID 
)
inline

Define an unlimited time dimension and coordinate variable.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable. The CF conventions dictate that the units attribute must be defined for a time variable: we give it the value "time since start"
Parameters
ncidfile ID
nameName of time variable (variable names are not standardized)
dimIDtime-dimension ID
tvarIDtime-variable ID (for a time variable of type NC_DOUBLE)
Returns
NetCDF error code if any

◆ define_time()

static int dg::file::define_time ( int  ncid,
const char *  name,
int *  dimID,
int *  tvarID 
)
inlinestatic

Define an unlimited time dimension and coordinate variable.

Note
By netCDF conventions a variable with the same name as a dimension is called a coordinate variable. The CF conventions dictate that the units attribute must be defined for a time variable: we give it the value "time since start"
Parameters
ncidfile ID
nameName of time variable (variable names are not standardized)
dimIDtime-dimension ID
tvarIDtime-variable ID (for a time variable of type NC_DOUBLE)
Returns
NetCDF error code if any

◆ put_var_double() [1/4]

template<class host_vector >
void dg::file::put_var_double ( int  ncid,
int  varid,
const dg::aMPITopology2d &  grid,
const dg::MPI_Vector< host_vector > &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-independent variable, i.e. writes a single variable in one go and is actually equivalent to nc_put_var_double. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_var_double() [2/4]

template<class host_vector >
void dg::file::put_var_double ( int  ncid,
int  varid,
const dg::aMPITopology3d &  grid,
const dg::MPI_Vector< host_vector > &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-independent variable, i.e. writes a single variable in one go and is actually equivalent to nc_put_var_double. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_var_double() [3/4]

template<class host_vector >
void dg::file::put_var_double ( int  ncid,
int  varid,
const dg::aTopology2d &  grid,
const host_vector &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-independent variable, i.e. writes a single variable in one go and is actually equivalent to nc_put_var_double. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_var_double() [4/4]

template<class host_vector >
void dg::file::put_var_double ( int  ncid,
int  varid,
const dg::aTopology3d &  grid,
const host_vector &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-independent variable, i.e. writes a single variable in one go and is actually equivalent to nc_put_var_double. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_vara_double() [1/4]

template<class host_vector >
void dg::file::put_vara_double ( int  ncid,
int  varid,
unsigned  slice,
const dg::aMPITopology2d &  grid,
const dg::MPI_Vector< host_vector > &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-dependent variable, i.e. writes a single time-slice into the file. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
sliceThe number of the time-slice to write (first element of the startp array in nc_put_vara_double)
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double,
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_vara_double() [2/4]

template<class host_vector >
void dg::file::put_vara_double ( int  ncid,
int  varid,
unsigned  slice,
const dg::aMPITopology3d &  grid,
const dg::MPI_Vector< host_vector > &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-dependent variable, i.e. writes a single time-slice into the file. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
sliceThe number of the time-slice to write (first element of the startp array in nc_put_vara_double)
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double,
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_vara_double() [3/4]

template<class host_vector >
void dg::file::put_vara_double ( int  ncid,
int  varid,
unsigned  slice,
const dg::aTopology2d &  grid,
const host_vector &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-dependent variable, i.e. writes a single time-slice into the file. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
sliceThe number of the time-slice to write (first element of the startp array in nc_put_vara_double)
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double,
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.

◆ put_vara_double() [4/4]

template<class host_vector >
void dg::file::put_vara_double ( int  ncid,
int  varid,
unsigned  slice,
const dg::aTopology3d &  grid,
const host_vector &  data,
bool  parallel = false 
)

Convenience wrapper around nc_put_vara_double()

The purpose of this function is mainly to simplify output in an MPI environment and to provide the same interface also in a shared memory system for uniform programming. This version is for a time-dependent variable, i.e. writes a single time-slice into the file. The dimensionality is given by the grid.

Note
This function throws a dg::file::NC_Error if an error occurs
Template Parameters
host_vectorType with data() member that returns pointer to first element in CPU (host) adress space, meaning it cannot be a GPU vector
Parameters
ncidForwarded to nc_put_vara_double
varidForwarded to nc_put_vara_double
sliceThe number of the time-slice to write (first element of the startp array in nc_put_vara_double)
gridThe grid from which to construct start and count variables to forward to nc_put_vara_double
datadata is forwarded to nc_put_vara_double,
parallelThis parameter is ignored in the serial version. In the MPI version this parameter indicates whether each process writes to the file independently in parallel (true) or each process funnels its data through the master rank (false), which involves communication but may be faster than the former method.
Attention
In the MPI version (i) all processes must call this function and (ii) if parallel==true a parallel netcdf and hdf5 must be linked, the file opened with the NC_MPIIO flag from the netcdf_par.h header and the variable be marked with NC_COLLECTIVE access while if parallel==false we need serial netcdf and hdf5 and only the master thread needs to open and access the file. Note that serious performance penalties have been observed on some platforms for parallel netcdf.