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