From 7a1ae55dcd0f351822346df6ecdd4c5312d1a747 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 6 May 2002 09:12:21 +0000 Subject: 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 --- par/jpeg.par | 8 ++--- param.ccl | 94 ++++++++++++++++++++++++++++++++++-------------------- src/ChooseOutput.c | 24 +++----------- src/Output.c | 63 +++++++++++++++++------------------- src/Startup.c | 26 +++++++-------- src/Write.c | 6 ++-- src/ioJpegGH.h | 2 +- 7 files changed, 114 insertions(+), 109 deletions(-) diff --git a/par/jpeg.par b/par/jpeg.par index a04a448..a4a5ace 100644 --- a/par/jpeg.par +++ b/par/jpeg.par @@ -13,14 +13,14 @@ ActiveThorns = "httpd httpdextra IOJpeg boundary time wavetoyc pugh pughslab pughreduce cartgrid3d ioutil ioascii iobasic idscalarwavec wavebinarysource jpeg6b" -IOJpeg::out2d_vars = "wavetoy::phi" +IOJpeg::out_vars = "wavetoy::phi" IOJpeg::mode = "remove" -IOJpeg::out2d_every = 5 +IOJpeg::out_every = 5 IOJpeg::colormap = "auto" IOJpeg::colormap_min = 0.4 IOJpeg::colormap_max = 1.2 IOJpeg::colormap_factor = 16 -IOJpeg::out2D_dir = "jpeg/JPEGS" +IOJpeg::out_dir = "jpeg/JPEGS" time::dtfac = 0.25 @@ -48,7 +48,7 @@ cactus::terminate = "time" cactus::cctk_final_time = 50000000 IO::out_every = 0 -IO::outdir = "jpeg" +IO::out_dir = "jpeg" IOBasic::outInfo_every = 1 IOBasic::outInfo_vars = "wavetoy::phi" diff --git a/param.ccl b/param.ccl index d8dfc53..7dc3157 100644 --- a/param.ccl +++ b/param.ccl @@ -12,19 +12,39 @@ private: # for which variables # into which output directory ######################## -INT out2D_every "How often to do output, overrides IO::out_every" STEERABLE = ALWAYS +INT out_every "How often to do IOJpeg output, overrides IO::out_every" STEERABLE = ALWAYS { - -1:* :: "Every so many iterations, values <= 0 disable IOJpeg output" + 1:* :: "Every so many iterations" + 0: :: "Disable IOJpeg output" + -1: :: "Choose the default from IO::out_every" +} -1 +INT out2D_every "How often to do IOJpeg output, overrides IO::out_every (DEPRICATED IN BETA13)" STEERABLE = ALWAYS +{ + 1:* :: "Every so many iterations" + 0: :: "Disable IOJpeg output" + -1: :: "Choose the default from IO::out_every" } -1 -STRING out2D_vars "Variables to output as JPEGs" STEERABLE = ALWAYS +STRING out_vars "Variables to output by IOJpeg" STEERABLE = ALWAYS { - .* :: "A regex which matches everything" + ".+" :: "Space-separated list of fully qualified variable/group names" + "^$" :: "An empty string to output nothing" +} "" +STRING out2D_vars "Variables to output by IOJpeg (DEPRICATED IN BETA13)" STEERABLE = ALWAYS +{ + ".+" :: "Space-separated list of fully qualified variable/group names" + "^$" :: "An empty string to output nothing" } "" -STRING out2D_dir "Name of IOJpeg output directory, overrides IO::outdir" +STRING out_dir "Output directory for IOJpeg files, overrides IO::out_dir" STEERABLE = RECOVER +{ + ".+" :: "A valid directory name" + "^$" :: "An empty string to choose the default from IO::out_dir" +} "" +STRING out2D_dir "Output directory for IOJpeg files, overrides IO::out_dir (DEPRECATED IN BETA13)" STEERABLE = RECOVER { - .* :: "Any valid directory name, an empty string defaults to outdir" + ".+" :: "A valid directory name" + "^$" :: "An empty string to choose the default from IO::out_dir" } "" KEYWORD mode "Output mode to use" STEERABLE = ALWAYS @@ -71,30 +91,37 @@ REAL colormap_max "maximum value to be mapped to colors" STEERABLE = ALWAYS ################################ # Choosing what planes to output ################################ -CCTK_REAL out2D_yzplane_x "x-coord for 2D planes in yz" +REAL out2D_yzplane_x "x-coord for 2D planes in yz" STEERABLE = RECOVER { - *:* :: "" -} 0.0 -CCTK_REAL out2D_xzplane_y "y-coord for 2D planes in xz" + *:* :: "A value between [xmin, xmax]" + -424242: :: "Default to IO::out_yzplane_x" +} -424242 +REAL out2D_xzplane_y "y-coord for 2D planes in xz" STEERABLE = RECOVER { - *:* :: "" -} 0.0 -CCTK_REAL out2D_xyplane_z "z-coord for 2D planes in xy" + *:* :: "A value between [ymin, ymax]" + -424242: :: "Default to IO::out_xzplane_y" +} -424242 +REAL out2D_xyplane_z "z-coord for 2D planes in xy" STEERABLE = RECOVER { - *:* :: "" -} 0.0 -CCTK_INT out2D_xyplane_zi "z-index (from 0) for 2D planes in xy" + *:* :: "A value between [zmin, zmax]" + -424242: :: "Default to IO::out_xyplane_z" +} -424242 + +INT out2D_yzplane_xi "x-index (from 0) for 2D planes in yz" STEERABLE = RECOVER { - 0:* :: "" -} 0 -CCTK_INT out2D_xzplane_yi "y-index (from 0) for 2D planes in xz" + 0:* :: "An index between [0, nx)" + -1: :: "Choose the default from IO::out_yzplane_xi" +} -1 +INT out2D_xzplane_yi "y-index (from 0) for 2D planes in xz" STEERABLE = RECOVER { - 0:* :: "" -} 0 -CCTK_INT out2D_yzplane_xi "x-index (from 0) for 2D planes in yz" + 0:* :: "An index between [0, ny)" + -1: :: "Choose the default from IO::out_xzplane_yi" +} -1 +INT out2D_xyplane_zi "z-index (from 0) for 2D planes in xy" STEERABLE = RECOVER { - 0:* :: "" -} 0 + 0:* :: "An index between [0, nz)" + -1: :: "Choose the default from IO::out_xyplane_zi" +} -1 ############################################################################# @@ -102,13 +129,12 @@ CCTK_INT out2D_yzplane_xi "x-index (from 0) for 2D planes in yz" ############################################################################# shares: IO -USES INT out_every -USES STRING outdir -USES BOOLEAN verbose -USES KEYWORD newverbose -USES CCTK_REAL out_yzplane_x -USES CCTK_REAL out_xzplane_y -USES CCTK_REAL out_xyplane_z -USES CCTK_INT out_xyplane_zi -USES CCTK_INT out_xzplane_yi -USES CCTK_INT out_yzplane_xi +#FIXME: want USES STRING out_dir AS default_out_dir +#FIXME: want USES INT out_every AS default_out_every +USES KEYWORD verbose +USES REAL out_yzplane_x +USES REAL out_xzplane_y +USES REAL out_xyplane_z +USES INT out_yzplane_xi +USES INT out_xzplane_yi +USES INT out_xyplane_zi 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] */ -- cgit v1.2.3