File Write_netcdf.cu
FileList > src > Write_netcdf.cu
Go to the source code of this file
#include "Write_netcdf.h"
#include "Util_CPU.h"
#include "General.h"
Public Functions
Type | Name |
---|---|
std::vector< int > | Calcactiveblockzone (Param XParam, int * activeblk, outzoneB Xzone) Calculate active blocks in a zone. Calculates the active blocks within a specified zone by comparing the active blocks with the blocks defined in the zone. |
void | Calcnxny (Param XParam, int level, int & nx, int & ny) Calculate grid dimensions based on level. Calculates the number of grid points in the x and y directions based on the specified level. |
void | Calcnxnyzone (Param XParam, int level, int & nx, int & ny, outzoneB Xzone) Calculate grid dimensions for a specific zone (output zones) based on level. Calculates the number of grid points in the x and y directions for a specified zone based on the given level. |
void | InitSave2Netcdf (Param & XParam, Model< T > & XModel) Initialize NetCDF output files for the model. Initializes NetCDF output files for the model based on the provided parameters and model configuration. If output variables are specified in the parameters, it creates the necessary NetCDF files and defines the variables to be saved. |
template void | InitSave2Netcdf< double > (Param & XParam, Model< double > & XModel) |
template void | InitSave2Netcdf< float > (Param & XParam, Model< float > & XModel) |
void | Save2Netcdf (Param XParam, Loop< T > XLoop, Model< T > & XModel) Save model output to NetCDF files at specified output times. Saves model output to NetCDF files at specified output times based on the provided parameters. It checks if the current output time matches the next scheduled output time for each output zone, and if so, writes the relevant variables to the corresponding NetCDF files. |
template void | Save2Netcdf< double > (Param XParam, Loop< double > XLoop, Model< double > & XModel) |
template void | Save2Netcdf< float > (Param XParam, Loop< float > XLoop, Model< float > & XModel) |
void | create2dnc (char * filename, int nx, int ny, double * xx, double * yy, double * var, char * varname) Create a NetCDF file containing a 2D variable, for testing for example. Creates a NetCDF file containing a 2D variable with the specified dimensions and data. If the file already exists, it will be overwritten. |
void | create3dnc (char * name, int nx, int ny, int nt, double * xx, double * yy, double * theta, double * var, char * varname) Create a NetCDF file containing a 3D variable, for testing for example. Creates a NetCDF file containing a 3D variable with the specified dimensions and data. If the file already exists, it will be overwritten. |
void | creatncfileBUQ (Param & XParam, int * activeblk, int * level, T * blockxo, T * blockyo, outzoneB & Xzone) Create a NetCDF file for BG-Flood output. Creates a NetCDF file for BG-Flood output based on the provided parameters and zone information. |
void | creatncfileBUQ (Param & XParam, BlockP< T > & XBlock) Create NetCDF files for all output zones in a block. Creates NetCDF files for all output zones defined in the block using the provided parameters and block information. |
template void | creatncfileBUQ< double > (Param & XParam, int * activeblk, int * level, double * blockxo, double * blockyo, outzoneB & Xzone) |
template void | creatncfileBUQ< double > (Param & XParam, BlockP< double > & XBlock) |
template void | creatncfileBUQ< float > (Param & XParam, int * activeblk, int * level, float * blockxo, float * blockyo, outzoneB & Xzone) |
template void | creatncfileBUQ< float > (Param & XParam, BlockP< float > & XBlock) |
void | defncvarBUQ (Param XParam, int * activeblk, int * level, T * blockxo, T * blockyo, std::string varst, int vdim, T * var, outzoneB Xzone) Define a NetCDF variable for BG-Flood output. Defines a NetCDF variable for BG-Flood output based on the provided parameters, block information and zone information. |
void | defncvarBUQ (Param XParam, int * activeblk, int * level, T * blockxo, T * blockyo, std::string varst, std::string longname, std::string stdname, std::string unit, int vdim, T * var, outzoneB Xzone) Define a NetCDF variable for BG-Flood output with detailed attributes. Defines a NetCDF variable for BG-Flood output based on the provided parameters, block information and zone information, along with detailed attributes such as long name, standard name, and unit. |
template void | defncvarBUQ< double > (Param XParam, int * activeblk, int * level, double * blockxo, double * blockyo, std::string varst, int vdim, double * var, outzoneB Xzone) |
template void | defncvarBUQ< float > (Param XParam, int * activeblk, int * level, float * blockxo, float * blockyo, std::string varst, int vdim, float * var, outzoneB Xzone) |
void | defncvarBUQlev (Param XParam, int * activeblk, int * level, T * blockxo, T * blockyo, std::string varst, std::string longname, std::string stdname, std::string unit, int vdim, T * var, outzoneB Xzone) Define a NetCDF variable for BG-Flood output with detailed attributes. Defines a NetCDF variable for BG-Flood output based on the provided parameters, block information and zone information, along with detailed attributes such as long name, standard name, and unit. |
void | handle_ncerror (int status) Handle NetCDF errors. |
void | write2dvarnc (int nx, int ny, double totaltime, double * var) Write a time step of a 2D variable to an existing NetCDF file, for testing for example. Writes a time step of a 2D variable to an existing NetCDF file by appending the provided variable data at the next available time index. |
void | write3dvarnc (int nx, int ny, int nt, double totaltime, double * var) Write a time step of a 3D variable to an existing NetCDF file, for testing for example. Writes a time step of a 3D variable to an existing NetCDF file by appending the provided variable data at the next available time index. |
void | writenctimestep (std::string outfile, double totaltime) Write the current time step to a NetCDF file. Writes the current time step to a NetCDF file by updating the "time" variable with the provided total time value. |
void | writencvarstepBUQ (Param XParam, int vdim, int * activeblk, int * level, T * blockxo, T * blockyo, std::string varst, T * var, outzoneB Xzone) Write a time step of a NetCDF variable for BG-Flood output. Writes a time step of a NetCDF variable for BG-Flood output based on the provided parameters, block information, variable data, and zone information. |
template void | writencvarstepBUQ< double > (Param XParam, int vdim, int * activeblk, int * level, double * blockxo, double * blockyo, std::string varst, double * var, outzoneB Xzone) |
template void | writencvarstepBUQ< float > (Param XParam, int vdim, int * activeblk, int * level, float * blockxo, float * blockyo, std::string varst, float * var, outzoneB Xzone) |
void | writencvarstepBUQlev (Param XParam, int vdim, int * activeblk, int * level, T * blockxo, T * blockyo, std::string varst, T * var, outzoneB Xzone) Write a time step of a NetCDF variable for BG-Flood output. Writes a time step of a NetCDF variable for BG-Flood output based on the provided parameters, block information, variable data, and zone information. |
template void | writencvarstepBUQlev< double > (Param XParam, int vdim, int * activeblk, int * level, double * blockxo, double * blockyo, std::string varst, double * var, outzoneB Xzone) |
template void | writencvarstepBUQlev< float > (Param XParam, int vdim, int * activeblk, int * level, float * blockxo, float * blockyo, std::string varst, float * var, outzoneB Xzone) |
Public Functions Documentation
function Calcactiveblockzone
Calculate active blocks in a zone. Calculates the active blocks within a specified zone by comparing the active blocks with the blocks defined in the zone.
Parameters:
XParam
The parameter object containing grid settings.activeblk
Pointer to an array of active block indices.Xzone
The output zone object defining the area for which to calculate active blocks.
Returns:
A vector containing the indices of active blocks within the specified zone. Inactive blocks are marked with -1.
function Calcnxny
Calculate grid dimensions based on level. Calculates the number of grid points in the x and y directions based on the specified level.
Parameters:
XParam
The parameter object containing grid settings.level
The level for which to calculate grid dimensions.nx
Reference to store the calculated number of grid points in the x direction.ny
Reference to store the calculated number of grid points in the y direction.
function Calcnxnyzone
Calculate grid dimensions for a specific zone (output zones) based on level. Calculates the number of grid points in the x and y directions for a specified zone based on the given level.
Parameters:
XParam
The parameter object containing grid settings.level
The level for which to calculate grid dimensions.nx
Reference to store the calculated number of grid points in the x direction.ny
Reference to store the calculated number of grid points in the y direction.Xzone
The output zone object defining the area for which to calculate grid dimensions.
function InitSave2Netcdf
Initialize NetCDF output files for the model. Initializes NetCDF output files for the model based on the provided parameters and model configuration. If output variables are specified in the parameters, it creates the necessary NetCDF files and defines the variables to be saved.
Parameters:
XParam
The parameter object containing grid settings and model parameters.XModel
The model object containing block information and output variable mappings.
Note:
This is a templated function that can handle different data types for the model (e.g., float, double).
See also: creatncfileBUQ for creating the NetCDF file and defining variables.
function InitSave2Netcdf< double >
function InitSave2Netcdf< float >
function Save2Netcdf
Save model output to NetCDF files at specified output times. Saves model output to NetCDF files at specified output times based on the provided parameters. It checks if the current output time matches the next scheduled output time for each output zone, and if so, writes the relevant variables to the corresponding NetCDF files.
Parameters:
XParam
The parameter object containing grid settings and model parameters.XLoop
The loop object containing time-stepping information.XModel
The model object containing block information and output variable mappings.
Note:
This is a templated function that can handle different data types for the model (e.g., float, double).
See also: writenctimestep for writing the time step to the NetCDF file.
function Save2Netcdf< double >
template void Save2Netcdf< double > (
Param XParam,
Loop < double > XLoop,
Model < double > & XModel
)
function Save2Netcdf< float >
function create2dnc
Create a NetCDF file containing a 2D variable, for testing for example. Creates a NetCDF file containing a 2D variable with the specified dimensions and data. If the file already exists, it will be overwritten.
void create2dnc (
char * filename,
int nx,
int ny,
double * xx,
double * yy,
double * var,
char * varname
)
Parameters:
filename
The name of the NetCDF file to be created.nx
The number of grid points in the x-direction.ny
The number of grid points in the y-direction.xx
Pointer to an array containing the x-coordinates of the grid points.yy
Pointer to an array containing the y-coordinates of the grid points.var
Pointer to an array containing the 2D variable data to be stored in the NetCDF file.varname
The name of the variable to be stored in the NetCDF file.
Note:
This function uses the NetCDF C library to create and write to the NetCDF file.
function create3dnc
Create a NetCDF file containing a 3D variable, for testing for example. Creates a NetCDF file containing a 3D variable with the specified dimensions and data. If the file already exists, it will be overwritten.
void create3dnc (
char * name,
int nx,
int ny,
int nt,
double * xx,
double * yy,
double * theta,
double * var,
char * varname
)
Parameters:
name
The name of the NetCDF file to be created.nx
The number of grid points in the x-direction.ny
The number of grid points in the y-direction.nt
The number of time steps.xx
Pointer to an array containing the x-coordinates of the grid points.yy
Pointer to an array containing the y-coordinates of the grid points.theta
Pointer to an array containing the time values.var
Pointer to an array containing the 3D variable data to be stored in the NetCDF file.varname
The name of the variable to be stored in the NetCDF file.
Note:
This function uses the NetCDF C library to create and write to the NetCDF file.
function creatncfileBUQ
Create a NetCDF file for BG-Flood output. Creates a NetCDF file for BG-Flood output based on the provided parameters and zone information.
template<class T>
void creatncfileBUQ (
Param & XParam,
int * activeblk,
int * level,
T * blockxo,
T * blockyo,
outzoneB & Xzone
)
Parameters:
XParam
The parameter object containing grid settings and model parameters.activeblk
Pointer to an array of active block indices.level
Pointer to an array of block levels.blockxo
Pointer to an array of block x-coordinates.blockyo
Pointer to an array of block y-coordinates.Xzone
The output zone object defining the area and settings for the NetCDF file.
function creatncfileBUQ
Create NetCDF files for all output zones in a block. Creates NetCDF files for all output zones defined in the block using the provided parameters and block information.
Parameters:
XParam
The parameter object containing grid settings and model parameters.XBlock
The block object containing block information and output zones.
function creatncfileBUQ< double >
template void creatncfileBUQ< double > (
Param & XParam,
int * activeblk,
int * level,
double * blockxo,
double * blockyo,
outzoneB & Xzone
)
function creatncfileBUQ< double >
function creatncfileBUQ< float >
template void creatncfileBUQ< float > (
Param & XParam,
int * activeblk,
int * level,
float * blockxo,
float * blockyo,
outzoneB & Xzone
)
function creatncfileBUQ< float >
function defncvarBUQ
Define a NetCDF variable for BG-Flood output. Defines a NetCDF variable for BG-Flood output based on the provided parameters, block information and zone information.
template<class T>
void defncvarBUQ (
Param XParam,
int * activeblk,
int * level,
T * blockxo,
T * blockyo,
std::string varst,
int vdim,
T * var,
outzoneB Xzone
)
Parameters:
XParam
The parameter object containing grid settings and model parameters.activeblk
Pointer to an array of active block indices.level
Pointer to an array of block levels.blockxo
Pointer to an array of block x-coordinates.blockyo
Pointer to an array of block y-coordinates.varst
The base name of the variable to be defined.vdim
The number of dimensions of the variable (2 or 3).var
Pointer to the array containing the variable data.Xzone
The output zone object defining the area and settings for the NetCDF variable.
Note:
This is an overloaded function that provides a simpler interface when longname, stdname, and unit are not needed.
function defncvarBUQ
Define a NetCDF variable for BG-Flood output with detailed attributes. Defines a NetCDF variable for BG-Flood output based on the provided parameters, block information and zone information, along with detailed attributes such as long name, standard name, and unit.
template<class T>
void defncvarBUQ (
Param XParam,
int * activeblk,
int * level,
T * blockxo,
T * blockyo,
std::string varst,
std::string longname,
std::string stdname,
std::string unit,
int vdim,
T * var,
outzoneB Xzone
)
Parameters:
XParam
The parameter object containing grid settings and model parameters.activeblk
Pointer to an array of active block indices.level
Pointer to an array of block levels.blockxo
Pointer to an array of block x-coordinates.blockyo
Pointer to an array of block y-coordinates.varst
The base name of the variable to be defined.longname
The long name attribute for the variable.stdname
The standard name attribute for the variable.unit
The unit attribute for the variable.vdim
The number of dimensions of the variable (2 or 3).var
Pointer to the array containing the variable data.Xzone
The output zone object defining the area and settings for the NetCDF variable.
Note:
This is a templated function that can handle different data types for the variable (e.g., float, double).
function defncvarBUQ< double >
template void defncvarBUQ< double > (
Param XParam,
int * activeblk,
int * level,
double * blockxo,
double * blockyo,
std::string varst,
int vdim,
double * var,
outzoneB Xzone
)
function defncvarBUQ< float >
template void defncvarBUQ< float > (
Param XParam,
int * activeblk,
int * level,
float * blockxo,
float * blockyo,
std::string varst,
int vdim,
float * var,
outzoneB Xzone
)
function defncvarBUQlev
Define a NetCDF variable for BG-Flood output with detailed attributes. Defines a NetCDF variable for BG-Flood output based on the provided parameters, block information and zone information, along with detailed attributes such as long name, standard name, and unit.
template<class T>
void defncvarBUQlev (
Param XParam,
int * activeblk,
int * level,
T * blockxo,
T * blockyo,
std::string varst,
std::string longname,
std::string stdname,
std::string unit,
int vdim,
T * var,
outzoneB Xzone
)
Parameters:
XParam
The parameter object containing grid settings and model parameters.activeblk
Pointer to an array of active block indices.level
Pointer to an array of block levels.blockxo
Pointer to an array of block x-coordinates.blockyo
Pointer to an array of block y-coordinates.varst
The base name of the variable to be defined.longname
The long name attribute for the variable.stdname
The standard name attribute for the variable.unit
The unit attribute for the variable.vdim
The number of dimensions of the variable (2 or 3).var
Pointer to the array containing the variable data.Xzone
The output zone object defining the area and settings for the NetCDF variable.
Note:
This is a templated function that can handle different data types for the variable (e.g., float, double).
function handle_ncerror
Handle NetCDF errors.
function write2dvarnc
Write a time step of a 2D variable to an existing NetCDF file, for testing for example. Writes a time step of a 2D variable to an existing NetCDF file by appending the provided variable data at the next available time index.
Parameters:
nx
The number of grid points in the x-direction.ny
The number of grid points in the y-direction.totaltime
The total time value to be written to the "time" variable.var
Pointer to an array containing the 2D variable data to be appended to the NetCDF file.
Note:
This function assumes that the NetCDF file "3Dvar.nc" already exists and is open for writing.
function write3dvarnc
Write a time step of a 3D variable to an existing NetCDF file, for testing for example. Writes a time step of a 3D variable to an existing NetCDF file by appending the provided variable data at the next available time index.
Parameters:
nx
The number of grid points in the x-direction.ny
The number of grid points in the y-direction.nt
The number of time steps.totaltime
The total time value to be written to the "time" variable.var
Pointer to an array containing the 3D variable data to be appended to the NetCDF file.
Note:
This function assumes that the NetCDF file "3Dvar.nc" already exists and is open for writing.
function writenctimestep
Write the current time step to a NetCDF file. Writes the current time step to a NetCDF file by updating the "time" variable with the provided total time value.
Parameters:
outfile
The name of the NetCDF output file.totaltime
The total time value to be written to the "time" variable.
function writencvarstepBUQ
Write a time step of a NetCDF variable for BG-Flood output. Writes a time step of a NetCDF variable for BG-Flood output based on the provided parameters, block information, variable data, and zone information.
template<class T>
void writencvarstepBUQ (
Param XParam,
int vdim,
int * activeblk,
int * level,
T * blockxo,
T * blockyo,
std::string varst,
T * var,
outzoneB Xzone
)
Parameters:
XParam
The parameter object containing grid settings and model parameters.vdim
The number of dimensions of the variable (2 or 3).activeblk
Pointer to an array of active block indices.level
Pointer to an array of block levels.blockxo
Pointer to an array of block x-coordinates.blockyo
Pointer to an array of block y-coordinates.varst
The base name of the variable to be written.var
Pointer to the array containing the variable data.Xzone
The output zone object defining the area and settings for the NetCDF variable.
Note:
This is a templated function that can handle different data types for the variable (e.g., float, double).
function writencvarstepBUQ< double >
template void writencvarstepBUQ< double > (
Param XParam,
int vdim,
int * activeblk,
int * level,
double * blockxo,
double * blockyo,
std::string varst,
double * var,
outzoneB Xzone
)
function writencvarstepBUQ< float >
template void writencvarstepBUQ< float > (
Param XParam,
int vdim,
int * activeblk,
int * level,
float * blockxo,
float * blockyo,
std::string varst,
float * var,
outzoneB Xzone
)
function writencvarstepBUQlev
Write a time step of a NetCDF variable for BG-Flood output. Writes a time step of a NetCDF variable for BG-Flood output based on the provided parameters, block information, variable data, and zone information.
template<class T>
void writencvarstepBUQlev (
Param XParam,
int vdim,
int * activeblk,
int * level,
T * blockxo,
T * blockyo,
std::string varst,
T * var,
outzoneB Xzone
)
Parameters:
XParam
The parameter object containing grid settings and model parameters.vdim
The number of dimensions of the variable (2 or 3).activeblk
Pointer to an array of active block indices.level
Pointer to an array of block levels.blockxo
Pointer to an array of block x-coordinates.blockyo
Pointer to an array of block y-coordinates.varst
The base name of the variable to be written.var
Pointer to the array containing the variable data.Xzone
The output zone object defining the area and settings for the NetCDF variable.
Note:
This is a templated function that can handle different data types for the variable (e.g., float, double). This version handles variables defined for each level separately.
See also: writencvarstepBUQ for the version that does not separate by levels.
function writencvarstepBUQlev< double >
template void writencvarstepBUQlev< double > (
Param XParam,
int vdim,
int * activeblk,
int * level,
double * blockxo,
double * blockyo,
std::string varst,
double * var,
outzoneB Xzone
)
function writencvarstepBUQlev< float >
template void writencvarstepBUQlev< float > (
Param XParam,
int vdim,
int * activeblk,
int * level,
float * blockxo,
float * blockyo,
std::string varst,
float * var,
outzoneB Xzone
)
The documentation for this class was generated from the following file src/Write_netcdf.cu