diff options
author | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2000-11-29 01:10:37 +0000 |
---|---|---|
committer | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2000-11-29 01:10:37 +0000 |
commit | 27d64bac96cfd0b3896763d2abad84dd08a93381 (patch) | |
tree | 7631b9b83e51a13a890ba27ee4ae912813772d0e /src/DumpUtils.c | |
parent | 257767c90a7f5cc2248e697feacd1337f8fd4a8e (diff) |
Use new PUGHSlab API for passing the directions of a hyperslab.
Also support single-precision output of CCTK_COMPLEX datatypes.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@14 7842ec3a-9562-4be5-9c5b-06ba18f2b668
Diffstat (limited to 'src/DumpUtils.c')
-rw-r--r-- | src/DumpUtils.c | 118 |
1 files changed, 61 insertions, 57 deletions
diff --git a/src/DumpUtils.c b/src/DumpUtils.c index 73d7fe3..d0895b3 100644 --- a/src/DumpUtils.c +++ b/src/DumpUtils.c @@ -57,7 +57,7 @@ int IOHDF5Util_DumpGH (cGH *GH, hid_t file) { DECLARE_CCTK_PARAMETERS - int index; + int vindex; int maxdim; int timelevel, current_timelevel; int *old_downsample; @@ -65,21 +65,24 @@ int IOHDF5Util_DumpGH (cGH *GH, ioGH *ioUtilGH; const char *thorn; const char *impl; - ioHDF5Geo_t slab; + ioHDF5Geo_t request; /* Get the GH extension for IOUtil */ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); - /* disable downsampling after saving original downsampling params */ maxdim = CCTK_MaxDim (); - old_downsample = (int *) malloc (maxdim * sizeof (int)); - for (index = 0; index < maxdim; index++) + request.origin = (int *) calloc (4 + maxdim, maxdim * sizeof (int)); + request.length = request.origin + 1 * maxdim; + request.downsample = request.origin + 2 * maxdim; + request.actlen = request.origin + 3 * maxdim; + request.direction = request.origin + 4 * maxdim; + + for (vindex = 0; vindex < maxdim; vindex++) { - old_downsample[index] = ioUtilGH->downsample[index]; - ioUtilGH->downsample[index] = 1; - slab.direction[index] = index; - slab.downsample[index] = 1; + request.length[vindex] = -1; + request.downsample[vindex] = 1; + request.direction[vindex * maxdim + vindex] = 1; } /* disable output in single precision */ @@ -87,12 +90,12 @@ int IOHDF5Util_DumpGH (cGH *GH, ioUtilGH->out_single = 0; /* sync all active groups */ - for (index = CCTK_NumGroups () - 1; index >= 0; index--) + for (vindex = CCTK_NumGroups () - 1; vindex >= 0; vindex--) { if (CCTK_IsImplementationActive ( - CCTK_ImpFromVarI (CCTK_FirstVarIndexI (index)))) + CCTK_ImpFromVarI (CCTK_FirstVarIndexI (vindex)))) { - CCTK_SyncGroupI (GH, index); + CCTK_SyncGroupI (GH, vindex); } } @@ -130,10 +133,10 @@ int IOHDF5Util_DumpGH (cGH *GH, } /* ... now the variables */ - for (index = CCTK_NumVars () - 1; index >= 0; index--) + for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--) { /* find out the thorn implementing variable with index */ - impl = CCTK_ImpFromVarI (index); + impl = CCTK_ImpFromVarI (vindex); thorn = CCTK_ImplementationThorn (impl); if (! thorn) { @@ -143,29 +146,29 @@ int IOHDF5Util_DumpGH (cGH *GH, /* let only variables pass which belong to an active thorn and have storage assigned */ if (! CCTK_IsThornActive (thorn) || - ! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) + ! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex))) { continue; } if (verbose && file >= 0) { - CCTK_VInfo (CCTK_THORNSTRING, " %s", CCTK_VarName (index)); + CCTK_VInfo (CCTK_THORNSTRING, " %s", CCTK_VarName (vindex)); } /* get the current timelevel */ - current_timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1; + current_timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1; if (current_timelevel > 0) { current_timelevel--; } - slab.sdim = slab.vdim = CCTK_GroupDimFromVarI (index); + request.sdim = request.vdim = CCTK_GroupDimFromVarI (vindex); /* now dump all timelevels up to the current */ for (timelevel = 0; timelevel <= current_timelevel; timelevel++) { - IOHDF5Util_DumpVar (GH, index, timelevel, &slab, file, 0); + IOHDF5Util_DumpVar (GH, vindex, timelevel, &request, file, 0); } } /* end of loop over all variables */ @@ -179,9 +182,8 @@ int IOHDF5Util_DumpGH (cGH *GH, /* restore output precision flag */ ioUtilGH->out_single = old_out_single; - /* restore original downsampling params */ - memcpy (ioUtilGH->downsample, old_downsample, maxdim * sizeof (int)); - free (old_downsample); + /* free temporary resources */ + free (request.origin); return (0); } @@ -209,7 +211,7 @@ int IOHDF5Util_DumpGH (cGH *GH, @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc CCTK index of the variable to dump @vtype int @vio in @@ -224,8 +226,8 @@ int IOHDF5Util_DumpGH (cGH *GH, @vtype CCTK_INT [] @vio in @endvar - @var slab - @vdesc pointer to hyperslab structure describing the dataset + @var request + @vdesc pointer to IO request structure describing the hyperslab @vtype ioHDF5Geo_t * @vio in @endvar @@ -236,15 +238,15 @@ int IOHDF5Util_DumpGH (cGH *GH, @endvar @@*/ void IOHDF5Util_DumpCommonAttributes (cGH *GH, - int index, + int vindex, int timelevel, CCTK_INT global_shape[], - ioHDF5Geo_t *slab, + ioHDF5Geo_t *request, hid_t dataset) { DECLARE_CCTK_PARAMETERS - int dim; char *groupname; + int maxdim; CCTK_INT attr_int; CCTK_REAL *attr_real; ioHDF5UtilGH *myGH; @@ -254,56 +256,57 @@ void IOHDF5Util_DumpCommonAttributes (cGH *GH, myGH = (ioHDF5UtilGH *) CCTK_GHExtension (GH, "IOHDF5Util"); /* attributes describing the variable */ - dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (index)); - groupname = CCTK_GroupNameFromVarI (index); + groupname = CCTK_GroupNameFromVarI (vindex); WRITE_ATTRIBUTE ("groupname", groupname, dataset, myGH->scalar_dataspace, 0, myGH->IOHDF5_STRING); free (groupname); - attr_int = CCTK_GroupTypeFromVarI (index); + attr_int = CCTK_GroupTypeFromVarI (vindex); WRITE_ATTRIBUTE ("grouptype", &attr_int, dataset, myGH->scalar_dataspace, 0, IOHDF5_INT); - attr_int = CCTK_NumTimeLevelsFromVarI (index); + attr_int = CCTK_NumTimeLevelsFromVarI (vindex); WRITE_ATTRIBUTE ("ntimelevels", &attr_int, dataset, myGH->scalar_dataspace, 0, IOHDF5_INT); WRITE_ATTRIBUTE ("global_size", global_shape, dataset, - myGH->array_dataspace, dim, IOHDF5_INT); + myGH->array_dataspace, request->sdim, IOHDF5_INT); WRITE_ATTRIBUTE ("time", &GH->cctk_time, dataset, myGH->scalar_dataspace, 0, IOHDF5_REAL); /* attributes describing the underlying grid */ - dim = CCTK_MaxDim (); - attr_real = (CCTK_REAL *) malloc (2 * dim * sizeof (CCTK_REAL)); - CCTK_CoordRange (GH, &attr_real[0], &attr_real[dim + 0], -1, "x", "cart3d"); - CCTK_CoordRange (GH, &attr_real[1], &attr_real[dim + 1], -1, "y", "cart3d"); - CCTK_CoordRange (GH, &attr_real[2], &attr_real[dim + 2], -1, "z", "cart3d"); + maxdim = CCTK_MaxDim (); + attr_real = (CCTK_REAL *) malloc (2 * maxdim * sizeof (CCTK_REAL)); + CCTK_CoordRange (GH, &attr_real[0], &attr_real[maxdim+0], -1, "x", "cart3d"); + CCTK_CoordRange (GH, &attr_real[1], &attr_real[maxdim+1], -1, "y", "cart3d"); + CCTK_CoordRange (GH, &attr_real[2], &attr_real[maxdim+2], -1, "z", "cart3d"); WRITE_ATTRIBUTE ("origin", attr_real, dataset, - myGH->array_dataspace, dim, IOHDF5_REAL); + myGH->array_dataspace, maxdim, IOHDF5_REAL); WRITE_ATTRIBUTE ("min_ext", attr_real, dataset, - myGH->array_dataspace, dim, IOHDF5_REAL); - WRITE_ATTRIBUTE ("max_ext", attr_real + dim, dataset, - myGH->array_dataspace, dim, IOHDF5_REAL); + myGH->array_dataspace, maxdim, IOHDF5_REAL); + WRITE_ATTRIBUTE ("max_ext", attr_real + maxdim, dataset, + myGH->array_dataspace, maxdim, IOHDF5_REAL); WRITE_ATTRIBUTE ("delta", GH->cctk_delta_space, dataset, - myGH->array_dataspace, dim, IOHDF5_REAL); + myGH->array_dataspace, maxdim, IOHDF5_REAL); free (attr_real); +#if 0 /* attributes describing the hyperslab */ - if (slab) + /* FIXME: what attributes are really needed here ?? ***/ + if (request) { - attr_real = (CCTK_REAL *) malloc (4 * slab->sdim * sizeof (CCTK_REAL)); - for (dim = 0; dim < slab->sdim; dim++) + attr_real = (CCTK_REAL *) malloc (4 * request->sdim * sizeof (CCTK_REAL)); + for (dim = 0; dim < request->sdim; dim++) { - attr_real[dim + 0*slab->sdim] = - slab->origin[slab->direction[dim]] * - GH->cctk_delta_space[slab->direction[dim]]; - attr_real[dim + 1*slab->sdim] = - slab->origin[dim] * GH->cctk_delta_space[dim]; - attr_real[dim + 2*slab->sdim] = - (slab->origin[dim] + slab->actlen[dim]-1) * - GH->cctk_delta_space[dim] * slab->downsample[dim]; - attr_real[dim + 3*slab->sdim] = - GH->cctk_delta_space[slab->direction[dim]] * - slab->downsample[slab->direction[dim]]; + attr_real[dim + 0*request->sdim] = + request->origin[request->direction[dim]] * + GH->cctk_delta_space[request->direction[dim]]; + attr_real[dim + 1*request->sdim] = + request->origin[dim] * GH->cctk_delta_space[dim]; + attr_real[dim + 2*request->sdim] = + (request->origin[dim] + request->actlen[dim]-1) * + GH->cctk_delta_space[dim] * request->downsample[dim]; + attr_real[dim + 3*request->sdim] = + GH->cctk_delta_space[request->direction[dim]] * + request->downsample[request->direction[dim]]; } WRITE_ATTRIBUTE ("origin_slab", attr_real + 0*dim, dataset, myGH->array_dataspace, dim, IOHDF5_REAL); @@ -315,6 +318,7 @@ void IOHDF5Util_DumpCommonAttributes (cGH *GH, myGH->array_dataspace, dim, IOHDF5_REAL); free (attr_real); } +#endif } |