File Write_netcdf.h
FileList > src > Write_netcdf.h
Go to the source code of this file
#include "General.h"#include "Param.h"#include "Write_txtlog.h"#include "ReadInput.h"#include "MemManagement.h"#include "Util_CPU.h"#include "Arrays.h"
Public Functions
| Type | Name |
|---|---|
| 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. |
| 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. |
| 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. |
| 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 | 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. |
Public Functions Documentation
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:
XParamThe parameter object containing grid settings and model parameters.XModelThe 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 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:
XParamThe parameter object containing grid settings and model parameters.XLoopThe loop object containing time-stepping information.XModelThe 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 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:
filenameThe name of the NetCDF file to be created.nxThe number of grid points in the x-direction.nyThe number of grid points in the y-direction.xxPointer to an array containing the x-coordinates of the grid points.yyPointer to an array containing the y-coordinates of the grid points.varPointer to an array containing the 2D variable data to be stored in the NetCDF file.varnameThe 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:
nameThe name of the NetCDF file to be created.nxThe number of grid points in the x-direction.nyThe number of grid points in the y-direction.ntThe number of time steps.xxPointer to an array containing the x-coordinates of the grid points.yyPointer to an array containing the y-coordinates of the grid points.thetaPointer to an array containing the time values.varPointer to an array containing the 3D variable data to be stored in the NetCDF file.varnameThe 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:
XParamThe parameter object containing grid settings and model parameters.activeblkPointer to an array of active block indices.levelPointer to an array of block levels.blockxoPointer to an array of block x-coordinates.blockyoPointer to an array of block y-coordinates.XzoneThe 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:
XParamThe parameter object containing grid settings and model parameters.XBlockThe block object containing block information and output zones.
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:
XParamThe parameter object containing grid settings and model parameters.activeblkPointer to an array of active block indices.levelPointer to an array of block levels.blockxoPointer to an array of block x-coordinates.blockyoPointer to an array of block y-coordinates.varstThe base name of the variable to be defined.vdimThe number of dimensions of the variable (2 or 3).varPointer to the array containing the variable data.XzoneThe 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 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:
nxThe number of grid points in the x-direction.nyThe number of grid points in the y-direction.totaltimeThe total time value to be written to the "time" variable.varPointer 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:
nxThe number of grid points in the x-direction.nyThe number of grid points in the y-direction.ntThe number of time steps.totaltimeThe total time value to be written to the "time" variable.varPointer 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:
outfileThe name of the NetCDF output file.totaltimeThe 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:
XParamThe parameter object containing grid settings and model parameters.vdimThe number of dimensions of the variable (2 or 3).activeblkPointer to an array of active block indices.levelPointer to an array of block levels.blockxoPointer to an array of block x-coordinates.blockyoPointer to an array of block y-coordinates.varstThe base name of the variable to be written.varPointer to the array containing the variable data.XzoneThe 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).
The documentation for this class was generated from the following file src/Write_netcdf.h