aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2001-03-14 22:20:11 +0000
committertradke <tradke@eff87b29-5268-4891-90a3-a07138403961>2001-03-14 22:20:11 +0000
commit8c3be93be642f3bf509cefac553ce97d529f4b61 (patch)
tree46689e2c0eb50088c3b2515f9b637b25bd0b0040
parent62135682b9b0ccf47aa0723475039b3d26803d30 (diff)
Omit the leading "./" in output filenames if output goes into the current
directory. This makes downloading such output files via the web interface nicer because they doen't have any special characters in it. Also fixed gcc warnings. git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@36 eff87b29-5268-4891-90a3-a07138403961
-rw-r--r--src/DumpVar.c45
-rw-r--r--src/GHExtension.c12
-rw-r--r--src/IOJpeg.h51
-rw-r--r--src/JPEG.c5
-rw-r--r--src/Output2D.c34
-rw-r--r--src/ParseGeometry.c1
-rw-r--r--src/Write2D.c39
7 files changed, 112 insertions, 75 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c
index d14249e..56ecbad 100644
--- a/src/DumpVar.c
+++ b/src/DumpVar.c
@@ -7,16 +7,23 @@
#include "Hyperslab.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 IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *fid)
+static int IOJpeg_Output (cGH *GH,
+ int vindex,
+ CCTK_REAL *data,
+ int sdim,
+ int *hsize,
+ FILE *fid);
+
+
+int IOJpeg_DumpVar (cGH *GH,
+ int vindex,
+ int timelevel,
+ IOJpegGeo_t *geo,
+ FILE *fid)
{
DECLARE_CCTK_PARAMETERS
void *data=NULL;
int *hsizes, slabstart[SLABSKEL_MAXDIM];
- int vtype;
int idim, vdim;
int sdir[3] = {0,0,0};
@@ -26,9 +33,6 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
vdim= geo->vdim;
- /* Checks for vartype can go here */
- vtype = CCTK_VarTypeI (index);
-
/* TEMPORARY FIX DUE TO INCONSISTENT DIR SPECIFICATION */
/* direction vector of 1d line in 3d volume */
if (geo->sdim==1) {
@@ -52,7 +56,7 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
}
else
{
- char *fullname = CCTK_FullName (index);
+ char *fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"No 0-dim extraction possible: '%s'", fullname);
free (fullname);
@@ -72,11 +76,11 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
hyperslab data will be in data,
hyperslab sizes: hsizes[SLAB_DIM].
*/
- if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, geo->sdim, slabstart,
+ if (Hyperslab_GetHyperslab (GH, 0, vindex, timelevel, geo->sdim, slabstart,
sdir, geo->length, geo->downs,
&data, hsizes) < 0)
{
- char *fullname = CCTK_FullName (index);
+ char *fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"Failed to extract hyperslab for variable '%s'", fullname);
free (fullname);
@@ -84,10 +88,9 @@ int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *f
}
/* Output the hyperslab data */
- if (IOJpeg_Output (GH, index, timelevel, data, geo->sdim, hsizes,
- vtype, fid)<0)
+ if (IOJpeg_Output (GH, vindex, data, geo->sdim, hsizes, fid) < 0)
{
- char *fullname = CCTK_FullName (index);
+ char *fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -111,8 +114,12 @@ 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)
+static int IOJpeg_Output (cGH *GH,
+ int vindex,
+ CCTK_REAL *data,
+ int sdim,
+ int *hsize,
+ FILE *fid)
{
DECLARE_CCTK_PARAMETERS
@@ -131,10 +138,10 @@ int IOJpeg_Output(cGH *GH, int index, int timelevel, CCTK_REAL *data,
int reduction_handle;
reduction_handle = CCTK_ReductionHandle ("maximum");
CCTK_Reduce (GH, 0, reduction_handle, 1,
- CCTK_VARIABLE_REAL,&max, 1, index);
+ CCTK_VARIABLE_REAL,&max, 1, vindex);
reduction_handle = CCTK_ReductionHandle ("minimum");
CCTK_Reduce (GH, 0, reduction_handle, 1,
- CCTK_VARIABLE_REAL,&min, 1, index);
+ CCTK_VARIABLE_REAL,&min, 1, vindex);
}
if(fid)
diff --git a/src/GHExtension.c b/src/GHExtension.c
index 4d03287..72076f8 100644
--- a/src/GHExtension.c
+++ b/src/GHExtension.c
@@ -8,13 +8,23 @@
#include "IOJpeg.h"
-void IOJpeg_DefaultGeo(cGH *GH, int sdim, IOJpegGeo_t *geo);
+
+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));
diff --git a/src/IOJpeg.h b/src/IOJpeg.h
index 61a7ff6..89871b7 100644
--- a/src/IOJpeg.h
+++ b/src/IOJpeg.h
@@ -43,36 +43,39 @@ typedef struct IOJpegGH {
} IOJpegGH;
/* function prototypes */
-int IOJpeg_Write3D (cGH *GH, int index, const char *alias);
-int IOJpeg_Write2D (cGH *GH, int index, const char *alias);
-int IOJpeg_Write1D (cGH *GH, int index, const char *alias);
-
-int IOJpeg_DumpVar (cGH *GH, int index, int timelevel, IOJpegGeo_t *geo, FILE *fid);
+int IOJpeg_Output2DGH (cGH *GH);
+int IOJpeg_Output2DVarAs (cGH *GH, const char *fullname, const char *alias);
+int IOJpeg_TimeFor2D (cGH *GH, int vindex);
+int IOJpeg_TriggerOutput2D (cGH *GH, int vindex);
+int IOJpeg_Write2D (cGH *GH, int vindex, const char *alias);
+void IOJpeg_DefaultGeo(cGH *GH, int sdim, IOJpegGeo_t *geo);
+int IOJpeg_SetDirection (IOJpegGeo_t *geometry, int direction);
+int IOJpeg_DumpVar (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 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);
+ 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"
diff --git a/src/JPEG.c b/src/JPEG.c
index 3103b41..aca497e 100644
--- a/src/JPEG.c
+++ b/src/JPEG.c
@@ -16,6 +16,11 @@ typedef struct jpeg_compress_struct JpgComp;
typedef struct jpeg_error_mgr JpgErr;
#endif
+/* prototypes of routines defined in this source file */
+GLOBAL(void)
+jpeg_memory_dest (j_compress_ptr cinfo, JOCTET *buffer,int bufsize);
+
+
/*
Image data is an array of unsigned character array of
RGB data. The data is stored in interleaved order.
diff --git a/src/Output2D.c b/src/Output2D.c
index 887e333..556c745 100644
--- a/src/Output2D.c
+++ b/src/Output2D.c
@@ -11,10 +11,8 @@
/* function prototypes */
-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);
+static void SetOutputFlag (int vindex, const char *optstring, void *arg);
/*@@
@@ -86,12 +84,12 @@ int IOJpeg_Output2DGH (cGH *GH)
int IOJpeg_Output2DVarAs (cGH *GH, const char *fullname, const char *alias)
{
DECLARE_CCTK_PARAMETERS
- int index,ierr=0;
+ int vindex,ierr=0;
- index = CCTK_VarIndex (fullname);
+ vindex = CCTK_VarIndex (fullname);
/* first, check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
+ if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex)))
{
CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
"No IOJpeg 2D output for '%s' (no storage)", fullname);
@@ -101,16 +99,16 @@ 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);
+ "index = (%s, %s, %d)", fullname, alias, vindex);
}
/* Do the 2D output */
- ierr=IOJpeg_Write2D (GH, index, alias);
+ ierr=IOJpeg_Write2D (GH, vindex, alias);
return (ierr);
}
-int IOJpeg_TimeFor2D (cGH *GH, int index)
+int IOJpeg_TimeFor2D (cGH *GH, int vindex)
{
IOJpegGH *myGH;
@@ -127,14 +125,14 @@ int IOJpeg_TimeFor2D (cGH *GH, int index)
}
/* Check this variable should be output */
- if (! (myGH->do_out2D [index] && GH->cctk_iteration % myGH->out2D_every == 0))
+ 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 [index] == GH->cctk_iteration)
+ if (myGH->out2D_last [vindex] == GH->cctk_iteration)
{
CCTK_WARN (2, "Already done 2D output in IOJpeg");
return (0);
@@ -143,28 +141,28 @@ int IOJpeg_TimeFor2D (cGH *GH, int index)
return (1);
}
-int IOJpeg_TriggerOutput2D (cGH *GH, int index)
+int IOJpeg_TriggerOutput2D (cGH *GH, int vindex)
{
DECLARE_CCTK_PARAMETERS
IOJpegGH *myGH;
const char *varname;
int ierr=0;
- varname = CCTK_VarName (index);
+ varname = CCTK_VarName (vindex);
myGH = (IOJpegGH *) GH->extensions [CCTK_GHExtensionHandle ("IOJpeg")];
if (!CCTK_Equals(verbose,"no"))
{
CCTK_VInfo (CCTK_THORNSTRING, "IOJpeg_TriggerOutput2D: varname, index = "
- "(%s, %d)", varname, index);
+ "(%s, %d)", varname, vindex);
}
/* Do the 2D output */
- ierr=IOJpeg_Write2D (GH, index, varname);
+ ierr=IOJpeg_Write2D (GH, vindex, varname);
/* Register variable as having 2D output this iteration */
- myGH->out2D_last [index] = GH->cctk_iteration;
+ myGH->out2D_last [vindex] = GH->cctk_iteration;
return (ierr);
}
@@ -204,12 +202,12 @@ static void CheckSteerableParameters (IOJpegGH *myGH)
/* callback for CCTK_TraverseString() to set the output flag
for the given variable */
-static void SetOutputFlag (int index, const char *optstring, void *arg)
+static void SetOutputFlag (int vindex, const char *optstring, void *arg)
{
char *flags = (char *) arg;
- flags[index] = 1;
+ flags[vindex] = 1;
if (optstring)
{
diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c
index ad003f9..ae4550c 100644
--- a/src/ParseGeometry.c
+++ b/src/ParseGeometry.c
@@ -10,6 +10,7 @@
#include "IOJpeg.h"
#include "CactusBase/IOASCII/src/ioASCIIGH.h"
+
void IOJpeg_DefaultGeo(cGH *GH, int sdim, IOJpegGeo_t *geo) {
DECLARE_CCTK_PARAMETERS
diff --git a/src/Write2D.c b/src/Write2D.c
index 457704f..0bab2cd 100644
--- a/src/Write2D.c
+++ b/src/Write2D.c
@@ -37,8 +37,6 @@ CCTK_FILEVERSION(DevThorns_IOJpeg_Write2D_c)
********************* Local Routine Prototypes *********************
********************************************************************/
-int IOJpeg_SetDirection (IOJpegGeo_t *geometry, int direction);
-
/********************************************************************
********************* Other Routine Prototypes *********************
********************************************************************/
@@ -72,7 +70,7 @@ int IOJpeg_SetDirection (IOJpegGeo_t *geometry, int direction);
@endhistory
@@*/
-int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
+int IOJpeg_Write2D (cGH *GH, int vindex, const char *alias)
{
DECLARE_CCTK_PARAMETERS
int timelevel;
@@ -95,8 +93,8 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
myproc = CCTK_MyProc (0);
/* get the variable's full name and the current timelevel */
- fullname = CCTK_FullName (index);
- timelevel = CCTK_NumTimeLevelsFromVarI (index) - 1;
+ fullname = CCTK_FullName (vindex);
+ timelevel = CCTK_NumTimeLevelsFromVarI (vindex) - 1;
if (timelevel > 0)
{
timelevel--;
@@ -106,7 +104,7 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
ssGH = (IOJpegGH *) GH->extensions[CCTK_GHExtensionHandle ("IOJpeg")];
/* Get this variable's slab geometry for 2D slabs */
- geo = &ssGH->out_geo[index][JPEG_SLABDIM];
+ 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;
@@ -147,15 +145,30 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
/* processor 0 opens the output file */
if (myproc == 0)
{
- /* get the output filename */
+ /* get the output filename
+ skip pathname if output goes into current directory */
if (CCTK_Equals (mode, "remove"))
{
- sprintf (filename, "%s/%s_%s.jpeg", ssGH->outdir2D, alias, slice);
+ if (strcmp (ssGH->outdir2D, "."))
+ {
+ sprintf (filename, "%s/%s_%s.jpeg", ssGH->outdir2D, alias, slice);
+ }
+ else
+ {
+ sprintf (filename, "%s_%s.jpeg", alias, slice);
+ }
}
else
{
- sprintf (filename, "%s/%s_%s.%d.jpeg", ssGH->outdir2D, alias, slice,
- GH->cctk_iteration);
+ 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);
@@ -171,7 +184,7 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
}
/* now output the actual data */
- if (IOJpeg_DumpVar (GH, index, timelevel, geo, file) < 0)
+ if (IOJpeg_DumpVar (GH, vindex, timelevel, geo, file) < 0)
{
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
"IOJpeg_DumpVar failed for variable '%s'", fullname);
@@ -185,10 +198,10 @@ int IOJpeg_Write2D (cGH *GH, int index, const char *alias)
fclose (file);
/* advertise the file for downloading */
- if (CCTK_Equals (mode, "remove") && ! ssGH->advertised[si][index])
+ if (CCTK_Equals (mode, "remove") && ! ssGH->advertised[si][vindex])
{
/* Set flag for remembering if file has been advertised */
- ssGH->advertised[si][index] = 1;
+ ssGH->advertised[si][vindex] = 1;
advertised_file.slice = slice;
advertised_file.thorn = CCTK_THORNSTRING;