aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2003-12-03 23:08:23 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2003-12-03 23:08:23 +0000
commit30bb1fa778e98ac7f2562bef700e1951c59b42e9 (patch)
treeb56cd4de87214e65d1697500b04377e61a7e3556
parent510b8ddc67fa2dc14b19a8b2f56cedb259a48af7 (diff)
Only register 2D IOFlexIO I/O method if the maximum dimension of grid
variables is >= 2. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@301 ebee0441-1374-4afa-a3b5-247f3ba15b9a
-rw-r--r--src/Startup.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/src/Startup.c b/src/Startup.c
index 20e1f32..dbf3590 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -99,7 +99,7 @@ int IOFlexIO_TerminateGH (const cGH *GH)
/* get the handle for IOFlexIO extensions */
- myGH = (flexioGH *) CCTK_GHExtension (GH, "IOFlexIO");
+ myGH = CCTK_GHExtension (GH, "IOFlexIO");
/* immediately return if IOFlexIO wasn't active */
if (! myGH)
@@ -205,7 +205,7 @@ int IOFlexIO_TerminateGH (const cGH *GH)
@@*/
static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
{
- int i, numvars;
+ int i, maxdim, numvars;
flexioGH *myGH;
const ioGH *ioUtilGH;
const char *timer_names[4] = {"IOFlexIO time to dump parameters",
@@ -220,11 +220,17 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
(void) (conv_level + 0);
/* register the IOFlexIO routines as I/O methods */
- i = CCTK_RegisterIOMethod ("IOFlexIO_2D");
- CCTK_RegisterIOMethodOutputGH (i, IOFlexIO_Output2DGH);
- CCTK_RegisterIOMethodOutputVarAs (i, IOFlexIO_Output2DVarAs);
- CCTK_RegisterIOMethodTimeToOutput (i, IOFlexIO_TimeFor2D);
- CCTK_RegisterIOMethodTriggerOutput (i, IOFlexIO_TriggerOutput2D);
+ /* the 2D I/O method will only be registered if there are any
+ 2D (or higher dimensional) grid variables defined by thorns */
+ maxdim = CCTK_MaxDim ();
+ if (maxdim >= 2)
+ {
+ i = CCTK_RegisterIOMethod ("IOFlexIO_2D");
+ CCTK_RegisterIOMethodOutputGH (i, IOFlexIO_Output2DGH);
+ CCTK_RegisterIOMethodOutputVarAs (i, IOFlexIO_Output2DVarAs);
+ CCTK_RegisterIOMethodTimeToOutput (i, IOFlexIO_TimeFor2D);
+ CCTK_RegisterIOMethodTriggerOutput (i, IOFlexIO_TriggerOutput2D);
+ }
i = CCTK_RegisterIOMethod ("IOFlexIO");
CCTK_RegisterIOMethodOutputGH (i, IOFlexIO_OutputGH);
@@ -240,11 +246,11 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
/* allocate a new GH extension structure */
numvars = CCTK_NumVars ();
- myGH = (flexioGH *) malloc (sizeof (flexioGH));
- myGH->requests = (ioRequest **) calloc (numvars, sizeof (ioRequest *));
- myGH->out2D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
- myGH->out_last = (int *) malloc (numvars * sizeof (int));
- myGH->out2D_last = (int *) malloc (numvars * sizeof (int));
+ myGH = malloc (sizeof (flexioGH));
+ myGH->requests = calloc (numvars, sizeof (ioRequest *));
+ myGH->out2D_every = malloc (numvars * sizeof (CCTK_INT));
+ myGH->out_last = malloc (numvars * sizeof (int));
+ myGH->out2D_last = malloc (numvars * sizeof (int));
myGH->out_vars = strdup ("");
myGH->out_every_default = out_every - 1;
@@ -256,21 +262,24 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
myGH->out_dir = strdup (*out_dir ? out_dir : io_out_dir);
/* create the output directories */
- ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
- i = IOUtil_CreateDirectory (GH, myGH->out2D_dir,
- ! CCTK_Equals (out_mode, "onefile"),
- ioUtilGH->ioproc);
- if (i < 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOFlexIO_InitGH: problem creating IOFlexIO 2D output"
- " directory '%s'", myGH->out2D_dir);
- }
- else if (i > 0 && CCTK_Equals (verbose, "full"))
+ ioUtilGH = CCTK_GHExtension (GH, "IO");
+ if (maxdim >= 2)
{
- CCTK_VInfo (CCTK_THORNSTRING,
- "IOFlexIO_InitGH: 2D IOFlexIO output directory '%s' "
- "already exists", myGH->out2D_dir);
+ i = IOUtil_CreateDirectory (GH, myGH->out2D_dir,
+ ! CCTK_Equals (out_mode, "onefile"),
+ ioUtilGH->ioproc);
+ if (i < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOFlexIO_InitGH: problem creating IOFlexIO 2D output"
+ " directory '%s'", myGH->out2D_dir);
+ }
+ else if (i > 0 && CCTK_Equals (verbose, "full"))
+ {
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "IOFlexIO_InitGH: 2D IOFlexIO output directory '%s' "
+ "already exists", myGH->out2D_dir);
+ }
}
i = IOUtil_CreateDirectory (GH, myGH->out_dir,
! CCTK_Equals (out_mode, "onefile"),