aboutsummaryrefslogtreecommitdiff
path: root/src/Write2D.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Write2D.c')
-rw-r--r--src/Write2D.c44
1 files changed, 23 insertions, 21 deletions
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;