aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2002-05-06 09:12:21 +0000
committertradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2002-05-06 09:12:21 +0000
commit7a1ae55dcd0f351822346df6ecdd4c5312d1a747 (patch)
tree84a165d179bddf953e1bfacd923961ee4f8a5345 /src
parentb4c1653f2660198eabb89c7030b4597769f23997 (diff)
Parameter names changes as announced in today's mail to users@cactuscode.org.
You must also update thorn IOUtil now. git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@69 eff87b29-5268-4891-90a3-a07138403961
Diffstat (limited to 'src')
-rw-r--r--src/ChooseOutput.c24
-rw-r--r--src/Output.c63
-rw-r--r--src/Startup.c26
-rw-r--r--src/Write.c6
-rw-r--r--src/ioJpegGH.h2
5 files changed, 50 insertions, 71 deletions
diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c
index efbe83c..7366fa7 100644
--- a/src/ChooseOutput.c
+++ b/src/ChooseOutput.c
@@ -31,25 +31,10 @@ CCTK_FILEVERSION(CactusIO_IOJpeg_ChooseOutput_c)
3. Coords from IOJpeg
4. Coords from IOUtil
*/
-#define GET_SLICE(IOJpeg_param, IOUtil_param, origin_index, origin_phys) \
+#define GET_SLICE(IOJpeg_param, IOUtil_param, index, coord) \
{ \
- origin_index = -1; \
- if (CCTK_ParameterQueryTimesSet (#IOJpeg_param "i", "IOJpeg") > 0)\
- { \
- origin_index = IOJpeg_param##i; \
- } \
- else if (CCTK_ParameterQueryTimesSet (#IOUtil_param "i", "IOUtil")>0)\
- { \
- origin_index = IOUtil_param##i; \
- } \
- else if (CCTK_ParameterQueryTimesSet (#IOJpeg_param, "IOJpeg") > 0)\
- { \
- origin_phys = IOJpeg_param; \
- } \
- else \
- { \
- origin_phys = IOUtil_param; \
- } \
+ index = IOJpeg_param##i >= 0 ? IOJpeg_param##i : IOUtil_param##i; \
+ coord = IOJpeg_param != -424242 ? IOJpeg_param : IOUtil_param; \
}
@@ -67,8 +52,7 @@ void IOJpeg_ChooseOutput (const cGH *GH);
Use parameters to choose the 2D slices through the output data.
@enddesc
- @calls CCTK_ParameterQueryTimesSet
- IOUtil_2DPlanes
+ @calls IOUtil_2DPlanes
@var GH
@vdesc Pointer to CCTK grid hierarchy
diff --git a/src/Output.c b/src/Output.c
index 42f4333..214ec12 100644
--- a/src/Output.c
+++ b/src/Output.c
@@ -43,7 +43,7 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg);
IOJpeg_Write
@var GH
- @vdesc Pointer to CCTK GH
+ @vdesc pointer to CCTK GH
@vtype const cGH *
@vio in
@endvar
@@ -57,22 +57,17 @@ static void SetOutputFlag (int vindex, const char *optstring, void *arg);
int IOJpeg_OutputGH (const cGH *GH)
{
int vindex, retval;
- ioJpegGH *myGH;
+ const ioJpegGH *myGH;
- myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
+ retval = 0;
+ myGH = (const ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
/* loop over all variables */
- for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++)
+ for (vindex = CCTK_NumVars () - 1; vindex >= 0; vindex--)
{
- /* check if this variable should be output */
- if (! IOJpeg_TimeFor (GH, vindex))
- {
- continue;
- }
-
- /* do the output */
- if (IOJpeg_Write (GH, vindex, CCTK_VarName (vindex)) == 0)
+ if (IOJpeg_TimeFor (GH, vindex) &&
+ IOJpeg_Write (GH, vindex, CCTK_VarName (vindex)) == 0)
{
/* register variable as having output this iteration */
myGH->out_last[vindex] = GH->cctk_iteration;
@@ -94,7 +89,7 @@ int IOJpeg_OutputGH (const cGH *GH)
@calls IOJpeg_Write
@var GH
- @vdesc Pointer to CCTK GH
+ @vdesc pointer to CCTK GH
@vtype const cGH *
@vio in
@endvar
@@ -143,7 +138,7 @@ int IOJpeg_OutputVarAs (const cGH *GH, const char *fullname, const char *alias)
@enddesc
@var GH
- @vdesc Pointer to CCTK GH
+ @vdesc pointer to CCTK GH
@vtype const cGH *
@vio in
@endvar
@@ -162,19 +157,17 @@ int IOJpeg_OutputVarAs (const cGH *GH, const char *fullname, const char *alias)
int IOJpeg_TimeFor (const cGH *GH, int vindex)
{
int result;
- ioJpegGH *myGH;
char *fullname;
+ ioJpegGH *myGH;
- /* default is not do any output */
- result = 0;
-
myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
CheckSteerableParameters (myGH);
/* check if this variable should be output */
- if (myGH->out_every[vindex] > 0 &&
- GH->cctk_iteration % myGH->out_every[vindex] == 0)
+ result = myGH->out_every[vindex] > 0 &&
+ GH->cctk_iteration % myGH->out_every[vindex] == 0;
+ if (result)
{
/* check if variable wasn't already output this iteration */
if (myGH->out_last[vindex] == GH->cctk_iteration)
@@ -184,10 +177,7 @@ int IOJpeg_TimeFor (const cGH *GH, int vindex)
"Already done IOJpeg output for '%s' in current "
"iteration (probably via triggers)", fullname);
free (fullname);
- }
- else
- {
- result = 1;
+ result = 0;
}
}
@@ -205,7 +195,7 @@ int IOJpeg_TimeFor (const cGH *GH, int vindex)
@calls IOJpeg_Write
@var GH
- @vdesc Pointer to CCTK GH
+ @vdesc pointer to CCTK GH
@vtype const cGH *
@vio in
@endvar
@@ -230,7 +220,7 @@ int IOJpeg_TriggerOutput (const cGH *GH, int vindex)
retval = IOJpeg_Write (GH, vindex, CCTK_VarName (vindex));
if (retval == 0)
{
- /* register variables as having output this iteration */
+ /* register variable as having output this iteration */
myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
myGH->out_last[vindex] = GH->cctk_iteration;
}
@@ -250,10 +240,15 @@ static void CheckSteerableParameters (ioJpegGH *myGH)
/* how often to output */
i = myGH->out_every_default;
- myGH->out_every_default = out2D_every >= 0 ? out2D_every : out_every;
+ myGH->out_every_default = out_every;
+ if (myGH->out_every_default < 0)
+ {
+ myGH->out_every_default = *(const CCTK_INT *)
+ CCTK_ParameterGet ("out_every", CCTK_ImplementationThorn ("IO"), NULL);
+ }
/* report if frequency changed */
- if (myGH->out_every_default != i && ! CCTK_Equals (newverbose, "none"))
+ if (myGH->out_every_default != i && ! CCTK_Equals (verbose, "none"))
{
if (myGH->out_every_default > 0)
{
@@ -266,14 +261,14 @@ static void CheckSteerableParameters (ioJpegGH *myGH)
}
}
- /* re-parse the 'out2D_vars' parameter if it was changed */
- if (strcmp (out2D_vars, myGH->out_vars) || myGH->out_every_default != i)
+ /* re-parse the 'IOJpeg::out_vars' parameter if it was changed */
+ if (strcmp (out_vars, myGH->out_vars) || myGH->out_every_default != i)
{
num_vars = CCTK_NumVars ();
memset (myGH->out_every, 0, num_vars * sizeof (int));
- CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
+ CCTK_TraverseString (out_vars, SetOutputFlag, myGH, CCTK_GROUP_OR_VAR);
- if (myGH->out_every_default == i || ! CCTK_Equals (newverbose, "none"))
+ if (myGH->out_every_default == i || ! CCTK_Equals (verbose, "none"))
{
msg = NULL;
for (i = 0; i < num_vars; i++)
@@ -300,9 +295,9 @@ static void CheckSteerableParameters (ioJpegGH *myGH)
}
}
- /* save the last setting of 'out2D_vars' parameter */
+ /* save the last setting of 'IOJpeg::out_vars' parameter */
free (myGH->out_vars);
- myGH->out_vars = strdup (out2D_vars);
+ myGH->out_vars = strdup (out_vars);
}
}
diff --git a/src/Startup.c b/src/Startup.c
index 50b82ea..d7406c0 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -118,7 +118,7 @@ static void *IOJpeg_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
CCTK_RegisterIOMethodTimeToOutput (i, IOJpeg_TimeFor);
CCTK_RegisterIOMethodTriggerOutput (i, IOJpeg_TriggerOutput);
- if (! CCTK_Equals (newverbose, "none"))
+ if (! CCTK_Equals (verbose, "none"))
{
CCTK_INFO ("I/O Method 'IOJpeg' registered");
CCTK_INFO ("IOJpeg: Output of 2D jpeg images of grid functions/arrays");
@@ -136,36 +136,36 @@ static void *IOJpeg_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
myGH->out_vars = strdup ("");
myGH->out_every_default = out_every - 1;
- /* Check whether "out2D_dir" was set.
- If so take this dir otherwise default to "IO::outdir" */
- if (*out2D_dir == 0)
+ /* get the name for IOJpeg's output directory */
+ if (*out_dir == 0)
{
- out2D_dir = outdir;
+ out_dir = *(const char **)
+ CCTK_ParameterGet ("out_dir", CCTK_ImplementationThorn ("IO"), NULL);
}
/* omit the directory if it's the current working dir */
- if (strcmp (out2D_dir, ".") == 0)
+ if (strcmp (out_dir, ".") == 0)
{
- myGH->outdir = strdup ("");
+ myGH->out_dir = strdup ("");
}
else
{
- myGH->outdir = (char *) malloc (strlen (out2D_dir) + 2);
- sprintf (myGH->outdir, "%s/", out2D_dir);
+ myGH->out_dir = (char *) malloc (strlen (out_dir) + 2);
+ sprintf (myGH->out_dir, "%s/", out_dir);
}
/* create the output dir */
- i = IOUtil_CreateDirectory (GH, myGH->outdir, 0, 0);
+ i = IOUtil_CreateDirectory (GH, myGH->out_dir, 0, 0);
if (i < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOJpeg_SetupGH: problem creating IOJpeg output directory '%s'",
- myGH->outdir);
+ myGH->out_dir);
}
- else if (i >= 0 && CCTK_Equals (newverbose, "full"))
+ else if (i >= 0 && CCTK_Equals (verbose, "full"))
{
CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg: Output to directory '%s'",
- myGH->outdir);
+ myGH->out_dir);
}
return (myGH);
diff --git a/src/Write.c b/src/Write.c
index 4c6ffb1..531e49d 100644
--- a/src/Write.c
+++ b/src/Write.c
@@ -262,16 +262,16 @@ static void WriteData (const cGH *GH, int vindex, const char *alias, int dim,
sprintf (slicename, "%s_[%d]", extensions[dir], myGH->sp2xyz[dim-1][dir]);
}
- filename = (char *) malloc (strlen (myGH->outdir) + strlen (alias) +
+ filename = (char *) malloc (strlen (myGH->out_dir) + strlen (alias) +
sizeof (slicename) + 20);
if (CCTK_Equals (mode, "remove"))
{
- sprintf (filename, "%s%s_%s.jpeg", myGH->outdir, alias, slicename);
+ sprintf (filename, "%s%s_%s.jpeg", myGH->out_dir, alias, slicename);
}
else
{
- sprintf (filename, "%s%s_%s.it_%d.jpeg", myGH->outdir, alias, slicename,
+ sprintf (filename, "%s%s_%s.it_%d.jpeg", myGH->out_dir, alias, slicename,
GH->cctk_iteration);
}
diff --git a/src/ioJpegGH.h b/src/ioJpegGH.h
index 917291e..2f3d849 100644
--- a/src/ioJpegGH.h
+++ b/src/ioJpegGH.h
@@ -31,7 +31,7 @@ typedef struct IOJpegGH
char *out_vars;
/* directories in which to output */
- char *outdir;
+ char *out_dir;
/* for 2D planes, we define the index where to locate the plane
sp2xyz[maxdim][perpendicular direction] */