aboutsummaryrefslogtreecommitdiff
path: root/src/Write1D.c
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2004-05-01 21:19:43 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2004-05-01 21:19:43 +0000
commit9bd4fce84980c2288099f34358853d07a3335238 (patch)
tree6f5a4c06f32b076b722d6cfff4e1d1e03dc2dfff /src/Write1D.c
parent1428cc9d574699f5d363807c327e8727c3973fc2 (diff)
Removed the hard-coded assumption of "cart%d" being the underlying coordinate
system. Now the coordinate functions provided by CoordBase are used to get the coordinate coordinate system associated with an output variable, as well as the physical coordinate ranges. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@168 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src/Write1D.c')
-rw-r--r--src/Write1D.c75
1 files changed, 28 insertions, 47 deletions
diff --git a/src/Write1D.c b/src/Write1D.c
index 40a44ba..e815969 100644
--- a/src/Write1D.c
+++ b/src/Write1D.c
@@ -130,15 +130,13 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias)
{
asciiioGH *myGH;
int do_dir[4], coord_index[3];
- int i, dir, myproc, groupindex, have_coords, mapping;
-#if 0
- int lower, upper;
-#endif
+ int i, dir, myproc, gindex, have_coords, mapping;
int hstride, num_files, num_requested_hslabs, num_returned_hslabs;
int *extent_int;
cGroup gdata;
- char *fullname;
- char coord_system[20], header[40], buffer[30];
+ char *fullname, *groupname;
+ char header[40], buffer[30];
+ CCTK_INT coord_system_handle, coord_handles[3];
char format[3][64];
FILE *file[8];
CCTK_REAL offset;
@@ -151,11 +149,11 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias)
/* get the variable's group index and its full name */
- groupindex = CCTK_GroupIndexFromVarI (vindex);
+ gindex = CCTK_GroupIndexFromVarI (vindex);
fullname = CCTK_FullName (vindex);
/* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, groupindex))
+ if (! CCTK_QueryGroupStorageI (GH, gindex))
{
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_Write1D: No IOASCII_1D output for '%s' (no storage)",
@@ -168,7 +166,7 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias)
myGH = CCTK_GHExtension (GH, "IOASCII");
/* get the variable's group information */
- CCTK_GroupData (groupindex, &gdata);
+ CCTK_GroupData (gindex, &gdata);
/* see what slices should be output */
do_dir[0] = out1D_x && gdata.dim >= 1;
@@ -191,26 +189,27 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias)
return (0);
}
- /* get the coordinate indices for CCTK_GF variables
- (CCTK_ARRAY variables never have coordinates associated) */
- have_coords = gdata.grouptype == CCTK_GF;
+ /* get the coordinate system associated with this grid variable */
+ groupname = CCTK_GroupName (gindex);
+ coord_system_handle = Coord_GroupSystem (GH, groupname);
+ free (groupname);
+
+ dir = gdata.dim < 3 ? gdata.dim : 3;
+
+ have_coords = coord_system_handle >= 0 &&
+ Util_TableGetIntArray (coord_system_handle, dir,
+ coord_handles, "COORDINATES") >= 0;
if (have_coords)
{
- /* FIXME: this assumes a cartesian coordinate system */
- sprintf (coord_system, "cart%dd", gdata.dim);
- for (i = 0; i < gdata.dim && i < 3; i++)
+ /* get the coordinate functions and coordinate physical minimum */
+ for (i = 0; i < dir; i++)
{
- CCTK_CoordRange (GH, &coord_lower[i], &offset, i + 1, NULL, coord_system);
- coord_index[i] = CCTK_CoordIndex (i + 1, NULL, coord_system);
+ coord_index[i] = -1;
+ coord_lower[i] = 0;
+ Util_TableGetInt (coord_handles[i], &coord_index[i], "GAINDEX");
+ Util_TableGetReal (coord_handles[i], &coord_lower[i], "COMPMIN");
have_coords &= coord_index[i] >= 0;
}
-
- if (! have_coords)
- {
- CCTK_VWarn (8, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOASCII_Write1D: No coordinate ranges found for '%s'",
- coord_system);
- }
}
/* set header format string */
@@ -305,27 +304,12 @@ int IOASCII_Write1D (const cGH *GH, int vindex, const char *alias)
origin[i] = myGH->spxyz[gdata.dim-1][dir][i];
}
extent -= origin[dir];
-#if 0
- if (CCTK_CoordRangePhysIndex (GH, &lower, &upper, dir + 1, NULL,
- coord_system) >= 0)
- {
-fprintf (stderr, "CCTK_CoordRangePhysIndex() resets origin/extent in dir %d from %d/%d to ", dir, origin[dir], extent);
- origin[dir] = lower; extent = upper - lower + 1;
-fprintf (stderr, "%d/%d\n", origin[dir], extent);
- }
- else
+
+ /* correct extent in the case of staggered grids */
+ if (CCTK_StaggerDirIndex(dir,gdata.stagtype)==1)
{
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOASCII_Write1D: failed to get physical coordinate ranges "
- "for variable '%s'", fullname);
+ --extent;
}
-#else
- /* correct extent in the case of staggered grids */
- if (CCTK_StaggerDirIndex(dir,gdata.stagtype)==1)
- {
- --extent;
- }
-#endif
}
else /* origin for CCTK_ARRAYS is always (0, 0, 0) */
{
@@ -421,10 +405,7 @@ fprintf (stderr, "%d/%d\n", origin[dir], extent);
if (myproc == 0)
{
free (hdata[0]);
- if (hdata[1])
- {
- free (hdata[1]);
- }
+ free (hdata[1]);
}
} /* end of loop through all directions */