aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Write1D.c75
-rw-r--r--src/Write2D.c44
-rw-r--r--src/Write3D.c33
3 files changed, 69 insertions, 83 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 */
diff --git a/src/Write2D.c b/src/Write2D.c
index f064c69..2017047 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -130,15 +130,15 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias)
{
asciiioGH *myGH;
int i, total_hsize, num_requested_hslabs, num_returned_hslabs;
- int dir, dir_i, dir_j, maxdir, myproc, groupindex, have_coords;
+ int dir, dir_i, dir_j, maxdir, myproc, gindex, have_coords;
int mapping;
cGroup gdata;
int coord_index[3];
+ CCTK_INT coord_system_handle, coord_handles[3];
CCTK_REAL coord_lower[3];
- char coord_system[20];
char format[3][64];
char header[40], buffer[30];
- char *fullname;
+ char *fullname, *groupname;
int extent_int[3];
CCTK_REAL offset[2];
CCTK_INT vindices[3], origin[3], extent[2], direction[6], hsize[2];
@@ -149,11 +149,11 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias)
/* get the variable name and group information */
fullname = CCTK_FullName (vindex);
- groupindex = CCTK_GroupIndexFromVarI (vindex);
- CCTK_GroupData (groupindex, &gdata);
+ gindex = CCTK_GroupIndexFromVarI (vindex);
+ CCTK_GroupData (gindex, &gdata);
/* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, groupindex))
+ if (! CCTK_QueryGroupStorageI (GH, gindex))
{
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"No IOASCII 2D output for '%s' (no storage)", fullname);
@@ -168,24 +168,26 @@ int IOASCII_Write2D (const cGH *GH, int vindex, const char *alias)
/* in general: maxdir = gdata.dim * (gdata.dim - 1) / 2; */
maxdir = gdata.dim == 2 ? 1 : 3;
- /* 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)
{
- sprintf (coord_system, "cart%dd", gdata.dim);
- for (dir = 0; dir < gdata.dim && dir < 3; dir++)
- {
- CCTK_CoordRange (GH, &coord_lower[dir], offset, dir+1, NULL,coord_system);
- coord_index[dir] = CCTK_CoordIndex (dir + 1, NULL, coord_system);
- have_coords &= coord_index[dir] >= 0;
- }
-
- if (! have_coords)
+ /* get the coordinate functions and coordinate physical minimum */
+ for (i = 0; i < dir; i++)
{
- CCTK_VWarn (8, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOASCII_Write2D: No coordinate ranges found for '%s'",
- 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;
}
}
num_requested_hslabs = have_coords ? 3 : 1;
diff --git a/src/Write3D.c b/src/Write3D.c
index 8db2f23..3220a13 100644
--- a/src/Write3D.c
+++ b/src/Write3D.c
@@ -124,13 +124,14 @@ static void WriteData (int vtype,
int IOASCII_Write3D (const cGH *GH, int vindex, const char *alias)
{
int i, total_hsize;
- int myproc, groupindex, have_coords;
+ int myproc, gindex, have_coords;
int num_requested_hslabs, num_returned_hslabs;
char header[40], buffer[30];
char format[3][64];
FILE *file;
cGroup gdata;
- char *fullname;
+ CCTK_INT coord_system_handle, coord_handles[3];
+ char *fullname, *groupname;
void *hdata[4];
int extent_int[3];
CCTK_REAL offset[3];
@@ -143,11 +144,11 @@ int IOASCII_Write3D (const cGH *GH, int vindex, const char *alias)
/* get the variable group information */
fullname = CCTK_FullName (vindex);
- groupindex = CCTK_GroupIndexFromVarI (vindex);
- CCTK_GroupData (groupindex, &gdata);
+ gindex = CCTK_GroupIndexFromVarI (vindex);
+ CCTK_GroupData (gindex, &gdata);
/* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, groupindex))
+ if (! CCTK_QueryGroupStorageI (GH, gindex))
{
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"No IOASCII 3D output for '%s' (no storage)", fullname);
@@ -155,22 +156,24 @@ int IOASCII_Write3D (const cGH *GH, int vindex, const char *alias)
return (-1);
}
- /* get the coordinate indices for CCTK_GF variables
- (CCTK_ARRAY variables never have coordinates associated) */
- vindices[0] = vindex;
- have_coords = gdata.grouptype == CCTK_GF;
+ /* get the coordinate system associated with this grid variable */
+ vindices[0] = vindex;
+ groupname = CCTK_GroupName (gindex);
+ coord_system_handle = Coord_GroupSystem (GH, groupname);
+ free (groupname);
+
+ have_coords = coord_system_handle >= 0 &&
+ Util_TableGetIntArray (coord_system_handle, 3,
+ coord_handles, "COORDINATES") >= 0;
if (have_coords)
{
+ /* get the coordinate functions and coordinate physical minimum */
for (i = 1; i <= 3; i++)
{
- vindices[i] = CCTK_CoordIndex (i, NULL, "cart3d");
+ vindices[i] = -1;
+ Util_TableGetInt (coord_handles[i-1], &vindices[i], "GAINDEX");
have_coords &= vindices[i] >= 0;
}
-
- if (! have_coords)
- {
- CCTK_WARN (8, "IOASCII_Write3D: No coordinate ranges found for 'card3d'");
- }
}
num_requested_hslabs = have_coords ? 4 : 1;