aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2000-09-21 14:02:08 +0000
committertradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2000-09-21 14:02:08 +0000
commit57ae482b470d367d66ea3fd47c0f094078584780 (patch)
tree2fca4fb106d734bb6f78ccfc19f4c47574284863
parentdd8258ecb8896aad2ccc92f9e8db680b7bd2bab0 (diff)
Removed ioGH.h from the include list.
Use CCTK_TraverseString() and the stuff from iotuil_*.h instead. git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@14 eff87b29-5268-4891-90a3-a07138403961
-rw-r--r--src/DumpVar.c38
-rw-r--r--src/GHExtension.c24
-rw-r--r--src/Output2D.c46
-rw-r--r--src/Startup.c1
-rw-r--r--src/Write2D.c114
5 files changed, 131 insertions, 92 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c
index c77c9d8..33ec428 100644
--- a/src/DumpVar.c
+++ b/src/DumpVar.c
@@ -4,12 +4,11 @@
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
#include "CactusPUGH/PUGHSlab/src/PUGHSlab.h"
#include "IOJpeg.h"
int IOJpeg_Output(cGH *GH, int index, int timelevel, CCTK_REAL *data,
- int sdim, int *hsize, int vtype, FILE *fid);
+ int sdim, int *hsize, int vtype, FILE *fid);
int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *fid)
@@ -59,7 +58,7 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
{
char *fullname = CCTK_FullName (index);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No 0-dim extraction possible: '%s'", fullname);
+ "No 0-dim extraction possible: '%s'", fullname);
free (fullname);
return (-1);
}
@@ -92,10 +91,10 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
if (fid)
{
if (IOJpeg_Output(GH, index, timelevel, data,
- geo->sdim, hsizes, vtype, fid)<0) {
+ geo->sdim, hsizes, vtype, fid)<0) {
char *fullname = CCTK_FullName (index);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOJpeg_Output failed for variable '%s'", fullname);
+ "IOJpeg_Output failed for variable '%s'", fullname);
free (fullname);
return (-1);
}
@@ -115,7 +114,7 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
int IOJpeg_Output(cGH *GH, int index, int timelevel, CCTK_REAL *data,
- int sdim, int *hsize, int vtype, FILE *fid)
+ int sdim, int *hsize, int vtype, FILE *fid)
{
DECLARE_CCTK_PARAMETERS
@@ -134,28 +133,27 @@ int IOJpeg_Output(cGH *GH, int index, int timelevel, CCTK_REAL *data,
int reduction_handle,ierr;
reduction_handle = CCTK_ReductionHandle ("maximum");
ierr = CCTK_Reduce (GH, 0, reduction_handle, 1,
- CCTK_VARIABLE_REAL,&max, 1, index);
+ CCTK_VARIABLE_REAL,&max, 1, index);
reduction_handle = CCTK_ReductionHandle ("minimum");
ierr = CCTK_Reduce (GH, 0, reduction_handle, 1,
- CCTK_VARIABLE_REAL,&min, 1, index);
+ CCTK_VARIABLE_REAL,&min, 1, index);
}
AutoColorDataSlice(hsize[0],
- hsize[1],
- data,
- dataout,
- min,
- max,
- colormap_bias,
- colormap_factor);
+ hsize[1],
+ data,
+ dataout,
+ min,
+ max,
+ colormap_bias,
+ colormap_factor);
WriteJPEGToFileRGB(hsize[0],
- hsize[1],
- dataout,
- colormap_quality,
- fid);
+ hsize[1],
+ dataout,
+ colormap_quality,
+ fid);
free(dataout);
return(1);
}
-
diff --git a/src/GHExtension.c b/src/GHExtension.c
index a82d359..e04724f 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -7,7 +7,6 @@
#include "cctk_Arguments.h"
#include "CactusPUGH/PUGH/src/include/pugh.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
#include "IOJpeg.h"
void IOJpeg_DefaultGeo(cGH *GH, int sdim, IOJpegGeo_t *geo);
@@ -26,7 +25,9 @@ void *IOJpeg_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
/* Allocate geometry structure for each grid variable/array */
newGH->out_geo = (IOJpegGeo_t**) malloc(SLABSKEL_MAXDIM * sizeof (IOJpegGeo_t));
for (iv=0;iv<numvars;iv++)
+ {
newGH->out_geo[iv] = (IOJpegGeo_t*) malloc(SLABSKEL_MAXDIM * sizeof (IOJpegGeo_t));
+ }
return (newGH);
}
@@ -37,14 +38,15 @@ int IOJpeg_InitGH (cGH *GH)
DECLARE_CCTK_PARAMETERS
int inum;
IOJpegGH *myGH;
- const cParamData *paramdata;
+
myGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
myGH->out2D_every = out_every > 0 ? out_every : -1;
if (out2D_every > 0)
+ {
myGH->out2D_every = out2D_every;
- IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D);
+ }
for (inum=0; inum<CCTK_NumVars(); inum++)
{
@@ -54,8 +56,7 @@ int IOJpeg_InitGH (cGH *GH)
/* Deal with the output directories */
/* Check whether "outdirXD" was set.
If so take this dir otherwise default to "IO::outdir" */
- paramdata = CCTK_ParameterData ("out2D_dir", CCTK_THORNSTRING);
- myGH->outdir2D = (paramdata && paramdata->n_set > 0) ?
+ myGH->outdir2D = CCTK_ParameterQueryTimesSet("out2D_dir",CCTK_THORNSTRING)>0 ?
strdup (out2D_dir) : strdup (outdir);
/* create the output dir */
@@ -67,17 +68,18 @@ int IOJpeg_InitGH (cGH *GH)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_InitGH: Problem creating 2D output directory '%s'",
- myGH->outdir2D);
+ myGH->outdir2D);
}
if (i > 0)
{
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOASCII_InitGH: 2D output directory '%s' already exists",
- myGH->outdir2D);
+ myGH->outdir2D);
}
}
myGH->fileList_2D = NULL;
+
return (0);
}
@@ -90,15 +92,19 @@ void IOJpeg_SliceCenterSetup(CCTK_ARGUMENTS)
IOJpegGeo_t geo_default;
IOJpegGH *myGH;
+
myGH = (IOJpegGH *) cctkGH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
/* Loop over all slab dimension */
- for (idim=0;idim<SLABSKEL_MAXDIM;idim++) {
+ for (idim = 0; idim < SLABSKEL_MAXDIM; idim++)
+ {
IOJpeg_DefaultGeo(cctkGH, idim, &geo_default);
/* Set the default HDF5 slab geometry for slab with dimension -idim-*/
- for (inum=0; inum<CCTK_NumVars(); inum++)
+ for (inum = 0; inum < CCTK_NumVars (); inum++)
+ {
myGH->out_geo[inum][idim] = geo_default;
+ }
}
}
diff --git a/src/Output2D.c b/src/Output2D.c
index f68e99c..1bd6ad0 100644
--- a/src/Output2D.c
+++ b/src/Output2D.c
@@ -20,7 +20,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
+#include "CactusBase/IOUtil/src/ioutil_Utils.h"
#include "IOJpeg.h"
@@ -29,6 +29,7 @@
int IOJpeg_TimeFor2D (cGH *GH, int index);
int IOJpeg_Output2DVarAs (cGH *GH, const char *var, const char *alias);
static void CheckSteerableParameters (IOJpegGH *myGH);
+static void SetOutputFlag (int index, const char *optstring, void *arg);
int IOJpeg_Output2DGH (cGH *GH)
@@ -46,7 +47,9 @@ int IOJpeg_Output2DGH (cGH *GH)
CheckSteerableParameters (myGH);
if (myGH->out2D_every <= 0)
+ {
return (0);
+ }
/* Loop over all variables */
for (i = 0; i < CCTK_NumVars (); i++)
@@ -59,8 +62,10 @@ int IOJpeg_Output2DGH (cGH *GH)
fullname = CCTK_FullName (i);
if (!CCTK_Equals(verbose,"no"))
+ {
CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_Output2DGH: fullname / name = "
"%s / %s", fullname, name);
+ }
ierr=IOJpeg_Output2DVarAs (GH, fullname, name);
@@ -71,7 +76,9 @@ int IOJpeg_Output2DGH (cGH *GH)
}
}
if (!CCTK_Equals(verbose,"no"))
+ {
CCTK_INFO("IOJpeg_Output2DGH Done");
+ }
return (ierr);
}
@@ -93,8 +100,10 @@ int IOJpeg_Output2DVarAs (cGH *GH, const char *fullname, const char *alias)
}
if (!CCTK_Equals(verbose,"no"))
+ {
CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_Output2DVarAs: fullname, alias, "
"index = (%s, %s, %d)", fullname, alias, index);
+ }
/* Do the 2D output */
ierr=IOJpeg_Write2D (GH, index, alias);
@@ -114,18 +123,22 @@ int IOJpeg_TimeFor2D (cGH *GH, int index)
/* Check if any output was requested */
if(myGH->out2D_every <= 0)
+ {
return (0);
+ }
/* Check this variable should be output */
if (! (myGH->do_out2D [index] && GH->cctk_iteration % myGH->out2D_every == 0))
+ {
return (0);
+ }
/* Check variable not already output this iteration */
if (myGH->out2D_last [index] == GH->cctk_iteration)
{
- CCTK_WARN (2, "Already done 2D output in IOJpeg");
- return (0);
+ CCTK_WARN (2, "Already done 2D output in IOJpeg");
+ return (0);
}
return (1);
@@ -143,8 +156,10 @@ int IOJpeg_TriggerOutput2D (cGH *GH, int index)
myGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
if (!CCTK_Equals(verbose,"no"))
+ {
CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_TriggerOutput2D: varname, index = "
"(%s, %d)", varname, index);
+ }
/* Do the 2D output */
ierr=IOJpeg_Write2D (GH, index, varname);
@@ -167,16 +182,39 @@ static void CheckSteerableParameters (IOJpegGH *myGH)
/* How often to output */
myGH->out2D_every = out_every > 0 ? out_every : -1;
if (out2D_every > 0)
+ {
myGH->out2D_every = out2D_every;
+ }
/* re-parse the 'out2D_vars' parameter if it was changed */
out2D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out2D_vars",
CCTK_THORNSTRING);
if (out2D_vars_current_nset != out2D_vars_lastset)
{
- IOUtil_ParseVarsForOutput (out2D_vars, myGH->do_out2D);
+ memset (myGH->do_out2D, 0, CCTK_NumVars ());
+ CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->do_out2D,
+ CCTK_GROUP_OR_VAR);
/* Save the last setting of 'out2D_vars' parameter */
out2D_vars_lastset = out2D_vars_current_nset;
}
}
+
+
+
+
+/* callback for CCTK_TraverseString() to set the output flag
+ for the given variable */
+static void SetOutputFlag (int index, const char *optstring, void *arg)
+{
+ char *flags = (char *) arg;
+
+
+ flags[index] = 1;
+
+ if (optstring)
+ {
+ CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Optional string '%s' in variable name ignored", optstring);
+ }
+}
diff --git a/src/Startup.c b/src/Startup.c
index 323ffd0..853eb30 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -2,7 +2,6 @@
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
int IOJpeg_Output2DGH(cGH *GH);
int IOJpeg_TriggerOutput2D(cGH *GH, int);
diff --git a/src/Write2D.c b/src/Write2D.c
index 6260c89..f0f0ee0 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -1,7 +1,7 @@
#include "cctk.h"
#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
+#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
#include "IOJpeg.h"
#include <stdio.h>
@@ -18,7 +18,6 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
{
DECLARE_CCTK_PARAMETERS
int timelevel;
- ioGH *ioUtilGH;
IOJpegGH *ssGH;
IOJpegGeo_t geo;
FILE **fdset_2D; /* array of output file pointers */
@@ -27,7 +26,6 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
int ierr=0;
/* Get the handle for IO extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
ssGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
/* The dimension of the slab - HARDCODED */
@@ -70,7 +68,7 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
fdset_2D = (FILE **) malloc (max_slabs * sizeof (FILE *));
}
fname = (char *) malloc ((strlen (ssGH->outdir2D) +
- strlen (alias) + 20)*sizeof(char));
+ strlen (alias) + 20)*sizeof(char));
/* Set flags for remembering if files have been advertised */
if (!advertised)
@@ -79,11 +77,11 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
advertised = (int **)malloc(max_slabs*sizeof(int *));
for (si=0;si<max_slabs;si++)
{
- advertised[si] = (int *)malloc(CCTK_NumVars()*sizeof(int));
- for (i=0;i<CCTK_NumVars();i++)
- {
- advertised[si][i] = 0;
- }
+ advertised[si] = (int *)malloc(CCTK_NumVars()*sizeof(int));
+ for (i=0;i<CCTK_NumVars();i++)
+ {
+ advertised[si][i] = 0;
+ }
}
}
@@ -92,57 +90,57 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
/* Get the next set of slab directions */
if (IOJpeg_SetDirection(geo.vdim, SDIM, si, geo.direction)<0) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot set direction for slab (#%d) in given volume (%d).\n",
- si, geo.vdim);
- continue;
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot set direction for slab (#%d) in given volume (%d).\n",
+ si, geo.vdim);
+ continue;
}
/* **********************************************
- File open procedures which are more complex,
- like for HDF5 can go here and you would pass
- the file ID through to DumpVar. He we set fid=1
- for proc0 and make it available as a flag
- ********************************************** */
+ File open procedures which are more complex,
+ like for HDF5 can go here and you would pass
+ the file ID through to DumpVar. He we set fid=1
+ for proc0 and make it available as a flag
+ ********************************************** */
if (CCTK_MyProc (GH) == 0)
{
- IOUtil_AdvertisedFileDesc_t advertised_file;
- const char *extensions [3] = {"yz", "xz", "xy"};
-
- if (CCTK_Equals(mode,"remove"))
- {
- sprintf (fname, "%s/%s_2d_%s.jpeg", ssGH->outdir2D,alias,
- extensions [si]);
- }
- else
- {
- sprintf (fname, "%s/%s_2d_%s.%d.jpeg", ssGH->outdir2D,alias,
- extensions [si],GH->cctk_iteration);
- }
-
- fdset_2D [si] = fopen (fname, "w");
- if (! fdset_2D [si])
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot open 2D output file '%s'", fname);
- return;
- }
-
- /* advertise the file for downloading */
- if (CCTK_Equals(mode,"remove") && advertised[si][index]==0)
- {
- advertised_file.slice = (char *) extensions [si];
- advertised_file.thorn = CCTK_THORNSTRING;
- advertised_file.varname = CCTK_FullName (index);
- advertised_file.description = "Jpegs of slices";
- advertised_file.mimetype = "image/jpeg";
-
- IOUtil_AdvertiseFile (GH, fname, &advertised_file);
- advertised[si][index] = 1;
- free (advertised_file.varname);
- }
+ ioAdvertisedFileDesc advertised_file;
+ const char *extensions [3] = {"yz", "xz", "xy"};
+
+ if (CCTK_Equals(mode,"remove"))
+ {
+ sprintf (fname, "%s/%s_2d_%s.jpeg", ssGH->outdir2D,alias,
+ extensions [si]);
+ }
+ else
+ {
+ sprintf (fname, "%s/%s_2d_%s.%d.jpeg", ssGH->outdir2D,alias,
+ extensions [si],GH->cctk_iteration);
+ }
+
+ fdset_2D [si] = fopen (fname, "w");
+ if (! fdset_2D [si])
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot open 2D output file '%s'", fname);
+ return (-1);
+ }
+
+ /* advertise the file for downloading */
+ if (CCTK_Equals(mode,"remove") && advertised[si][index]==0)
+ {
+ advertised_file.slice = (char *) extensions [si];
+ advertised_file.thorn = CCTK_THORNSTRING;
+ advertised_file.varname = CCTK_FullName (index);
+ advertised_file.description = "Jpegs of slices";
+ advertised_file.mimetype = "image/jpeg";
+
+ IOUtil_AdvertiseFile (GH, fname, &advertised_file);
+ advertised[si][index] = 1;
+ free (advertised_file.varname);
+ }
}
/* store file desriptors in database */
@@ -155,13 +153,13 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
ierr = IOJpeg_DumpVar(GH, index, timelevel, &geo, fdset_2D[si]);
if (ierr<0) CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOJpeg_DumpVar failed for GF index: %d\n",
- index);
+ "IOJpeg_DumpVar failed for GF index: %d\n",
+ index);
/* **********************************************
- File close procedures which are more complex,
- like for HDF5 can go here.
- ********************************************** */
+ File close procedures which are more complex,
+ like for HDF5 can go here.
+ ********************************************** */
/* Close the file */
fclose (fdset_2D [si]);