aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2002-04-18 22:52:48 +0000
committertradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2002-04-18 22:52:48 +0000
commit2d91d4f970e1f31365da061077384eee8a839b28 (patch)
tree3e6dc81312746a07cbe04de5e1a095d0747613f2
parent19a205fc66c0caa75d1acf50bacdd9c7d03dedbe (diff)
Completly reworked IOJpeg. All the old hyperslabbing crap and dependency on
IOASCII is gone now. IOJpeg uses the new Hyperslab API and does its own slice center setup. It also uses the new filenaming scheme. git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@59 eff87b29-5268-4891-90a3-a07138403961
-rw-r--r--README6
-rw-r--r--interface.ccl4
-rw-r--r--param.ccl139
-rw-r--r--schedule.ccl8
-rw-r--r--src/ChooseOutput.c105
-rw-r--r--src/DumpVar.c180
-rw-r--r--src/GHExtension.c141
-rw-r--r--src/IOJpeg.h82
-rw-r--r--src/JPEG.c4
-rw-r--r--src/Output.c377
-rw-r--r--src/Output2D.c282
-rw-r--r--src/ParseGeometry.c129
-rw-r--r--src/Startup.c176
-rw-r--r--src/Write.c313
-rw-r--r--src/Write2D.c219
-rw-r--r--src/ioJpegGH.h65
-rw-r--r--src/make.code.defn6
17 files changed, 1084 insertions, 1152 deletions
diff --git a/README b/README
index 91a9638..1942f6b 100644
--- a/README
+++ b/README
@@ -1,7 +1,11 @@
Cactus Code Thorn IOJpeg
-Authors : ...
+Authors : John Shalf, Gabrielle Allen, Tom Goodale, Gerd Lanfermann, Thomas Radke
CVS info : $Header$
--------------------------------------------------------------------------
Purpose of the thorn:
+This thorn does output of 2D slices from Cactus grid functions and arrays
+in jpeg image format.
+
+It registers the I/O method "IOJpeg" with the flesh.
diff --git a/interface.ccl b/interface.ccl
index cd8ac2a..516dd5e 100644
--- a/interface.ccl
+++ b/interface.ccl
@@ -1,8 +1,8 @@
-# Interface definition for thorn IOSkeleton
+# Interface definition for thorn IOJpeg
# $Header$
implements: IOJpeg
-inherits: Hyperslab, IOASCII, jpeg6b
+inherits: IO, Hyperslab, jpeg6b
USES INCLUDE HEADER: Hyperslab.h
USES INCLUDE HEADER: jconfig.h
diff --git a/param.ccl b/param.ccl
index f98494f..b6d1f46 100644
--- a/param.ccl
+++ b/param.ccl
@@ -1,12 +1,44 @@
# Parameter definitions for thorn IOJpeg
# $Header$
+#############################################################################
+### declare IOASCII parameters
+#############################################################################
private:
########################
+# The basic parameters:
+# how often to do output
+# for which variables
+# into which output directory
+########################
+INT out2D_every "How often to do output, overrides IO::out_every" STEERABLE = ALWAYS
+{
+ -1 :: "Never"
+ 1:* :: "Every so many iterations"
+} -1
+
+STRING out2D_vars "Variables to output as JPEGs" STEERABLE = ALWAYS
+{
+ .* :: "A regex which matches everything"
+} ""
+
+STRING out2D_dir "Name of IOJpeg output directory, overrides IO::outdir"
+{
+ .* :: "A regex which matches everything"
+} "."
+
+KEYWORD mode "Output mode to use" STEERABLE = ALWAYS
+{
+ "remove" :: "Remove files from old timesteps"
+ "standard" :: "Generate a file for each out2D_every timesteps"
+} "standard"
+
+
+########################
# Specific to jpegs
########################
-REAL colormap_bias "Bias automatic colormap generation towards red (low) or blue (high)" STEERABLE = ALWAYS
+REAL colormap_bias "Bias automatic colormap generation towards red (low) or blue (high)" STEERABLE = ALWAYS
{
-1:1 :: "Could be unrestricted"
} 0.5
@@ -21,7 +53,7 @@ INT colormap_factor "How to scale float values to rgb color" STEERABLE = ALWAYS
2:256 :: "Positive scaling"
} 32
-KEYWORD colormap "how to set the colormap" STEERABLE=ALWAYS
+KEYWORD colormap "How to set the colormap" STEERABLE = ALWAYS
{
"auto" :: "Set automatically using min/max of grid variables"
"custom" :: "Set min/max manually"
@@ -29,94 +61,55 @@ KEYWORD colormap "how to set the colormap" STEERABLE=ALWAYS
REAL colormap_min "minimum value to be mapped to colors" STEERABLE = ALWAYS
{
- *:* :: "Only for custom colormap scale"
+ *:* :: "Only for custom colormap scale"
} -1.0
-
REAL colormap_max "maximum value to be mapped to colors" STEERABLE = ALWAYS
{
- *:* :: "Only for custom colormap scale"
+ *:* :: "Only for custom colormap scale"
} +1.0
-########################
-# How often to do output
-########################
-INT out2D_every "How often to do output, overrides IO::out_every" STEERABLE = ALWAYS
-{
- -1 :: "Never"
- 1:* :: "Every so many iterations"
-} -1
-
-KEYWORD verbose "Verbosity level"
-{
- "yes" :: "information output"
- "debug":: "debugging output"
- "no" :: "silent"
-} "no"
-
-#####################
-# Variables to output
-#####################
-STRING out2D_vars "Variables to extract data from" STEERABLE = ALWAYS
-{
- .* :: "A regex which matches everything"
-} ""
-STRING out2D_dir "Name of 2D Jpeg output directory, overrides outdir"
+################################
+# Choosing what planes to output
+################################
+CCTK_REAL out2D_yzplane_x "x-coord for 2D planes in yz"
{
- .* :: "A regex which matches everything"
-} "."
-
-KEYWORD mode "Output mode to use" STEERABLE=ALWAYS
+ *:* :: ""
+} 0.0
+CCTK_REAL out2D_xzplane_y "y-coord for 2D planes in xz"
{
- "remove" :: "Remove files from old timesteps"
- "standard" :: "Generate a file for each out2D_every timesteps"
-} "standard"
-
-#####################
-# Geometry information on the slab to extract
-#####################
-
-STRING origin2D "Common Intersection point of the n Slices" STEERABLE = ALWAYS
+ *:* :: ""
+} 0.0
+CCTK_REAL out2D_xyplane_z "z-coord for 2D planes in xy"
{
- .* :: "Comma separated list of positive integer values"
-} "-1,-1,-1"
-
-STRING downsampling2D "Default downsampling" STEERABLE = ALWAYS
+ *:* :: ""
+} 0.0
+CCTK_INT out2D_xyplane_zi "z-index (from 0) for 2D planes in xy"
{
- .* :: "Comma separated list of positive integer values"
-} "1,1,1"
-
-STRING length2D "Default length of the hyperslab to stream" STEERABLE = ALWAYS
+ 0:* :: ""
+} 0
+CCTK_INT out2D_xzplane_yi "y-index (from 0) for 2D planes in xz"
{
- .* :: "Comma separated list of integer values"
-} "-1,-1,-1"
-
-STRING direction2D "Default direction of hyperslab to stream" STEERABLE = ALWAYS
-{
- .* :: "Comma separated list of positive integer values"
-} "0,1,2"
-
-CCTK_INT slabdim "default dimension of slab"
+ 0:* :: ""
+} 0
+CCTK_INT out2D_yzplane_xi "x-index (from 0) for 2D planes in yz"
{
- 1:3 :: "dimension of slab (1,2,3)"
-} 2
+ 0:* :: ""
+} 0
#############################################################################
### import IOUtil parameters
#############################################################################
-
shares: IO
+USES INT out_every
+USES STRING outdir
+USES BOOLEAN verbose
USES KEYWORD newverbose
-
-########################
-# How often to do output
-########################
-USES INT out_every
-
-####################
-# Output directories
-####################
-USES STRING outdir
-
+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
diff --git a/schedule.ccl b/schedule.ccl
index 8c02501..85438ad 100644
--- a/schedule.ccl
+++ b/schedule.ccl
@@ -2,16 +2,14 @@
# $Header$
########################################################################
-### register StreamedHDF5 routines
+### register IOJpeg routines
########################################################################
-
schedule IOJpeg_Startup at STARTUP after IOUtil_Startup
{
LANG:C
} "Startup routine"
-schedule IOJpeg_SliceCenterSetup at BASEGRID after IOASCII_Choose1D
+schedule IOJpeg_ChooseOutput at BASEGRID after SpatialCoordinates
{
LANG:C
-} "Set slice center"
-
+} "Choose 2D output planes"
diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c
new file mode 100644
index 0000000..efbe83c
--- /dev/null
+++ b/src/ChooseOutput.c
@@ -0,0 +1,105 @@
+/*@@
+ @file ChooseOutput.c
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Choose what 2D planes to output by IOJpeg.
+ @enddesc
+
+ @version $Id$
+ @@*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_Parameters.h"
+#include "CactusBase/IOUtil/src/ioutil_Utils.h"
+#include "ioJpegGH.h"
+
+/* the rcs ID and its dummy function to use it */
+static const char *rcsid = "$Header$";
+CCTK_FILEVERSION(CactusIO_IOJpeg_ChooseOutput_c)
+
+
+/********************************************************************
+ ******************** Macro Definitions ************************
+ ********************************************************************/
+/* macro to choose origin according actual parameter settings:
+ 1. Indices from IOJpeg
+ 2. Indices from IOUtil
+ 3. Coords from IOJpeg
+ 4. Coords from IOUtil
+ */
+#define GET_SLICE(IOJpeg_param, IOUtil_param, origin_index, origin_phys) \
+ { \
+ 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; \
+ } \
+ }
+
+
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
+void IOJpeg_ChooseOutput (const cGH *GH);
+
+
+/*@@
+ @routine IOJpeg_ChooseOutput
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Use parameters to choose the 2D slices through the output data.
+ @enddesc
+
+ @calls CCTK_ParameterQueryTimesSet
+ IOUtil_2DPlanes
+
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @@*/
+void IOJpeg_ChooseOutput (const cGH *GH)
+{
+ int i, maxdim;
+ ioJpegGH *myGH;
+ int origin_index[3];
+ CCTK_REAL origin_phys[3];
+ DECLARE_CCTK_PARAMETERS
+
+
+ GET_SLICE (out2D_xyplane_z, out_xyplane_z, origin_index[0], origin_phys[0]);
+ GET_SLICE (out2D_xzplane_y, out_xzplane_y, origin_index[1], origin_phys[1]);
+ GET_SLICE (out2D_yzplane_x, out_yzplane_x, origin_index[2], origin_phys[2]);
+
+ maxdim = CCTK_MaxDim ();
+ myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
+ myGH->sp2xyz = (int **) malloc (3 * sizeof (int *));
+
+ for (i = 0; i < maxdim; i++)
+ {
+ myGH->sp2xyz[i] = (int *) calloc (i + 1, sizeof (int));
+
+ if (i > 0 && i < 3)
+ {
+ IOUtil_2DPlanes (GH, i + 1, origin_index, origin_phys, myGH->sp2xyz[i]);
+ }
+ }
+}
diff --git a/src/DumpVar.c b/src/DumpVar.c
deleted file mode 100644
index 949d3fb..0000000
--- a/src/DumpVar.c
+++ /dev/null
@@ -1,180 +0,0 @@
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "Hyperslab.h"
-#include "IOJpeg.h"
-
-static const char *rcsid = "$Header$";
-
-CCTK_FILEVERSION(CactusIO_IOJpeg_DumpVar_c)
-
-static int IOJpeg_Output (const cGH *GH,
- int vindex,
- CCTK_REAL *data,
- int sdim,
- int *hsize,
- FILE *fid);
-
-
-int IOJpeg_DumpVar (const cGH *GH,
- int vindex,
- int timelevel,
- IOJpegGeo_t *geo,
- FILE *fid)
-{
- DECLARE_CCTK_PARAMETERS
- void *data=NULL;
- int *hsizes, slabstart[SLABSKEL_MAXDIM];
- int idim, vdim;
-
- int sdir[3] = {0,0,0};
-
- /* Allocate buffer to hold actual slab sizes */
- hsizes = (int*)malloc(geo->sdim*sizeof(int));
-
- vdim= geo->vdim;
-
- /* TEMPORARY FIX DUE TO INCONSISTENT DIR SPECIFICATION */
- /* direction vector of 1d line in 3d volume */
- if (geo->sdim==1) {
- sdir[0] = (geo->direction[0]==0) ? 1:0;
- sdir[1] = (geo->direction[0]==1) ? 1:0;
- sdir[2] = (geo->direction[0]==2) ? 1:0;
- }
- /* norm vector of 2d surface in 3d volume */
- else if (geo->sdim==2)
- {
- sdir[0] = ((geo->direction[0]==1)&&(geo->direction[1]==2)) ? 1:0;
- sdir[1] = ((geo->direction[0]==0)&&(geo->direction[1]==2)) ? 1:0;
- sdir[2] = ((geo->direction[0]==0)&&(geo->direction[1]==1)) ? 1:0;
- }
- /* spanning directions for 3d */
- else if (geo->sdim==3)
- {
- sdir[0] = geo->direction[0];
- sdir[1] = geo->direction[1];
- sdir[2] = geo->direction[2];
- }
- else
- {
- char *fullname = CCTK_FullName (vindex);
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No 0-dim extraction possible: '%s'", fullname);
- free (fullname);
- return (-1);
- }
-
- /* Get the start indices for the slab from slab_start. */
- /* Slab_start from the geo structure is not a true start index, it is currently
- used as the intersection point of n surfaces , that's why two entries
- have to be set to zero in the case of a surface (one entry for line) FIXME */
- for (idim=0;idim<vdim;idim++)
- slabstart[idim] = geo->slab_start[idim];
- for (idim=0;idim<geo->sdim;idim++)
- slabstart[geo->direction[idim]]=0;
-
- /* Data Extraction takes place, data will be gathered onto processor 0
- hyperslab data will be in data,
- hyperslab sizes: hsizes[SLAB_DIM].
- */
- if (Hyperslab_GetHyperslab (GH, 0, vindex, timelevel, geo->sdim, slabstart,
- sdir, geo->length, geo->downs,
- &data, hsizes) < 0)
- {
- char *fullname = CCTK_FullName (vindex);
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Failed to extract hyperslab for variable '%s'", fullname);
- free (fullname);
- return (-1);
- }
-
- /* Output the hyperslab data */
- if (IOJpeg_Output (GH, vindex, data, geo->sdim, hsizes, fid) < 0)
- {
- char *fullname = CCTK_FullName (vindex);
-
-
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOJpeg_Output failed for variable '%s'", fullname);
- free (fullname);
- return (-1);
- }
-
- /* free allocated resources */
- if (data)
- {
- free (data);
- }
- if (hsizes)
- {
- free (hsizes);
- }
-
- return (0);
-}
-
-
-
-static int IOJpeg_Output (const cGH *GH,
- int vindex,
- CCTK_REAL *data,
- int sdim,
- int *hsize,
- FILE *fid)
-{
- unsigned char *dataout=(unsigned char *)malloc(3*hsize[0]*hsize[1]);
- CCTK_REAL min,max;
- /*** FIXME: can CCTK_Reduce() have a 'const cGH *' parameter ?? ***/
- union
- {
- const cGH *const_ptr;
- cGH *non_const_ptr;
- } GH_fake_const;
- DECLARE_CCTK_PARAMETERS
-
-
- GH_fake_const.const_ptr = GH;
-
- if (sdim!=2) return(-1);
-
- if (CCTK_Equals(colormap,"custom"))
- {
- min = colormap_min;
- max = colormap_max;
- }
- else
- {
- int reduction_handle;
- reduction_handle = CCTK_ReductionHandle ("maximum");
- CCTK_Reduce (GH_fake_const.non_const_ptr, 0, reduction_handle, 1,
- CCTK_VARIABLE_REAL,&max, 1, vindex);
- reduction_handle = CCTK_ReductionHandle ("minimum");
- CCTK_Reduce (GH_fake_const.non_const_ptr, 0, reduction_handle, 1,
- CCTK_VARIABLE_REAL,&min, 1, vindex);
- }
-
- if(fid)
- {
- AutoColorDataSlice(hsize[0],
- hsize[1],
- data,
- dataout,
- min,
- max,
- colormap_bias,
- colormap_factor);
-
- WriteJPEGToFileRGB(hsize[0],
- hsize[1],
- dataout,
- colormap_quality,
- fid);
- }
-
- free (dataout);
-
- return (1);
-}
diff --git a/src/GHExtension.c b/src/GHExtension.c
deleted file mode 100644
index 1b65a07..0000000
--- a/src/GHExtension.c
+++ /dev/null
@@ -1,141 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "cctk_Arguments.h"
-
-#include "IOJpeg.h"
-
-static const char *rcsid = "$Header$";
-
-CCTK_FILEVERSION(CactusIO_IOJpeg_GHExtension_c)
-
-void *IOJpeg_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH);
-void IOJpeg_SliceCenterSetup(CCTK_ARGUMENTS);
-int IOJpeg_InitGH (cGH *GH);
-
-void *IOJpeg_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
-{
- int numvars,iv;
- IOJpegGH *newGH;
-
-
- /* prevent compiler warnings about unused parameters */
- config = config;
- convergence_level = convergence_level;
- GH = GH;
-
- numvars = CCTK_NumVars ();
-
- newGH = (IOJpegGH *) malloc (sizeof (IOJpegGH));
- newGH->do_out2D = (char *) malloc (numvars * sizeof (char));
- newGH->out2D_last = (int *) malloc (numvars * sizeof (int));
-
- /* Allocate geometry structure for each grid variable/array */
- newGH->out_geo = (IOJpegGeo_t**) malloc(numvars * sizeof (IOJpegGeo_t));
- for (iv=0;iv<numvars;iv++)
- {
- newGH->out_geo[iv] = (IOJpegGeo_t*) malloc(SLABSKEL_MAXDIM * sizeof (IOJpegGeo_t));
- }
-
- return (newGH);
-}
-
-
-int IOJpeg_InitGH (cGH *GH)
-{
- DECLARE_CCTK_PARAMETERS
- int inum;
- IOJpegGH *myGH;
-
- myGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
-
- /* How often to output */
-
- myGH->out2D_every = out_every > 0 ? out_every : -1;
- if (out2D_every > 0)
- {
- myGH->out2D_every = out2D_every;
- }
-
- if (CCTK_Equals (newverbose, "standard") ||
- CCTK_Equals (newverbose, "full"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_2D: Output every %d iterations",
- myGH->out2D_every);
- }
-
- /* Initialise iteration of last output */
-
- for (inum=0; inum<CCTK_NumVars(); inum++)
- {
- myGH->out2D_last [inum] = -1;
- }
-
- /* Deal with the output directories */
- /* Check whether "outdirXD" was set.
- If so take this dir otherwise default to "IO::outdir" */
- myGH->outdir2D =
- CCTK_ParameterQueryTimesSet("out2D_dir",CCTK_THORNSTRING)>0 ?
- strdup (out2D_dir) : strdup (outdir);
-
- /* create the output dir */
- if (CCTK_MyProc (GH) == 0)
- {
- int i;
- i = CCTK_CreateDirectory (0755, myGH->outdir2D);
- if (i < 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOJpeg_InitGH: Problem creating 2D output directory '%s'",
- myGH->outdir2D);
- }
- else if (i >= 0 && CCTK_Equals (newverbose, "full"))
- {
- CCTK_VInfo (CCTK_THORNSTRING,
- "IOJpeg_2D: Jpeg output to directory '%s'",
- myGH->outdir2D);
- }
- }
-
- return (0);
-}
-
-
-
-void IOJpeg_SliceCenterSetup(CCTK_ARGUMENTS)
-{
- DECLARE_CCTK_PARAMETERS
- int inum,idim;
- int numvars;
- IOJpegGeo_t geo_default;
- IOJpegGH *myGH;
- int extension_handle;
-
- extension_handle = CCTK_GHExtensionHandle ("IOJpeg");
-
- if(extension_handle >= 0)
- {
- myGH = (IOJpegGH *) cctkGH->extensions [extension_handle];
-
- numvars = CCTK_NumVars ();
-
- /* Loop over all slab dimension */
- 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 < numvars; inum++)
- {
- myGH->out_geo[inum][idim] = geo_default;
- myGH->out_geo[inum][idim].vdim = CCTK_GroupDimFromVarI (inum);
- }
-
- /* allocate the flags array for every possible 2D hyperslab */
- myGH->advertised[idim] = (char *) calloc (numvars, 1);
- }
- }
-}
diff --git a/src/IOJpeg.h b/src/IOJpeg.h
deleted file mode 100644
index 0fbda45..0000000
--- a/src/IOJpeg.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SLABSKEL_MAXDIM 4
-
-#include "StoreNamedData.h"
-
-/* structure holding information on the output geometry */
-typedef struct IOJpegGeo
-{
- int vdim; /* dimension of the gridvariable (dynamic) */
- int sdim; /* dimension of the slab (dynamic) */
- int direction[SLABSKEL_MAXDIM]; /* direction of slab (by parameter) */
- int slab_start[SLABSKEL_MAXDIM];/* global start index (by parameter) */
- int length[SLABSKEL_MAXDIM]; /* requested index slab length (by parameter) */
- int actlen[SLABSKEL_MAXDIM]; /* actual index slab length (by PUGHSlab)*/
- int downs[SLABSKEL_MAXDIM]; /* downsampling (by parameter) */
-} IOJpegGeo_t;
-
-
-/* IOJpeg GH extension structure */
-typedef struct IOJpegGH {
-
- /* how often to output */
- int out2D_every;
-
- /* flags indicating output for var [i] */
- char *do_out2D;
-
- /* directories in which to output */
- char *outdir2D;
-
- /* the last iteration output */
- int *out2D_last;
-
- /* geometry information (downsampling, zooming, etc.) */
- IOJpegGeo_t **out_geo;
-
- /* flags indicating file [slab][variable] is advertised */
- char *advertised[SLABSKEL_MAXDIM];
-
-} IOJpegGH;
-
-/* function prototypes */
-int IOJpeg_Output2DGH (const cGH *GH);
-int IOJpeg_Output2DVarAs (const cGH *GH, const char *fullname, const char *alias);
-int IOJpeg_TimeFor2D (const cGH *GH, int vindex);
-int IOJpeg_TriggerOutput2D (const cGH *GH, int vindex);
-int IOJpeg_Write2D (const cGH *GH, int vindex, const char *alias);
-void IOJpeg_DefaultGeo(const cGH *GH, int sdim, IOJpegGeo_t *geo);
-int IOJpeg_SetDirection (IOJpegGeo_t *geometry, int direction);
-int IOJpeg_DumpVar (const cGH *GH, int vindex, int timelevel, IOJpegGeo_t *geo, FILE *fid);
-
-int WriteJPEGToFileRGB(int nx, /* width of image in pixels */
- int ny, /* height of the image in pixels */
- void *data, /* buffer containing image data */
- int Quality, /* Integer from 0 to 100 */
- FILE* outfile); /* name of file to store in */
-
-int WriteJPEGToMemoryRGB(int nx,int ny, void *data, int Quality, char *memorybuffer,int bufsize);
-
-void AutoColorDataSlice(int nx,int ny, /* size of the image x & y */
- CCTK_REAL *datain, /* 2D slice of data input */
- unsigned char *dataout, /* RGB image data output */
- CCTK_REAL min,CCTK_REAL max, /* range of the entire 3D dataset
- This could be ranged based
- on the values of the slice,
- but then that would be a
- bit untrustworthy. Its
- best to pass in the
- range for the entire
- dataset or a pre-defined
- fixed range. It does
- handle clamping of the
- range. */
- CCTK_REAL bias,
- int rdfac);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
diff --git a/src/JPEG.c b/src/JPEG.c
index 3c51a06..5d4fdd9 100644
--- a/src/JPEG.c
+++ b/src/JPEG.c
@@ -5,7 +5,7 @@
#include <string.h>
#include <math.h>
-#include "IOJpeg.h"
+#include "ioJpegGH.h"
#include "jconfig.h"
#include "jpeglib.h"
@@ -217,7 +217,7 @@ int WriteJPEGToMemoryRGB(int nx,int ny, void *data, int Quality, char *memorybuf
*/
void AutoColorDataSlice(int nx,int ny, /* size of the image x & y */
- CCTK_REAL *datain, /* 2D slice of data input */
+ const CCTK_REAL *datain, /* 2D slice of data input */
unsigned char *dataout, /* RGB image data output */
CCTK_REAL min,CCTK_REAL max, /* range of the entire 3D dataset
This could be ranged based
diff --git a/src/Output.c b/src/Output.c
new file mode 100644
index 0000000..02464de
--- /dev/null
+++ b/src/Output.c
@@ -0,0 +1,377 @@
+ /*@@
+ @file Output.c
+ @date Thu May 11 2000
+ @author Thomas Radke
+ @desc
+ Functions to deal with Jpeg output of variables.
+ @enddesc
+ @version $Id$
+ @@*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_Parameters.h"
+#include "util_String.h"
+#include "ioJpegGH.h"
+
+/* the rcs ID and its dummy function to use it */
+static const char *rcsid = "$Id$";
+CCTK_FILEVERSION(CactusIO_IOJpeg_Output_c)
+
+/* define this if you want debug output */
+/* #define IOJPEG_DEBUG 1 */
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+static int CheckOutputVar (int vindex);
+static void CheckSteerableParameters (ioJpegGH *myGH);
+static void SetOutputFlag (int vindex, const char *optstring, void *arg);
+
+
+/*@@
+ @routine IOJpeg_OutputGH
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Loops over all variables and outputs them if necessary
+ @enddesc
+ @calls IOJpeg_TimeFor
+ IOJpeg_Write
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype const cGH *
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ the number of variables which were output at this iteration
+ (or 0 if it wasn't time to output yet)
+ @endreturndesc
+@@*/
+int IOJpeg_OutputGH (const cGH *GH)
+{
+ int vindex, retval;
+ ioJpegGH *myGH;
+
+
+ myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
+ CheckSteerableParameters (myGH);
+
+ /* loop over all variables */
+ for (vindex = retval = 0; vindex < CCTK_NumVars (); 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)
+ {
+ /* register variable as having output this iteration */
+ myGH->out_last[vindex] = GH->cctk_iteration;
+ retval++;
+ }
+ }
+
+ return (retval);
+}
+
+
+/*@@
+ @routine IOJpeg_OutputVarAs
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Unconditional output of a variable using the IOJpeg I/O method.
+ @enddesc
+ @calls IOJpeg_Write
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var fullname
+ @vdesc complete name of variable to output
+ @vtype const char *
+ @vio in
+ @endvar
+ @var alias
+ @vdesc alias name of variable to output
+ (used to generate output filename)
+ @vtype const char *
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ return code of @seeroutine IOJpeg_Write, or<BR>
+ -1 if variable cannot be output by IOJpeg
+ @endreturndesc
+@@*/
+int IOJpeg_OutputVarAs (const cGH *GH, const char *fullname, const char *alias)
+{
+ int vindex, retval;
+
+
+ retval = -1;
+ vindex = CCTK_VarIndex (fullname);
+
+ if (CheckOutputVar (vindex) == 0)
+ {
+ retval = IOJpeg_Write (GH, vindex, alias);
+ }
+
+ return (retval);
+}
+
+
+ /*@@
+ @routine IOJpeg_TimeFor
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Decides if it is time to output a variable
+ using the IOJpeg I/O method.
+ @enddesc
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var vindex
+ @vdesc index of variable
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 1 if output should take place at this iteration, or<BR>
+ 0 if not
+ @endreturndesc
+@@*/
+int IOJpeg_TimeFor (const cGH *GH, int vindex)
+{
+ int result;
+ ioJpegGH *myGH;
+ char *fullname;
+
+
+ /* 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)
+ {
+ /* check if variable wasn't already output this iteration */
+ if (myGH->out_last[vindex] == GH->cctk_iteration)
+ {
+ fullname = CCTK_FullName (vindex);
+ CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Already done IOJpeg output for '%s' in current "
+ "iteration (probably via triggers)", fullname);
+ free (fullname);
+ }
+ else
+ {
+ result = 1;
+ }
+ }
+
+ return (result);
+}
+
+
+/*@@
+ @routine IOJpeg_TriggerOutput
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Triggers the output of a variable using the IOJpeg I/O method.
+ @enddesc
+ @calls IOJpeg_Write
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var vindex
+ @vdesc index of variable to output
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ return code of @seeroutine IOJpeg_Write
+ @endreturndesc
+@@*/
+int IOJpeg_TriggerOutput (const cGH *GH, int vindex)
+{
+ int retval;
+ ioJpegGH *myGH;
+
+
+ /* do the output */
+ retval = IOJpeg_Write (GH, vindex, CCTK_VarName (vindex));
+ if (retval == 0)
+ {
+ /* register variables as having output this iteration */
+ myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
+ myGH->out_last[vindex] = GH->cctk_iteration;
+ }
+
+ return (retval);
+}
+
+
+/**************************** local functions ******************************/
+/* check if steerable parameters have changed */
+static void CheckSteerableParameters (ioJpegGH *myGH)
+{
+ int i, num_vars;
+ char *fullname, *msg;
+ DECLARE_CCTK_PARAMETERS
+
+
+ /* how often to output */
+ i = myGH->out_every_default;
+ myGH->out_every_default = out2D_every > 0 ? out2D_every : out_every;
+
+ /* report if frequency changed */
+ if (myGH->out_every_default != i && ! CCTK_Equals (newverbose, "none"))
+ {
+ if (myGH->out_every_default > 0)
+ {
+ CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg: Periodic output every %d "
+ "iterations", myGH->out_every_default);
+ }
+ else
+ {
+ CCTK_INFO ("IOJpeg: Periodic output turned off");
+ }
+ }
+
+ /* re-parse the 'out2D_vars' parameter if it was changed */
+ if (strcmp (out2D_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);
+
+ if (myGH->out_every_default == i || ! CCTK_Equals (newverbose, "none"))
+ {
+ msg = NULL;
+ for (i = 0; i < num_vars; i++)
+ {
+ if (myGH->out_every[i])
+ {
+ fullname = CCTK_FullName (i);
+ if (! msg)
+ {
+ Util_asprintf (&msg, "IOJpeg: Periodic output requested for '%s'",
+ fullname);
+ }
+ else
+ {
+ Util_asprintf (&msg, "%s, '%s'", msg, fullname);
+ }
+ free (fullname);
+ }
+ }
+ if (msg)
+ {
+ CCTK_INFO (msg);
+ free (msg);
+ }
+ }
+
+ /* save the last setting of 'out2D_vars' parameter */
+ free (myGH->out_vars);
+ myGH->out_vars = strdup (out2D_vars);
+ }
+}
+
+
+/* check if this variable can be output (static conditions) */
+static int CheckOutputVar (int vindex)
+{
+ int groupindex;
+ cGroup groupinfo;
+ char *fullname;
+ const char *errormsg;
+
+
+ /* get the variable group information */
+ groupindex = CCTK_GroupIndexFromVarI (vindex);
+ CCTK_GroupData (groupindex, &groupinfo);
+
+ errormsg = NULL;
+ if (groupinfo.dim < 2 || groupinfo.dim > 3)
+ {
+ errormsg = "dim != [2,3]";
+ }
+ else if (groupinfo.grouptype != CCTK_GF && groupinfo.grouptype != CCTK_ARRAY)
+ {
+ errormsg = "not a grid function or array";
+ }
+ else if (! strncmp (CCTK_VarTypeName (groupinfo.vartype), "CCTK_COMPLEX", 12))
+ {
+ errormsg = "CCTK_COMPLEX variables cannot be dealt with";
+ }
+
+ if (errormsg)
+ {
+ fullname = CCTK_FullName (vindex);
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "No IOJpeg output for '%s': %s", fullname, errormsg);
+ free (fullname);
+ }
+
+ return (errormsg != NULL);
+}
+
+
+/* callback for CCTK_TraverseString() to set the output flag
+ for the given variable */
+static void SetOutputFlag (int vindex, const char *optstring, void *arg)
+{
+ char *endptr;
+ ioJpegGH *myGH = (ioJpegGH *) arg;
+
+
+ if (CheckOutputVar (vindex) == 0)
+ {
+ myGH->out_every[vindex] = myGH->out_every_default;
+ if (optstring)
+ {
+ endptr = "error";
+ if (strncmp ("out_every=", optstring, 10) == 0)
+ {
+ myGH->out_every[vindex] = strtol (optstring + 10, &endptr, 10);
+ }
+ if (endptr && *endptr)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "SetOutputFlag: Optional string '%s' could not be parsed",
+ optstring);
+ myGH->out_every[vindex] = 0;
+ }
+ }
+ }
+}
diff --git a/src/Output2D.c b/src/Output2D.c
deleted file mode 100644
index 0489095..0000000
--- a/src/Output2D.c
+++ /dev/null
@@ -1,282 +0,0 @@
- /*@@
- @file Output2D.c
- @date Sun 23 Dec 2001
- @author Thomas Radke
- @desc
- Functions to deal with 2D JPeg output.
- @enddesc
- @version $Id$
- @@*/
-
-
-#include "cctk.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "cctk_Parameters.h"
-#include "util_String.h"
-#include "CactusBase/IOUtil/src/ioutil_Utils.h"
-#include "IOJpeg.h"
-
-static const char *rcsid = "$Header$";
-
-CCTK_FILEVERSION(CactusIO_IOJpeg_Output2D_c)
-
-/* function prototypes */
-static void CheckSteerableParameters (IOJpegGH *myGH);
-static void SetOutputFlag (int vindex, const char *optstring, void *arg);
-
- /*@@
- @routine IOJpeg_Output2DGH
- @date Thu Sep 14 10:47:58 2000
- @author Gerd Lanfermann
- @desc
- Preparing 2D data for output
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
-@@*/
-int IOJpeg_Output2DGH (const cGH *GH)
-{
- int i, retval;
- IOJpegGH *myGH;
- const char *name;
- char *fullname;
- DECLARE_CCTK_PARAMETERS
-
-
- /* Get the GH extension for IOJpeg */
- myGH = (IOJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
-
- CheckSteerableParameters (myGH);
-
- if (myGH->out2D_every <= 0)
- {
- return (0);
- }
-
- /* Loop over all variables */
- for (i = retval = 0; i < CCTK_NumVars (); i++)
- {
- if (IOJpeg_TimeFor2D (GH, i))
- {
- name = CCTK_VarName (i);
- fullname = CCTK_FullName (i);
-
- if (!CCTK_Equals(verbose,"no"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_Output2DGH: fullname / name = "
- "%s / %s", fullname, name);
- }
-
- if (IOJpeg_Output2DVarAs (GH, fullname, name) == 0)
- {
- /* Register variable as having 2D output this iteration */
- myGH->out2D_last [i] = GH->cctk_iteration;
- retval++;
- }
-
- free (fullname);
- }
- }
-
- return (retval);
-}
-
-
-int IOJpeg_Output2DVarAs (const cGH *GH, const char *fullname, const char *alias)
-{
- int vindex, retval;
- DECLARE_CCTK_PARAMETERS
-
-
- vindex = CCTK_VarIndex (fullname);
-
- /* first, check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex)))
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No IOJpeg 2D output for '%s' (no storage)", fullname);
- return(-1);
- }
-
- if (!CCTK_Equals(verbose,"no"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_Output2DVarAs: fullname, alias, "
- "index = (%s, %s, %d)", fullname, alias, vindex);
- }
-
- /* Do the 2D output */
- retval = IOJpeg_Write2D (GH, vindex, alias);
-
- return (retval);
-}
-
-
-int IOJpeg_TimeFor2D (const cGH *GH, int vindex)
-{
- char *fullname;
- IOJpegGH *myGH;
-
-
- /* Get the GH extension for IOJpeg */
- myGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
-
- CheckSteerableParameters (myGH);
-
- /* Check if any output was requested */
- if(myGH->out2D_every <= 0)
- {
- return (0);
- }
-
- /* Check this variable should be output */
- if (! (myGH->do_out2D [vindex] && GH->cctk_iteration % myGH->out2D_every == 0))
- {
- return (0);
- }
-
-
- /* Check variable not already output this iteration */
- if (myGH->out2D_last [vindex] == GH->cctk_iteration)
- {
- fullname = CCTK_FullName (vindex);
- CCTK_VWarn (6, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Already done IOJpeg 2D output for variable '%s'", fullname);
- free (fullname);
- return (0);
- }
-
- return (1);
-}
-
-
-int IOJpeg_TriggerOutput2D (const cGH *GH, int vindex)
-{
- int retval;
- IOJpegGH *myGH;
- const char *varname;
- DECLARE_CCTK_PARAMETERS
-
-
- varname = CCTK_VarName (vindex);
-
- myGH = (IOJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
-
- if (!CCTK_Equals(verbose,"no"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_TriggerOutput2D: varname, index = "
- "(%s, %d)", varname, vindex);
- }
-
- /* Do the 2D output */
- retval = IOJpeg_Write2D (GH, vindex, varname);
-
- if (retval == 0)
- {
- /* Register variable as having 2D output this iteration */
- myGH->out2D_last [vindex] = GH->cctk_iteration;
- }
-
- return (retval);
-}
-
-
-/**************************** local functions ******************************/
-static void CheckSteerableParameters (IOJpegGH *myGH)
-{
- int i, out_old, out2D_vars_current_nset;
- char *msg, *oldmsg, *fullname;
- static int out2D_vars_lastset = 0;
- DECLARE_CCTK_PARAMETERS
-
-
- out_old = myGH->out2D_every;
-
- /* How often to output */
-
- myGH->out2D_every = out_every > 0 ? out_every : -1;
- if (out2D_every > 0)
- {
- myGH->out2D_every = out2D_every;
- }
-
- /* Report if frequency changed */
-
- if (myGH->out2D_every != out_old)
- {
- if (CCTK_Equals (newverbose, "standard") ||
- CCTK_Equals (newverbose, "full"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_2D: Output every %d iterations",
- myGH->out2D_every);
- }
- out_old = myGH->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)
- {
- memset (myGH->do_out2D, 0, CCTK_NumVars ());
- CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->do_out2D,
- CCTK_GROUP_OR_VAR);
-
- if (CCTK_Equals (newverbose, "standard") ||
- CCTK_Equals (newverbose, "full"))
- {
- msg = NULL;
- for (i = CCTK_NumVars () - 1; i >= 0; i--)
- {
- if (myGH->do_out2D[i])
- {
- fullname = CCTK_FullName (i);
- if (! msg)
- {
- Util_asprintf (&msg, "IOJpeg_2D: Output requested for %s",fullname);
- }
- else
- {
- oldmsg = msg;
- Util_asprintf (&msg, "%s %s", oldmsg, fullname);
- free (oldmsg);
- }
- free (fullname);
- }
- }
- if (msg)
- {
- CCTK_INFO (msg);
- free (msg);
- }
- }
-
- /* 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 vindex, const char *optstring, void *arg)
-{
- char *flags = (char *) arg;
-
-
- flags[vindex] = 1;
-
- if (optstring)
- {
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Optional string '%s' in variable name ignored", optstring);
- }
-}
diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c
deleted file mode 100644
index 556c69d..0000000
--- a/src/ParseGeometry.c
+++ /dev/null
@@ -1,129 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "cctk.h"
-#include "cctk_Arguments.h"
-#include "cctk_Parameters.h"
-
-#include "util_String.h"
-#include "IOJpeg.h"
-#include "CactusBase/IOASCII/src/ioASCIIGH.h"
-
-static const char *rcsid = "$Header$";
-
-CCTK_FILEVERSION(CactusIO_IOJpeg_ParseGeometry_c)
-
-void IOJpeg_DefaultGeo(const cGH *GH, int sdim, IOJpegGeo_t *geo) {
- DECLARE_CCTK_PARAMETERS
-
- asciiioGH *asGH;
- int idim,ti;
- const char *tmp_origin, *tmp_downs, *tmp_length;
- const char *token;
-
- asGH = (asciiioGH *) GH->extensions
- [CCTK_GHExtensionHandle ("IOASCII")];
-
- geo->vdim = -1;
- geo->sdim = sdim;
-
- for (idim=0;idim<SLABSKEL_MAXDIM;idim++) {
- geo->direction[idim] = idim;
- geo->slab_start[idim]= 0;
- geo->length[idim] =-1;
- geo->actlen[idim] =-1;
- geo->downs[idim] = 1;
- }
-
- /* FIXME: we use spxyz, which is hardcoded to 3D */
- for (idim=0;idim<3;idim++)
- geo->slab_start[idim]=asGH->spxyz[2][(idim+1)%3][idim];
-
- /* Parse the parameter of the requested dimension */
- switch (sdim) {
- case 2:
- tmp_origin = origin2D;
- tmp_downs = downsampling2D;
- tmp_length = length2D;
- break;
- default:
- tmp_origin = origin2D;
- tmp_downs = downsampling2D;
- tmp_length = length2D;
- break;
- }
-
- /* Origin, set from parameter only if parameter value .ne. -1 */
- idim=0;
- while((token = Util_StrSep(&tmp_origin,","))) {
- ti=atoi(token);
- if (ti>-1) geo->slab_start[idim++] = ti;
- }
- ti = atoi(tmp_origin);
- if (ti>-1) geo->slab_start[idim] = ti;
-
- /* Downsample */
- idim=0;
- while((token = Util_StrSep(&tmp_downs,","))) {
- geo->downs[idim++]=atoi(token);
- }
- geo->downs[idim] = atoi(tmp_downs);
-
- /* Length */
- idim=0;
- while((token = Util_StrSep(&tmp_length,","))) {
- geo->length[idim++]=atoi(token);
- }
- geo->length[idim] = atoi(tmp_length);
-}
-
-
-int IOJpeg_SetDirection (IOJpegGeo_t *geometry, int direction)
-{
- int retval = 0;
-
-
- if (geometry->vdim == 3)
- {
- if (geometry->sdim == 2)
- {
- switch (direction)
- {
- case 0: geometry->direction[0]=0; geometry->direction[1]=1; break;
- case 1: geometry->direction[0]=0; geometry->direction[1]=2; break;
- case 2: geometry->direction[0]=1; geometry->direction[1]=2; break;
- }
- }
- else if (geometry->sdim == 1)
- {
- switch (direction)
- {
- case 0: geometry->direction[0]=0; break;
- case 1: geometry->direction[0]=1; break;
- case 2: geometry->direction[0]=2; break;
- }
- }
- }
- else if (geometry->vdim==2)
- {
- if (geometry->sdim == 2)
- {
- geometry->direction[0]=0; geometry->direction[1]=1;
- }
- else if (geometry->sdim == 1)
- {
- switch (direction)
- {
- case 0: geometry->direction[0]=0; break;
- case 1: geometry->direction[0]=1; break;
- }
- }
- }
- else
- {
- retval = -1;
- }
-
- return (retval);
-}
diff --git a/src/Startup.c b/src/Startup.c
index 6927697..eee9631 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -1,58 +1,172 @@
-#include <stdio.h>
+ /*@@
+ @file Startup.c
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Startup routines for IOJpeg.
+ @enddesc
+ @version $Id$
+ @@*/
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "IOJpeg.h"
+#include <stdlib.h>
+#include <string.h>
-static const char *rcsid = "$Header$";
+#include "cctk.h"
+#include "cctk_IOMethods.h"
+#include "cctk_Parameters.h"
+#include "CactusBase/IOUtil/src/ioutil_Utils.h"
+#include "ioJpegGH.h"
+/* the rcs ID and its dummy function to use it */
+static const char *rcsid = "$Id$";
CCTK_FILEVERSION(CactusIO_IOJpeg_Startup_c)
-void *IOJpeg_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH);
-int IOJpeg_InitGH (cGH *GH);
-
+/********************************************************************
+ ******************** External Routines ************************
+ ********************************************************************/
void IOJpeg_Startup (void);
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+static void *IOJpeg_SetupGH (tFleshConfig *config, int conv_level, cGH *GH);
+
+
+ /*@@
+ @routine IOJpeg_Startup
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ The startup registration routine for IOJpeg.
+ Registers the GH extensions needed for IOJpeg
+ along with its setup routine.
+ @enddesc
+ @calls CCTK_RegisterGHExtension
+ CCTK_RegisterGHExtensionSetupGH
+@@*/
void IOJpeg_Startup (void)
{
+ CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOJpeg"),
+ IOJpeg_SetupGH);
+}
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+ /*@@
+ @routine IOJpeg_SetupGH
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Allocates and sets up IOJpeg's GH extension structure
+ @enddesc
+
+ @calls CCTK_RegisterIOMethod
+ CCTK_RegisterIOMethodOutputGH
+ CCTK_RegisterIOMethodOutputVarAs
+ CCTK_RegisterIOMethodTimeToOutput
+ CCTK_RegisterIOMethodTriggerOutput
+
+ @var config
+ @vdesc the CCTK configuration as provided by the flesh
+ @vtype tFleshConfig *
+ @vio unused
+ @endvar
+ @var conv_level
+ @vdesc the convergence level
+ @vtype int
+ @vio unused
+ @endvar
+ @var GH
+ @vdesc Pointer to CCTK grid hierarchy
+ @vtype cGH *
+ @vio in
+ @endvar
+
+ @returntype void *
+ @returndesc
+ pointer to the allocated GH extension structure
+ @endreturndesc
+@@*/
+static void *IOJpeg_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
+{
+ int i, numvars;
+ ioJpegGH *myGH;
DECLARE_CCTK_PARAMETERS
- int IO_GHExtension;
- int IOMethod;
- if (CCTK_GHExtensionHandle ("IO") < 0)
+ /* suppress compiler warnings about unused variables */
+ (void) (config + 0);
+ (void) (conv_level + 0);
+ (void) (GH + 0);
+
+ /* allocate the GH extension and its components */
+ myGH = (ioJpegGH *) malloc (sizeof (ioJpegGH));
+ if (! myGH)
+ {
+ CCTK_WARN (0, "IOJpeg_SetupGH: Unable to allocate memory for GH");
+ }
+
+ /* register the IOJpeg routines as output methods */
+ i = CCTK_RegisterIOMethod ("IOJpeg");
+ CCTK_RegisterIOMethodOutputGH (i, IOJpeg_OutputGH);
+ CCTK_RegisterIOMethodOutputVarAs (i, IOJpeg_OutputVarAs);
+ CCTK_RegisterIOMethodTimeToOutput (i, IOJpeg_TimeFor);
+ CCTK_RegisterIOMethodTriggerOutput (i, IOJpeg_TriggerOutput);
+
+ if (! CCTK_Equals (newverbose, "none"))
{
- CCTK_WARN (1, "IOJpeg: Thorn IOUtil was not activated. "
- "No IOJpeg IO methods will be enabled.");
- return;
+ CCTK_INFO ("I/O Method 'IOJpeg' registered");
+ CCTK_INFO ("IOJpeg: Output of 2D jpeg images of grid functions/arrays");
}
- if (CCTK_MaxDim() < 3)
+ numvars = CCTK_NumVars ();
+ myGH->out_every = (int *) malloc (numvars * sizeof (int));
+ myGH->out_last = (int *) malloc (numvars * sizeof (int));
+
+ for (i = 0; i < numvars; i++)
{
- CCTK_WARN (1, "IOJpeg: IOJpeg can only currently handle 3D GVs. "
- "No IOJpeg IO methods will be enabled.");
- return;
+ myGH->out_last[i] = -1;
}
- IO_GHExtension = CCTK_RegisterGHExtension ("IOJpeg");
- CCTK_RegisterGHExtensionSetupGH (IO_GHExtension, IOJpeg_SetupGH);
- CCTK_RegisterGHExtensionInitGH (IO_GHExtension, IOJpeg_InitGH);
+ myGH->out_vars = strdup ("");
+ myGH->out_every_default = 0;
- /* Register the 2D IOJpeg routines as output methods */
+ /* Check whether "out2D_dir" was set.
+ If so take this dir otherwise default to "IO::outdir" */
+ if (CCTK_ParameterQueryTimesSet ("out2D_dir", CCTK_THORNSTRING) <= 0)
+ {
+ out2D_dir = outdir;
+ }
- IOMethod = CCTK_RegisterIOMethod ("IOJpeg_2D");
- CCTK_RegisterIOMethodOutputGH (IOMethod, IOJpeg_Output2DGH);
- CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOJpeg_Output2DVarAs);
- CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOJpeg_TimeFor2D);
- CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOJpeg_TriggerOutput2D);
+ /* omit the directory if it's the current working dir */
+ if (strcmp (out2D_dir, ".") == 0)
+ {
+ myGH->outdir = strdup ("");
+ }
+ else
+ {
+ myGH->outdir = (char *) malloc (strlen (out2D_dir) + 2);
+ sprintf (myGH->outdir, "%s/", out2D_dir);
+ }
- if (CCTK_Equals (newverbose, "standard") ||
- CCTK_Equals( newverbose, "full"))
+ /* create the output dir */
+ i = IOUtil_CreateDirectory (GH, myGH->outdir, 0, 0);
+ if (i < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOJpeg_SetupGH: problem creating IOJpeg output directory '%s'",
+ myGH->outdir);
+ }
+ else if (i >= 0 && CCTK_Equals (newverbose, "full"))
{
- CCTK_INFO ("I/O Method 'IOJpeg_2D' registered");
- CCTK_INFO ("IOJpeg_2D: Output of 2D slices in 3D in Jpeg format");
+ CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg: Output to directory '%s'",
+ myGH->outdir);
}
+ return (myGH);
}
diff --git a/src/Write.c b/src/Write.c
new file mode 100644
index 0000000..64d1928
--- /dev/null
+++ b/src/Write.c
@@ -0,0 +1,313 @@
+/*@@
+ @file Write.c
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Output two-dimensional slices in Jpeg image format.
+ @enddesc
+ @version $Id$
+ @@*/
+
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_Parameters.h"
+#include "Hyperslab.h"
+#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
+#include "ioJpegGH.h"
+
+/* the rcs ID and its dummy function to use it */
+static const char *rcsid = "$Id$";
+CCTK_FILEVERSION(CactusIO_IOJpeg_Write_c)
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+static void WriteData (const cGH *GH, int vindex, const char *alias, int dim,
+ int dir, const CCTK_INT hsize[2], const void *hdata);
+
+
+/*@@
+ @routine IOJpeg_Write
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Writes the slices of a variable into separate Jpeg files.
+ @enddesc
+ @calls Hyperslab_DefineGlobalMappingByIndex
+ Hyperslab_FreeMapping
+ Hyperslab_GetList
+ OpenFile
+ WriteData
+
+ @var GH
+ @vdesc Pointer to CCTK GH
+ @vtype const cGH *
+ @vio in
+ @endvar
+ @var vindex
+ @vdesc index of variable to output
+ @vtype CCTK_INT
+ @vio in
+ @endvar
+ @var alias
+ @vdesc alias name of variable to output
+ @vtype const char *
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 for success, or<BR>
+ -1 if variable has no storage assigned<BR>
+ -2 if output file couldn't be opened<BR>
+ -3 if hyperslab for coordinates and/or variable couldn't be
+ extracted
+ @endreturndesc
+@@*/
+int IOJpeg_Write (const cGH *GH, CCTK_INT vindex, const char *alias)
+{
+ ioJpegGH *myGH;
+ int i, total_hsize;
+ int dir, dir_i, dir_j, maxdir, myproc, groupindex;
+ cGroup gdata;
+ char *fullname;
+ int extent_int[3];
+ CCTK_INT mapping;
+ CCTK_INT origin[3], extent[3], direction[6], hsize[2];
+ void *hdata;
+ const CCTK_INT htype = CCTK_VARIABLE_REAL;
+ DECLARE_CCTK_PARAMETERS
+
+
+ /* get the variable name and group information */
+ fullname = CCTK_FullName (vindex);
+ groupindex = CCTK_GroupIndexFromVarI (vindex);
+ CCTK_GroupData (groupindex, &gdata);
+
+ /* check if variable has storage assigned */
+ if (! CCTK_QueryGroupStorageI (GH, groupindex))
+ {
+ CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "No IOJpeg output for '%s' (no storage)", fullname);
+ free (fullname);
+ return (-1);
+ }
+
+ /* get the handle for IOJpeg extensions */
+ myproc = CCTK_MyProc (GH);
+ myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
+
+ /* get the number of slices to output */
+ /* in general: maxdir = gdata.dim * (gdata.dim - 1) / 2; */
+ maxdir = gdata.dim == 2 ? 1 : 3;
+
+ /* get the extents of the variable */
+ CCTK_GroupgshVI (GH, 3, extent_int, vindex);
+
+ /* now do the actual I/O looping over all directions */
+ for (dir = 0; dir < maxdir; dir++)
+ {
+ /* get the directions to span the hyperslab */
+ if (dir == 0)
+ {
+ dir_i = 0; dir_j = 1; /* xy */
+ }
+ else if (dir == 1)
+ {
+ dir_i = 0; dir_j = 2; /* xz */
+ }
+ else
+ {
+ dir_i = 1; dir_j = 2; /* yz */
+ }
+
+ /* set the extent vector */
+ for (i = 0; i < 3; i++)
+ {
+ extent[i] = extent_int[i];
+ }
+
+ /* set the origin using the slice center from IOUtil */
+ memset (origin, 0, sizeof (origin));
+ if (gdata.grouptype == CCTK_GF)
+ {
+ origin[maxdir-dir-1] = myGH->sp2xyz[gdata.dim - 1][dir];
+ }
+
+ /* set the direction vector */
+ memset (direction, 0, sizeof (direction));
+ direction[dir_i] = direction[gdata.dim + dir_j] = 1;
+
+ mapping = Hyperslab_DefineGlobalMappingByIndex (GH, vindex, 2,
+ direction, origin, extent,
+ NULL, -1, NULL, hsize);
+ if (mapping < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOJpeg_Write: Failed to define hyperslab mapping for "
+ "variable '%s'", fullname);
+ continue;
+ }
+ total_hsize = hsize[0] * hsize[1];
+ if (total_hsize <= 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOJpeg_Write: selected hyperslab has zero size for "
+ "variable '%s' direction %d", fullname, dir);
+ Hyperslab_FreeMapping (mapping);
+ continue;
+ }
+
+ if (myproc == 0)
+ {
+ /* allocate hyperslab buffer */
+ hdata = malloc (total_hsize * CCTK_VarTypeSize (gdata.vartype));
+ }
+
+ /* get the hyperslab */
+ i = Hyperslab_GetList (GH, mapping, 1, NULL, &vindex, NULL, &htype, &hdata,
+ NULL);
+ if (i != 1)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "IOJpeg_Write: Failed to extract hyperslab for variable '%s'",
+ fullname);
+ }
+
+ /* release the mapping structure */
+ Hyperslab_FreeMapping (mapping);
+
+ /* and dump the data to file */
+ if (myproc == 0)
+ {
+ if (i == 1)
+ {
+ WriteData (GH, vindex, alias, gdata.dim, dir, hsize, hdata);
+ }
+
+ /* clean up */
+ free (hdata);
+ }
+ } /* end of looping through xyz directions */
+
+ free (fullname);
+
+ return (0);
+}
+
+
+/********************************************************************
+ ******************** Internal Routines ************************
+ ********************************************************************/
+/*@@
+ @routine WriteData
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ Writes the given hyperslab into a Jpeg output file.
+ @enddesc
+ @@*/
+static void WriteData (const cGH *GH, int vindex, const char *alias, int dim,
+ int dir, const CCTK_INT hsize[2], const void *hdata)
+{
+ FILE *file;
+ CCTK_REAL min, max;
+ int reduction_handle;
+ unsigned char *dataout;
+ ioJpegGH *myGH;
+ ioAdvertisedFileDesc advertised_file;
+ char *filename, *fullname;
+ char slicename[30];
+ const char *extensions[] = {"xy", "xz", "yz"};
+ /*** FIXME: can CCTK_Reduce() have a 'const cGH *' parameter ?? ***/
+ union
+ {
+ const cGH *const_ptr;
+ cGH *non_const_ptr;
+ } GH_fake_const;
+ DECLARE_CCTK_PARAMETERS
+
+
+ GH_fake_const.const_ptr = GH;
+ myGH = (ioJpegGH *) CCTK_GHExtension (GH, "IOJpeg");
+
+ if (CCTK_Equals (colormap, "custom"))
+ {
+ min = colormap_min;
+ max = colormap_max;
+ }
+ else
+ {
+ reduction_handle = CCTK_ReductionHandle ("minimum");
+ CCTK_Reduce (GH_fake_const.non_const_ptr, 0, reduction_handle, 1,
+ CCTK_VARIABLE_REAL, &min, 1, vindex);
+ reduction_handle = CCTK_ReductionHandle ("maximum");
+ CCTK_Reduce (GH_fake_const.non_const_ptr, 0, reduction_handle, 1,
+ CCTK_VARIABLE_REAL, &max, 1, vindex);
+ }
+
+ /* allocate the RGB image buffer */
+ dataout = (unsigned char *) malloc (3 * hsize[0] * hsize[1]);
+
+ AutoColorDataSlice (hsize[0], hsize[1], hdata, dataout, min, max,
+ colormap_bias, colormap_factor);
+
+ /* open the file */
+ if (dim == 2)
+ {
+ strcpy (slicename, "2D");
+ }
+ else
+ {
+ /* give the slice origin as range [1 .. n] */
+ sprintf (slicename, "%s_[%d]", extensions[dir], myGH->sp2xyz[dim-1][dir]);
+ }
+
+ filename = (char *) malloc (strlen (myGH->outdir) + strlen (alias) +
+ sizeof (slicename) + 20);
+
+ if (CCTK_Equals (mode, "remove"))
+ {
+ sprintf (filename, "%s%s_%s.jpeg", myGH->outdir, alias, slicename);
+ }
+ else
+ {
+ sprintf (filename, "%s%s_%s.it_%d.jpeg", myGH->outdir, alias, slicename,
+ GH->cctk_iteration);
+ }
+
+ file = fopen (filename, "w");
+ if (file)
+ {
+ /* write the data */
+ WriteJPEGToFileRGB (hsize[0], hsize[1], dataout, colormap_quality, file);
+
+ /* advertise the file for downloading */
+ if (CCTK_Equals (mode, "remove") && myGH->out_last[vindex] < 0)
+ {
+ fullname = CCTK_FullName (vindex);
+ advertised_file.slice = slicename;
+ advertised_file.thorn = CCTK_THORNSTRING;
+ advertised_file.varname = fullname;
+ advertised_file.description = "Jpegs of slices";
+ advertised_file.mimetype = "image/jpeg";
+
+ IOUtil_AdvertiseFile (GH, filename, &advertised_file);
+
+ free (fullname);
+ }
+ }
+ else
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Cannot open IOJpeg output file '%s'", filename);
+ }
+
+ /* clean up */
+ free (dataout);
+ free (filename);
+}
diff --git a/src/Write2D.c b/src/Write2D.c
deleted file mode 100644
index 985c856..0000000
--- a/src/Write2D.c
+++ /dev/null
@@ -1,219 +0,0 @@
- /*@@
- @file Write2D.c
- @date
- @author Gabrielle Allen
- @desc
-
- @enddesc
- @version $Header$
- @@*/
-
-#include "cctk.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioutil_AdvertisedFiles.h"
-#include "IOJpeg.h"
-
-static const char *rcsid = "$Header$";
-
-CCTK_FILEVERSION(CactusIO_IOJpeg_Write2D_c)
-
-/* The dimension of the Jpeg hyperslabs */
-#define JPEG_SLABDIM 2
-
-/********************************************************************
- ********************* Local Data Types ***********************
- ********************************************************************/
-
-/********************************************************************
- ********************* Local Routine Prototypes *********************
- ********************************************************************/
-
-/********************************************************************
- ********************* Other Routine Prototypes *********************
- ********************************************************************/
-
-/********************************************************************
- ********************* Local Data *****************************
- ********************************************************************/
-
-#ifdef _WIN32
-#define FILEOPENSTRING "wb"
-#else
-#define FILEOPENSTRING "w"
-#endif
-
-/********************************************************************
- ********************* External Routines **********************
- ********************************************************************/
-
-
- /*@@
- @routine IOJpeg_Write2D
- @date
- @author Gabrielle Allen
- @desc
-
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
-@@*/
-int IOJpeg_Write2D (const cGH *GH, int vindex, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int timelevel;
- IOJpegGH *ssGH;
- IOJpegGeo_t *geo;
- FILE *file; /* output file descriptor */
- int si,max_slabs;
- char *filename;
- char *fullname;
- char slice[20];
- ioAdvertisedFileDesc advertised_file;
- int myproc;
- int retval;
-
-
- /* the return code for success */
- retval = 0;
-
- /* get the processor ID */
- myproc = CCTK_MyProc (0);
-
- /* get the variable's full name and the current timelevel */
- fullname = CCTK_FullName (vindex);
- timelevel = 0;
-
- /* Get the handle for Jpeg's IO extensions */
- ssGH = (IOJpegGH *) GH->extensions[CCTK_GHExtensionHandle ("IOJpeg")];
-
- /* Get this variable's slab geometry for 2D slabs */
- geo = &ssGH->out_geo[vindex][JPEG_SLABDIM];
-
- /* Maximal number of 2D slabs in given volume (dimension vdim) */
- max_slabs = (geo->vdim * (geo->vdim - 1)) / 2;
- if (max_slabs <= 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No 2D jpeg output available for variable '%s' alias '%s' "
- "(dim %d)", fullname, alias, geo->vdim);
- free (fullname);
- return (-1);
- }
-
- if (! CCTK_Equals (verbose, "no"))
- {
- CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg 2D-output of variable '%s' "
- "alias '%s'", fullname, alias);
- }
-
- /* allocate memory for building the filename */
- filename = (char *) malloc (strlen (ssGH->outdir2D) + strlen (alias) + 50);
-
- /* Loop over all possible hyperslabs */
- for (si = 0; si < max_slabs; si++)
- {
-
- /* Get the next set of slab directions */
- if (IOJpeg_SetDirection (geo, si) < 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot set direction for slab (#%d) in given volume (%d).",
- si, geo->vdim);
- continue;
- }
-
- /* set the slice string */
- sprintf (slice, "%d_%d", si, geo->vdim);
-
- /* processor 0 opens the output file */
- if (myproc == 0)
- {
- /* get the output filename
- skip pathname if output goes into current directory */
- if (CCTK_Equals (mode, "remove"))
- {
- if (strcmp (ssGH->outdir2D, "."))
- {
- sprintf (filename, "%s/%s_%s.jpeg", ssGH->outdir2D, alias, slice);
- }
- else
- {
- sprintf (filename, "%s_%s.jpeg", alias, slice);
- }
- }
- else
- {
- if (strcmp (ssGH->outdir2D, "."))
- {
- sprintf (filename, "%s/%s_%s.%d.jpeg", ssGH->outdir2D, alias, slice,
- GH->cctk_iteration);
- }
- else
- {
- sprintf (filename, "%s_%s.%d.jpeg", alias, slice, GH->cctk_iteration);
- }
- }
-
- file = fopen (filename, FILEOPENSTRING);
- if (! file)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot open 2D jpeg output file '%s'", filename);
- }
- }
- else
- {
- file = NULL;
- }
-
- /* now output the actual data */
- if (IOJpeg_DumpVar (GH, vindex, timelevel, geo, file) < 0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "IOJpeg_DumpVar failed for variable '%s'", fullname);
- retval--;
- }
-
- /* close the output file and advertise it */
- if (file)
- {
- /* Close the file */
- fclose (file);
-
- /* advertise the file for downloading */
- if (CCTK_Equals (mode, "remove") && ! ssGH->advertised[si][vindex])
- {
- /* Set flag for remembering if file has been advertised */
- ssGH->advertised[si][vindex] = 1;
-
- advertised_file.slice = slice;
- advertised_file.thorn = CCTK_THORNSTRING;
- advertised_file.varname = fullname;
- advertised_file.description = "Jpegs of slices";
- advertised_file.mimetype = "image/jpeg";
-
- IOUtil_AdvertiseFile (GH, filename, &advertised_file);
- }
- }
-
- } /* end of loop over all 2D hyperslabs */
-
- /* free allocated resources */
- free (filename);
- free (fullname);
-
- return (retval);
-}
diff --git a/src/ioJpegGH.h b/src/ioJpegGH.h
new file mode 100644
index 0000000..d9ee66f
--- /dev/null
+++ b/src/ioJpegGH.h
@@ -0,0 +1,65 @@
+ /*@@
+ @header ioJpegGH.h
+ @date Thu 18 April 2002
+ @author Thomas Radke
+ @desc
+ The extensions to the GH structure from IOJpeg.
+ @version $Header$
+ @@*/
+
+#ifndef IOJPEG_IOJPEGGH_H_
+#define IOJPEG_IOJPEGGH_H_ 1
+
+#include "StoreNamedData.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct IOJpegGH
+{
+ /* default number of times to output */
+ int out_every_default;
+
+ /* number of times to output every variable */
+ int *out_every;
+
+ /* the last iteration output for every variable */
+ int *out_last;
+
+ /* list of variables to output */
+ char *out_vars;
+
+ /* directories in which to output */
+ char *outdir;
+
+ /* for 2D planes, we define the index where to locate the plane
+ sp2xyz[maxdim][perpendicular direction] */
+ int **sp2xyz;
+
+} ioJpegGH;
+
+
+/* prototypes of functions to be registered as I/O method */
+int IOJpeg_OutputGH (const cGH *GH);
+int IOJpeg_OutputVarAs (const cGH *GH, const char *fullname, const char *alias);
+int IOJpeg_TimeFor (const cGH *GH, int vindex);
+int IOJpeg_TriggerOutput (const cGH *GH, int vindex);
+int IOJpeg_Write (const cGH *GH, CCTK_INT vindex, const char *alias);
+
+/* other function prototypes */
+int IOJpeg_Write (const cGH *GH, int vindex, const char *alias);
+
+/* routines called from JPEG.c */
+int WriteJPEGToFileRGB (int nx, int ny, void *data, int Quality, FILE* outfile);
+int WriteJPEGToMemoryRGB (int nx, int ny, void *data, int Quality, char *buffer,
+ int buffersize);
+void AutoColorDataSlice (int nx, int ny, const CCTK_REAL *datain,
+ unsigned char *dataout, CCTK_REAL min, CCTK_REAL max,
+ CCTK_REAL bias, int rdfac);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif /* IOJPEG_IOJPEGGH_H_ */
diff --git a/src/make.code.defn b/src/make.code.defn
index 096edce..07c6877 100644
--- a/src/make.code.defn
+++ b/src/make.code.defn
@@ -2,8 +2,4 @@
# $Header$
# Source files in this directory
-SRCS = DumpVar.c Output2D.c Write2D.c Startup.c ParseGeometry.c GHExtension.c JPEG.c
-
-# Subdirectories containing source files
-SUBDIRS =
-
+SRCS = Startup.c Output.c Write.c ChooseOutput.c JPEG.c