aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/OutputInfo.c26
-rw-r--r--src/OutputScalar.c50
-rw-r--r--src/Startup.c89
-rw-r--r--src/WriteScalar.c12
-rw-r--r--src/iobasicGH.h2
5 files changed, 71 insertions, 108 deletions
diff --git a/src/OutputInfo.c b/src/OutputInfo.c
index 5bc12b1..8a813c2 100644
--- a/src/OutputInfo.c
+++ b/src/OutputInfo.c
@@ -196,29 +196,25 @@ int IOBasic_TimeForInfoOutput (const cGH *GH, int vindex)
DECLARE_CCTK_PARAMETERS
- /* get the GH extensions for IOBasic */
- myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
-
/* check if steerable parameters changed */
+ myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
CheckSteerableParameters (myGH);
- /* return if no output requested */
- if (myGH->outInfo_every <= 0 || GH->cctk_iteration % myGH->outInfo_every ||
- myGH->info_reductions[vindex].num_reductions == 0)
- {
- retval = 0;
- }
- else
+ /* check if this variable should be output */
+ retval = myGH->outInfo_every > 0 &&
+ GH->cctk_iteration % myGH->outInfo_every &&
+ myGH->info_reductions[vindex].num_reductions > 0;
+ if (retval)
{
- /* check if not already output this iteration */
- retval = myGH->outInfo_last[vindex] != GH->cctk_iteration;
- if (! retval)
+ /* check if variable was not already output this iteration */
+ if (myGH->outInfo_last[vindex] == GH->cctk_iteration)
{
fullname = CCTK_FullName (vindex);
CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
"Already done Info output for '%s' in current iteration "
"(probably via triggers)", fullname);
free (fullname);
+ retval = 0;
}
}
@@ -317,7 +313,7 @@ static void CheckSteerableParameters (iobasicGH *myGH)
myGH->outInfo_every = outInfo_every >= 0 ? outInfo_every : out_every;
/* report if frequency changed */
- if (myGH->outInfo_every != out_old && ! CCTK_Equals (newverbose, "none"))
+ if (myGH->outInfo_every != out_old && ! CCTK_Equals (verbose, "none"))
{
if (myGH->outInfo_every > 0)
{
@@ -417,7 +413,7 @@ static void PrintHeader (iobasicGH *myGH, int num_vars)
num_columns += myGH->info_reductions[vindex].num_reductions;
if (myGH->info_reductions[vindex].num_reductions > 0 &&
- ! CCTK_Equals (newverbose, "none"))
+ ! CCTK_Equals (verbose, "none"))
{
fullname = CCTK_FullName (vindex);
if (! msg)
diff --git a/src/OutputScalar.c b/src/OutputScalar.c
index 20c2695..b336f49 100644
--- a/src/OutputScalar.c
+++ b/src/OutputScalar.c
@@ -54,48 +54,31 @@ static void CheckSteerableParameters (iobasicGH *myGH);
int IOBasic_ScalarOutputGH (const cGH *GH)
{
int vindex, retval;
- const char *name;
iobasicGH *myGH;
- /* Get the GH extensions for IOBasic */
myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
-
CheckSteerableParameters (myGH);
- /* Return if no output is required */
+ /* return if no output is required */
if (myGH->outScalar_every <= 0)
{
return (0);
}
- /* Loop over all variables */
- for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
- {
- /* Is it time for output ? */
- if (! IOBasic_TimeForScalarOutput (GH, vindex))
- {
- continue;
- }
-
- /* Get the variable name for this index (for filename) */
- name = CCTK_VarName (vindex);
+ retval = 0;
-#ifdef IOBASIC_DEBUG
- printf("\nIn IOBasic_ScalarOutputGH\n----------------\n");
- printf(" Index = %d\n",vindex);
- printf(" Variable = -%s-\n",name);
- printf(" Last output iteration was = %d\n",myGH->outScalar_last[vindex]);
-#endif
-
- /* Make the IO call */
- if (IOBasic_WriteScalar (GH, vindex, name) == 0)
+ /* loop over all variables */
+ for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--)
+ {
+ if (IOBasic_TimeForScalarOutput (GH, vindex) &&
+ IOBasic_WriteScalar (GH, vindex, CCTK_VarName (vindex)) == 0)
{
- /* Register GF as having 0D output this iteration */
- myGH->outScalar_last [vindex] = GH->cctk_iteration;
+ /* register variable as having output this iteration */
+ myGH->outScalar_last[vindex] = GH->cctk_iteration;
retval++;
}
- } /* end of loop over all variables */
+ }
return (retval);
}
@@ -147,7 +130,7 @@ int IOBasic_TimeForScalarOutput (const cGH *GH, int vindex)
else
{
/* Check if variable wasn't already output this iteration */
- retval = myGH->outScalar_last [vindex] != GH->cctk_iteration;
+ retval = myGH->outScalar_last[vindex] != GH->cctk_iteration;
if (! retval)
{
fullname = CCTK_FullName (vindex);
@@ -205,13 +188,12 @@ int IOBasic_TriggerScalarOutput (const cGH *GH, int vindex)
printf (" Variable = -%s-\n", name);
#endif
- /* Do the Scalar output */
+ /* do the Scalar output */
retval = IOBasic_WriteScalar (GH, vindex, name);
-
if (retval == 0)
{
- /* Register variable as having Scalar output this iteration */
- myGH->outScalar_last [vindex] = GH->cctk_iteration;
+ /* register variable as having Scalar output this iteration */
+ myGH->outScalar_last[vindex] = GH->cctk_iteration;
}
return (retval);
@@ -255,7 +237,7 @@ static void CheckSteerableParameters (iobasicGH *myGH)
myGH->outScalar_every = outScalar_every >= 0 ? outScalar_every : out_every;
/* report if frequency changed */
- if (myGH->outScalar_every != out_old && ! CCTK_Equals (newverbose, "none"))
+ if (myGH->outScalar_every != out_old && ! CCTK_Equals (verbose, "none"))
{
if (myGH->outScalar_every > 0)
{
@@ -313,7 +295,7 @@ static void CheckSteerableParameters (iobasicGH *myGH)
{
CCTK_WARN (1, "Failed to parse 'IOBasic::outScalar_vars' parameter");
}
- else if (! CCTK_Equals (newverbose, "none"))
+ else if (! CCTK_Equals (verbose, "none"))
{
msg = NULL;
for (vindex = 0; vindex < num_vars; vindex++)
diff --git a/src/Startup.c b/src/Startup.c
index 3821d86..ab26165 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -8,7 +8,6 @@
@version $Id$
@@*/
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
@@ -28,12 +27,11 @@ CCTK_FILEVERSION(CactusBase_IOBasic_Startup_c)
********************************************************************/
void IOBasic_Startup (void);
+
/********************************************************************
******************** Internal Routines ************************
********************************************************************/
-static void *IOBasic_SetupGH (tFleshConfig *config,
- int convergence_level,
- cGH *GH);
+static void *IOBasic_SetupGH (tFleshConfig *config, int conv_level, cGH *GH);
/*@@
@@ -82,7 +80,7 @@ void IOBasic_Startup (void)
@vtype tFleshConfig *
@vio unused
@endvar
- @var convergence_level
+ @var conv_level
@vdesc the convergence level
@vtype int
@vio unused
@@ -98,23 +96,21 @@ void IOBasic_Startup (void)
pointer to the allocated GH extension structure
@endreturndesc
@@*/
-static void *IOBasic_SetupGH (tFleshConfig *config,
- int convergence_level,
- cGH *GH)
+static void *IOBasic_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
{
- DECLARE_CCTK_PARAMETERS
int i;
- iobasicGH *newGH;
+ iobasicGH *myGH;
+ DECLARE_CCTK_PARAMETERS
- /* suppress compiler warnings about unused variables */
- config = config;
- convergence_level = convergence_level;
- GH = GH;
+ /* suppress compiler warnings about unused parameters */
+ (void) (config + 0);
+ (void) (conv_level + 0);
+ (void) (GH + 0);
/* allocate the GH extension and its components */
- newGH = (iobasicGH *) malloc (sizeof (iobasicGH));
- if (newGH)
+ myGH = (iobasicGH *) malloc (sizeof (iobasicGH));
+ if (myGH)
{
/* Register the IOBasic routines as output methods */
i = CCTK_RegisterIOMethod ("Scalar");
@@ -127,7 +123,7 @@ static void *IOBasic_SetupGH (tFleshConfig *config,
CCTK_RegisterIOMethodTimeToOutput (i, IOBasic_TimeForInfoOutput);
CCTK_RegisterIOMethodTriggerOutput (i, IOBasic_TriggerInfoOutput);
- if (! CCTK_Equals (newverbose, "none"))
+ if (! CCTK_Equals (verbose, "none"))
{
CCTK_INFO ("I/O Method 'Scalar' registered");
CCTK_INFO ("Scalar: Output of scalar quantities (grid scalars, "
@@ -139,68 +135,57 @@ static void *IOBasic_SetupGH (tFleshConfig *config,
i = CCTK_NumVars ();
- newGH->info_reductions = (iobasic_reductionlist_t *)
+ myGH->info_reductions = (iobasic_reductionlist_t *)
calloc (2 * i, sizeof (iobasic_reductionlist_t));
- newGH->scalar_reductions = newGH->info_reductions + i;
- newGH->outInfo_last = (int *) malloc (2 * i * sizeof (int));
- newGH->outScalar_last = newGH->outInfo_last + i;
+ myGH->scalar_reductions = myGH->info_reductions + i;
+ myGH->outInfo_last = (int *) malloc (2 * i * sizeof (int));
+ myGH->outScalar_last = myGH->outInfo_last + i;
- memset (newGH->outInfo_last, -1, 2 * i * sizeof (int));
+ memset (myGH->outInfo_last, -1, 2 * i * sizeof (int));
- newGH->filenameListScalar = NULL;
+ myGH->filenameListScalar = NULL;
- /* Check whether "IOBasic::outdir" was set.
- If so take this dir otherwise default to "IO::outdir" */
- if (CCTK_ParameterQueryTimesSet ("outdir", CCTK_THORNSTRING) > 0 ||
- CCTK_ParameterQueryTimesSet ("outdirScalar", CCTK_THORNSTRING) > 0)
+ /* get the name of IOBasic's output directory */
+ if (*out_dir == 0)
{
- if (CCTK_ParameterQueryTimesSet ("outdir", CCTK_THORNSTRING) <= 0)
- {
- CCTK_WARN (1, "Parameter 'IOBasic::outdirScalar is depricated in "
- "BETA12, please use 'IOBasic::outdir' instead");
- outdir = outdirScalar;
- }
- }
- else
- {
- outdir = *(const char **)
- CCTK_ParameterGet ("outdir", CCTK_ImplementationThorn ("IO"), &i);
+ out_dir = *(const char **)
+ CCTK_ParameterGet ("out_dir", CCTK_ImplementationThorn ("IO"),
+ NULL);
}
/* skip the directory pathname if output goes into current directory */
- if (strcmp (outdir, "."))
+ if (strcmp (out_dir, "."))
{
- i = strlen (outdir);
- newGH->outdir = (char *) malloc (i + 2);
- strcpy (newGH->outdir, outdir);
- newGH->outdir[i] = '/';
- newGH->outdir[i+1] = 0;
+ i = strlen (out_dir);
+ myGH->out_dir = (char *) malloc (i + 2);
+ strcpy (myGH->out_dir, out_dir);
+ myGH->out_dir[i] = '/';
+ myGH->out_dir[i+1] = 0;
}
else
{
- newGH->outdir = "";
+ myGH->out_dir = strdup ("");
}
/* create the output dir */
- if (*newGH->outdir && CCTK_MyProc (GH) == 0)
+ if (*myGH->out_dir && CCTK_MyProc (GH) == 0)
{
- i = IOUtil_CreateDirectory (GH, newGH->outdir, 0, 0);
+ i = IOUtil_CreateDirectory (GH, myGH->out_dir, 0, 0);
if (i < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOBasic_SetupGH: Couldn't create Scalar output directory "
- "'%s'", newGH->outdir);
+ "'%s'", myGH->out_dir);
}
- else if (i >= 0 && CCTK_Equals (newverbose, "full"))
+ else if (i >= 0 && CCTK_Equals (verbose, "full"))
{
CCTK_VInfo (CCTK_THORNSTRING, "Scalar: Output to directory '%s'",
- newGH->outdir);
+ myGH->out_dir);
}
-
}
}
- return (newGH);
+ return (myGH);
}
diff --git a/src/WriteScalar.c b/src/WriteScalar.c
index e2856bf..118b48b 100644
--- a/src/WriteScalar.c
+++ b/src/WriteScalar.c
@@ -190,10 +190,10 @@ static int IOBasic_WriteScalarGA (const cGH *GH, int vindex, const char *alias)
if (new_filename_scheme)
{
/* allocate filename string buffer and build the filename */
- filename = (char *) malloc (strlen (myGH->outdir) +
+ filename = (char *) malloc (strlen (myGH->out_dir) +
strlen (alias) + strlen (reduction->name) +
strlen (file_extension) + 2);
- sprintf (filename, "%s%s_%s%s", myGH->outdir, alias,
+ sprintf (filename, "%s%s_%s%s", myGH->out_dir, alias,
reduction->name, file_extension);
}
else
@@ -221,9 +221,9 @@ static int IOBasic_WriteScalarGA (const cGH *GH, int vindex, const char *alias)
}
/* allocate filename string buffer and build the filename */
- filename = (char *) malloc (strlen (myGH->outdir) +
+ filename = (char *) malloc (strlen (myGH->out_dir) +
strlen (alias) + strlen (file_extension)+5);
- sprintf (filename, "%s%s_%s.tl", myGH->outdir, alias,
+ sprintf (filename, "%s%s_%s.tl", myGH->out_dir, alias,
file_extension);
}
@@ -321,9 +321,9 @@ static int IOBasic_WriteScalarGS (const cGH *GH, int vindex, const char *alias)
}
/* build the output filename */
- filename = (char *) malloc (strlen (myGH->outdir) + strlen (alias) +
+ filename = (char *) malloc (strlen (myGH->out_dir) + strlen (alias) +
strlen (file_extension) + 1);
- sprintf (filename, "%s%s%s", myGH->outdir, alias, file_extension);
+ sprintf (filename, "%s%s%s", myGH->out_dir, alias, file_extension);
/* create/reopen the file */
file = OpenScalarFile (GH, vindex, filename, "tl", "Scalar value", alias);
diff --git a/src/iobasicGH.h b/src/iobasicGH.h
index e957a00..573ccdf 100644
--- a/src/iobasicGH.h
+++ b/src/iobasicGH.h
@@ -39,7 +39,7 @@ typedef struct IOBASIC_GH
char info_reductions_changed;
/* directory in which to place scalar output */
- char *outdir;
+ char *out_dir;
/* The last iteration output */
int *outInfo_last, *outScalar_last;