aboutsummaryrefslogtreecommitdiff
path: root/src/Write2D.c
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 /src/Write2D.c
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
Diffstat (limited to 'src/Write2D.c')
-rw-r--r--src/Write2D.c103
1 files changed, 49 insertions, 54 deletions
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 */