aboutsummaryrefslogtreecommitdiff
path: root/src/DumpUtils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/DumpUtils.c')
-rw-r--r--src/DumpUtils.c130
1 files changed, 59 insertions, 71 deletions
diff --git a/src/DumpUtils.c b/src/DumpUtils.c
index 2045d1a..3c12431 100644
--- a/src/DumpUtils.c
+++ b/src/DumpUtils.c
@@ -55,29 +55,15 @@ CCTK_FILEVERSION(BetaThorns_IOHDF5Util_DumpUtils_c)
@@*/
int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
{
- int first_vindex, gindex, timelevels, retval;
- int *extent_int;
+ int first_vindex, gindex, retval;
cGroup gdata;
- ioSlab slab;
+ char *fullname;
+ ioRequest *request;
DECLARE_CCTK_PARAMETERS
retval = 0;
- /* set up a hyperslab description for full hyperslabs */
- slab.vdim = CCTK_MaxDim ();
- slab.vectors = (CCTK_INT *) calloc ((slab.vdim + 6)*slab.vdim + 1,
- sizeof(CCTK_INT));
- slab.hoffset = slab.vectors + 0*slab.vdim;
- slab.hsize = slab.vectors + 1*slab.vdim;
- slab.hsize_chunk = slab.vectors + 2*slab.vdim;
- slab.origin = slab.vectors + 3*slab.vdim + 1;
- slab.extent = slab.vectors + 4*slab.vdim + 1;
- slab.downsample = slab.vectors + 5*slab.vdim + 1;
- slab.direction = slab.vectors + 6*slab.vdim + 1;
-
- extent_int = (int *) malloc (slab.vdim * sizeof (int));
-
/* start CP_PARAMETERS_TIMER timer */
if (timers)
{
@@ -96,7 +82,7 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
if (verbose)
{
- CCTK_INFO ("Dumping variables ...");
+ CCTK_INFO ("Dumping Grid Variables ...");
}
/* stop CP_PARAMETERS_TIMER timer and start CP_VARIABLES_TIMER */
@@ -118,41 +104,44 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
/* dump all timelevels except the oldest (for multi-level groups) */
CCTK_GroupData (gindex, &gdata);
- CCTK_GroupgshGI (GH, gdata.dim, extent_int, gindex);
- timelevels = gdata.numtimelevels;
- if (timelevels > 1)
+ if (gdata.numtimelevels > 1)
{
- timelevels--;
+ gdata.numtimelevels--;
}
- slab.vdim = gdata.dim;
- slab.check_exist = 0;
- slab.hdatatype = gdata.vartype;
-
- /* set the hyperslab extents, the directions (orthogonal to all axes),
- and disable downsampling */
- memset (slab.direction, 0, slab.vdim * slab.vdim * sizeof (int));
- for (slab.hdim = 0; slab.hdim < slab.vdim; slab.hdim++)
+
+ first_vindex = CCTK_FirstVarIndexI (gindex);
+
+ /* get the default I/O request for this group */
+ request = IOUtil_DefaultIORequest (GH, first_vindex);
+
+ /* disable checking for old data objects, disable datatype conversion
+ and downsampling */
+ request->check_exist = 0;
+ request->hdatatype = gdata.vartype;
+ for (request->hdim = 0; request->hdim < request->vdim; request->hdim++)
{
- slab.extent[slab.hdim] = extent_int[slab.hdim];
- slab.direction[slab.hdim * (slab.vdim + 1)] = 1;
- slab.downsample[slab.hdim] = 1;
+ request->downsample[request->hdim] = 1;
}
/* loop over all variables in this group */
- first_vindex = CCTK_FirstVarIndexI (gindex);
- for (slab.vindex = first_vindex;
- slab.vindex < first_vindex + gdata.numvars;
- slab.vindex++)
+ for (request->vindex = first_vindex;
+ request->vindex < first_vindex + gdata.numvars;
+ request->vindex++)
{
- if (verbose && file >= 0)
- {
- CCTK_VInfo (CCTK_THORNSTRING, " %s", CCTK_VarName (slab.vindex));
- }
-
/* loop over all timelevels of this variable */
- for (slab.timelevel = 0; slab.timelevel < timelevels; slab.timelevel++)
+ for (request->timelevel = 0;
+ request->timelevel < gdata.numtimelevels;
+ request->timelevel++)
{
- retval += IOHDF5Util_DumpVar (GH, &slab, file);
+ if (verbose && file >= 0)
+ {
+ fullname = CCTK_FullName (request->vindex);
+ CCTK_VInfo (CCTK_THORNSTRING, " %s (timelevel %d)",
+ fullname, request->timelevel);
+ free (fullname);
+ }
+
+ retval += IOHDF5Util_DumpVar (GH, request, file);
}
} /* end of loop over all variables */
@@ -164,9 +153,8 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
CCTK_TimerStopI (timers[CP_VARIABLES_TIMER]);
}
- /* free temporary resources */
- free (slab.vectors);
- free (extent_int);
+ /* free I/O request */
+ IOUtil_FreeIORequest (&request);
return (retval);
}
@@ -194,9 +182,9 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
@vtype const cGH *
@vio in
@endvar
- @var slab
- @vdesc reference to the I/O hyperslab description
- @vtype const ioSlab *
+ @var request
+ @vdesc reference to the I/O request description
+ @vtype const ioRequest *
@vio in
@endvar
@var dataset
@@ -205,7 +193,7 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
@vio in
@endvar
@@*/
-void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioSlab *slab,
+void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioRequest *request,
hid_t object)
{
int dim, vdim;
@@ -220,14 +208,14 @@ void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioSlab *slab,
myGH = (ioHDF5UtilGH *) CCTK_GHExtension (GH, "IOHDF5Util");
/* attributes describing the variable */
- groupname = CCTK_GroupNameFromVarI (slab->vindex);
+ groupname = CCTK_GroupNameFromVarI (request->vindex);
WRITE_ATTRIBUTE ("groupname", groupname, object, myGH, 0, myGH->HDF5_STRING);
free (groupname);
- attr_int = CCTK_GroupTypeFromVarI (slab->vindex);
+ attr_int = CCTK_GroupTypeFromVarI (request->vindex);
WRITE_ATTRIBUTE ("grouptype", &attr_int, object, myGH, 0, HDF5_INT);
- attr_int = CCTK_NumTimeLevelsFromVarI (slab->vindex);
+ attr_int = CCTK_NumTimeLevelsFromVarI (request->vindex);
WRITE_ATTRIBUTE ("ntimelevels", &attr_int, object, myGH, 0, HDF5_INT);
- WRITE_ATTRIBUTE ("global_size", slab->hsize, object, myGH, slab->hdim,
+ WRITE_ATTRIBUTE ("global_size", request->hsize, object, myGH, request->hdim,
HDF5_INT);
WRITE_ATTRIBUTE ("time", &GH->cctk_time, object, myGH, 0, HDF5_REAL);
@@ -237,9 +225,9 @@ void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioSlab *slab,
/* FIXME: This is hardcoded for cartesian coordinate systems.
A better solution would be to be able to query the coordinate
system which is associated with the variable. */
- vdim = CCTK_GroupDimFromVarI (slab->vindex);
+ vdim = CCTK_GroupDimFromVarI (request->vindex);
sprintf (coord_system_name, "cart%dd", vdim);
- if (CCTK_GroupTypeFromVarI (slab->vindex) == CCTK_GF &&
+ if (CCTK_GroupTypeFromVarI (request->vindex) == CCTK_GF &&
CCTK_CoordSystemHandle (coord_system_name) >= 0)
{
attr_real = (CCTK_REAL *) malloc (2 * vdim * sizeof (CCTK_REAL));
@@ -260,22 +248,22 @@ void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioSlab *slab,
#if 0
/* attributes describing the hyperslab */
/* FIXME: what attributes are really needed here ?? ***/
- if (slab)
+ if (request)
{
- attr_real = (CCTK_REAL *) malloc (4 * slab->hdim * sizeof (CCTK_REAL));
- for (dim = 0; dim < slab->hdim; dim++)
+ attr_real = (CCTK_REAL *) malloc (4 * request->hdim * sizeof (CCTK_REAL));
+ for (dim = 0; dim < request->hdim; dim++)
{
- attr_real[dim + 0*slab->hdim] =
- slab->origin[slab->direction[dim]] *
- GH->cctk_delta_space[slab->direction[dim]];
- attr_real[dim + 1*slab->hdim] =
- slab->origin[dim] * GH->cctk_delta_space[dim];
- attr_real[dim + 2*slab->hdim] =
- (slab->origin[dim] + slab->actlen[dim]-1) *
- GH->cctk_delta_space[dim] * slab->downsample[dim];
- attr_real[dim + 3*slab->hdim] =
- GH->cctk_delta_space[slab->direction[dim]] *
- slab->downsample[slab->direction[dim]];
+ attr_real[dim + 0*request->hdim] =
+ request->origin[request->direction[dim]] *
+ GH->cctk_delta_space[request->direction[dim]];
+ attr_real[dim + 1*request->hdim] =
+ request->origin[dim] * GH->cctk_delta_space[dim];
+ attr_real[dim + 2*request->hdim] =
+ (request->origin[dim] + request->actlen[dim]-1) *
+ GH->cctk_delta_space[dim] * request->downsample[dim];
+ attr_real[dim + 3*request->hdim] =
+ GH->cctk_delta_space[request->direction[dim]] *
+ request->downsample[request->direction[dim]];
}
WRITE_ATTRIBUTE ("origin_slab", attr_real + 0*dim, object, myGH, dim,
HDF5_REAL);