aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--param.ccl101
-rw-r--r--schedule.ccl2
-rw-r--r--src/CheckpointRecovery.c2
-rw-r--r--src/GHExtension.c106
-rw-r--r--src/Utils.c263
-rw-r--r--src/ioGH.h51
-rw-r--r--src/make.code.defn9
7 files changed, 430 insertions, 104 deletions
diff --git a/param.ccl b/param.ccl
index 7cb0d1a..f94ccb5 100644
--- a/param.ccl
+++ b/param.ccl
@@ -1,15 +1,6 @@
# Parameter definitions for thorn IOUtil
#############################################################################
-### import grid parameters
-#############################################################################
-shares: grid
-
-USES KEYWORD domain ""
-{
-}
-
-#############################################################################
### declare IOUtil parameters
### These are declared protected so that they can be seen by other IO thorns.
#############################################################################
@@ -141,3 +132,95 @@ STRING recover_ID_vars "List of variables to read in from the given initial data
{
.* :: A regex which matches everything
} "all"
+
+
+
+CCTK_REAL out_xline_y "y-coord for 1D lines in x-direction"
+{
+ *:* :: ""
+} 0.0
+CCTK_REAL out_xline_z "z-coord for 1D lines in x-direction"
+{
+ *:* :: ""
+} 0.0
+
+CCTK_REAL out_yline_x "x-coord for 1D lines in y-direction"
+{
+ *:* :: ""
+} 0.0
+CCTK_REAL out_yline_z "z-coord for 1D lines in y-direction"
+{
+ *:* :: ""
+} 0.0
+
+CCTK_REAL out_zline_x "x-coord for 1D lines in z-direction"
+{
+ *:* :: ""
+} 0.0
+CCTK_REAL out_zline_y "y-coord for 1D lines in z-direction"
+{
+ *:* :: ""
+} 0.0
+
+CCTK_INT out_xline_yi "y-index (from 0) for 1D lines in x-direction"
+{
+ 0:* :: ""
+} 0
+CCTK_INT out_xline_zi "z-index (from 0) for 1D lines in x-direction"
+{
+ 0:* :: ""
+} 0
+
+CCTK_INT out_yline_xi "x-index (from 0) for 1D lines in y-direction"
+{
+ 0:* :: ""
+} 0
+CCTK_INT out_yline_zi "z-index (from 0) for 1D lines in y-direction"
+{
+ 0:* :: ""
+} 0
+
+CCTK_INT out_zline_xi "x-index (from 0) for 1D lines in z-direction"
+{
+ 0:* :: ""
+} 0
+CCTK_INT out_zline_yi "y-index (from 0) for 1D lines in z-direction"
+{
+ 0:* :: ""
+} 0
+
+
+############################
+# Specific to 2D output
+# Choosing what output to do
+############################
+CCTK_REAL out_yzplane_x "x-coord for 2D planes in yz"
+{
+ *:* :: ""
+} 0.0
+
+CCTK_REAL out_xzplane_y "y-coord for 2D planes in xz"
+{
+ *:* :: ""
+} 0.0
+
+CCTK_REAL out_xyplane_z "z-coord for 2D planes in xy"
+{
+ *:* :: ""
+} 0.0
+
+CCTK_INT out_xyplane_zi "z-index (from 0) for 2D planes in xy"
+{
+ 0:* :: ""
+} 0
+
+CCTK_INT out_xzplane_yi "y-index (from 0) for 2D planes in xz"
+{
+ 0:* :: ""
+} 0
+
+CCTK_INT out_yzplane_xi "x-index (from 0) for 2D planes in yz"
+{
+ 0:* :: ""
+} 0
+
diff --git a/schedule.ccl b/schedule.ccl
index 9fe0019..ea43999 100644
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -3,7 +3,7 @@
schedule IOUtil_Startup at STARTUP after Driver_Startup
{
LANG:C
-} "IOUtil startup routine"
+} "Startup routine"
if (! CCTK_Equals (recover, "no"))
{
diff --git a/src/CheckpointRecovery.c b/src/CheckpointRecovery.c
index 5c83063..b63cb37 100644
--- a/src/CheckpointRecovery.c
+++ b/src/CheckpointRecovery.c
@@ -347,7 +347,7 @@ void IOUtil_RecoverVarsFromDatafiles (cGH *GH,
if (CCTK_NumVars () > 0)
{
myGH->do_inVars = (char *) malloc (CCTK_NumVars ());
- ParseVarsForOutput (in_vars, myGH->do_inVars);
+ IOUtil_ParseVarsForOutput (in_vars, myGH->do_inVars);
}
else
{
diff --git a/src/GHExtension.c b/src/GHExtension.c
index 178bc44..b32c5a8 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -21,8 +21,10 @@
#include "ioGH.h"
+static char *rcsid = "$Header$";
+CCTK_FILEVERSION(CactusBase_IOUtil_GHExtension_c)
+
/* local function prototypes */
-static void SetupSliceCenter (cGH *GH);
/*@@
@@ -158,10 +160,6 @@ int IOUtil_InitGH (cGH *GH)
/* reset the flags array for the file reader */
myGH->do_inVars = NULL;
- /* set up 2D planes to plot */
- myGH->sp2xyz = (int *) calloc (GH->cctk_dim, sizeof (int));
- SetupSliceCenter (GH);
-
/* initialize the file advertising listeners database */
myGH->listener_DB = NULL;
@@ -174,7 +172,7 @@ int IOUtil_InitGH (cGH *GH)
===============================================================*/
/*@@
- @routine ParseVarsForOutput
+ @routine IOUtil_ParseVarsForOutput
@date Sat March 6 1999
@author Gabrielle Allen
@desc
@@ -198,7 +196,7 @@ int IOUtil_InitGH (cGH *GH)
@endvar
@@*/
-void ParseVarsForOutput (const char *var_list, char do_output [])
+void IOUtil_ParseVarsForOutput (const char *var_list, char do_output [])
{
char *before=NULL;
char *after=NULL;
@@ -207,7 +205,9 @@ void ParseVarsForOutput (const char *var_list, char do_output [])
/* First initialise every variable to no output */
for (i=0; i<CCTK_NumVars(); i++)
+ {
do_output[i] = 0;
+ }
splitstring = (char *) var_list;
@@ -220,36 +220,47 @@ void ParseVarsForOutput (const char *var_list, char do_output [])
if (CCTK_Equals(before," ")) continue;
- if (strlen(before) > 0) {
+ if (strlen(before) > 0)
+ {
/* Look for any special tokens */
- if (CCTK_Equals(before,"all")) {
+ if (CCTK_Equals(before,"all"))
+ {
int ilab;
for (ilab=0;ilab<CCTK_NumVars();ilab++)
do_output[ilab]=1;
- } else {
+ }
+ else
+ {
/* See if this name is implementation::variable */
varnum = CCTK_VarIndex(before);
- if ( varnum < 0 ) {
+ if ( varnum < 0 )
+ {
/* See if this name is implementation::group */
groupnum = CCTK_GroupIndex(before);
- if (groupnum < 0) {
+ if (groupnum < 0)
+ {
char *msg;
msg = (char *)malloc((100+strlen(before))*sizeof(char));
- sprintf(msg,"Ignoring %s in IO string (invalid token)",before);
+ sprintf(msg,"Ignoring <%s> in IO string (invalid token)",before);
CCTK_WARN(2,msg);
free(msg);
- } else {
+ }
+ else
+ {
/* We have a group so now need all the variables in the group */
first = CCTK_FirstVarIndexI(groupnum);
last = first+CCTK_NumVarsInGroupI(groupnum)-1;
for (index=first;index<=last;index++)
do_output[index] = 1;
}
- } else
+ }
+ else
+ {
do_output[varnum] = 1;
+ }
}
}
if(before)
@@ -513,68 +524,3 @@ void IOUtil_PrintTimings (const char *description,
}
-/****************************************************************************/
-/* local routines */
-/****************************************************************************/
-static void SetupSliceCenter (cGH *GH)
-{
- DECLARE_CCTK_PARAMETERS
- int dim;
- int slice_center;
- ioGH *myGH;
-
-
- /* Get the handle for IOUtil extensions */
- myGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
-
- if ( CCTK_Equals (domain, "octant")
- || CCTK_Equals (domain, "quadrant")
- || CCTK_Equals (domain, "bitant"))
- {
- slice_center = 0;
- }
- else
- {
- slice_center = 1;
- }
-
- 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++)
- {
- myGH->sp2xyz [dim] = GH->cctk_gsh [dim] >> 1;
- }
-
- }
-
- /* for octant mode, the slicing center is the index 1 or zero*/
- else
-
- {
- for (dim = 0; dim < GH->cctk_dim; dim++)
- {
- myGH->sp2xyz [dim] = (GH->cctk_lsh [dim] == 1) ?
- 0 : 1 - GH->cctk_lbnd [dim];
- }
- }
-
- /* In quadrant mode x and y are like full, but z is like octant */
- if (CCTK_Equals (domain, "quadrant"))
- {
- myGH->sp2xyz [2] = (GH->cctk_lsh [2] == 1) ?
- 0 : GH->cctk_lsh [2]/2 - GH->cctk_lbnd [2];
- }
-
- if (CCTK_Equals (domain, "bitant"))
- {
- myGH->sp2xyz [0] = (GH->cctk_lsh [0] == 1) ?
- 0 : myGH->sp2xyz [0]/2 - GH->cctk_lbnd [0];
-
- myGH->sp2xyz [1] = (GH->cctk_lsh [1] == 1) ?
- 0 : GH->cctk_lsh [1]/2 - GH->cctk_lbnd [1];
- }
-}
diff --git a/src/Utils.c b/src/Utils.c
new file mode 100644
index 0000000..d38b1c6
--- /dev/null
+++ b/src/Utils.c
@@ -0,0 +1,263 @@
+ /*@@
+ @file Utils.c
+ @date Tue 4th July 2000
+ @author Gabrielle Allen
+ @desc
+ Utility routines which may be called by other IO thorns
+ @enddesc
+ @history
+ @endhistory
+ @@*/
+
+/*#define DEBUG_IOUTIL*/
+
+#include "cctk.h"
+#include "cctk_Parameters.h"
+
+ /*@@
+ @routine IOUtil_1DLines
+ @date July 4 2000
+ @author Gabrielle Allen, Gerd Lanfermann, Thomas Radke
+ @desc
+ Fills out an array determining where to position 1D lines for output
+ on a multidimensional regular Cartesian unigrid.
+ The first slot of the array specifies the 1D line direction, the
+ second slot fixes the indices of the starting point of that line on the
+ grid.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+
+int IOUtil_1DLines (cGH *GH,
+ int dimension,
+ int **index,
+ CCTK_REAL **coord,
+ int **spxyz)
+{
+ DECLARE_CCTK_PARAMETERS
+
+ int ierr=0;
+ int dim, dir;
+ CCTK_REAL lower,upper;
+ const char *name=NULL;
+ CCTK_REAL lowercoords[3]={0,0,0};
+ CCTK_REAL uppercoords[3]={0,0,0};
+
+ /* Get the appropriate coordinate system */
+ switch (dimension)
+ {
+ case 1:
+ name = "cart1d";
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
+ }
+ break;
+ case 2:
+ name = "cart2d";
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
+ }
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
+ }
+ break;
+ case 3:
+ name = "cart3d";
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
+ }
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
+ }
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 3, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[2] = lower;
+ uppercoords[2] = upper;
+ }
+ break;
+ default:
+ CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII",
+ "IOUtil_1DLines: Support only for dim<=3");
+ ierr = -1;
+ break;
+ }
+
+ for (dir = 0; dir < dimension; dir++)
+ {
+ for (dim = 0; dim < dimension; dim++)
+ {
+ if (dim == dir)
+ {
+ spxyz[dir][dim] = 0;
+ }
+ else if (index && index[dir][dim]>-1)
+ {
+ spxyz[dir][dim] = index[dir][dim];
+ }
+ else if (ierr < 0)
+ {
+ CCTK_VWarn(4, __LINE__,__FILE__,"IOASCII",
+ "IOUtil_1DLines: Cartesian coordinate system %s not found",
+ name);
+ spxyz[dir][dim] = 0;
+ }
+ else if (lowercoords[dim]>coord[dir][dim] ||
+ uppercoords[dim]<coord[dir][dim])
+ {
+ CCTK_VWarn(2,__LINE__,__FILE__,"IOUtil",
+ "IOUtil_1DLines: Coordinate in direction %d (%f,%f)"
+ " doesn't contain %f",
+ dim,lowercoords[dim],uppercoords[dim],coord[dir][dim]);
+ spxyz[dir][dim] = 0;
+ }
+ else
+ {
+ /* Find index for first point above the chosen coordinate */
+ spxyz[dir][dim] = 0.5-(lowercoords[dim]-coord[dir][dim])/
+ (GH->cctk_delta_space[dim]);
+
+#ifdef DEBUG_IOUTIL
+ printf("spxyz for %d-coord of lines in %d-direction is %d\n",
+ dim,dir,spxyz[dir][dim]);
+#endif
+ }
+ }
+ }
+
+ return 0;
+}
+
+
+
+int IOUtil_2DPlanes (cGH *GH,
+ int dimension,
+ int *index,
+ CCTK_REAL *coord,
+ int *sp2xyz)
+{
+ DECLARE_CCTK_PARAMETERS
+
+ int ierr=0;
+ int dir;
+ CCTK_REAL lower,upper;
+ const char *name=NULL;
+ CCTK_REAL lowercoords[3]={0,0,0};
+ CCTK_REAL uppercoords[3]={0,0,0};
+
+ /* Get the appropriate coordinate system */
+ /* Get the appropriate coordinate system */
+ switch (dimension)
+ {
+ case 1:
+ name = "cart1d";
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
+ }
+ break;
+ case 2:
+ name = "cart2d";
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
+ }
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
+ }
+ break;
+ case 3:
+ name = "cart3d";
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 1, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[0] = lower;
+ uppercoords[0] = upper;
+ }
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 2, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[1] = lower;
+ uppercoords[1] = upper;
+ }
+ ierr = CCTK_CoordRange(GH, &lower, &upper, 3, NULL, name);
+ if (ierr>-1)
+ {
+ lowercoords[2] = lower;
+ uppercoords[2] = upper;
+ }
+ break;
+ default:
+ CCTK_VWarn(4,__LINE__,__FILE__,"IOASCII",
+ "IOUtil_2DPlanes: Support only for dim<=3");
+ ierr = -1;
+ break;
+ }
+
+
+ for (dir = 0; dir < dimension; dir++)
+ {
+ if (index && index[dir]>-1)
+ {
+ sp2xyz[dir] = index[dir];
+ }
+ else if (ierr < 0)
+ {
+ CCTK_VWarn(4, __LINE__,__FILE__,"IOUtil",
+ "IOUtil_2DPlanes: Cartesian coordinate system %s not found",
+ name);
+ sp2xyz[dir] = 0;
+ }
+ else if (lowercoords[dir]>coord[dir] ||
+ uppercoords[dir]<coord[dir])
+ {
+ CCTK_VWarn(2,__LINE__,__FILE__,"IOUtil",
+ "IOUtil_2DPlanes: Coordinate in direction %d (%lf,%lf)"
+ " doesn't contain %f",
+ dir,lowercoords[dir],uppercoords[dir],coord[dir]);
+ sp2xyz[dir] = 0;
+ }
+ else
+ {
+ /* Find index for first point above the chosen coordinate */
+ sp2xyz[dir] = 0.5-(lowercoords[dir]-coord[dir])/
+ (GH->cctk_delta_space[dir]);
+
+#ifdef DEBUG_IOUTIL
+ printf("sp2xyz for planes perpendicular to"
+ " %d-direction is %d\n",
+ dir,sp2xyz[dir]);
+#endif
+ }
+ }
+
+ return 0;
+
+}
diff --git a/src/ioGH.h b/src/ioGH.h
index 05c3194..98e3059 100644
--- a/src/ioGH.h
+++ b/src/ioGH.h
@@ -78,9 +78,6 @@ typedef struct IOGH {
char *outpfx_3D;
#endif
- /* for 2D output */
- int *sp2xyz; /* slice point for 2D planes */
-
/* for 3D output */
int ioproc; /* the IO processor each proc belongs to */
int nioprocs; /* total number of IO processors */
@@ -95,6 +92,7 @@ typedef struct IOGH {
/* for data file reader */
char *do_inVars; /* flags indicating to read in variable [i] */
+
/* database holding all registered listeners for file advertising */
pNamedData *listener_DB;
@@ -105,33 +103,62 @@ enum {CP_INITIAL_DATA, CP_EVOLUTION_DATA, CP_RECOVER_PARAMETERS,
CP_RECOVER_DATA, FILEREADER_DATA};
/* prototypes of routines that are exported by IOUtil to other IO thorns */
-extern void ParseVarsForOutput (const char *var_list, char do_output []);
-extern void IOUtil_PrepareFilename (cGH *GH, const char *basename, char *fname,
- int called_from, int ioproc,int file_unchunked);
-extern int IOUtil_RegisterRecover (const char *name,
+
+extern int IOUtil_1DLines (cGH *GH,
+ int dimension,
+ int **index,
+ CCTK_REAL **coord,
+ int **spxyz);
+
+extern int IOUtil_2DPlanes (cGH *GH,
+ int dimension,
+ int *index,
+ CCTK_REAL *coord,
+ int *spxyz);
+
+extern void IOUtil_ParseVarsForOutput (const char *var_list,
+ char do_output []);
+
+extern void IOUtil_PrepareFilename (cGH *GH,
+ const char *basename,
+ char *fname,
+ int called_from,
+ int ioproc,
+ int file_unchunked);
+
+extern int IOUtil_RegisterRecover (const char *name,
int (*func) (cGH *, const char *, int));
+
extern void IOUtil_RecoverVarsFromDatafiles (cGH *GH,
const char *in_files,
const char *in_vars);
-extern int IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH,
- const char *basename,
- int called_from),
- const char *fileExtension,
- const char *fileType);
+
+extern int IOUtil_RecoverParameters (int (*recoverFn) (cGH *GH,
+ const char *basename,
+ int called_from),
+ const char *fileExtension,
+ const char *fileType);
+
extern char *IOUtil_GetAllParameters (cGH *GH);
+
extern void IOUtil_SetAllParameters (char *parameters);
/*** routines to handle with file advertising ***/
+
/* register a new listener with its own callbacks for file advertising */
+
extern int IOUtil_RegisterAdvertisedFileListener (cGH *GH,
const char *listener,
const IOUtil_AdvertisedFileListenerCallbacks_t *callbacks);
+
/* advertise a file */
+
extern int IOUtil_AdvertiseFile (cGH *GH,
const char *filename,
const IOUtil_AdvertisedFileDesc_t *desc);
/*** routine to output timing information ***/
+
extern void IOUtil_PrintTimings (const char *description,
int ntimers,
int timers[/* ntimers */],
diff --git a/src/make.code.defn b/src/make.code.defn
index 9f7b8ea..e3dbc41 100644
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -1 +1,8 @@
-SRCS = Startup.c GHExtension.c CheckpointRecovery.c
+# Main make.code.defn file for thorn IOUtil
+# $Header$
+
+# Source files in this directory
+SRCS = Startup.c\
+ GHExtension.c\
+ CheckpointRecovery.c\
+ Utils.c