@@ -31,7 +31,7 @@ the IO routines within the Omega and IO namespaces.
3131Before using any IO functions, the parallel IO system must be initialized
3232using:
3333``` c++
34- int Err = IO::init(Comm);
34+ IO::init (Comm);
3535```
3636where Comm is an MPI communicator and should in most cases be the communicator
3737from the Omega default MachEnv (see [MachEnv](#omega-dev-mach-env)). This
@@ -44,13 +44,13 @@ As mentioned above, most I/O operations will take place within the IOStreams
4444module, but the base IO functions can be accessed directly. To open and close
4545files for reading/writing, use:
4646```c++
47- int Err = IO::openFile(FileID, Filename, Mode);
48- Err = IO::closeFile(FileID);
47+ IO::openFile(FileID, Filename, Mode);
48+ IO::closeFile(FileID);
4949```
5050or
5151``` c++
52- int Err = IO::openFile(FileID, Filename, Mode, Format, IfExists);
53- Err = IO::closeFile(FileID);
52+ IO::openFile (FileID, Filename, Mode, Format, IfExists);
53+ IO::closeFile(FileID);
5454```
5555In both case, an integer FileID is assigned to the open file which is then
5656used by all subsequent operations. The Filename is a ``std::string`` that
@@ -89,8 +89,8 @@ Once the file is open, data is read/written using one of two interfaces,
8989depending on whether the array is decomposed across MPI tasks or not. For
9090large decomposed arrays, the interface is:
9191``` c++
92- int Err = IO::readArray (&Array, Size, VariableName, FileID, DecompID, VarID);
93- int Err = IO::writeArray(&Array, Size, &FillValue, FileID, DecompID, VarID);
92+ Error Err = IO::readArray (&Array, Size, VariableName, FileID, DecompID, VarID);
93+ IO::writeArray (&Array, Size, &FillValue, FileID, DecompID, VarID);
9494```
9595where the pointer to the data array is passed and data is assumed to be
9696contiguous with the full local size of the array passed as Size. The FileID is
@@ -99,21 +99,25 @@ as described below. For reading, the variable name (as a ``std::string``) is
9999supplied and the variable ID (VarID) is returned in case it is needed for
100100reading of variable metadata. For writing, a FillValue is supplied to fill
101101undefined locations in an array and the variable ID must have been assigned
102- in a prior defineVar call prior to the write as described below.
102+ in a prior defineVar call prior to the write as described below. The readArray
103+ returns an error code so that the calling routine can re-try the read. This
104+ is used in Omega to manage name changes between Omega and the earlier MPAS
105+ names.
103106
104107Writing or reading multiple time slices (where there in an unlimited time
105108dimension) is also possible and an additional optional Frame argument
106109specifies the time index along that dimension that should be read/written:
107110```c++
108- int Err = IO::readArray (&Array, Size, VariableName, FileID, DecompID, VarID, Frame);
109- int Err = IO::writeArray(&Array, Size, &FillValue, FileID, DecompID, VarID, Frame);
111+ Error Err = IO::readArray (&Array, Size, VariableName, FileID, DecompID,
112+ VarID, Frame);
113+ IO::writeArray(&Array, Size, &FillValue, FileID, DecompID, VarID, Frame);
110114```
111115
112116For arrays or scalars that are not distributed, the non-distributed variable
113117interface must be used:
114118``` c++
115- int Err = IO::readNDVar(&Array, VariableName, FileID, VarID);
116- int Err = IO::writeNDVar(&Array, FileID, VarID);
119+ Error Err = IO::readNDVar(&Array, VariableName, FileID, VarID);
120+ IO::writeNDVar (&Array, FileID, VarID);
117121```
118122with arguments similar to the distributed array calls above. Note that
119123when defining dimensions for these fields, the dimensions must be
@@ -124,8 +128,8 @@ Frame (index of the time slice) must be provided. In addition, a vector
124128``std::vector<int> DimLengths`` containing the length of the non-time
125129dimensions must be provided:
126130```c++
127- int Err = IO::readNDVar(&Array, VariableName, FileID, VarID, Frame, DimLengths);
128- int Err = IO::writeNDVar(&Array, FileID, VarID, Frame, DimLengths);
131+ Error Err = IO::readNDVar(&Array, VariableName, FileID, VarID, Frame, DimLengths);
132+ IO::writeNDVar(&Array, FileID, VarID, Frame, DimLengths);
129133```
130134Note that the full arrays in this case are written so if any masking or
131135pruning of points is required, it should be performed before the call.
@@ -135,24 +139,24 @@ decomposition. Both the dimensions of the array and the decomposition
135139across tasks must be defined. For each dimension, a dimension must be
136140defined using:
137141``` c++
138- int Err = IO::defineDim(FileID, DimName, Length, DimID );
142+ int DimID = IO::defineDim(FileID, DimName, Length);
139143```
140144where FileID is the ID of an open file, the DimName is a `` std::string ``
141145with the dimension name (eg NCells, NEdges, NVertices, NVertLevels or
142146NTracers), length is the length of the full global array and DimID is
143147the ID assigned to this dimension. Note that for reading a file, we
144148supply the function:
145149``` c++
146- int Err = IO::getDimFromFile(FileID, DimName, DimID, DimLength);
150+ Error Err = IO::getDimFromFile(FileID, DimName, DimID, DimLength);
147151```
148152that can be used to inquire about the dimension length and retrieve the
149153dimension ID from the file.
150154
151155Once the dimensions are defined, the decomposition of an array must
152156be defined using:
153157``` c++
154- int Err = createDecomp(DecompID, IODataType, NDims, DimLengths,
155- Size, GlobalIndx, Rearr);
158+ int DecompID = createDecomp(IODataType, NDims, DimLengths,
159+ Size, GlobalIndx, Rearr);
156160```
157161where DecompID is the ID assigned to the newly created decomposition,
158162NDims is the number of dimensions for the array, DimLengths is an
@@ -196,7 +200,7 @@ for an Omega I4 data type.
196200Now that dimensions and decompositions have been defined, a variable can
197201be defined (this is required for writing only) using:
198202``` c++
199- int Err = IO::defineVar(FileID, VarName, IODataType, NDims, DimIDs, VarID );
203+ int VarID = IO::defineVar(FileID, VarName, IODataType, NDims, DimIDs);
200204```
201205where VarID is the ID assigned to the variable, FileID is the usual ID of
202206the data file, VarName is a `` std::string `` holding the variable name,
@@ -212,8 +216,8 @@ interfaces, but the base IO module contains interfaces for reading and
212216writing metadata associated with either an array or the file or simulation
213217itself. To read/write metadata, use:
214218``` c++
215- int Err = IO::writeMeta(MetaName, MetaValue, FileID, VarID);
216- int Err = IO::readMeta (MetaName, MetaValue, FileID, VarID);
219+ IO::writeMeta (MetaName, MetaValue, FileID, VarID);
220+ Error Err = IO::readMeta (MetaName, MetaValue, FileID, VarID);
217221```
218222where MetaName is a ``std::string`` holding the name of the metadata and
219223the MetaValue is the value of the MetaData. All supported Omega data types are
0 commit comments