diff options
author | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2004-05-08 19:04:15 +0000 |
---|---|---|
committer | tradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a> | 2004-05-08 19:04:15 +0000 |
commit | e0a849da7a3f0715806f0c1d1adc1d7f11bf4c3f (patch) | |
tree | 84e147380e681adc8c15254715afacb7cf607e09 /src/DumpVar.c | |
parent | 4baafb06b93c50c836bc178b2bd99a7edaff9163 (diff) |
Remove calls to deprecated CCTK_Coord*() routines and use aliased functions
from CoordBase instead.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@320 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src/DumpVar.c')
-rw-r--r-- | src/DumpVar.c | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c index 807f4ec..99c6cde 100644 --- a/src/DumpVar.c +++ b/src/DumpVar.c @@ -516,9 +516,12 @@ static int WriteGA (const cGH *GH, const ioRequest *request, IOFile file) @date July 1998 @author Paul Walker @desc - Add "Common" attributes, these are the GF name, the current date, - simulation time, origin, bounding box, and gridspacings (both - downsampled and evolution). + Add "Common" attributes: + - the GV variable and group name, type, timelevel info + - the current iteration number and simulation time + - bbox information (only if the GV has a coordinate system + associated with it) + - chunk information @enddesc @calls @@ -544,15 +547,17 @@ static int WriteGA (const cGH *GH, const ioRequest *request, IOFile file) static void AddCommonAttributes (const cGH *GH, const ioRequest *request, IOFile file) { - int i; + int hdim, vdim, coord_system_handle; CCTK_REAL *dtmp; CCTK_INT4 *itmp; + CCTK_INT *coord_handles; char *name; - ioGH *ioUtilGH; - char coord_system_name[20]; + const ioGH *ioUtilGH; DECLARE_CCTK_PARAMETERS + ioUtilGH = CCTK_GHExtension (GH, "IO"); + /* allocate at least one CCTK_INT4 if hdim is 0 */ itmp = malloc ((request->hdim+1) * sizeof (CCTK_INT4)); @@ -564,6 +569,7 @@ static void AddCommonAttributes (const cGH *GH, const ioRequest *request, name = CCTK_GroupNameFromVarI (request->vindex); FLEXIO_ERROR (IOwriteAttribute (file, "groupname", FLEXIO_CHAR, strlen (name) + 1, name)); + coord_system_handle = Coord_GroupSystem (GH, name); free (name); itmp[0] = CCTK_GroupTypeFromVarI (request->vindex); @@ -577,35 +583,46 @@ static void AddCommonAttributes (const cGH *GH, const ioRequest *request, FLEXIO_ERROR (IOwriteAttribute (file, "time", FLEXIO_REAL, 1,&GH->cctk_time)); - /* 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. */ - ioUtilGH = CCTK_GHExtension (GH, "IO"); - sprintf (coord_system_name, "cart%dd", request->hdim); - 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) { - dtmp = malloc (3 * request->hdim * sizeof (CCTK_REAL)); - for (i = 0; i < request->hdim; i++) + dtmp = calloc (3 * request->vdim, sizeof (CCTK_REAL)); + + for (vdim = 0; vdim < request->vdim; vdim++) { - CCTK_CoordRange (GH, &dtmp[i], &dtmp[i + request->hdim], i + 1, - NULL, coord_system_name); - dtmp[i + 2*request->hdim] = GH->cctk_delta_space[i] * - ioUtilGH->downsample[i]; + for (hdim = 0; hdim < request->hdim; hdim++) + { + if (request->direction[hdim*request->hdim + vdim]) + { + Util_TableGetReal (coord_handles[vdim], &dtmp[hdim + 0*request->vdim], + "COMPMIN"); + if (Util_TableGetReal (coord_handles[vdim], + &dtmp[hdim+2*request->vdim], "DELTA") >= 0) + { + dtmp[hdim+2*request->vdim] *= request->downsample[hdim]; + dtmp[hdim+1*request->vdim] = dtmp[hdim+0*request->vdim]; + dtmp[hdim+1*request->vdim] += + ((request->extent[hdim] + request->downsample[hdim]-1) + / request->downsample[hdim] - 1) + * dtmp[hdim+2*request->vdim]; + } + } + } } FLEXIO_ERROR (IOwriteAttribute (file, "origin", FLEXIO_REAL, request->hdim, - dtmp)); + dtmp + 0*request->vdim)); FLEXIO_ERROR (IOwriteAttribute (file, "min_ext", FLEXIO_REAL, request->hdim, - dtmp)); + dtmp + 0*request->vdim)); FLEXIO_ERROR (IOwriteAttribute (file, "max_ext", FLEXIO_REAL, request->hdim, - dtmp + request->hdim)); + dtmp + 1*request->vdim)); FLEXIO_ERROR (IOwriteAttribute (file, "delta", FLEXIO_REAL, request->hdim, - dtmp + 2*request->hdim)); + dtmp + 2*request->vdim)); +#if 0 if (ioUtilGH->downsample[0] > 1 || ioUtilGH->downsample[1] > 1 || ioUtilGH->downsample[2] > 1) @@ -613,24 +630,19 @@ static void AddCommonAttributes (const cGH *GH, const ioRequest *request, FLEXIO_ERROR (IOwriteAttribute (file, "evolution_delta", FLEXIO_REAL, request->hdim, GH->cctk_delta_space)); } +#endif free (dtmp); } + free (coord_handles); - if (request->hdim) + itmp[0] = 0; + for (hdim = 0; hdim < request->hdim; hdim++) { - for (i = 0; i < request->hdim; i++) - { - itmp[i] = request->hsize[i]; - } - FLEXIO_ERROR (IOwriteAttribute (file, "global_size", FLEXIO_INT4, - request->hdim, itmp)); - } - else - { - itmp[0] = 0; - FLEXIO_ERROR (IOwriteAttribute (file, "global_size", FLEXIO_INT4, 1, itmp)); + itmp[hdim] = request->hsize[hdim]; } + FLEXIO_ERROR (IOwriteAttribute (file, "global_size", FLEXIO_INT4, + hdim ? hdim : 1, itmp)); itmp[0] = CCTK_nProcs (GH); FLEXIO_ERROR (IOwriteAttribute (file, "nprocs", FLEXIO_INT4, 1, itmp)); |