From 72962251b5a7a3d48055dc52d94fa4d295327731 Mon Sep 17 00:00:00 2001 From: tradke Date: Sat, 8 May 2004 19:04:58 +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/IOPanda/trunk@65 38c3d835-c875-442e-b0fe-21c19ce1d001 --- src/Output.c | 71 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/src/Output.c b/src/Output.c index 4b5e4db..eb4841e 100644 --- a/src/Output.c +++ b/src/Output.c @@ -476,7 +476,7 @@ static int DumpVar (const cGH *GH, const ioRequest *request, const char *alias) ainfo.name_ = cast_to_const.non_const_char; /* copy from CCTK_INT[] to int[] */ - ainfo.size_ = (int *) malloc (request->hdim * sizeof (int)); + ainfo.size_ = malloc (request->hdim * sizeof (int)); for (ainfo.rank_ = 0; ainfo.rank_ < request->hdim; ainfo.rank_++) { ainfo.size_[ainfo.rank_] = request->hsize[i]; @@ -572,15 +572,18 @@ static int DumpVar (const cGH *GH, const ioRequest *request, const char *alias) static void AddCommonAttributes (const cGH *GH, const ioRequest *request, const char *fname) { - int i; + int hdim, vdim, coord_system_handle; char *name; CCTK_INT4 *itmp; CCTK_REAL *dtmp; + CCTK_INT *coord_handles; const ioGH *ioUtilGH; char coord_system_name[20]; - itmp = (CCTK_INT4 *) malloc (request->hdim * sizeof (CCTK_INT4)); + ioUtilGH = CCTK_GHExtension (GH, "IO"); + + itmp = malloc (request->hdim * sizeof (CCTK_INT4)); name = CCTK_FullName (request->vindex); Panda_WriteAttribute (fname, "name", BYTE, strlen (name) + 1, name); @@ -588,6 +591,7 @@ static void AddCommonAttributes (const cGH *GH, const ioRequest *request, name = CCTK_GroupNameFromVarI (request->vindex); Panda_WriteAttribute (fname, "groupname", BYTE, strlen (name) + 1, name); + coord_system_handle = Coord_GroupSystem (GH, name); free (name); itmp[0] = CCTK_GroupTypeFromVarI (request->vindex); @@ -601,33 +605,46 @@ static void AddCommonAttributes (const cGH *GH, const ioRequest *request, Panda_WriteAttribute (fname, "time", FLOAT64, 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 = (ioGH *) 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 = (CCTK_REAL *) 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]; + } + } + } } - Panda_WriteAttribute (fname, "origin", FLOAT64, request->hdim, dtmp); - Panda_WriteAttribute (fname, "min_ext", FLOAT64, request->hdim, dtmp); + Panda_WriteAttribute (fname, "origin", FLOAT64, request->hdim, + dtmp + 0*request->vdim); + Panda_WriteAttribute (fname, "min_ext", FLOAT64, request->hdim, + dtmp + 0*request->vdim); Panda_WriteAttribute (fname, "max_ext", FLOAT64, request->hdim, - dtmp + 1*request->hdim); + dtmp + 1*request->vdim); Panda_WriteAttribute (fname, "delta", FLOAT64, 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) @@ -635,13 +652,15 @@ static void AddCommonAttributes (const cGH *GH, const ioRequest *request, Panda_WriteAttribute (fname, "evolution_delta", FLOAT64, request->hdim, GH->cctk_delta_space); } +#endif free (dtmp); } + free (coord_handles); - for (i = 0; i < request->hdim; i++) + for (hdim = 0; hdim < request->hdim; hdim++) { - itmp[i] = request->hsize[i]; + itmp[hdim] = request->hsize[hdim]; } Panda_WriteAttribute (fname, "global_size", INT32, 3, itmp); @@ -675,7 +694,7 @@ static void AddChunkAttributes (const cGH *GH, const ioRequest *request, return; } - itmp = (CCTK_INT4 *) malloc (2 * request->hdim * sizeof (CCTK_INT4)); + itmp = malloc (2 * request->hdim * sizeof (CCTK_INT4)); /* copy from CCTK_INT[] to CCTK_INT4[] */ for (i = 0; i < request->hdim; i++) -- cgit v1.2.3