aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>1999-10-27 00:01:40 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>1999-10-27 00:01:40 +0000
commit9fdeb058697419a6934a71d92987efcbb27f2233 (patch)
treec42741a4a1348649e29cf5c0f224c27504d12658
parent8d56ec8a794219d8f2623133ba5afb59c2f4549b (diff)
Tidying up several things:
- sp2xyz moved from PUGH's into IOFlexIO's GH extension call SetupSliceCenter() at startup to set up slice center for 2D output - fixed wrong indexing on ownership[] which caused buggy 2D output - use ParseVarsForOutput() instead of InitIONum() for parsing the out_vars parameter - decide which output dir shall be used by using CCTK_ParameterInfo() rather than comparing it with its old "outdir" default value - outdirs are always created now (not only if out_vars was non-empty) because IO methods might be invoked via CCTK_OutputVarAs() also - some variables renamed for better readability - fixed compiler warnings - hopefully get rid of empty IEEEIO subdir git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@62 ebee0441-1374-4afa-a3b5-247f3ba15b9a
-rw-r--r--src/GHExtension.c132
-rw-r--r--src/Output2D.c24
-rw-r--r--src/Output3D.c35
-rw-r--r--src/RestoreFile.c4
-rw-r--r--src/Write2D.c103
-rw-r--r--src/Write3D.c13
-rw-r--r--src/ioFlexGH.h28
7 files changed, 197 insertions, 142 deletions
diff --git a/src/GHExtension.c b/src/GHExtension.c
index e097add..eebb0cb 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -19,11 +19,16 @@
#include "cctk.h"
#include "cctk_parameters.h"
+#include "cctk_ParameterFunctions.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
#include "CactusBase/IOUtil/src/ioGH.h"
#include "ioFlexGH.h"
+/* local function prototypes */
+void SetupSliceCenter (cGH *GH);
+
+
void *IOFlexIO_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
{
int i, numvars;
@@ -32,10 +37,10 @@ void *IOFlexIO_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
numvars = CCTK_NumVars ();
newGH = (flexioGH *) malloc (sizeof (flexioGH));
- newGH->IO_2Dnum = (int *) malloc (numvars * sizeof (int));
- newGH->IO_3Dnum = (int *) malloc (numvars * sizeof (int));
- newGH->IO_2Dlast = (int *) malloc (numvars * sizeof (int));
- newGH->IO_3Dlast = (int *) malloc (numvars * sizeof (int));
+ newGH->do_out2D = (char *) malloc (numvars * sizeof (char));
+ newGH->do_out3D = (char *) malloc (numvars * sizeof (char));
+ newGH->out2D_last = (int *) malloc (numvars * sizeof (int));
+ newGH->out3D_last = (int *) malloc (numvars * sizeof (int));
newGH->IEEEfname_3D = (char **) malloc (numvars * sizeof (char **));
@@ -52,42 +57,48 @@ int IOFlexIO_InitGH (cGH *GH)
int i;
ioGH *ioUtilGH;
flexioGH *myGH;
+ t_param_prop *param_prop;
+
/* get the handles for IOUtil and IOFlexIO extensions */
ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
/* How often to output */
- myGH->IO_2Devery = out_every > 0 ? out_every : -1;
- myGH->IO_3Devery = out_every > 0 ? out_every : -1;
+ myGH->out2D_every = out_every > 0 ? out_every : -1;
+ myGH->out3D_every = out_every > 0 ? out_every : -1;
if (out2D_every > 0)
- myGH->IO_2Devery = out2D_every;
+ myGH->out2D_every = out2D_every;
if (out3D_every > 0)
- myGH->IO_3Devery = out3D_every;
+ myGH->out3D_every = out3D_every;
- InitIONum (myGH->IO_2Dnum, out2D_vars);
- InitIONum (myGH->IO_3Dnum, out3D_vars);
+ ParseVarsForOutput (out2D_vars, myGH->do_out2D);
+ ParseVarsForOutput (out3D_vars, myGH->do_out3D);
- /* Deal with the output directories */
- myGH->outpfx_2D = outdir;
- myGH->outpfx_3D = outdir;
- if (!CCTK_Equals(outdir2D,"outdir"))
- myGH->outpfx_2D = outdir2D;
- if (!CCTK_Equals(outdir3D,"outdir"))
- myGH->outpfx_3D = outdir3D;
+ /* Check whether "outdir2D" and/or "outdir3D" was set.
+ If so take these dirs otherwise default to "IO::outdir" */
+ param_prop = CCTK_ParameterInfo ("outdir2D", CCTK_THORNSTRING);
+ if (param_prop && param_prop->n_set > 0)
+ myGH->outdir2D = outdir2D;
+ else
+ myGH->outdir2D = outdir;
+
+ param_prop = CCTK_ParameterInfo ("outdir3D", CCTK_THORNSTRING);
+ if (param_prop && param_prop->n_set > 0)
+ myGH->outdir3D = outdir3D;
+ else
+ myGH->outdir3D = outdir;
/* Create the output directories */
if (CCTK_MyProc (GH) == 0) {
- if (myGH->IO_2Devery > 0 && strcmp (myGH->outpfx_2D, "."))
- if (CCTK_mkdir (myGH->outpfx_2D) != 0)
- CCTK_WARN (2,"Problem creating IO 2D directory");
- if (myGH->IO_3Devery > 0 && strcmp (myGH->outpfx_3D, "."))
- if (CCTK_mkdir (myGH->outpfx_3D) != 0)
- CCTK_WARN (2,"Problem creating IO 3D directory");
+ if (CCTK_mkdir (myGH->outdir2D) != 0)
+ CCTK_WARN (2,"Problem creating IO 2D directory");
+ if (CCTK_mkdir (myGH->outdir3D) != 0)
+ CCTK_WARN (2,"Problem creating IO 3D directory");
}
for (i=0; i<CCTK_NumVars(); i++)
- myGH->IO_2Dlast [i] = myGH->IO_3Dlast [i] = -1;
+ myGH->out2D_last [i] = myGH->out3D_last [i] = -1;
myGH->out3d_reuse_filehandles = out3d_reuse_filehandles;
@@ -108,5 +119,78 @@ int IOFlexIO_InitGH (cGH *GH)
myGH->filenameList2D = NULL;
myGH->fileList_3D = NULL;
+ /* set up 2D planes to plot */
+ SetupSliceCenter (GH);
+
return (0);
}
+
+
+/****************************************************************************/
+/* local routines */
+/****************************************************************************/
+void SetupSliceCenter (cGH *GH)
+{
+ DECLARE_CCTK_PARAMETERS
+ int dim;
+ int slice_center;
+ pGH *pughGH;
+ flexioGH *myGH;
+
+
+ /* Get the handles for PUGH IOFlexIO extensions */
+ pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")];
+ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
+
+ slice_center=1;
+ if ( CCTK_Equals (domain, "octant")
+ || CCTK_Equals (domain, "quadrant")
+ || CCTK_Equals (domain, "bitant"))
+ slice_center=0;
+
+ if (slice_center)
+ {
+ /* For NONE octant mode: the center for slicings */
+ /* is moved to the center index */
+ /* (unless nx,ny,nz=1) */
+
+ for (dim = 0; dim < GH->cctk_dim; dim++)
+ if (pughGH->lnsize [dim] == 1)
+ myGH->sp2xyz [dim] = 0;
+ else
+ myGH->sp2xyz [dim] = pughGH->nsize [dim]/2 -
+ pughGH->lb [pughGH->myproc][dim];
+
+ }
+
+ /* for octant mode, the slicing center is the index 1 or zero*/
+ else
+
+ {
+ for (dim = 0; dim < GH->cctk_dim; dim++)
+ if (pughGH->lnsize [dim] == 1)
+ myGH->sp2xyz [dim] = 0;
+ else
+ myGH->sp2xyz [dim] = 1 - pughGH->lb [pughGH->myproc][dim];
+ }
+
+ /* In quadrant mode x and y are like full, but z is like octant */
+ if (CCTK_Equals (domain, "quadrant")) {
+ if (pughGH->lnsize [2] == 1)
+ myGH->sp2xyz[2] = 0;
+ else
+ myGH->sp2xyz[2] = pughGH->lnsize [2]/2 - pughGH->lb [pughGH->myproc][2];
+ }
+
+ if (CCTK_Equals (domain, "bitant")) {
+ if (pughGH->lnsize [0] == 1)
+ myGH->sp2xyz[0] = 0;
+ else
+ myGH->sp2xyz[0] = myGH->sp2xyz[0]/2 - pughGH->lb [pughGH->myproc][0];
+
+ if (pughGH->lnsize [1] == 1)
+ myGH->sp2xyz[1] = 0;
+ else
+ myGH->sp2xyz[1] = pughGH->lnsize [1]/2 - pughGH->lb [pughGH->myproc][1];
+ }
+}
diff --git a/src/Output2D.c b/src/Output2D.c
index 9223938..7b4d14b 100644
--- a/src/Output2D.c
+++ b/src/Output2D.c
@@ -58,8 +58,8 @@ int IOFlexIO_Output2DGH (cGH *GH)
/* Get the GH extension for IOFlexIO */
myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
- if (myGH->IO_2Devery <= 0)
- return 0;
+ if (myGH->out2D_every <= 0)
+ return (0);
/* Loop over all variables */
for (i = 0; i < CCTK_NumVars (); i++) {
@@ -78,11 +78,8 @@ int IOFlexIO_Output2DGH (cGH *GH)
free (fullname);
- /* Register another 2D output for this GF */
- myGH->IO_2Dnum[i]++;
-
/* Register GF as having 2D output this iteration */
- myGH->IO_2Dlast[i] = GH->cctk_iteration;
+ myGH->out2D_last[i] = GH->cctk_iteration;
}
}
@@ -129,13 +126,9 @@ int IOFlexIO_Output2DVarAs (cGH *GH, const char *fullname, const char *alias)
{
DECLARE_CCTK_PARAMETERS
int index;
- flexioGH *myGH;
index = CCTK_VarIndex (fullname);
- /* get the handle for IOFlexIO extensions */
- myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
-
if (verbose) {
printf ("\nIn IOFlexIO Output2DVarAs\n-------------------\n");
printf (" Fullname = -%s-\n", fullname);
@@ -190,12 +183,12 @@ int IOFlexIO_TimeFor2D (cGH *GH, int index)
myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
/* Check this GF should be output */
- if (! (CCTK_GroupTypeFromVarI (index) == GROUP_GF && myGH->IO_2Dnum [index] != 0
- && GH->cctk_iteration % myGH->IO_2Devery == 0))
+ if (! (CCTK_GroupTypeFromVarI (index) == GROUP_GF && myGH->do_out2D [index]
+ && GH->cctk_iteration % myGH->out2D_every == 0))
return (0);
/* Check GF not already output this iteration */
- if (myGH->IO_2Dlast [index] == GH->cctk_iteration) {
+ if (myGH->out2D_last [index] == GH->cctk_iteration) {
CCTK_WARN (2, "Already done 2D output in IOFlexIO");
return (0);
}
@@ -266,11 +259,8 @@ int IOFlexIO_TriggerOutput2D (cGH *GH, int index)
/* Do the 2D output */
IOFlexIO_Write2D (GH, index, varname);
- /* Register another 2D output for this GF */
- myGH->IO_2Dnum [index]++;
-
/* Register GF as having 2D output this iteration */
- myGH->IO_2Dlast [index] = GH->cctk_iteration;
+ myGH->out2D_last [index] = GH->cctk_iteration;
return (0);
}
diff --git a/src/Output3D.c b/src/Output3D.c
index ecb72fa..2c83fd2 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -3,7 +3,7 @@
@date Tue Jan 9 1999
@author Gabrielle Allen
@desc
- Functions to deal 3D output of GFs
+ Functions to deal 3D output of variables
@enddesc
@history
@hauthor Thomas Radke @hdate 16 Mar 1999
@@ -60,8 +60,8 @@ int IOFlexIO_Output3DGH (cGH *GH)
/* Get the GH extension for IOFlexIO */
myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
- if (myGH->IO_3Devery <= 0)
- return 0;
+ if (myGH->out3D_every <= 0)
+ return (0);
/* Loop over all variables */
for (i = 0; i < CCTK_NumVars (); i++) {
@@ -82,11 +82,8 @@ int IOFlexIO_Output3DGH (cGH *GH)
free (fullname);
- /* Register another 3D output for this GF */
- myGH->IO_3Dnum [i]++;
-
- /* Register GF as having 3D output this iteration */
- myGH->IO_3Dlast [i] = GH->cctk_iteration;
+ /* Register variables as having 3D output this iteration */
+ myGH->out3D_last [i] = GH->cctk_iteration;
}
}
@@ -133,13 +130,9 @@ int IOFlexIO_Output3DVarAs (cGH *GH, const char *fullname, const char *alias)
{
DECLARE_CCTK_PARAMETERS
int index;
- flexioGH *myGH;
index = CCTK_VarIndex(fullname);
- /* Get the GH extension for IOFlexIO */
- myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
-
if (verbose) {
printf ("\nIn IOFlexIO Output3DVarAs\n-------------------\n");
printf (" Fullname = -%s-\n", fullname);
@@ -192,18 +185,17 @@ int IOFlexIO_TimeFor3D (cGH *GH, int index)
/* Get the GH extension for IOFlexIO */
myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
- /* Check this GF should be output */
- if (! (myGH->IO_3Dnum [index] != 0 &&
- GH->cctk_iteration % myGH->IO_3Devery == 0))
+ /* Check this var should be output */
+ if (! (myGH->do_out3D [index] && GH->cctk_iteration % myGH->out3D_every == 0))
return (0);
- /* Check GF not already output this iteration */
- if (myGH->IO_3Dlast [index] == GH->cctk_iteration) {
+ /* Check var not already output this iteration */
+ if (myGH->out3D_last [index] == GH->cctk_iteration) {
CCTK_WARN (2, "Already done 3D output in IOFlexIO");
return (0);
}
- /* Check GF has storage */
+ /* Check var has storage */
if (! CCTK_QueryGroupStorageI (GH,
CCTK_GroupIndexFromVarI(index))) {
char *fullname = CCTK_FullName (index);
@@ -269,11 +261,8 @@ int IOFlexIO_TriggerOutput3D (cGH *GH, int index)
/* Do the 3D output */
IOFlexIO_Write3D (GH, index, varname);
- /* Register another 3D output for this GF */
- myGH->IO_3Dnum [index]++;
-
- /* Register GF as having 3D output this iteration */
- myGH->IO_3Dlast [index] = GH->cctk_iteration;
+ /* Register var as having 3D output this iteration */
+ myGH->out3D_last [index] = GH->cctk_iteration;
return (0);
}
diff --git a/src/RestoreFile.c b/src/RestoreFile.c
index f15143d..eec8999 100644
--- a/src/RestoreFile.c
+++ b/src/RestoreFile.c
@@ -220,11 +220,7 @@ int GetChunkAttributes (cGH *GH, IOFile ifp, int index)
int vtype_stored, rank_stored, dims_stored [MAXDIM];
char fullname [512];
char msg [160];
- pGH *pughGH; /* PUGH extension handle */
-
- /* Get the handle for PUGH extensions */
- pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")];
/* read the next dataset's info from the file */
result = IOreadInfo (ifp, &vtype_stored, &rank_stored, dims_stored, MAXDIM);
diff --git a/src/Write2D.c b/src/Write2D.c
index fcd9251..cf192c5 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -85,7 +85,6 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
/* Attributes */
CCTK_REAL origin [2], delta [2];
int maxrempt;
- int dims [2];
void *locdat = NULL, *alldat = NULL, *recd;
int hi = 0, lo = 0;
int locbnd [4];
@@ -125,13 +124,13 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
char *msg;
IEEEfile_2D = (IOFile *) malloc (3 * sizeof (IOFile));
- len = strlen (myGH->outpfx_2D) + strlen (alias);
+ len = strlen (myGH->outdir2D) + strlen (alias);
fname = (char *) malloc (len + 20);
msg = (char *) malloc (len + 20 + 40);
assert (IEEEfile_2D && fname && msg);
/* Create files (open mode "w") */
- sprintf (fname, "%s/%s_2d_yz.ieee", myGH->outpfx_2D, alias);
+ sprintf (fname, "%s/%s_2d_yz.ieee", myGH->outdir2D, alias);
IEEEfile_2D [0] = IEEEopen (fname, "w");
if (! IOisValid (IEEEfile_2D [0])) {
sprintf (msg, "Cannot open output file %s", fname);
@@ -139,7 +138,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
return;
}
- sprintf (fname, "%s/%s_2d_xz.ieee", myGH->outpfx_2D, alias);
+ sprintf (fname, "%s/%s_2d_xz.ieee", myGH->outdir2D, alias);
IEEEfile_2D [1] = IEEEopen (fname, "w");
if (! IOisValid (IEEEfile_2D [1])) {
sprintf (msg, "Cannot open output file %s", fname);
@@ -147,7 +146,7 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
return;
}
- sprintf (fname, "%s/%s_2d_xy.ieee", myGH->outpfx_2D, alias);
+ sprintf (fname, "%s/%s_2d_xy.ieee", myGH->outdir2D, alias);
IEEEfile_2D [2] = IEEEopen (fname, "w");
if (! IOisValid (IEEEfile_2D [2])) {
sprintf (msg, "Cannot open output file %s", fname);
@@ -206,12 +205,12 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
for (dir = 0; dir < 3; dir++) {
npoints = 0;
/* Figure out the number of points */
- if ((pughGH->ownership[pughGH->stagger][dir][0] <= pughGH->sp2dxyz[dir]) &&
- (pughGH->sp2dxyz[dir] < pughGH->ownership[pughGH->stagger][dir][1]))
- npoints = (pughGH->ownership[pughGH->stagger][(dir+1)%3][1] -
- pughGH->ownership[pughGH->stagger][(dir+1)%3][0]) *
- (pughGH->ownership[pughGH->stagger][(dir+2)%3][1] -
- pughGH->ownership[pughGH->stagger][(dir+2)%3][0]);
+ if ((pughGH->ownership[pughGH->stagger][0][dir] <= myGH->sp2xyz[dir]) &&
+ (myGH->sp2xyz[dir] < pughGH->ownership[pughGH->stagger][1][dir]))
+ npoints = (pughGH->ownership[pughGH->stagger][1][(dir+1)%3] -
+ pughGH->ownership[pughGH->stagger][0][(dir+1)%3]) *
+ (pughGH->ownership[pughGH->stagger][1][(dir+2)%3] -
+ pughGH->ownership[pughGH->stagger][0][(dir+2)%3]);
/* Set up the number of global points and the points in the "i"
and "j" directions */
@@ -277,20 +276,20 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
if (npoints > 0) {
/* See above comment ... */
bnd [lo] = GH->cctk_lbnd[(dir+1)%3] +
- pughGH->ownership[pughGH->stagger][(dir+1)%3][0];
+ pughGH->ownership[pughGH->stagger][0][(dir+1)%3];
bnd [lo+1] = GH->cctk_lbnd[(dir+1)%3] +
- pughGH->ownership[pughGH->stagger][(dir+1)%3][1];
+ pughGH->ownership[pughGH->stagger][1][(dir+1)%3];
bnd [hi] = GH->cctk_lbnd[(dir+2)%3] +
- pughGH->ownership[pughGH->stagger][(dir+2)%3][0];
+ pughGH->ownership[pughGH->stagger][0][(dir+2)%3];
bnd [hi+1] = GH->cctk_lbnd[(dir+2)%3] +
- pughGH->ownership[pughGH->stagger][(dir+2)%3][1];
+ pughGH->ownership[pughGH->stagger][1][(dir+2)%3];
- locbnd [lo] = pughGH->ownership[pughGH->stagger][(dir+1)%3][0];
- locbnd [lo+1] = pughGH->ownership[pughGH->stagger][(dir+1)%3][1];
+ locbnd [lo] = pughGH->ownership[pughGH->stagger][0][(dir+1)%3];
+ locbnd [lo+1] = pughGH->ownership[pughGH->stagger][1][(dir+1)%3];
- locbnd [hi] = pughGH->ownership[pughGH->stagger][(dir+2)%3][0];
- locbnd [hi+1] = pughGH->ownership[pughGH->stagger][(dir+2)%3][1];
+ locbnd [hi] = pughGH->ownership[pughGH->stagger][0][(dir+2)%3];
+ locbnd [hi+1] = pughGH->ownership[pughGH->stagger][1][(dir+2)%3];
} else {
bnd [lo] = 0;
@@ -314,9 +313,9 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
for (k = locbnd [2]; k < locbnd [3]; k++)
for (j = locbnd [0]; j < locbnd [1]; j++) {
int pt = 0;
- if (dir==0) pt = DATINDEX (pughGH, pughGH->sp2dxyz [dir], j, k);
- if (dir==1) pt = DATINDEX (pughGH, j, pughGH->sp2dxyz [dir], k);
- if (dir==2) pt = DATINDEX (pughGH, j, k, pughGH->sp2dxyz [dir]);
+ if (dir==0) pt = DATINDEX (pughGH, myGH->sp2xyz [dir], j, k);
+ if (dir==1) pt = DATINDEX (pughGH, j, myGH->sp2xyz [dir], k);
+ if (dir==2) pt = DATINDEX (pughGH, j, k, myGH->sp2xyz [dir]);
assert (l <= npoints && pt <= pughGH->npoints);
char_locdat [l++] = ((CCTK_CHAR *) data) [pt];
}
@@ -326,9 +325,9 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
for (k = locbnd [2]; k < locbnd [3]; k++)
for (j = locbnd [0]; j < locbnd [1]; j++) {
int pt = 0;
- if (dir==0) pt = DATINDEX (pughGH, pughGH->sp2dxyz [dir], j, k);
- if (dir==1) pt = DATINDEX (pughGH, j, pughGH->sp2dxyz [dir], k);
- if (dir==2) pt = DATINDEX (pughGH, j, k, pughGH->sp2dxyz [dir]);
+ if (dir==0) pt = DATINDEX (pughGH, myGH->sp2xyz [dir], j, k);
+ if (dir==1) pt = DATINDEX (pughGH, j, myGH->sp2xyz [dir], k);
+ if (dir==2) pt = DATINDEX (pughGH, j, k, myGH->sp2xyz [dir]);
assert (l <= npoints && pt <= pughGH->npoints);
int_locdat [l++] = ((CCTK_INT *) data) [pt];
}
@@ -339,9 +338,9 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
for (k = locbnd [2]; k < locbnd [3]; k++)
for (j = locbnd [0]; j < locbnd [1]; j++) {
int pt = 0;
- if (dir==0) pt = DATINDEX (pughGH, pughGH->sp2dxyz [dir], j, k);
- if (dir==1) pt = DATINDEX (pughGH, j, pughGH->sp2dxyz [dir], k);
- if (dir==2) pt = DATINDEX (pughGH, j, k, pughGH->sp2dxyz [dir]);
+ if (dir==0) pt = DATINDEX (pughGH, myGH->sp2xyz [dir], j, k);
+ if (dir==1) pt = DATINDEX (pughGH, j, myGH->sp2xyz [dir], k);
+ if (dir==2) pt = DATINDEX (pughGH, j, k, myGH->sp2xyz [dir]);
assert (l <= npoints && pt <= pughGH->npoints);
if (ioUtilGH->out_single)
real4_locdat [l++] = (CCTK_REAL4) (((CCTK_REAL *) data) [pt]);
@@ -429,35 +428,31 @@ void IOFlexIO_Write2D (cGH *GH, int index, const char *alias)
/* Proc 0 writes */
if (myproc == 0) {
+ int dims [2];
+ CCTK_REAL min_ext [2], max_ext [2];
+
dims [0] = ni;
dims [1] = nj;
- /*** FIXME: since slice center is not yet set up, npoints might be 0 ***/
- if (npoints <= 0)
- CCTK_WARN (1, "2D output doesn't work since slice center is not set up");
- else {
- CCTK_REAL min_ext [2], max_ext [2];
-
- /* the data itself */
- CACTUS_IEEEIO_ERROR (IOwrite (IEEEfile_2D [dir],
- ioflex_type, 2, dims, alldat));
-
- /* Time and space attributes */
- CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
- "time", FLEXIO_REAL, 1, &GH->cctk_time));
- CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
- "origin", FLEXIO_REAL, 2, origin));
- CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
- "delta", FLEXIO_REAL, 2, delta));
-
- /* and also the coordinate ranges */
- CCTK_CoordRange (GH, &min_ext [0], &max_ext [0], "x");
- CCTK_CoordRange (GH, &min_ext [1], &max_ext [1], "x");
- CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
- "min_ext", FLEXIO_REAL, 2, min_ext));
- CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
- "max_ext", FLEXIO_REAL, 2, max_ext));
- }
+ /* the data itself */
+ CACTUS_IEEEIO_ERROR (IOwrite (IEEEfile_2D [dir],
+ ioflex_type, 2, dims, alldat));
+
+ /* Time and space attributes */
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
+ "time", FLEXIO_REAL, 1, &GH->cctk_time));
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
+ "origin", FLEXIO_REAL, 2, origin));
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
+ "delta", FLEXIO_REAL, 2, delta));
+
+ /* and also the coordinate ranges */
+ CCTK_CoordRange (GH, &min_ext [0], &max_ext [0], "x");
+ CCTK_CoordRange (GH, &min_ext [1], &max_ext [1], "x");
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
+ "min_ext", FLEXIO_REAL, 2, min_ext));
+ CACTUS_IEEEIO_ERROR (IOwriteAttribute (IEEEfile_2D [dir],
+ "max_ext", FLEXIO_REAL, 2, max_ext));
}
/* Free memory for this time through */
diff --git a/src/Write3D.c b/src/Write3D.c
index e99a870..453559c 100644
--- a/src/Write3D.c
+++ b/src/Write3D.c
@@ -130,17 +130,15 @@ void IOFlexIO_Write3D_closeFile (cGH *GH, IEEEfile_3D_t *IEEEfile_3D);
void IOFlexIO_Write3D (cGH *GH, int index, const char *alias)
{
DECLARE_CCTK_PARAMETERS
- int myproc, nprocs;
+ int myproc;
int timelevel;
ioGH *ioUtilGH;
- flexioGH *myGH;
int isNewFile;
IEEEfile_3D_t *IEEEfile_3D;
/* Get the handle for IOUtil and IOFlexIO extensions */
ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")];
if (verbose) {
printf ("-------------------------------------------------------\n");
@@ -153,7 +151,6 @@ void IOFlexIO_Write3D (cGH *GH, int index, const char *alias)
/* What processor are we on? */
myproc = CCTK_MyProc (GH);
- nprocs = CCTK_nProcs (GH);
/* Get the filename and descriptor for output */
@@ -410,9 +407,9 @@ IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile)
/* If necessary create the output directory */
if (myproc == 0) {
- outputdir = (char *) malloc (strlen (myGH->outpfx_3D) +
+ outputdir = (char *) malloc (strlen (myGH->outdir3D) +
strlen (alias) + 5);
- sprintf (outputdir, "%s/%s_3d", myGH->outpfx_3D, alias);
+ sprintf (outputdir, "%s/%s_3d", myGH->outdir3D, alias);
if (CCTK_mkdir (outputdir) != 0)
CCTK_WARN (1, "Problem creating 3D output directory");
@@ -436,12 +433,12 @@ IEEEfile_3D_t *IOFlexIO_Get3Dfile (cGH *GH, const char *alias, int *isNewFile)
IEEEfile_3D = (IEEEfile_3D_t *) malloc (sizeof (IEEEfile_3D_t));
- IEEEfile_3D->filename = (char *) malloc (strlen (myGH->outpfx_3D) +
+ IEEEfile_3D->filename = (char *) malloc (strlen (myGH->outdir3D) +
strlen (extradir) +
strlen (alias) +
strlen (extra) +
10);
- sprintf (IEEEfile_3D->filename, "%s/%s%s_3d%s.ieee", myGH->outpfx_3D,
+ sprintf (IEEEfile_3D->filename, "%s/%s%s_3d%s.ieee", myGH->outdir3D,
extradir, alias, extra);
/* no need to store file info if used only once */
diff --git a/src/ioFlexGH.h b/src/ioFlexGH.h
index 4138fa5..69d3d73 100644
--- a/src/ioFlexGH.h
+++ b/src/ioFlexGH.h
@@ -21,6 +21,7 @@
#include "external/IEEEIO/src/IOProtos.h"
#include "external/IEEEIO/src/IEEEIO.h"
+#include "external/IEEEIO/src/MPIO.h"
/* define the IOFlexIO datatypes according to CCTK_??? datatypes */
@@ -66,21 +67,21 @@
typedef struct IOFlexIOGH {
- /* The number of times output */
- int *IO_2Dnum;
- int *IO_3Dnum;
+ /* flags indicating output for var [i] */
+ char *do_out2D;
+ char *do_out3D;
- /* How often to output */
- int IO_2Devery;
- int IO_3Devery;
+ /* how often to output */
+ int out2D_every;
+ int out3D_every;
- /* Directory in which to output */
- char *outpfx_2D;
- char *outpfx_3D;
+ /* directory in which to output */
+ char *outdir2D;
+ char *outdir3D;
- /* The last iteration output */
- int *IO_2Dlast;
- int *IO_3Dlast;
+ /* the last iteration output */
+ int *out2D_last;
+ int *out3D_last;
/* IEEEIO file name and pointer for 3D output */
char **IEEEfname_3D;
@@ -93,6 +94,9 @@ typedef struct IOFlexIOGH {
pNamedData *filenameList2D;
pNamedData *fileList_3D;
+ /* slice point for 2D output */
+ int sp2xyz [3];
+
} flexioGH;