diff options
Diffstat (limited to 'src/Write3D.c')
-rw-r--r-- | src/Write3D.c | 33 |
1 files changed, 18 insertions, 15 deletions
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; |