From e0b6ba41334383e750bc2af3f80818b347d5cd5c Mon Sep 17 00:00:00 2001 From: tradke Date: Sat, 8 May 2004 19:04:49 +0000 Subject: Remove calls to deprecated CCTK_Coord*() routines and use aliased functions from CoordBase instead. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@117 7842ec3a-9562-4be5-9c5b-06ba18f2b668 --- src/DumpUtils.c | 85 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 39 deletions(-) diff --git a/src/DumpUtils.c b/src/DumpUtils.c index fd9c389..1cef010 100644 --- a/src/DumpUtils.c +++ b/src/DumpUtils.c @@ -196,11 +196,10 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file)
  • the variable's groupname
  • the grouptype
  • number of timelevels -
  • simulation time -
  • origin -
  • bounding box -
  • gridspacings
  • global grid size +
  • simulation time +
  • bounding box info (if the variable has a coordinate + system associated with it) @enddesc @var GH @@ -222,12 +221,12 @@ int IOHDF5Util_DumpGH (const cGH *GH, const int *timers, hid_t file) void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioRequest *request, hid_t object) { - int dim, vdim; + int hdim, vdim, coord_system_handle; char *groupname; - CCTK_INT attr_int; - CCTK_REAL *attr_real; + CCTK_INT iattr; + CCTK_INT *coord_handles; + CCTK_REAL *rattr; const ioHDF5UtilGH *myGH; - char coord_system_name[20]; DECLARE_CCTK_PARAMETERS @@ -236,47 +235,55 @@ void IOHDF5Util_DumpCommonAttributes (const cGH *GH, const ioRequest *request, /* attributes describing the variable */ groupname = CCTK_GroupNameFromVarI (request->vindex); WRITE_ATTRIBUTE ("groupname", groupname, object, myGH, 0, myGH->HDF5_STRING); + coord_system_handle = Coord_GroupSystem (GH, groupname); free (groupname); - attr_int = CCTK_GroupTypeFromVarI (request->vindex); - WRITE_ATTRIBUTE ("grouptype", &attr_int, object, myGH, 0, HDF5_INT); - attr_int = CCTK_MaxTimeLevelsVI (request->vindex); - WRITE_ATTRIBUTE ("ntimelevels", &attr_int, object, myGH, 0, HDF5_INT); + iattr = CCTK_GroupTypeFromVarI (request->vindex); + WRITE_ATTRIBUTE ("grouptype", &iattr, object, myGH, 0, HDF5_INT); + iattr = CCTK_MaxTimeLevelsVI (request->vindex); + WRITE_ATTRIBUTE ("ntimelevels", &iattr, object, myGH, 0, HDF5_INT); WRITE_ATTRIBUTE ("global_size", request->hsize, object, myGH, request->hdim, HDF5_INT); WRITE_ATTRIBUTE ("time", &GH->cctk_time, object, myGH, 0, HDF5_REAL); - /* attributes describing the underlying grid - These are only stored for CCTK_GF variables if they are associated - with coordinates. */ - /* 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 (request->vindex); - sprintf (coord_system_name, "cart%dd", vdim); - if (CCTK_GroupTypeFromVarI (request->vindex) == CCTK_GF && - CCTK_CoordSystemHandle (coord_system_name) >= 0) + /* write bbox attributes if we have coordinate system info */ + coord_handles = malloc (request->vdim * sizeof (CCTK_INT)); + if (coord_system_handle >= 0 && + Util_TableGetIntArray (coord_system_handle, request->vdim, + coord_handles, "COORDINATES") >= 0) { - attr_real = malloc (3 * vdim * sizeof (CCTK_REAL)); - for (dim = 0; dim < vdim; dim++) + rattr = calloc (3 * request->vdim, sizeof (CCTK_REAL)); + + for (vdim = 0; vdim < request->vdim; vdim++) { - CCTK_CoordRange (GH, &attr_real[dim], &attr_real[dim + vdim], dim + 1, - NULL, coord_system_name); - - attr_real[dim + 0*vdim] += - request->origin[dim] * GH->cctk_delta_space[dim]; - attr_real[dim + 2*vdim] = - GH->cctk_delta_space[dim] * request->downsample[dim]; - attr_real[dim + 1*vdim] = attr_real[dim + 0*vdim] + - ((request->extent[dim] + request->downsample[dim]-1) / - request->downsample[dim] - 1) * attr_real[dim + 2*vdim]; + for (hdim = 0; hdim < request->hdim; hdim++) + { + if (request->direction[hdim*request->hdim + vdim]) + { + Util_TableGetReal (coord_handles[vdim], &rattr[hdim+0*request->vdim], + "COMPMIN"); + if (Util_TableGetReal (coord_handles[vdim], + &rattr[hdim+2*request->vdim], "DELTA") >= 0) + { + rattr[hdim+2*request->vdim] *= request->downsample[hdim]; + rattr[hdim+1*request->vdim] = rattr[hdim+0*request->vdim]; + rattr[hdim+1*request->vdim] += + ((request->extent[hdim] + request->downsample[hdim]-1) + / request->downsample[hdim] - 1) + * rattr[hdim+2*request->vdim]; + } + } + } } - WRITE_ATTRIBUTE ("origin", attr_real, object, myGH, vdim, HDF5_REAL); - WRITE_ATTRIBUTE ("min_ext", attr_real, object, myGH, vdim, HDF5_REAL); - WRITE_ATTRIBUTE ("max_ext", attr_real + vdim, object, myGH, vdim,HDF5_REAL); - WRITE_ATTRIBUTE ("delta", attr_real + 2*vdim, object, myGH, vdim,HDF5_REAL); - free (attr_real); + WRITE_ATTRIBUTE ("origin", rattr + 0*vdim, object, myGH, vdim, HDF5_REAL); + WRITE_ATTRIBUTE ("min_ext", rattr + 0*vdim, object, myGH, vdim, HDF5_REAL); + WRITE_ATTRIBUTE ("max_ext", rattr + 1*vdim, object, myGH, vdim, HDF5_REAL); + WRITE_ATTRIBUTE ("delta", rattr + 2*vdim, object, myGH, vdim, HDF5_REAL); + + free (rattr); } + + free (coord_handles); } -- cgit v1.2.3