File dataformat.hxx¶
Generic interface for file formats e.g. netCDF, HDF5.
Copyright 2010 B.D.Dudson, S.Farley, M.V.Umansky, X.Q.Xu
- Author
- B.Dudson
- Date
- April 2009
Contact Ben Dudson, bd512@york.ac.uk
This file is part of BOUT++.
BOUT++ is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
BOUT++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with BOUT++. If not, see http://www.gnu.org/licenses/.
Functions
-
std::unique_ptr<DataFormat>
data_format
(const char *filename = nullptr)¶
-
class
DataFormat
¶ Subclassed by H5Format, NcFormat, Ncxx4, PncFormat
Public Functions
-
virtual
~DataFormat
()¶
-
virtual bool
openr
(const char *name) = 0¶
-
virtual bool
openr
(const std::string &name)¶
-
bool
openr
(const std::string &base, int mype)¶
-
virtual bool
openw
(const char *name, bool append = false) = 0¶
-
virtual bool
openw
(const std::string &name, bool append = false)¶
-
bool
openw
(const std::string &base, int mype, bool append = false)¶
-
virtual bool
is_valid
() = 0¶
-
virtual void
close
() = 0¶
-
virtual void
flush
() = 0¶
-
virtual const std::vector<int>
getSize
(const char *var) = 0¶
-
virtual const std::vector<int>
getSize
(const std::string &var) = 0¶
-
virtual bool
setGlobalOrigin
(int x = 0, int y = 0, int z = 0) = 0¶
-
bool
setLocalOrigin
(int x = 0, int y = 0, int z = 0, int offset_x = 0, int offset_y = 0, int offset_z = 0)¶
-
virtual bool
setRecord
(int t) = 0¶
-
virtual bool
addVarInt
(const std::string &name, bool repeat) = 0¶
-
virtual bool
addVarBoutReal
(const std::string &name, bool repeat) = 0¶
-
virtual bool
addVarField2D
(const std::string &name, bool repeat) = 0¶
-
virtual bool
addVarField3D
(const std::string &name, bool repeat) = 0¶
-
virtual bool
addVarFieldPerp
(const std::string &name, bool repeat) = 0¶
-
virtual bool
read
(int *var, const char *name, int lx = 1, int ly = 0, int lz = 0) = 0¶
-
virtual bool
read
(int *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) = 0¶
-
virtual bool
write
(int *var, const char *name, int lx = 0, int ly = 0, int lz = 0) = 0¶
-
virtual bool
write
(int *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) = 0¶
-
virtual bool
read_rec
(int *var, const char *name, int lx = 1, int ly = 0, int lz = 0) = 0¶
-
virtual bool
read_rec
(int *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) = 0¶
-
virtual bool
read_rec
(BoutReal *var, const std::string &name, int lx = 1, int ly = 0, int lz = 0) = 0¶
-
virtual bool
write_rec
(int *var, const char *name, int lx = 0, int ly = 0, int lz = 0) = 0¶
-
virtual bool
write_rec
(int *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) = 0¶
-
virtual bool
write_rec
(BoutReal *var, const std::string &name, int lx = 0, int ly = 0, int lz = 0) = 0¶
-
virtual void
setLowPrecision
()¶
-
virtual void
setAttribute
(const std::string &varname, const std::string &attrname, const std::string &text) = 0¶ Sets a string attribute
Inputs
- Parameters
varname
: Variable name. The variable must already exist. If varname is the empty string “” then the attribute will be added to the file instead of to a variable.attrname
: Attribute nametext
: A string attribute to attach to the variable
-
virtual void
setAttribute
(const std::string &varname, const std::string &attrname, int value) = 0¶ Sets an integer attribute
Inputs
- Parameters
varname
: Variable name. The variable must already exist. If varname is the empty string “” then the attribute will be added to the file instead of to a variable.attrname
: Attribute namevalue
: An int attribute to attach to the variable
-
virtual void
setAttribute
(const std::string &varname, const std::string &attrname, BoutReal value) = 0¶ Sets a BoutReal attribute
Inputs
- Parameters
varname
: Variable name. The variable must already exist. If varname is the empty string “” then the attribute will be added to the file instead of to a variable.attrname
: Attribute namevalue
: A BoutReal attribute to attach to the variable
-
virtual bool
getAttribute
(const std::string &varname, const std::string &attrname, std::string &text) = 0¶ Gets a string attribute
Inputs
Returns
- Parameters
varname
: Variable name. The variable must already exist. If varname is the empty string “” then get the attribute from the top-level of the file instead of from a variable.attrname
: Attribute name
text A string attribute of the variable
-
virtual bool
getAttribute
(const std::string &varname, const std::string &attrname, int &value) = 0¶ Gets an integer attribute
Inputs
Returns
- Parameters
varname
: Variable name. The variable must already exist. If varname is the empty string “” then get the attribute from the top-level of the file instead of from a variable.attrname
: Attribute name
value An int attribute of the variable
-
virtual bool
getAttribute
(const std::string &varname, const std::string &attrname, BoutReal &value) = 0¶ Gets a BoutReal attribute
Inputs
Returns
- Parameters
varname
: Variable name. The variable must already exist. If varname is the empty string “” then get the attribute from the top-level of the file instead of from a variable.attrname
: Attribute name
value A BoutReal attribute of the variable
-
void
writeFieldAttributes
(const std::string &name, const Field &f)¶ Write out the meta-data of a field as attributes of the variable.
-
virtual