diff options
Diffstat (limited to 'src/Write2D.c')
-rw-r--r-- | src/Write2D.c | 219 |
1 files changed, 0 insertions, 219 deletions
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); -} |