aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2004-05-08 19:04:15 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2004-05-08 19:04:15 +0000
commite0a849da7a3f0715806f0c1d1adc1d7f11bf4c3f (patch)
tree84e147380e681adc8c15254715afacb7cf607e09
parent4baafb06b93c50c836bc178b2bd99a7edaff9163 (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
-rw-r--r--src/DumpVar.c88
-rw-r--r--src/Write2D.c64
2 files changed, 86 insertions, 66 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));
diff --git a/src/Write2D.c b/src/Write2D.c
index 8da9182..a2925d1 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -2,15 +2,15 @@
@file Write2D.c
@date Tue Feb 3 19:06:12 1998
@author Paul Walker
- @desc
+ @desc
Two dimensional slices into IEEEIO files on MPI distributed cactus data.
- @enddesc
+ @enddesc
@history
@hauthor Gabrielle Allen @hdate 26 Sep 1998
@hdesc Changed subroutine name (SliceTwoD -> Write2D), renamed IO parameters
@hauthor Gabrielle Allen @hdate Oct 17 1998
@hdesc Added the IO_verbose parameter instead of an ifdef
- @hauthor Gabrielle Allen @hdate 19 Oct 1998
+ @hauthor Gabrielle Allen @hdate 19 Oct 1998
@hdesc Changed names ready for thorn_IO
@hauthor Thomas Radke @hdate 16 Mar 1999
@hdesc Converted to Cactus 4.0
@@ -77,11 +77,11 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
CCTK_REAL min_ext[3], max_ext[3]; /* bounding box information */
CCTK_REAL min_ext_attr[2], max_ext_attr[2], delta_attr[2];
IOFile *IEEEfile_2D; /* file descriptors */
- int total_hsize, mapping, dir_i, dir_j, retval;
+ int total_hsize, mapping, dir_i, dir_j, coord_system_handle, coord_handle, retval;
int extent_int[3], extent_flexio[2];
- CCTK_INT origin[3], extent[2], direction[6], hsize[2];
+ CCTK_INT origin[3], extent[2], direction[6], hsize[2], coord_handles[3];
void *data;
- char *fullname;
+ char *fullname, *groupname;
/* to make the compiler happy */
@@ -133,15 +133,15 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
/* see if output file for this alias name was already created */
IEEEfile_2D = (IOFile *) GetNamedData (myGH->fileList_2D, alias);
- if (IEEEfile_2D == NULL)
+ if (IEEEfile_2D == NULL)
{
char *fname;
- IEEEfile_2D = (IOFile *) malloc (3 * sizeof (IOFile));
- fname = (char *) malloc (strlen (myGH->out2D_dir) + strlen (alias) +
+ IEEEfile_2D = malloc (3 * sizeof (IOFile));
+ fname = malloc (strlen (myGH->out2D_dir) + strlen (alias) +
strlen (GH->identity) + 20);
-
+
/* Open/Create files */
for (dir = 0; dir < 3; dir++)
{
@@ -165,11 +165,11 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
{
IEEEfile_2D[dir] = IEEEopen (fname, "w");
}
- if (! IOisValid (IEEEfile_2D[dir]))
+ if (! IOisValid (IEEEfile_2D[dir]))
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOFlexIO_Write2D: Cannot open 2D output file '%s'",
- fname);
+ "IOFlexIO_Write2D: Cannot open 2D output file '%s'",
+ fname);
return (-3);
}
@@ -197,7 +197,7 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
strlen (buffer) + 1, buffer));
}
}
-
+
/* store file desriptors in database */
StoreNamedData (&myGH->fileList_2D, alias, IEEEfile_2D);
@@ -223,15 +223,26 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
}
/* get the coordinate ranges */
- CCTK_CoordRange (GH, &min_ext[0], &max_ext[0], -1, "x", "cart3d");
- CCTK_CoordRange (GH, &min_ext[1], &max_ext[1], -1, "y", "cart3d");
- CCTK_CoordRange (GH, &min_ext[2], &max_ext[2], -1, "z", "cart3d");
+ groupname = CCTK_GroupNameFromVarI (vindex);
+ coord_system_handle = Coord_GroupSystem (GH, groupname);
+ free (groupname);
+
+ if (coord_system_handle >= 0 &&
+ Util_TableGetIntArray (coord_system_handle, 3,
+ coord_handles, "COORDINATES") >= 0)
+ {
+ for (dir = 0; dir < 3; dir++)
+ {
+ Util_TableGetReal (coord_handles[dir], &min_ext[dir], "COMPMIN");
+ Util_TableGetReal (coord_handles[dir], &max_ext[dir], "COMPMAX");
+ }
+ }
/* get the extents of the variable */
CCTK_GroupgshVI (GH, 3, extent_int, vindex);
/* loop over all 3 planes */
- for (dir = 0; dir < 3; dir++)
+ for (dir = 0; dir < 3; dir++)
{
/* get the directions to span the hyperslab */
if (dir == 0)
@@ -285,14 +296,11 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
}
/* allocate hyperslab buffers */
+ data = NULL;
if (myproc == 0)
{
data = malloc (total_hsize * CCTK_VarTypeSize (groupinfo.vartype));
}
- else
- {
- data = NULL;
- }
/* get the variable slice */
retval = Hyperslab_Get (GH, mapping, 0, vindex, 0, -1, data);
@@ -301,7 +309,7 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
Hyperslab_FreeMapping (mapping);
/* processor 0 write the hyperslab data */
- if (myproc == 0)
+ if (myproc == 0)
{
if (retval >= 0)
{
@@ -317,15 +325,15 @@ int IOFlexIO_Write2D (const cGH *GH, int vindex, const char *alias)
delta_attr[0] = GH->cctk_delta_space[dir_i];
delta_attr[1] = GH->cctk_delta_space[dir_j];
FLEXIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "time",
- FLEXIO_REAL, 1, &GH->cctk_time));
+ FLEXIO_REAL, 1, &GH->cctk_time));
FLEXIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "origin",
- FLEXIO_REAL, 2, min_ext_attr));
+ FLEXIO_REAL, 2, min_ext_attr));
FLEXIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "min_ext",
- FLEXIO_REAL, 2, min_ext_attr));
+ FLEXIO_REAL, 2, min_ext_attr));
FLEXIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "max_ext",
- FLEXIO_REAL, 2, max_ext_attr));
+ FLEXIO_REAL, 2, max_ext_attr));
FLEXIO_ERROR (IOwriteAttribute (IEEEfile_2D[dir], "delta",
- FLEXIO_REAL, 2, delta_attr));
+ FLEXIO_REAL, 2, delta_attr));
}
else
{