aboutsummaryrefslogtreecommitdiff
path: root/src/RestoreFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/RestoreFile.c')
-rw-r--r--src/RestoreFile.c413
1 files changed, 219 insertions, 194 deletions
diff --git a/src/RestoreFile.c b/src/RestoreFile.c
index 995e0a8..6dbfc02 100644
--- a/src/RestoreFile.c
+++ b/src/RestoreFile.c
@@ -2,17 +2,12 @@
@file RestoreFile.c
@date Thu Jun 18 16:34:59 1998
@author Tom Goodale
- @desc
- Routines to restore GFs from a given file
- @enddesc
- @history
- @hauthor Gabrielle Allen @hdate 19 Oct 1998
- @hdesc Changed names ready for thorn_IO
- @endhistory
- @version $Id$
+ @desc
+ Routines to restore grid variables from a given file
+ @enddesc
+ @version $Id$
@@*/
-
#include <stdio.h>
#include <stdlib.h>
@@ -22,22 +17,25 @@
#include "CactusBase/IOUtil/src/ioGH.h"
#include "ioFlexGH.h"
+/* the rcs ID and its dummy function to use it */
+static const char *rcsid = "$Id$";
+CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_RestoreFile_c)
+
-/* MPI tag base */
-#define STARTUPBASE 1001
+/********************************************************************
+ ******************** Macro Definitions ************************
+ ********************************************************************/
+/* tag base for MPI messages */
+#define STARTUPBASE 1001
/* The maximum number of dimensions we can deal with.
- There's no routine provided by the IEEEIO lib to query the number of
+ There's no routine provided by the IEEEIO lib to query the number of
dims from a dataset. */
#define MAXDIM 10
-/* the rcs ID and its dummy funtion to use it */
-static const char *rcsid = "$Id$";
-CCTK_FILEVERSION(CactusPUGHIO_IOFlexIO_RestoreFile_c)
-
-
-/* prototypes of routines defined in this source file */
-int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file);
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
int *grouptype, int *timelevel,int has_version);
#ifdef CCTK_MPI
@@ -45,29 +43,37 @@ static int GetChunkAttributes (IOFile fid, int vindex);
#endif
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
+int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file);
+
+
/*@@
@routine IOFlexIO_RecoverVariables
@date Fri Jun 19 09:19:48 1998
@author Tom Goodale
- @desc
+ @desc
Reads in data from an IEEEIO file.
The file has to be opened already, and the file layout
determined (ioproc, ioproc_every, unchunked).
This information is used to read the file and distribute
- the data among all processors.
- @enddesc
- @calledby IOFlexIO_RecoverGH
- @history
- @hauthor Gabrielle Allen @hdate Oct 17 1998
- @hdesc Changed logic so that cactus stops if any of the dimensions of the
- input file and the current cactus run differ.
- @hauthor Thomas Radke @hdate May 05 1999
- @hdesc Added parameter unchunked
- @endhistory
+ the data among all processors.
+ @enddesc
+
+ @history
+ @hauthor Gabrielle Allen
+ @hdate Oct 17 1998
+ @hdesc Changed logic so that cactus stops if any of the dimensions of
+ the input file and the current cactus run differ.
+ @hauthor Thomas Radke
+ @hdate May 05 1999
+ @hdesc Added parameter unchunked
+ @endhistory
@var GH
@vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
+ @vtype cGH *
@vio in
@endvar
@var file
@@ -78,38 +84,43 @@ static int GetChunkAttributes (IOFile fid, int vindex);
@@*/
int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
{
- DECLARE_CCTK_PARAMETERS
- int vindex, gtype;
- int myproc, nprocs;
+ int vindex, gtype, timelevel, myproc, nprocs;
int nDatasets, currentDataset;
- int timelevel; /* current timelevel to be restored */
- pGH *pughGH; /* PUGH extension handle */
- ioGH *ioUtilGH; /* IOUtil extension handle */
+ const pGH *pughGH;
+ const ioGH *ioUtilGH;
+ char *fullname;
#ifdef CCTK_MPI
- pGExtras *extras;
int i, proc;
- CCTK_INT info [3]; /* communication buffer for MPI */
+ pGExtras *extras;
+ CCTK_INT info[3];
+ int dim, npoints, vtype;
+ void *buffer;
+ int *chunkdims, *chunkorigin;
+ int element_size, flexio_type;
+ MPI_Datatype mpi_type;
+ MPI_Status ms;
#endif
+ DECLARE_CCTK_PARAMETERS
- /* to make the compiler happy */
+ /* suppress compiler warnings about potentially uninitialized variables */
nDatasets = 0;
- /* Get the handles for PUGH IOUtil extensions */
- pughGH = PUGH_pGH (GH);
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
+ pughGH = (const pGH *) PUGH_pGH (GH);
+ ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
myproc = CCTK_MyProc (GH);
nprocs = CCTK_nProcs (GH);
- /* all IO procs determine the number of datasets in their checkpoint files */
- if (myproc == file->ioproc) {
-
- /* Get the number of sets */
- nDatasets = IOnDatasets (file->fid);
+ /* all I/O procs determine the number of datasets in their checkpoint files */
+ if (myproc == file->ioproc)
+ {
+ /* get the number of sets */
+ nDatasets = IOnDatasets (file->fid);
if (verbose)
+ {
CCTK_VInfo (CCTK_THORNSTRING, " Input file has %d datasets", nDatasets);
-
+ }
}
/* In Cactus 3.x we had only datasets containing grid function data.
@@ -127,24 +138,25 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
CCTK_WARN (0, "Number of datasets isn't a multiple of nioprocs");
*/
- /* Now process the datasets.
- All IO processors read the datasets from their checkpoint file
- verify their contents and communicate them to the non-IO processors. */
-
- /* At first the code for the IO processors ... */
- if (myproc == file->ioproc) {
+ /* now process the datasets.
+ All I/O processors read the datasets from their checkpoint file
+ verify their contents and communicate them to the non-I/O processors. */
- /* Seek here once to the beginning of the file, the file pointer
+ /* at first the code for the I/O processors ... */
+ if (myproc == file->ioproc)
+ {
+ /* seek here once to the beginning of the file, the file pointer
is advanced then implicitely by subsequent calls to IOreadInfo() */
FLEXIO_ERROR (IOseek (file->fid, 0));
- /* Each IO processor loops over all available datasets, checks their
- consistency and broadcasts them to the non-IO processors. */
- for (currentDataset = 0; currentDataset < nDatasets; currentDataset++) {
-
+ /* each IO processor loops over all available datasets, checks their
+ consistency and broadcasts them to the non-IO processors */
+ for (currentDataset = 0; currentDataset < nDatasets; currentDataset++)
+ {
/* read in the next dataset's attributes and verify them */
if (GetCommonAttributes (GH, file->fid, file->unchunked, &vindex,
- &gtype, &timelevel, file->has_version) < 0) {
+ &gtype, &timelevel, file->has_version) < 0)
+ {
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Ignoring dataset %d", currentDataset);
continue;
@@ -152,52 +164,49 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
/* if we read in initial data via the file reader interface
check whether the user wants to have this variable restored */
- if (ioUtilGH->do_inVars && ! ioUtilGH->do_inVars [vindex]) {
- if (verbose) {
- char *varname = CCTK_FullName (vindex);
-
+ if (ioUtilGH->do_inVars && ! ioUtilGH->do_inVars[vindex])
+ {
+ if (verbose)
+ {
+ fullname = CCTK_FullName (vindex);
CCTK_VInfo (CCTK_THORNSTRING, "Ignoring variable '%s' for file "
- "reader recovery", varname);
- free (varname);
+ "reader recovery", fullname);
+ free (fullname);
}
continue;
}
- /* Read in the data */
- if (verbose) {
- char *fullname = CCTK_FullName (vindex);
-
+ /* read in the data */
+ if (verbose)
+ {
+ fullname = CCTK_FullName (vindex);
CCTK_VInfo (CCTK_THORNSTRING, " dataset %d: %s (timelevel %d)",
currentDataset, fullname, timelevel);
free (fullname);
}
- if (file->ioproc_every == 1)
- FLEXIO_ERROR (
- IOread (file->fid, CCTK_VarDataPtrI (GH, timelevel, vindex)));
+ if (file->ioproc_every == 1)
+ {
+ FLEXIO_ERROR (IOread (file->fid,
+ CCTK_VarDataPtrI (GH, timelevel, vindex)));
+ }
#ifdef CCTK_MPI
- else {
- int dim, npoints, vtype;
- void *buffer;
- int *chunkdims, *chunkorigin;
- int element_size, flexio_type;
- MPI_Datatype mpi_type;
-
-
+ else
+ {
vtype = CCTK_VarTypeI (vindex);
element_size = CCTK_VarTypeSize (vtype);
mpi_type = PUGH_MPIDataType (pughGH, vtype);
flexio_type = IOFlexIO_DataType (vtype);
-
+
if (element_size <= 0 || mpi_type == MPI_DATATYPE_NULL || flexio_type<0)
- {
+ {
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Unsupported variable type %d", vtype);
continue;
}
- /* Get the pGExtras pointer as a shortcut */
- extras = ((pGA ***) pughGH->variables) [vindex][timelevel]->extras;
+ /* get the pGExtras pointer as a shortcut */
+ extras = ((pGA ***) pughGH->variables)[vindex][timelevel]->extras;
/* get the dimension of the variable */
dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex));
@@ -208,12 +217,16 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
/* read my own data directly into data,
read others data into buffer and communicate it */
if (! file->unchunked || gtype == CCTK_SCALAR)
+ {
FLEXIO_ERROR (IOread (file->fid,
- CCTK_VarDataPtrI (GH, timelevel, vindex)));
- else {
- for (i = 0; i < dim; i++) {
- chunkdims [i] = extras->rnsize [file->ioproc][i];
- chunkorigin [i] = extras->lb [file->ioproc][i];
+ CCTK_VarDataPtrI (GH, timelevel, vindex)));
+ }
+ else
+ {
+ for (i = 0; i < dim; i++)
+ {
+ chunkdims[i] = extras->rnsize[file->ioproc][i];
+ chunkorigin[i] = extras->lb[file->ioproc][i];
}
FLEXIO_ERROR (IOreadChunk (file->fid, chunkdims, chunkorigin,
@@ -221,60 +234,73 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
}
/* read data for non-IO processors */
- if (gtype == CCTK_SCALAR) {
+ if (gtype == CCTK_SCALAR)
+ {
npoints = 1;
buffer = CCTK_VarDataPtrI (GH, timelevel, vindex);
- } else {
+ }
+ else
+ {
/* allocate memory for the biggest chunk */
- npoints = extras->rnpoints [file->ioproc + 1];
+ npoints = extras->rnpoints[file->ioproc + 1];
for (proc = 2; proc < file->ioproc_every; proc++)
- if (npoints < extras->rnpoints [file->ioproc + proc])
- npoints = extras->rnpoints [file->ioproc + proc];
+ {
+ if (npoints < extras->rnpoints[file->ioproc + proc])
+ {
+ npoints = extras->rnpoints[file->ioproc + proc];
+ }
+ }
buffer = malloc (npoints * element_size);
}
for (proc = file->ioproc + 1;
proc < file->ioproc + file->ioproc_every && proc < nprocs;
- proc++) {
-
- if (gtype != CCTK_SCALAR) {
-
- if (! file->unchunked) {
+ proc++)
+ {
+ if (gtype != CCTK_SCALAR)
+ {
+ if (! file->unchunked)
+ {
/* Also increment dataset counter here !!! */
currentDataset++;
- if (GetChunkAttributes (file->fid, vindex) < 0) {
+ if (GetChunkAttributes (file->fid, vindex) < 0)
+ {
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Ignoring chunk in dataset %d", currentDataset+1);
continue;
}
FLEXIO_ERROR (IOread (file->fid, buffer));
- } else {
- for (i = 0; i < dim; i++) {
- chunkdims [i] = extras->rnsize [proc][i];
- chunkorigin [i] = extras->lb [proc][i];
+ }
+ else
+ {
+ for (i = 0; i < dim; i++)
+ {
+ chunkdims[i] = extras->rnsize[proc][i];
+ chunkorigin[i] = extras->lb[proc][i];
}
- FLEXIO_ERROR (IOreadChunk (file->fid, chunkdims,
- chunkorigin, buffer));
+ FLEXIO_ERROR (IOreadChunk (file->fid, chunkdims, chunkorigin,
+ buffer));
}
- npoints = extras->rnpoints [proc];
+ npoints = extras->rnpoints[proc];
}
/* and finally send the index and the data */
- info [0] = vindex; info [1] = timelevel; info [2] = npoints;
+ info[0] = vindex; info[1] = timelevel; info[2] = npoints;
CACTUS_MPI_ERROR (MPI_Send (info, 3, PUGH_MPI_INT, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
+ STARTUPBASE, pughGH->PUGH_COMM_WORLD));
CACTUS_MPI_ERROR (MPI_Send (buffer, npoints, mpi_type, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
-
+ STARTUPBASE, pughGH->PUGH_COMM_WORLD));
}
/* free allocated chunk */
if (gtype != CCTK_SCALAR)
+ {
free (buffer);
+ }
free (chunkorigin);
@@ -284,57 +310,47 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
} /* end of loop over all datasets */
#ifdef CCTK_MPI
- /* Finally an invalid variable index is communicated
- to indicate completion to the non-IO processors. */
- info [0] = -1;
+ /* finally an invalid variable index is communicated
+ to indicate completion to the non-I/O processors */
+ info[0] = -1;
for (proc = file->ioproc + 1;
proc < file->ioproc + file->ioproc_every && proc < nprocs;
proc++)
+ {
CACTUS_MPI_ERROR (MPI_Send (info, 3, PUGH_MPI_INT, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
+ STARTUPBASE, pughGH->PUGH_COMM_WORLD));
+ }
#endif
- } else {
-
- /* And here the code for non-IO processors: */
+ }
+ else
+ {
+ /* and here the code for non-IO processors: */
#ifdef CCTK_MPI
- int npoints;
- MPI_Datatype mpi_type;
- MPI_Status ms;
-
/* They don't know how many datasets there are, because the IO processors
could skip some on the fly during their consistency checks.
The IO Processor sends the index of the variable to be processed next.
So, all non-IO processors execute a loop where the termination condition
is when an invalid index was received.
*/
- while (1) {
+ while (1)
+ {
/* receive the next variable index from the IO processor */
CACTUS_MPI_ERROR (MPI_Recv (info, 3, PUGH_MPI_INT, file->ioproc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms));
- vindex = info [0]; timelevel = info [1]; npoints = info [2];
+ STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms));
+ vindex = info[0]; timelevel = info[1]; npoints = info[2];
/* check for termination condition */
if (vindex < 0)
+ {
break;
-
- switch (CCTK_VarTypeI (vindex)) {
- case CCTK_VARIABLE_CHAR: mpi_type = PUGH_MPI_CHAR; break;
- case CCTK_VARIABLE_INT: mpi_type = PUGH_MPI_INT; break;
- case CCTK_VARIABLE_REAL: mpi_type = PUGH_MPI_REAL; break;
-#if 0
-/* FIXME: Don't know how to support COMPLEX types too !! */
- case CCTK_VARIABLE_COMPLEX: mpi_type = pughGH->PUGH_mpi_complex; break;
-#endif
- default:
- CCTK_WARN (1, "Unsupported datatype");
- continue;
}
/* receive following data from my IO processor */
+ mpi_type = PUGH_MPIDataType (pughGH, CCTK_VarTypeI (vindex));
CACTUS_MPI_ERROR (MPI_Recv (CCTK_VarDataPtrI (GH, timelevel, vindex),
- npoints, mpi_type, file->ioproc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms));
+ npoints, mpi_type, file->ioproc,
+ STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms));
}
#endif
}
@@ -342,8 +358,10 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
return (0);
}
-/************************* local routines ********************************/
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
/* local routine getDatasetAttributes() reads in the next dataset's attributes
and verifies them:
@@ -364,30 +382,29 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
int *grouptype, int *timelevel, int has_version)
{
- int i, flag;
- int atype;
+ int i, flag, atype, vartype_stored, rank_stored, result;
Long asize;
pGExtras *extras;
cGroup groupdata;
- int vartype_stored, rank_stored, dims_stored [MAXDIM];
CCTK_INT4 grouptype_stored, numtimelevels_stored, timelevel_stored;
- int result, *dims;
+ int *dims, dims_stored[MAXDIM];
char *groupname;
- char fullname [512], groupname_stored [512];
+ char fullname[512], groupname_stored[512];
/* read the next dataset's info from the file */
result = IOreadInfo (fid, &vartype_stored, &rank_stored, dims_stored, MAXDIM);
FLEXIO_ERROR (result);
- if (result == 0) {
+ if (result == 0)
+ {
CCTK_WARN (1, "Can't read dataset info");
return (-1);
}
-
+
/* retrieve the name attribute */
i = IOreadAttributeInfo (fid, "name", &atype, &asize);
- if (i < 0 || atype != FLEXIO_CHAR ||
- (unsigned int) asize >= sizeof (fullname)) {
+ if (i < 0 || atype != FLEXIO_CHAR || asize >= (int) sizeof (fullname))
+ {
CCTK_WARN (2, "Can't read name attribute");
return (-1);
}
@@ -395,7 +412,8 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
/* check if there is a matching variable */
*vindex = CCTK_VarIndex (fullname);
- if (*vindex < 0) {
+ if (*vindex < 0)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"No matching variable found for '%s'", fullname);
return (-1);
@@ -404,14 +422,16 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
/* read and verify the group name */
i = IOreadAttributeInfo (fid, "groupname", &atype, &asize);
if (i < 0 || atype != FLEXIO_CHAR ||
- (unsigned int) asize >= sizeof (groupname_stored)) {
+ (unsigned int) asize >= sizeof (groupname_stored))
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Can't read groupname attribute of '%s'", fullname);
return (-1);
}
FLEXIO_ERROR (IOreadAttribute (fid, i, groupname_stored));
groupname = CCTK_GroupNameFromVarI (*vindex);
- if (! CCTK_Equals (groupname_stored, groupname)) {
+ if (! CCTK_Equals (groupname_stored, groupname))
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Groupnames don't match for '%s'", fullname);
return (-1);
@@ -420,7 +440,8 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
/* read the group type */
i = IOreadAttributeInfo (fid, "grouptype", &atype, &asize);
- if (i < 0 || atype != FLEXIO_INT4 || asize != 1) {
+ if (i < 0 || atype != FLEXIO_INT4 || asize != 1)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Can't read grouptype attribute for '%s'", fullname);
return (-1);
@@ -429,7 +450,8 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
/* read the number of timelevels */
i = IOreadAttributeInfo (fid, "ntimelevels", &atype, &asize);
- if (i < 0 || atype != FLEXIO_INT4 || asize != 1) {
+ if (i < 0 || atype != FLEXIO_INT4 || asize != 1)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Can't read ntimelevels attribute for '%s'", fullname);
return (-1);
@@ -438,7 +460,8 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
/* read the timelevel to restore */
i = IOreadAttributeInfo (fid, "timelevel", &atype, &asize);
- if (i < 0 || atype != FLEXIO_INT4 || asize != 1) {
+ if (i < 0 || atype != FLEXIO_INT4 || asize != 1)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Can't read timelevel attribute for '%s'", fullname);
return (-1);
@@ -447,17 +470,20 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
*timelevel = (int) timelevel_stored;
/* verify group type, variable type, dims, sizes and ntimelevels */
- if (CCTK_GroupData (CCTK_GroupIndex (groupname_stored), &groupdata) != 0) {
+ if (CCTK_GroupData (CCTK_GroupIndex (groupname_stored), &groupdata) != 0)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Could not get group info for '%s'", fullname);
return (-1);
}
- if (groupdata.grouptype != grouptype_stored) {
+ if (groupdata.grouptype != grouptype_stored)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Group types don't match for '%s'", fullname);
return (-1);
}
- if (groupdata.numtimelevels != numtimelevels_stored) {
+ if (groupdata.numtimelevels != numtimelevels_stored)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Number of timelevels don't match for '%s'", fullname);
return (-1);
@@ -478,42 +504,44 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
#if 0
/* FIXME: Don't know how to support COMPLEX type too !! */
(vartype_stored == FLEXIO_REAL &&
- groupdata.vartype == CCTK_VARIABLE_COMPLEX)) {
+ groupdata.vartype == CCTK_VARIABLE_COMPLEX))
#else
- 0) {
+ 0)
+ {
#endif
/* everything is okay */
- } else {
+ }
+ else
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Variable types don't match for '%s'", fullname);
return (-1);
}
/* verify the dims and sizes */
- flag = 0;
- if (groupdata.dim != rank_stored)
- flag = 1;
- switch (groupdata.grouptype) {
- case CCTK_SCALAR:
- if (dims_stored [0] != 1)
- flag = 1;
- break;
- case CCTK_GF:
- case CCTK_ARRAY:
- extras = ((pGA ***) PUGH_pGH (GH)->variables)[*vindex][*timelevel]->extras;
- dims = unchunked ? extras->nsize : extras->lnsize;
- for (i = 0; i < groupdata.dim; i++)
- if (dims [i] != dims_stored [i])
- flag = 1;
- break;
+ flag = groupdata.dim != rank_stored;
+ if (groupdata.grouptype == CCTK_SCALAR)
+ {
+ flag |= dims_stored[0] != 1;
+ }
+ else
+ {
+ extras = ((pGA ***) PUGH_pGH (GH)->variables)[*vindex][*timelevel]->extras;
+ dims = unchunked ? extras->nsize : extras->lnsize;
+ for (i = 0; i < groupdata.dim; i++)
+ {
+ flag |= dims[i] != dims_stored[i];
+ }
}
- if (flag) {
+ if (flag)
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Variable sizes don't match for '%s'", fullname);
return (-1);
}
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (*vindex))) {
+ if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (*vindex)))
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"Can't read into '%s': no storage assigned", fullname);
return (-1);
@@ -529,37 +557,34 @@ static int GetCommonAttributes (cGH *GH, IOFile fid, int unchunked, int *vindex,
that should be a chunk.
It verifies via the name attribute that this chunk belongs to the
current variable given by its index. */
-
#ifdef CCTK_MPI
static int GetChunkAttributes (IOFile fid, int vindex)
{
- int i;
- int atype;
+ int i, atype, vtype_stored, rank_stored;
Long asize;
- int result;
- int vtype_stored, rank_stored, dims_stored [MAXDIM];
- char fullname [512];
+ int dims_stored[MAXDIM];
+ char fullname[512];
/* read the next dataset's info from the file */
- result = IOreadInfo (fid, &vtype_stored, &rank_stored, dims_stored, MAXDIM);
- FLEXIO_ERROR (result);
- if (result == 0) {
+ if (! IOreadInfo (fid, &vtype_stored, &rank_stored, dims_stored, MAXDIM))
+ {
CCTK_WARN (1, "Can't read dataset info");
return (-1);
}
-
+
/* retrieve the name attribute */
i = IOreadAttributeInfo (fid, "name", &atype, &asize);
- if (i < 0 || atype != FLEXIO_CHAR ||
- (unsigned int) asize >= sizeof (fullname)) {
+ if (i < 0 || atype != FLEXIO_CHAR || asize >= (int) sizeof (fullname))
+ {
CCTK_WARN (2, "Can't read name attribute");
return (-1);
}
FLEXIO_ERROR (IOreadAttribute (fid, i, fullname));
/* check if there is a matching variable */
- if (vindex != CCTK_VarIndex (fullname)) {
+ if (vindex != CCTK_VarIndex (fullname))
+ {
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"No matching variable found for '%s'", fullname);
return (-1);