From cf7d25d425bb83833c99ff88a73ea4838b50feb5 Mon Sep 17 00:00:00 2001 From: tradke Date: Tue, 23 Apr 2002 16:41:31 +0000 Subject: Code cleanup before moving into production mode. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOPanda/trunk@29 38c3d835-c875-442e-b0fe-21c19ce1d001 --- src/DumpVar.c | 207 -------------- src/GHExtension.c | 159 ----------- src/Output.c | 670 ++++++++++++++++++++++++++++++++++++++++++++ src/Output3D.c | 659 ------------------------------------------- src/Panda/c_interface.h | 7 + src/Startup.c | 213 ++++++++++---- src/Write.c | 207 ++++++++++++++ src/ioPandaGH.h | 45 ++- src/make.code.defn | 9 +- src/make.configuration.defn | 13 +- 10 files changed, 1084 insertions(+), 1105 deletions(-) delete mode 100644 src/DumpVar.c delete mode 100644 src/GHExtension.c create mode 100644 src/Output.c delete mode 100644 src/Output3D.c create mode 100644 src/Write.c (limited to 'src') diff --git a/src/DumpVar.c b/src/DumpVar.c deleted file mode 100644 index 5715d9e..0000000 --- a/src/DumpVar.c +++ /dev/null @@ -1,207 +0,0 @@ -/*@@ - @file DumpVar.c - @date 01 Oct 1999 - @author Jonghyun Lee - @desc Do the actual writing of a 3D grid array. - @enddesc - @history - @hendhistory - @@*/ - -#include -#include - -#include "cctk.h" -#include "cctk_Parameters.h" -#include "CactusPUGH/PUGH/src/include/pugh.h" -#include "CactusBase/IOUtil/src/ioGH.h" -#include "ioPandaGH.h" - - -void IOPanda_getDumpData (const cGH *GH, int vindex, int timelevel, - void **outme, int *free_outme, CCTK_INT4 *geom, - int element_size); - - -void IOPanda_getDumpData (const cGH *GH, int vindex, int timelevel, - void **outme, int *free_outme, CCTK_INT4 *geom, - int element_size) -{ - DECLARE_CCTK_PARAMETERS - int i, myproc, do_downsample, dim; - ioGH *ioUtilGH; - CCTK_REAL4 *single_ptr; - CCTK_REAL *real_ptr; - CCTK_BYTE *char_ptr; - CCTK_INT *int_ptr; - pGExtras *extras; - void *data = CCTK_VarDataPtrI (GH, timelevel, vindex); - - /* to make the compiler happy */ - single_ptr = NULL; - real_ptr = NULL; - char_ptr = NULL; - int_ptr = NULL; - - /* get the processor ID */ - myproc = CCTK_MyProc (GH); - - /* get the handle for IOUtil GH extensions */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; - - /* get the pGExtras pointer as a shortcut */ - extras = ((pGA ***) PUGH_pGH (GH)->variables) [vindex][timelevel]->extras; - - /* get the dimension of the variable */ - dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex)); - - do_downsample = 0; - for (i = 0; i < dim; i++) - do_downsample |= ioUtilGH->downsample [i] > 1; - - /* All the downsampling code is hard-coded for 3D data. - For other-dimensional variables we print a warning - and return the non-downsampled data. */ - if (do_downsample && dim != 3) { - char *fullname = CCTK_FullName (vindex); - - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "No downsampling for %dD variable '%s' ! Downsampling is only " - "supported for 3D variables.", dim, fullname); - free (fullname); - do_downsample = 0; - } - - /* Simple case if no downsampling */ - if (! do_downsample) { - - if (ioUtilGH->out_single) { - single_ptr = (CCTK_REAL4 *) malloc (extras->npoints*sizeof (CCTK_REAL4)); - - for (i = 0; i < extras->npoints; i++) - single_ptr [i] = (CCTK_REAL4) ((CCTK_REAL *) data) [i]; - - *outme = single_ptr; - *free_outme = 1; - } else { - *outme = data; - *free_outme = 0; - } - - /* set the bounds, the sizes, and the global shape */ - for (i = 0; i < dim; i++) { - geom [i + 0*dim] = extras->lb [myproc][i]; - geom [i + 1*dim] = extras->lnsize [i]; - geom [i + 2*dim] = extras->nsize [i]; - } - - } else { - - /* NOTE: the following downsampling code is hard-coded for 3D data */ - - int start [3], end [3]; - int j, k, l; - - /* downsampled global shape */ - for (i = 0; i < 3; i++) { - geom [i + 6] = extras->nsize [i] / ioUtilGH->downsample [i]; - if (extras->nsize [i] % ioUtilGH->downsample [i]) - geom [i + 6]++; - } - - if (verbose) - CCTK_VInfo (CCTK_THORNSTRING, "Downsampled sizes (%d, %d, %d) -> " - "(%d, %d, %d)", - extras->nsize [0], extras->nsize [1], extras->nsize [2], - (int) geom [6], (int) geom [7], (int) geom [8]); - - /* Now figure out the local downsampling */ - /* The local starts are the lb modded into the downsample */ - for (i = 0; i < 3; i++) { - geom [i] = extras->lb [myproc][i] / ioUtilGH->downsample [i]; - start [i] = geom [i] * ioUtilGH->downsample [i]; - if (start [i] < - extras->lb [myproc][i] + extras->ownership [PUGH_NO_STAGGER][0][i]) { - start [i] += ioUtilGH->downsample [i]; - geom [i] ++; - } - end [i] = ((extras->lb [myproc][i] + - extras->ownership [PUGH_NO_STAGGER][1][i] - 1) / - ioUtilGH->downsample [i]) * ioUtilGH->downsample [i]; - geom [i+3] = (end [i] - start [i]) / ioUtilGH->downsample [i] + 1; - } - - if (verbose) { - CCTK_VInfo (CCTK_THORNSTRING, "Downsample ranges (%d, %d, %d) -> " - "(%d, %d, %d)", - start [0], start [1], start [2], end [0], end [1], end [2]); - CCTK_VInfo (CCTK_THORNSTRING, "Local size/bound (%d, %d, %d) " - "(%d, %d, %d)", (int) geom [3], (int) geom [4], (int) geom[5], - (int) geom [0], (int) geom [1], (int) geom [2]); - } - - /* compute local ranges */ - for (i = 0; i < 3; i++) { - start [i] -= extras->lb [myproc][i]; - end [i] -= extras->lb [myproc][i]; - } - - *outme = malloc (geom [3] * geom [4] * geom [5] * element_size); - *free_outme = 1; - - /* I hate it to repeat the loops for each case label - but that way produces much more efficient code */ - l = 0; - switch (CCTK_VarTypeI (vindex)) { - case CCTK_VARIABLE_CHAR: - char_ptr = (CCTK_BYTE *) *outme; - for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample [2]) - for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample [1]) - for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample [0]) - char_ptr [l++] = ((CCTK_BYTE *) data) [DATINDEX (extras, i, j, k)]; - break; - - case CCTK_VARIABLE_INT: - int_ptr = (CCTK_INT *) *outme; - for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample [2]) - for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample [1]) - for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample [0]) - int_ptr [l++] = ((CCTK_INT *) data) [DATINDEX (extras, i, j, k)]; - break; - - case CCTK_VARIABLE_REAL: - if (ioUtilGH->out_single) - single_ptr = (CCTK_REAL4 *) *outme; - else - real_ptr = (CCTK_REAL *) *outme; - for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample [2]) - for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample [1]) - for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample [0]) - if (ioUtilGH->out_single) - single_ptr [l++] = (CCTK_REAL4) - (((CCTK_REAL *) data) [DATINDEX (extras, i, j, k)]); - else - real_ptr [l++] = ((CCTK_REAL *) data) [DATINDEX (extras, i, j, k)]; - break; - - default: - CCTK_WARN (1, "Unsupported variable type in IOPanda_getDumpData"); - return; - } - } - -#ifdef IOPANDA_DEBUG - printf ("Lower bound: %d", (int) geom [0]); - for (i = 1; i < dim; i++) - printf (" %d", (int) geom [i]); - printf ("\n"); - printf ("Chunk size : %d", (int) geom [1*dim + 0]); - for (i = 1; i < dim; i++) - printf (" %d", (int) geom [1*dim + i]); - printf ("\n"); - printf ("Global size: %d", (int) geom [2*dim + 0]); - for (i = 1; i < dim; i++) - printf (" %d", (int) geom [2*dim + i]); - printf ("\n"); -#endif -} diff --git a/src/GHExtension.c b/src/GHExtension.c deleted file mode 100644 index b3cdd1d..0000000 --- a/src/GHExtension.c +++ /dev/null @@ -1,159 +0,0 @@ - /*@@ - @file GHExtension.c - @date 01 Oct 1999 - @author Jonghyun Lee - @desc IOPanda GH extension stuff - @enddesc - @history - @endhistory - @@*/ - -/*#define DEBUG_IO*/ - -#include -#include -#include - -#include "cctk.h" -#include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" -#include "ioPandaGH.h" - -void *IOPanda_SetupGH (tFleshConfig *config, - int convergence_level, - cGH *GH); -int IOPanda_InitGH (cGH *GH); -void Panda_Create(int, int); - - - /*@@ - @routine IOPanda_SetupGH - @date Fri 01 Oct 1999 - @author Jonghyun Lee - @desc - Allocates the IOPanda GH extension structure. - @enddesc - @calledby CCTK scheduler at CCTK_INITIALIZE - @var config - @vdesc flesh configuration structure (unused) - @vtype tFleshConfig * - @vio in - @endvar - @var convergence_level - @vdesc convergence level (unused) - @vtype int - @vio in - @endvar - @var GH - @vdesc pointer to grid hierarchy - @vtype cGH * - @vio in - @endvar - @history - - @endhistory -@@*/ -void *IOPanda_SetupGH (tFleshConfig *config, - int convergence_level, - cGH *GH) -{ - int numvars; - pandaGH *newGH; - - - /* avoid warnings about unused arguments */ - config = config; - convergence_level = convergence_level; - GH = GH; - - numvars = CCTK_NumVars (); - - newGH = (pandaGH *) malloc (sizeof (pandaGH)); - newGH->do_out3D = (char *) malloc (numvars * sizeof (char)); - newGH->out3D_last = (int *) malloc (numvars * sizeof (int)); - - return (newGH); -} - - - /*@@ - @routine IOPanda_InitGH - @date Fri 01 Oct 1999 - @author Jonghyun Lee - @desc - The GH initialization routine for IOFlexIO. - Necessary output dirs are created. - @enddesc - @calledby CCTK scheduler at CCTK_INITIALIZE - @var GH - @vdesc pointer to grid hierarchy - @vtype cGH * - @vio in - @endvar - @history - - @endhistory -@@*/ -int IOPanda_InitGH (cGH *GH) -{ - DECLARE_CCTK_PARAMETERS - int i; - ioGH *ioUtilGH; - pandaGH *myGH; - - - /* get the handles for IOUtil and IOPanda extensions */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; - myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")]; - - /* How often to output */ - myGH->out3D_every = out_every > 0 ? out_every : -1; - if (out3D_every > 0) - { - myGH->out3D_every = out3D_every; - } - - /* Check whether "outdir3D" was set. - If so take this dir otherwise default to "IO::outdir" */ - if (CCTK_ParameterQueryTimesSet ("outdir3D", CCTK_THORNSTRING) > 0) - { - myGH->outdir3D = strdup (outdir3D); - } - else - { - myGH->outdir3D = strdup (outdir); - } - - /* Create the output directory */ - if (CCTK_MyProc (GH) == 0) - { - FILE *fp; - - - i = CCTK_CreateDirectory (0755, myGH->outdir3D); - if (i < 0) - { - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOPanda_InitGH: Problem creating IOPanda 3D output " - "directory '%s'", myGH->outdir3D); - } - else if (i > 0) - { - CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "IOPanda_InitGH: IOPanda 3D output directory '%s' already " - "exists", myGH->outdir3D); - } - fp = fopen ("FILEPREFIX", "w"); - fprintf (fp, "%s", myGH->outdir3D); - fclose (fp); - } - - for (i = 0; i < CCTK_NumVars (); i++) - { - myGH->out3D_last [i] = -1; - } - - Panda_Create (ioUtilGH->ioproc_every, 1); - - return (0); -} diff --git a/src/Output.c b/src/Output.c new file mode 100644 index 0000000..4bb6a86 --- /dev/null +++ b/src/Output.c @@ -0,0 +1,670 @@ + /*@@ + @file Output.c + @date 01 Oct 1999 + @author Jonghyun Lee + @desc + Functions to deal with IOPanda output of grid variables + @enddesc + @version $Id$ + @@*/ + +#include +#include +#include + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusPUGH/PUGH/src/include/pugh.h" + +#include "ioPandaGH.h" +#include "Panda/c_interface.h" + +/* the rcs ID and its dummy funtion to use it */ +static const char *rcsid = "$Header$"; +CCTK_FILEVERSION(BetaThorns_IOPanda_Output_c) + + +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ +static int CheckOutputVar (int vindex); +static void CheckSteerableParameters (pandaGH *myGH); +static void SetOutputFlag (int vindex, const char *optstring, void *arg); +static int IOPanda_Timestep (const cGH *GH, int vindex, const char *alias); +static void IOPanda_IEEEIOStructDump (const cGH *GH, const char *fname); +static void IOPanda_AddCommonAttributes (const cGH *GH, int vindex, int timelevel, int global_size[3], char *fname); +static void IOPanda_AddChunkAttributes (const cGH *GH, int vindex, CCTK_INT4 *geom, char *fname); + + +/*@@ + @routine IOPanda_OutputGH + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Loops over all variables and outputs them if necessary + @enddesc + + @calls IOPanda_TimeFor + IOPanda_Timestep + + @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 IOPanda_OutputGH (const cGH *GH) +{ + int vindex, retval; + pandaGH *myGH; + char *fullname; + const char *name; + DECLARE_CCTK_PARAMETERS + + + /* Get the GH extension for IOPanda */ + myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda"); + + CheckSteerableParameters (myGH); + + if (myGH->out_every <= 0) + { + return (0); + } + + /* Loop over all variables */ + for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) + { + if (IOPanda_TimeFor (GH, vindex)) + { + name = CCTK_VarName (vindex); + + if (verbose) + { + fullname = CCTK_FullName (vindex); + CCTK_VInfo (CCTK_THORNSTRING, "IOPanda_OutputGH: " + "(fullname, name) = (%s, %s)", fullname, name); + free (fullname); + } + + /* Do the output */ + if (IOPanda_Timestep (GH, vindex, name) == 0) + { + /* Register variable as having output this iteration */ + myGH->out_last [vindex] = GH->cctk_iteration; + retval++; + } + } + } + + return (retval); +} + + +/*@@ + @routine IOPanda_OutputVarAs + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Unconditional output of a variable using the IOPanda I/O method + @enddesc + + @calls IOPanda_Timestep + + @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 IOPanda_Timestep + @endreturndesc +@@*/ +int IOPanda_OutputVarAs (const cGH *GH, const char *fullname, const char *alias) +{ + int vindex, retval; + DECLARE_CCTK_PARAMETERS + + + vindex = CCTK_VarIndex (fullname); + if (verbose) + { + CCTK_VInfo (CCTK_THORNSTRING, "IOPanda_OutputVarAs: " + "(fullname, alias, index) = (%s, %s, %d)", + fullname, alias, vindex); + } + + /* Do the output */ + retval = IOPanda_Timestep (GH, vindex, alias); + + return (retval); +} + + +/*@@ + @routine IOPanda_TimeFor + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Decides if it is time to output a variable + using the IOPanda output method + @enddesc + + @calls CheckSteerableParameters + + @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
+ 0 if not + @endreturndesc +@@*/ +int IOPanda_TimeFor (const cGH *GH, int vindex) +{ + pandaGH *myGH; + char *fullname; + + + /* Get the GH extension for IOPanda */ + myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda"); + + CheckSteerableParameters (myGH); + + /* Check if any output was requested */ + if (myGH->out_every <= 0) + { + return (0); + } + + /* Check this variable should be output */ + if (! (myGH->do_out[vindex] && GH->cctk_iteration % myGH->out_every == 0)) + { + return (0); + } + + /* Check variable not 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 IOPanda output for variable '%s' in current " + "iteration (probably via triggers)", fullname); + free (fullname); + return (0); + } + + return (1); +} + + +/*@@ + @routine IOPanda_TriggerOutput + @date Sat March 6 1999 + @author Gabrielle Allen + @desc + Triggers the output a variable using the IOPanda output method + @enddesc + + @calls IOPanda_Timestep + + @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 IOPanda_Timestep + @endreturndesc +@@*/ +int IOPanda_TriggerOutput (const cGH *GH, int vindex) +{ + int retval; + pandaGH *myGH; + const char *varname; + DECLARE_CCTK_PARAMETERS + + + varname = CCTK_VarName (vindex); + + /* Get the GH extension for IOPanda */ + myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda"); + + if (verbose) + { + CCTK_VInfo (CCTK_THORNSTRING, "TriggerOutput: " + "name, index = %s, %d", varname, vindex); + } + + /* Do the output */ + retval = IOPanda_Timestep (GH, vindex, varname); + + if (retval == 0) + { + /* Register variable as having output this iteration */ + myGH->out_last [vindex] = GH->cctk_iteration; + } + + return (retval); +} + + +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ +/*@@ + @routine CheckSteerableParameters + @date Mon Oct 10 2000 + @author Thomas Radke + @desc + Checks if IOPanda steerable parameters were changed + and does appropriate re-evaluation. + @enddesc + + @calls CCTK_TraverseString + + @var myGH + @vdesc Pointer to IOPanda GH + @vtype pandaGH * + @vio in + @endvar +@@*/ +static void CheckSteerableParameters (pandaGH *myGH) +{ + int times_set; + static int out_vars_lastset = -1; + DECLARE_CCTK_PARAMETERS + + + /* how often to output */ + myGH->out_every = out_every; + if (myGH->out_every < 0) + { + myGH->out_every = *(const CCTK_INT *) + CCTK_ParameterGet ("out_every", + CCTK_ImplementationThorn ("IO"), NULL); + } + + /* re-parse the 'out_vars' parameter if it was changed */ + times_set = CCTK_ParameterQueryTimesSet ("out_vars", CCTK_THORNSTRING); + if (times_set != out_vars_lastset) + { + memset (myGH->do_out, 0, CCTK_NumVars ()); + CCTK_TraverseString (out_vars, SetOutputFlag, myGH->do_out, + CCTK_GROUP_OR_VAR); + + /* Save the last setting of 'out_vars' parameter */ + out_vars_lastset = times_set; + } +} + + +/* check if this variable can be output (static conditions) */ +static int CheckOutputVar (int vindex) +{ + char *errormsg, *fullname; + + + errormsg = NULL; + +/*** FIXME: IEEEIO doesn't provide a COMPLEX datatype + so somehow CCTK_COMPLEX has to be mapped onto REALs or so. + We have to check this already here because if an IEEEIO file + is created and nothing is written to, it crashes at re-opening. ***/ + if (CCTK_VarTypeI (vindex) == CCTK_VARIABLE_COMPLEX) + { + errormsg = "IOPanda output for complex variable '%s' not yet supported"; + } + else if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) + { + errormsg = "IOPanda output for scalar variable '%s' not supported"; + } + + if (errormsg) + { + fullname = CCTK_FullName (vindex); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + errormsg, fullname); + 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 *flags = (char *) arg; + + + /* Check the variable type */ + flags[vindex] = CheckOutputVar (vindex) == 0; + + if (optstring) + { + CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, + "Optional string '%s' in variable name ignored", optstring); + } +} + + +static int IOPanda_Timestep (const cGH *GH, int vindex, const char *alias) +{ + void *data; + int tmp[1], tmp1[3], tmp2[3]; + Distribution dist1[3], dist2[3]; + CCTK_INT4 bnd[9]; + int free_flag, timelevel; + ArrayInfo ainfo; + ioGH *ioUtilGH; + pGH *pughGH; + char *fullname; + union + { + char *non_const_char; + const char *const_char; + } cast_to_const; + DECLARE_CCTK_PARAMETERS + + + /* check if variable has storage assigned */ + if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex))) + { + fullname = CCTK_FullName (vindex); + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOPanda output for '%s' (no storage)", fullname); + free (fullname); + return (-1); + } + + /* get the handles for PUGH and IOUtil GH extensions */ + pughGH = PUGH_pGH (GH); + ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); + + /* prevent compiler warning "cast discards `const' from pointer target type"*/ + cast_to_const.const_char = alias; + ainfo.name_ = cast_to_const.non_const_char; + + ainfo.rank_ = 3; + tmp1[0] = GH->cctk_gsh[2]; + tmp1[1] = GH->cctk_gsh[1]; + tmp1[2] = GH->cctk_gsh[0]; + ainfo.size_ = tmp1; + + switch (CCTK_VarTypeI (vindex)) + { + case CCTK_VARIABLE_CHAR: + ainfo.esize_ = CHAR; + break; + + case CCTK_VARIABLE_INT: +#ifdef CCTK_INTEGER_PRECISION_8 + ainfo.esize_ = INT64; +#elif CCTK_INTEGER_PRECISION_4 + ainfo.esize_ = INT32; +#elif CCTK_INTEGER_PRECISION_2 + ainfo.esize_ = INT16; +#endif + break; + + case CCTK_VARIABLE_REAL: + if (ioUtilGH->out_single) + { + ainfo.esize_ = FLOAT32; + } + else + { +#ifdef CCTK_REAL_PRECISION_8 + ainfo.esize_ = FLOAT64; +#elif CCTK_REAL_PRECISION_4 + ainfo.esize_ = FLOAT32; +#endif + } + } + + /* FIXME: rank */ + ainfo.mem_rank_ = 3; + tmp2[0] = pughGH->Connectivity [2]->nprocs [2]; + tmp2[1] = pughGH->Connectivity [2]->nprocs [1]; + tmp2[2] = pughGH->Connectivity [2]->nprocs [0]; + ainfo.mem_layout_ = tmp2; + dist1[0] = dist1[1] = dist1[2] = BLOCK; + ainfo.mem_dist_ = dist1; + + ainfo.disk_rank_ = 1; + dist2[0] = BLOCK; dist2[1] = dist2[2] = NONE; + tmp[0]= ((CCTK_nProcs(GH) - 1) / ioUtilGH->ioproc_every + 1); + + ainfo.disk_layout_ = tmp; + ainfo.disk_dist_ = dist2; + + timelevel = 0; + + IOPanda_getDumpData(GH, vindex, timelevel, &data, &free_flag, bnd, ainfo.esize_); + ainfo.data_ = (char *)data; + + /*** FIXME: asymmetric ghostzones */ + ainfo.stencil_width_ = GH->cctk_nghostzones [0]; + + PandaTimestep(&ainfo); + if (free_flag) + { + free (data); + } + + IOPanda_AddCommonAttributes(GH, vindex, timelevel, ainfo.size_, ainfo.name_); + + if (! ioUtilGH->unchunked) + { + /* Write chunk attributes */ + IOPanda_AddChunkAttributes (GH, vindex, bnd, ainfo.name_); + } + + if (PandaIsNewFile(ainfo.name_)) + { + IOPanda_IEEEIOStructDump(GH, ainfo.name_); + } + + return (0); +} + + +static void IOPanda_AddCommonAttributes (const cGH *GH, + int vindex, + int timelevel, + int global_size[3], + char *fname) +{ + DECLARE_CCTK_PARAMETERS + CCTK_REAL d3_to_IO [6]; /* buffer for writing doubles to IEEEIO */ + CCTK_INT4 i_to_IO; /* buffer for writing an int to IEEEIO */ + CCTK_INT4 i3_to_IO[3]; /* buffer for writing ints to IEEEIO */ + CCTK_REAL dummy; + char *name, *gname; + ioGH *ioUtilGH; + + + /* Get the handle for IO extensions */ + ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); + + name = CCTK_FullName (vindex); + Panda_WriteAttribute (fname, "name", BYTE, strlen (name) + 1, name); + free (name); + + gname = CCTK_GroupNameFromVarI (vindex); + Panda_WriteAttribute (fname, "groupname", BYTE, strlen (gname) + 1, gname); + free (gname); + + i_to_IO = CCTK_GroupTypeFromVarI (vindex); + Panda_WriteAttribute (fname, "grouptype", INT32, 1, &i_to_IO); + + i_to_IO = CCTK_NumTimeLevelsFromVarI (vindex); + Panda_WriteAttribute (fname, "ntimelevels", INT32, 1, &i_to_IO); + + i_to_IO = timelevel; + Panda_WriteAttribute (fname, "timelevel", INT32, 1, &i_to_IO); + + Panda_WriteAttribute (fname, "time", FLOAT64, 1,&GH->cctk_time); + + d3_to_IO [0] = CCTK_CoordRange (GH, &d3_to_IO [0], &dummy, -1, "x", "cart3d"); + d3_to_IO [1] = CCTK_CoordRange (GH, &d3_to_IO [1], &dummy, -1, "y", "cart3d"); + d3_to_IO [2] = CCTK_CoordRange (GH, &d3_to_IO [2], &dummy, -1, "z", "cart3d"); + Panda_WriteAttribute (fname, "origin", FLOAT64,3,d3_to_IO); + CCTK_CoordRange (GH, &d3_to_IO [0], &d3_to_IO [3], -1, "x", "cart3d"); + CCTK_CoordRange (GH, &d3_to_IO [1], &d3_to_IO [4], -1, "y", "cart3d"); + CCTK_CoordRange (GH, &d3_to_IO [2], &d3_to_IO [5], -1, "z", "cart3d"); + Panda_WriteAttribute (fname, "min_ext", FLOAT64, 3, d3_to_IO); + Panda_WriteAttribute (fname, "max_ext", FLOAT64, 3, d3_to_IO+3); + + /* FIXME: dimension */ + d3_to_IO [0] = GH->cctk_delta_space [0] * ioUtilGH->downsample[0]; + d3_to_IO [1] = GH->cctk_delta_space [1] * ioUtilGH->downsample[1]; + d3_to_IO [2] = GH->cctk_delta_space [2] * ioUtilGH->downsample[2]; + Panda_WriteAttribute (fname, "delta", FLOAT64, 3, d3_to_IO); + + if (ioUtilGH->downsample[0] > 1 || + ioUtilGH->downsample[1] > 1 || + ioUtilGH->downsample[2] > 1) + { + d3_to_IO [0] = GH->cctk_delta_space [0]; + d3_to_IO [1] = GH->cctk_delta_space [1]; + d3_to_IO [2] = GH->cctk_delta_space [2]; + Panda_WriteAttribute (fname, "evolution_delta", FLOAT64, 3, d3_to_IO); + } + + i3_to_IO[0] = global_size[0]; + i3_to_IO[1] = global_size[1]; + i3_to_IO[2] = global_size[2]; + Panda_WriteAttribute (fname, "global_size", INT32, 3, i3_to_IO); + + i_to_IO = CCTK_nProcs (GH); + Panda_WriteAttribute (fname, "nprocs", INT32, 1, &i_to_IO); + + i_to_IO = ioUtilGH->ioproc_every; + Panda_WriteAttribute (fname, "ioproc_every", INT32, 1, &i_to_IO); + + i_to_IO = ioUtilGH->unchunked; + Panda_WriteAttribute (fname, "unchunked", INT32, 1, &i_to_IO); + + i_to_IO = GH->cctk_iteration; + Panda_WriteAttribute (fname, "iteration", INT32, 1, &i_to_IO); +} + + +static void IOPanda_AddChunkAttributes (const cGH *GH, + int vindex, + CCTK_INT4 *geom, + char *fname) +{ + int dim; + char *name; + CCTK_INT4 i_to_IO; + + + /* there is nothing to do for a serial run */ + if (CCTK_nProcs (GH) == 1) + { + return; + } + + /* get the dimension of the variable */ + dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex)); + + Panda_WriteAttribute (fname, "chunk_origin", INT32, dim, &geom[0]); + Panda_WriteAttribute (fname, "subchunk_lb", INT32, dim, &geom[0]); + Panda_WriteAttribute (fname, "global_size", INT32, dim, &geom[2*dim]); + + i_to_IO = GH->cctk_iteration; + Panda_WriteAttribute (fname, "chunk_dataset", INT32, 1, &i_to_IO); + + name = CCTK_FullName (vindex); + Panda_WriteAttribute (fname, "name", CHAR, strlen (name)+1, name); + free (name); +} + + +static void IOPanda_IEEEIOStructDump (const cGH *GH, + const char *fname) +{ + DECLARE_CCTK_PARAMETERS + int len; + CCTK_INT4 i_temp; + CCTK_REAL d_temp; + ioGH *ioUtilGH; + char buffer[128]; + + + ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); + + i_temp = GH->cctk_iteration; + Panda_WriteAttribute (fname, "GH$iteration", INT32, 1, &i_temp); + + i_temp = ioUtilGH->ioproc_every; + Panda_WriteAttribute (fname, "GH$ioproc_every", INT32, 1, &i_temp); + + i_temp = CCTK_nProcs (GH); + Panda_WriteAttribute (fname, "GH$nprocs", INT32, 1, &i_temp); + + d_temp = GH->cctk_time; + Panda_WriteAttribute (fname, "GH$time", FLOAT64, 1, &d_temp); + + /* add the parameter filename and the creation date + as file identification attributes */ + if (CCTK_Equals (out_fileinfo, "parameter filename") || + CCTK_Equals (out_fileinfo, "all")) + { + buffer[0] = 0; + CCTK_ParameterFilename (sizeof (buffer), buffer); + Panda_WriteAttribute (fname, "parameter file", CHAR, + strlen (buffer) + 1, buffer); + } + if (CCTK_Equals (out_fileinfo, "creation date") || + CCTK_Equals (out_fileinfo, "all")) + { + buffer[0] = 0; + Util_CurrentDate (sizeof (buffer), buffer); + len = strlen (buffer) + 1; + buffer[len-1] = ' '; + Util_CurrentTime (sizeof (buffer) - len, buffer + len); + Panda_WriteAttribute (fname, "creation date", CHAR, + strlen (buffer) + 1, buffer); + } +} diff --git a/src/Output3D.c b/src/Output3D.c deleted file mode 100644 index 860f96a..0000000 --- a/src/Output3D.c +++ /dev/null @@ -1,659 +0,0 @@ - /*@@ - @file Output3D.c - @date 01 Oct 1999 - @author Jonghyun Lee - @desc Functions to deal 3D output of GFs - @enddesc - @version $Id$ - @@*/ - -#include -#include -#include - -#include "cctk.h" -#include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" -#include "CactusPUGH/PUGH/src/include/pugh.h" -#include "CactusExternal/FlexIO/src/IOProtos.h" -#include "ioPandaGH.h" -#include "Panda/c_interface.h" - -/* the rcs ID and its dummy funtion to use it */ -static const char *rcsid = "$Header$"; -CCTK_FILEVERSION(BetaThorns_IOPanda_Output3D_c) - - -/* function prototypes */ -int IOPanda_Output3DGH (const cGH *GH); -int IOPanda_TriggerOutput3D (const cGH *GH, int vindex); -int IOPanda_Output3DVarAs (const cGH *GH, const char *var, const char *alias); -int IOPanda_TimeFor3D (const cGH *GH, int vindex); -void IOPanda_getDumpData (const cGH *GH, int vindex, int timelevel, void **outme, - int *free_outme, CCTK_INT4 *geom, int element_size); -void PandaTimestep(ArrayInfo *); -int PandaIsNewFile(char *); -void Panda_WriteAttribute(const char *, const char *, int, int, const void *); - -static int CheckOutputVar (int vindex); -static void CheckSteerableParameters (pandaGH *myGH); -static void SetOutputFlag (int vindex, const char *optstring, void *arg); -static int IOPanda_Timestep (const cGH *GH, int vindex, const char *alias); -static void IOPanda_IEEEIOStructDump (const cGH *GH, const char *fname); -static void IOPanda_AddCommonAttributes (const cGH *GH, int vindex, int timelevel, int global_size[3], char *fname); -static void IOPanda_AddChunkAttributes (const cGH *GH, int vindex, CCTK_INT4 *geom, char *fname); - -/*@@ - @routine IOPanda_Output3DGH - @date Sat March 6 1999 - @author Gabrielle Allen - @desc - Loops over all variables and outputs them if necessary - @enddesc - @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 IOPanda_Output3DGH (const cGH *GH) -{ - int vindex, retval; - char *fullname; - const char *name; - pandaGH *myGH; - DECLARE_CCTK_PARAMETERS - - - /* Get the GH extension for IOPanda */ - myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda"); - - CheckSteerableParameters (myGH); - - if (myGH->out3D_every <= 0) - { - return (0); - } - - /* Loop over all variables */ - for (vindex = retval = 0; vindex < CCTK_NumVars (); vindex++) - { - if (IOPanda_TimeFor3D (GH, vindex)) - { - name = CCTK_VarName (vindex); - - if (verbose) - { - fullname = CCTK_FullName (vindex); - CCTK_VInfo (CCTK_THORNSTRING, "IOPanda_Output3DGH: " - "(fullname, name) = (%s, %s)", fullname, name); - free (fullname); - } - - /* Do the 3D output */ - if (IOPanda_Timestep (GH, vindex, name) == 0) - { - /* Register variable as having 3D output this iteration */ - myGH->out3D_last [vindex] = GH->cctk_iteration; - retval++; - } - } - } - - return (retval); -} - - -/*@@ - @routine IOPanda_Output3DVarAs - @date Sat March 6 1999 - @author Gabrielle Allen - @desc - Unconditional output of a variable - using the IOPanda 3D output method - @enddesc - @calledby IOPanda_Output3DGH - @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 IOPanda_Timestep - @endreturndesc -@@*/ -int IOPanda_Output3DVarAs (const cGH *GH, - const char *fullname, - const char *alias) -{ - int vindex, retval; - DECLARE_CCTK_PARAMETERS - - - vindex = CCTK_VarIndex(fullname); - - if (verbose) - { - CCTK_VInfo (CCTK_THORNSTRING, "IOPanda_Output3DVarAs: " - "(fullname, alias, index) = (%s, %s, %d)", - fullname, alias, vindex); - } - - /* Do the 3D output */ - retval = IOPanda_Timestep (GH, vindex, alias); - - return (retval); -} - - -/*@@ - @routine IOPanda_TimeFor3D - @date Sat March 6 1999 - @author Gabrielle Allen - @desc - Decides if it is time to output a variable - using the IOPanda 3D output method - @enddesc - @calledby IOPanda_Output3DGH - @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
- 0 if not - @endreturndesc -@@*/ -int IOPanda_TimeFor3D (const cGH *GH, - int vindex) -{ - pandaGH *myGH; - - - /* Get the GH extension for IOPanda */ - myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda"); - - CheckSteerableParameters (myGH); - - /* Check if any output was requested */ - if (myGH->out3D_every <= 0) - { - return (0); - } - - /* Check this variable should be output */ - if (! (myGH->do_out3D [vindex] && GH->cctk_iteration % myGH->out3D_every == 0)) - { - return (0); - } - - /* Check variable not already output this iteration */ - if (myGH->out3D_last [vindex] == GH->cctk_iteration) - { - char *fullname = CCTK_FullName (vindex); - - - CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Already done IOPanda 3D output for variable '%s' in current " - "iteration (probably via triggers)", fullname); - free (fullname); - return (0); - } - - return (1); -} - - -/*@@ - @routine IOPanda_TriggerOutput3D - @date Sat March 6 1999 - @author Gabrielle Allen - @desc - Triggers the output a variable using the IOPanda 3D output method - @enddesc - @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 IOPanda_Timestep - @endreturndesc -@@*/ -int IOPanda_TriggerOutput3D (const cGH *GH, - int vindex) -{ - int retval; - pandaGH *myGH; - const char *varname; - DECLARE_CCTK_PARAMETERS - - - varname = CCTK_VarName (vindex); - - /* Get the GH extension for IOPanda */ - myGH = (pandaGH *) CCTK_GHExtension (GH, "IOPanda"); - - if (verbose) - { - CCTK_VInfo (CCTK_THORNSTRING, "TriggerOutput3D: " - "name, index = %s, %d", varname, vindex); - } - - /* Do the 3D output */ - retval = IOPanda_Timestep (GH, vindex, varname); - - if (retval == 0) - { - /* Register variable as having 3D output this iteration */ - myGH->out3D_last [vindex] = GH->cctk_iteration; - } - - return (retval); -} - - -/**************************** local functions ******************************/ -/* check if steerable parameters have changed */ -static void CheckSteerableParameters (pandaGH *myGH) -{ - DECLARE_CCTK_PARAMETERS - int times_set; - static int out3D_vars_lastset = -1; - - - /* How often to output */ - myGH->out3D_every = out_every > 0 ? out_every : -1; - if (out3D_every > 0) - { - myGH->out3D_every = out3D_every; - } - - /* re-parse the 'out3D_vars' parameter if it was changed */ - times_set = CCTK_ParameterQueryTimesSet ("out3D_vars", CCTK_THORNSTRING); - if (times_set != out3D_vars_lastset) - { - memset (myGH->do_out3D, 0, CCTK_NumVars ()); - CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH->do_out3D, - CCTK_GROUP_OR_VAR); - - /* Save the last setting of 'out3D_vars' parameter */ - out3D_vars_lastset = times_set; - } - -} - - -/* check if this variable can be output (static conditions) */ -static int CheckOutputVar (int vindex) -{ - char *errormsg; - char *fullname; - - - errormsg = NULL; - -/*** FIXME: IEEEIO doesn't provide a COMPLEX datatype - so somehow CCTK_COMPLEX has to be mapped onto REALs or so. - We have to check this already here because if an IEEEIO file - is created and nothing is written to, it crashes at re-opening. ***/ - if (CCTK_VarTypeI (vindex) == CCTK_VARIABLE_COMPLEX) - { - errormsg = "IOPanda 3D output for complex variable '%s' not yet supported"; - } - else if (CCTK_GroupTypeFromVarI (vindex) == CCTK_SCALAR) - { - errormsg = "IOPanda 3D output for scalar variable '%s' not supported"; - } - - if (errormsg) - { - fullname = CCTK_FullName (vindex); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - errormsg, fullname); - 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 *flags = (char *) arg; - - - /* Check the variable type */ - if (CheckOutputVar (vindex) == 0) - { - flags[vindex] = 1; - } - - if (optstring) - { - CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING, - "Optional string '%s' in variable name ignored", optstring); - } -} - - -static int IOPanda_Timestep (const cGH *GH, int vindex, const char *alias) -{ - void *data; - int tmp[1], tmp1[3], tmp2[3]; - Distribution dist1[3], dist2[3]; - CCTK_INT4 bnd[9]; - int free_flag, timelevel; - ArrayInfo ainfo; - ioGH *ioUtilGH; - pGH *pughGH; - union - { - char *non_const_char; - const char *const_char; - } cast_to_const; - DECLARE_CCTK_PARAMETERS - - - /* prevent compiler warning "cast discards `const' from pointer target type"*/ - cast_to_const.const_char = alias; - - /* check if variable has storage assigned */ - if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (vindex))) - { - char *fullname = CCTK_FullName (vindex); - - - CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, - "No IOPanda 3D output for '%s' (no storage)", fullname); - free (fullname); - return (-1); - } - - /* get the handles for PUGH and IOUtil GH extensions */ - pughGH = PUGH_pGH (GH); - ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); - - ainfo.name_ = cast_to_const.non_const_char; - - ainfo.rank_ = 3; - tmp1[0] = GH->cctk_gsh[2]; - tmp1[1] = GH->cctk_gsh[1]; - tmp1[2] = GH->cctk_gsh[0]; - ainfo.size_ = tmp1; - - switch (CCTK_VarTypeI (vindex)) - { - case CCTK_VARIABLE_CHAR: - ainfo.esize_ = CHAR; - break; - - case CCTK_VARIABLE_INT: -#ifdef CCTK_INTEGER_PRECISION_8 - ainfo.esize_ = INT64; -#elif CCTK_INTEGER_PRECISION_4 - ainfo.esize_ = INT32; -#elif CCTK_INTEGER_PRECISION_2 - ainfo.esize_ = INT16; -#endif - break; - - case CCTK_VARIABLE_REAL: - if (ioUtilGH->out_single) - { - ainfo.esize_ = FLOAT32; - } - else - { -#ifdef CCTK_REAL_PRECISION_8 - ainfo.esize_ = FLOAT64; -#elif CCTK_REAL_PRECISION_4 - ainfo.esize_ = FLOAT32; -#endif - } - } - - /* FIXME: rank */ - ainfo.mem_rank_ = 3; - tmp2[0] = pughGH->Connectivity [2]->nprocs [2]; - tmp2[1] = pughGH->Connectivity [2]->nprocs [1]; - tmp2[2] = pughGH->Connectivity [2]->nprocs [0]; - ainfo.mem_layout_ = tmp2; - dist1[0] = dist1[1] = dist1[2] = BLOCK; - ainfo.mem_dist_ = dist1; - - ainfo.disk_rank_ = 1; - dist2[0] = BLOCK; dist2[1] = dist2[2] = NONE; - tmp[0]= ((CCTK_nProcs(GH) - 1) / ioUtilGH->ioproc_every + 1); - - ainfo.disk_layout_ = tmp; - ainfo.disk_dist_ = dist2; - - timelevel = 0; - - IOPanda_getDumpData(GH, vindex, timelevel, &data, &free_flag, bnd, ainfo.esize_); - ainfo.data_ = (char *)data; - - /*** FIXME: asymmetric ghostzones */ - ainfo.stencil_width_ = GH->cctk_nghostzones [0]; - - PandaTimestep(&ainfo); - if (free_flag) - { - free (data); - } - - IOPanda_AddCommonAttributes(GH, vindex, timelevel, ainfo.size_, ainfo.name_); - - if (! ioUtilGH->unchunked) - { - /* Write chunk attributes */ - IOPanda_AddChunkAttributes (GH, vindex, bnd, ainfo.name_); - } - - if (PandaIsNewFile(ainfo.name_)) - { - IOPanda_IEEEIOStructDump(GH, ainfo.name_); - } - - return (0); -} - - -static void IOPanda_AddCommonAttributes (const cGH *GH, - int vindex, - int timelevel, - int global_size[3], - char *fname) -{ - DECLARE_CCTK_PARAMETERS - CCTK_REAL d3_to_IO [6]; /* buffer for writing doubles to IEEEIO */ - CCTK_INT4 i_to_IO; /* buffer for writing an int to IEEEIO */ - CCTK_INT4 i3_to_IO[3]; /* buffer for writing ints to IEEEIO */ - CCTK_REAL dummy; - char *name, *gname; - ioGH *ioUtilGH; - - - /* Get the handle for IO extensions */ - ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); - - name = CCTK_FullName (vindex); - Panda_WriteAttribute (fname, "name", BYTE, strlen (name) + 1, name); - free (name); - - gname = CCTK_GroupNameFromVarI (vindex); - Panda_WriteAttribute (fname, "groupname", BYTE, strlen (gname) + 1, gname); - free (gname); - - i_to_IO = CCTK_GroupTypeFromVarI (vindex); - Panda_WriteAttribute (fname, "grouptype", INT32, 1, &i_to_IO); - - i_to_IO = CCTK_NumTimeLevelsFromVarI (vindex); - Panda_WriteAttribute (fname, "ntimelevels", INT32, 1, &i_to_IO); - - i_to_IO = timelevel; - Panda_WriteAttribute (fname, "timelevel", INT32, 1, &i_to_IO); - - Panda_WriteAttribute (fname, "time", FLOAT64, 1,&GH->cctk_time); - - d3_to_IO [0] = CCTK_CoordRange (GH, &d3_to_IO [0], &dummy, -1, "x", "cart3d"); - d3_to_IO [1] = CCTK_CoordRange (GH, &d3_to_IO [1], &dummy, -1, "y", "cart3d"); - d3_to_IO [2] = CCTK_CoordRange (GH, &d3_to_IO [2], &dummy, -1, "z", "cart3d"); - Panda_WriteAttribute (fname, "origin", FLOAT64,3,d3_to_IO); - CCTK_CoordRange (GH, &d3_to_IO [0], &d3_to_IO [3], -1, "x", "cart3d"); - CCTK_CoordRange (GH, &d3_to_IO [1], &d3_to_IO [4], -1, "y", "cart3d"); - CCTK_CoordRange (GH, &d3_to_IO [2], &d3_to_IO [5], -1, "z", "cart3d"); - Panda_WriteAttribute (fname, "min_ext", FLOAT64, 3, d3_to_IO); - Panda_WriteAttribute (fname, "max_ext", FLOAT64, 3, d3_to_IO+3); - - /* FIXME: dimension */ - d3_to_IO [0] = GH->cctk_delta_space [0] * ioUtilGH->downsample[0]; - d3_to_IO [1] = GH->cctk_delta_space [1] * ioUtilGH->downsample[1]; - d3_to_IO [2] = GH->cctk_delta_space [2] * ioUtilGH->downsample[2]; - Panda_WriteAttribute (fname, "delta", FLOAT64, 3,d3_to_IO); - - if (ioUtilGH->downsample[0] > 1 || - ioUtilGH->downsample[1] > 1 || - ioUtilGH->downsample[2] > 1) - { - d3_to_IO [0] = GH->cctk_delta_space [0]; - d3_to_IO [1] = GH->cctk_delta_space [1]; - d3_to_IO [2] = GH->cctk_delta_space [2]; - Panda_WriteAttribute (fname, "evolution_delta", FLOAT64, 3, d3_to_IO); - } - - i3_to_IO[0] = global_size[0]; - i3_to_IO[1] = global_size[1]; - i3_to_IO[2] = global_size[2]; - Panda_WriteAttribute (fname, "global_size", INT32, 3, i3_to_IO); - - i_to_IO = CCTK_nProcs (GH); - Panda_WriteAttribute (fname, "nprocs", INT32, 1, &i_to_IO); - - i_to_IO = ioUtilGH->ioproc_every; - Panda_WriteAttribute (fname, "ioproc_every", INT32, 1, &i_to_IO); - - i_to_IO = ioUtilGH->unchunked; - Panda_WriteAttribute (fname, "unchunked", INT32, 1, &i_to_IO); - - i_to_IO = GH->cctk_iteration; - Panda_WriteAttribute (fname, "iteration", INT32, 1, &i_to_IO); -} - - -static void IOPanda_AddChunkAttributes (const cGH *GH, - int vindex, - CCTK_INT4 *geom, - char *fname) -{ - int dim; - char *name; - CCTK_INT4 i_to_IO; - - - /* there is nothing to do for a serial run */ - if (CCTK_nProcs (GH) == 1) - return; - - /* get the dimension of the variable */ - dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex)); - - Panda_WriteAttribute (fname, "chunk_origin", INT32, dim, &geom[0]); - Panda_WriteAttribute (fname, "subchunk_lb", INT32, dim, &geom[0]); - Panda_WriteAttribute (fname, "global_size", INT32, dim, &geom[2*dim]); - - i_to_IO = GH->cctk_iteration; - Panda_WriteAttribute (fname, "chunk_dataset", INT32, 1, &i_to_IO); - - name = CCTK_FullName (vindex); - Panda_WriteAttribute (fname, "name", CHAR, strlen (name)+1, name); - free (name); -} - - -static void IOPanda_IEEEIOStructDump (const cGH *GH, - const char *fname) -{ - DECLARE_CCTK_PARAMETERS - int len; - CCTK_INT4 i_temp; - CCTK_REAL d_temp; - ioGH *ioUtilGH; - char buffer[128]; - - - ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); - - i_temp = GH->cctk_iteration; - Panda_WriteAttribute (fname, "GH$iteration", INT32, 1, &i_temp); - - i_temp = ioUtilGH->ioproc_every; - Panda_WriteAttribute (fname, "GH$ioproc_every", INT32, 1, &i_temp); - - i_temp = CCTK_nProcs (GH); - Panda_WriteAttribute (fname, "GH$nprocs", INT32, 1, &i_temp); - - d_temp = GH->cctk_time; - Panda_WriteAttribute (fname, "GH$time", FLOAT64, 1, &d_temp); - - /* add the parameter filename and the creation date - as file identification attributes */ - if (CCTK_Equals (out_fileinfo, "parameter filename") || - CCTK_Equals (out_fileinfo, "all")) - { - buffer[0] = 0; - CCTK_ParameterFilename (sizeof (buffer), buffer); - Panda_WriteAttribute (fname, "parameter file", CHAR, - strlen (buffer) + 1, buffer); - } - if (CCTK_Equals (out_fileinfo, "creation date") || - CCTK_Equals (out_fileinfo, "all")) - { - buffer[0] = 0; - Util_CurrentDate (sizeof (buffer), buffer); - len = strlen (buffer) + 1; - buffer[len-1] = ' '; - Util_CurrentTime (sizeof (buffer) - len, buffer + len); - Panda_WriteAttribute (fname, "creation date", CHAR, - strlen (buffer) + 1, buffer); - } -} diff --git a/src/Panda/c_interface.h b/src/Panda/c_interface.h index 1b0786c..e142ab3 100644 --- a/src/Panda/c_interface.h +++ b/src/Panda/c_interface.h @@ -25,4 +25,11 @@ typedef struct ArrayInfo { struct ArrayInfo *next_; /* next element */ } ArrayInfo; +/* prototypes for functions called in the Panda library */ +int Panda_Create (int ioproc_every, int is_part_time_mode); +void Panda_Finalize (void); +void PandaTimestep (ArrayInfo *); +int PandaIsNewFile (char *); +void Panda_WriteAttribute (const char *, const char *, int, int, const void *); + #endif diff --git a/src/Startup.c b/src/Startup.c index d4cd4eb..04a5fe6 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -2,10 +2,10 @@ @file Startup.c @date 01 Oct 1999 @author Jonghyun Lee - @desc Startup routines for IOPanda. - @enddesc - @history - @endhistory + @desc + Startup routines for IOPanda. + @enddesc + @version $Id$ @@*/ #include @@ -16,77 +16,180 @@ #include "cctk_GHExtensions.h" #include "cctk_Parameters.h" #include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusBase/IOUtil/src/ioutil_Utils.h" +#include "ioPandaGH.h" -/* prototypes of functions to be registered */ -int IOPanda_Output3DGH (const cGH *GH); -int IOPanda_TriggerOutput3D (const cGH *GH, int); -int IOPanda_TimeFor3D (const cGH *GH, int); -int IOPanda_Output3DVarAs (const cGH *GH, const char *var, const char *alias); -void *IOPanda_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH); -int IOPanda_InitGH (cGH *GH); -int IOPanda_RecoverGH (cGH *GH, const char *basename, int called_from); +/* the rcs ID and its dummy function to use it */ +static const char *rcsid = "$Id$"; +CCTK_FILEVERSION(BetaThorns_IOPanda_Startup_c) + +/******************************************************************** + ******************** External Routines ************************ + ********************************************************************/ void IOPanda_Startup (void); -void IOPanda_Finalize(void); -void Panda_Finalize(void); +void IOPanda_Finalize (void); + + +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ +static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH); + /*@@ @routine IOPanda_Startup @date Fri May 21 1999 @author Thomas Radke - @desc - The startup registration routine for IOPanda. - Registers the GH extensions needed for IOPanda and - the registerable routines used for each method of IOPanda. - IOPanda does not overload any functions. - @enddesc - @calls - @calledby - @history - - @endhistory - + @desc + The startup registration routine for IOPanda. + Registers the GH extensions needed for IOPanda + along with its setup routine. + @enddesc + @calls CCTK_RegisterGHExtension + CCTK_RegisterGHExtensionSetupGH @@*/ void IOPanda_Startup (void) { - int IO_GHExtension; - int IOMethod; - - - if (CCTK_GHExtensionHandle ("IO") < 0) + /* check that thorn PUGH was activated */ + if (CCTK_GHExtensionHandle ("PUGH") >= 0) { - CCTK_WARN (1, "Thorn IOUtil was not activated. " - "No IOPanda IO methods will be enabled."); - return; + CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("IOPanda"), + SetupGH); } - if (CCTK_GHExtensionHandle ("PUGH") < 0) + else { CCTK_WARN (1, "Thorn PUGH was not activated. " - "No IOPanda IO methods will be enabled."); - return; + "No IOPanda I/O methods will be enabled."); } +} + + + /*@@ + @routine IOPanda_Finalize + @date Fri May 21 1999 + @author Thomas Radke + @desc + The termination routine for IOPanda. + Shuts down the Panda subsystem. + @enddesc +@@*/ +void IOPanda_Finalize (void) +{ + Panda_Finalize (); +} - IO_GHExtension = CCTK_RegisterGHExtension ("IOPanda"); - CCTK_RegisterGHExtensionSetupGH (IO_GHExtension, IOPanda_SetupGH); - CCTK_RegisterGHExtensionInitGH (IO_GHExtension, IOPanda_InitGH); - /* Register the 3D IOPandaIO routines as output methods */ - IOMethod = CCTK_RegisterIOMethod ("IOPandaIO_3D"); - CCTK_RegisterIOMethodOutputGH (IOMethod, IOPanda_Output3DGH); - CCTK_RegisterIOMethodOutputVarAs (IOMethod, IOPanda_Output3DVarAs); - CCTK_RegisterIOMethodTimeToOutput (IOMethod, IOPanda_TimeFor3D); - CCTK_RegisterIOMethodTriggerOutput (IOMethod, IOPanda_TriggerOutput3D); +/******************************************************************** + ******************** Internal Routines ************************ + ********************************************************************/ + /*@@ + @routine SetupGH + @date Fri 01 Oct 1999 + @author Jonghyun Lee + @desc + Allocates and sets up IOPanda's GH extension structure. + @enddesc -#if 0 - /* Register the IOPanda recovery routine to thorn IOUtil */ - if (IOUtil_RegisterRecover ("IOPanda recovery", IOPanda_RecoverGH) < 0) - CCTK_WARN (1, "Failed to register IOPanda recovery routine"); - Panda_Create(1, 1); -#endif + @calls CCTK_RegisterIOMethod + CCTK_RegisterIOMethodOutputGH + CCTK_RegisterIOMethodOutputVarAs + CCTK_RegisterIOMethodTimeToOutput + CCTK_RegisterIOMethodTriggerOutput + IOUtil_CreateDirectory -} + @var config + @vdesc flesh configuration structure (unused) + @vtype tFleshConfig * + @vio in + @endvar + @var convergence_level + @vdesc convergence level (unused) + @vtype int + @vio in + @endvar + @var GH + @vdesc pointer to grid hierarchy + @vtype cGH * + @vio in + @endvar -void IOPanda_Finalize(void) + @returntype void * + @returndesc + pointer to the allocated GH extension structure + @endreturndesc +@@*/ +static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { - Panda_Finalize(); + int i, numvars; + FILE *fp; + pandaGH *myGH; + const ioGH *ioUtilGH; + DECLARE_CCTK_PARAMETERS + + + /* suppress compiler warnings about unused variables */ + (void) (config + 0); + (void) (convergence_level + 0); + + + /* Register IOPanda's routines as a new I/O method */ + i = CCTK_RegisterIOMethod ("IOPandaIO"); + CCTK_RegisterIOMethodOutputGH (i, IOPanda_OutputGH); + CCTK_RegisterIOMethodOutputVarAs (i, IOPanda_OutputVarAs); + CCTK_RegisterIOMethodTimeToOutput (i, IOPanda_TimeFor); + CCTK_RegisterIOMethodTriggerOutput (i, IOPanda_TriggerOutput); + + /* allocate a new GH extension structure */ + myGH = (pandaGH *) malloc (sizeof (pandaGH)); + numvars = CCTK_NumVars (); + myGH->do_out = (char *) malloc (numvars * sizeof (char)); + myGH->out_last = (int *) malloc (numvars * sizeof (int)); + + for (i = 0; i < numvars; i++) + { + myGH->out_last[i] = -1; + } + + /* get the handle for IOUtil extensions */ + ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO"); + + /* Check whether "IOPanda::outdir" was set. + If so take this directory otherwise default to "IO::outdir" */ + if (CCTK_ParameterQueryTimesSet ("outdir", CCTK_THORNSTRING) > 0) + { + myGH->outdir = strdup (outdir); + } + else + { + myGH->outdir = CCTK_ParameterValString ("outdir", + CCTK_ImplementationThorn ("IO")); + } + + /* Create the output directory */ + i = IOUtil_CreateDirectory (GH, myGH->outdir, + ! CCTK_Equals (out3D_mode, "onefile"), + ioUtilGH->ioproc); + if (i < 0) + { + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Problem creating IOPanda output directory '%s'", myGH->outdir); + } + else if (i > 0 && CCTK_Equals (newverbose, "full")) + { + CCTK_VInfo (CCTK_THORNSTRING, + "IOPanda output directory '%s' already exists", myGH->outdir); + } + + if (CCTK_MyProc (GH) == 0) + { + fp = fopen ("FILEPREFIX", "w"); + fprintf (fp, "%s", myGH->outdir); + fclose (fp); + } + + /* start the Panda subsystem */ + Panda_Create (ioUtilGH->ioproc_every, 1); + + return (myGH); } diff --git a/src/Write.c b/src/Write.c new file mode 100644 index 0000000..9900d96 --- /dev/null +++ b/src/Write.c @@ -0,0 +1,207 @@ +/*@@ + @file Write.c + @date 01 Oct 1999 + @author Jonghyun Lee + @desc Do the actual writing of a 3D grid array. + @enddesc + @history + @hendhistory + @@*/ + +#include +#include + +#include "cctk.h" +#include "cctk_Parameters.h" +#include "CactusPUGH/PUGH/src/include/pugh.h" +#include "CactusBase/IOUtil/src/ioGH.h" +#include "ioPandaGH.h" + + +void IOPanda_getDumpData (const cGH *GH, int vindex, int timelevel, + void **outme, int *free_outme, CCTK_INT4 *geom, + int element_size); + + +void IOPanda_getDumpData (const cGH *GH, int vindex, int timelevel, + void **outme, int *free_outme, CCTK_INT4 *geom, + int element_size) +{ + DECLARE_CCTK_PARAMETERS + int i, myproc, do_downsample, dim; + ioGH *ioUtilGH; + CCTK_REAL4 *single_ptr; + CCTK_REAL *real_ptr; + CCTK_BYTE *char_ptr; + CCTK_INT *int_ptr; + pGExtras *extras; + void *data = CCTK_VarDataPtrI (GH, timelevel, vindex); + + /* to make the compiler happy */ + single_ptr = NULL; + real_ptr = NULL; + char_ptr = NULL; + int_ptr = NULL; + + /* get the processor ID */ + myproc = CCTK_MyProc (GH); + + /* get the handle for IOUtil GH extensions */ + ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + + /* get the pGExtras pointer as a shortcut */ + extras = ((pGA ***) PUGH_pGH (GH)->variables) [vindex][timelevel]->extras; + + /* get the dimension of the variable */ + dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (vindex)); + + do_downsample = 0; + for (i = 0; i < dim; i++) + do_downsample |= ioUtilGH->downsample [i] > 1; + + /* All the downsampling code is hard-coded for 3D data. + For other-dimensional variables we print a warning + and return the non-downsampled data. */ + if (do_downsample && dim != 3) { + char *fullname = CCTK_FullName (vindex); + + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "No downsampling for %dD variable '%s' ! Downsampling is only " + "supported for 3D variables.", dim, fullname); + free (fullname); + do_downsample = 0; + } + + /* Simple case if no downsampling */ + if (! do_downsample) { + + if (ioUtilGH->out_single) { + single_ptr = (CCTK_REAL4 *) malloc (extras->npoints*sizeof (CCTK_REAL4)); + + for (i = 0; i < extras->npoints; i++) + single_ptr [i] = (CCTK_REAL4) ((CCTK_REAL *) data) [i]; + + *outme = single_ptr; + *free_outme = 1; + } else { + *outme = data; + *free_outme = 0; + } + + /* set the bounds, the sizes, and the global shape */ + for (i = 0; i < dim; i++) { + geom [i + 0*dim] = extras->lb [myproc][i]; + geom [i + 1*dim] = extras->lnsize [i]; + geom [i + 2*dim] = extras->nsize [i]; + } + + } else { + + /* NOTE: the following downsampling code is hard-coded for 3D data */ + + int start [3], end [3]; + int j, k, l; + + /* downsampled global shape */ + for (i = 0; i < 3; i++) { + geom [i + 6] = extras->nsize [i] / ioUtilGH->downsample [i]; + if (extras->nsize [i] % ioUtilGH->downsample [i]) + geom [i + 6]++; + } + + if (verbose) + CCTK_VInfo (CCTK_THORNSTRING, "Downsampled sizes (%d, %d, %d) -> " + "(%d, %d, %d)", + extras->nsize [0], extras->nsize [1], extras->nsize [2], + (int) geom [6], (int) geom [7], (int) geom [8]); + + /* Now figure out the local downsampling */ + /* The local starts are the lb modded into the downsample */ + for (i = 0; i < 3; i++) { + geom [i] = extras->lb [myproc][i] / ioUtilGH->downsample [i]; + start [i] = geom [i] * ioUtilGH->downsample [i]; + if (start [i] < + extras->lb [myproc][i] + extras->ownership [PUGH_NO_STAGGER][0][i]) { + start [i] += ioUtilGH->downsample [i]; + geom [i] ++; + } + end [i] = ((extras->lb [myproc][i] + + extras->ownership [PUGH_NO_STAGGER][1][i] - 1) / + ioUtilGH->downsample [i]) * ioUtilGH->downsample [i]; + geom [i+3] = (end [i] - start [i]) / ioUtilGH->downsample [i] + 1; + } + + if (verbose) { + CCTK_VInfo (CCTK_THORNSTRING, "Downsample ranges (%d, %d, %d) -> " + "(%d, %d, %d)", + start [0], start [1], start [2], end [0], end [1], end [2]); + CCTK_VInfo (CCTK_THORNSTRING, "Local size/bound (%d, %d, %d) " + "(%d, %d, %d)", (int) geom [3], (int) geom [4], (int) geom[5], + (int) geom [0], (int) geom [1], (int) geom [2]); + } + + /* compute local ranges */ + for (i = 0; i < 3; i++) { + start [i] -= extras->lb [myproc][i]; + end [i] -= extras->lb [myproc][i]; + } + + *outme = malloc (geom [3] * geom [4] * geom [5] * element_size); + *free_outme = 1; + + /* I hate it to repeat the loops for each case label + but that way produces much more efficient code */ + l = 0; + switch (CCTK_VarTypeI (vindex)) { + case CCTK_VARIABLE_CHAR: + char_ptr = (CCTK_BYTE *) *outme; + for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample [2]) + for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample [1]) + for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample [0]) + char_ptr [l++] = ((CCTK_BYTE *) data) [DATINDEX (extras, i, j, k)]; + break; + + case CCTK_VARIABLE_INT: + int_ptr = (CCTK_INT *) *outme; + for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample [2]) + for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample [1]) + for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample [0]) + int_ptr [l++] = ((CCTK_INT *) data) [DATINDEX (extras, i, j, k)]; + break; + + case CCTK_VARIABLE_REAL: + if (ioUtilGH->out_single) + single_ptr = (CCTK_REAL4 *) *outme; + else + real_ptr = (CCTK_REAL *) *outme; + for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample [2]) + for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample [1]) + for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample [0]) + if (ioUtilGH->out_single) + single_ptr [l++] = (CCTK_REAL4) + (((CCTK_REAL *) data) [DATINDEX (extras, i, j, k)]); + else + real_ptr [l++] = ((CCTK_REAL *) data) [DATINDEX (extras, i, j, k)]; + break; + + default: + CCTK_WARN (1, "Unsupported variable type in IOPanda_getDumpData"); + return; + } + } + +#ifdef IOPANDA_DEBUG + printf ("Lower bound: %d", (int) geom [0]); + for (i = 1; i < dim; i++) + printf (" %d", (int) geom [i]); + printf ("\n"); + printf ("Chunk size : %d", (int) geom [1*dim + 0]); + for (i = 1; i < dim; i++) + printf (" %d", (int) geom [1*dim + i]); + printf ("\n"); + printf ("Global size: %d", (int) geom [2*dim + 0]); + for (i = 1; i < dim; i++) + printf (" %d", (int) geom [2*dim + i]); + printf ("\n"); +#endif +} diff --git a/src/ioPandaGH.h b/src/ioPandaGH.h index b4c20a8..d066d37 100644 --- a/src/ioPandaGH.h +++ b/src/ioPandaGH.h @@ -2,28 +2,47 @@ @header ioPandaGH.h @date 01 Oct 1999 @author Jonghyun Lee - @desc The extensions to the GH structure from IOPanda. - @history - @endhistory + @desc + The extensions to the GH structure from IOPanda. + @enddesc + @version $Header$ @@*/ -#include +#ifndef _IOPANDA_IOPANDAGH_H_ +#define _IOPANDA_IOPANDAGH_H_ 1 #include "StoreNamedData.h" -typedef struct IOPandaGH { - +typedef struct IOPandaGH +{ /* the number of times to output */ - int out3D_every; + int out_every; - /* flags indicating output for var [i] */ - char *do_out3D; + /* flags indicating output for variable[i] */ + char *do_out; /* directory in which to output */ - char *outdir3D; - - /* the last iteration output for var [i] */ - int *out3D_last; + char *outdir; + /* the last iteration output for variable[i] */ + int *out_last; } pandaGH; + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* prototypes of functions to be registered as IOPanda's IO method */ +int IOPanda_OutputGH (const cGH *GH); +int IOPanda_TriggerOutput (const cGH *GH, int); +int IOPanda_TimeFor (const cGH *GH, int); +int IOPanda_OutputVarAs (const cGH *GH, const char *var, const char *alias); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif /* _IOPANDA_IOPANDAGH_H_ */ diff --git a/src/make.code.defn b/src/make.code.defn index 4ab0091..f16782d 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -1,6 +1,11 @@ -SRCS = Startup.c GHExtension.c Output3D.c DumpVar.c +# Main make.code.defn file for thorn IOPanda +# $Header$ +# Source files in this directory +SRCS = Startup.c Output.c DumpVar.c + +# Other subdirectories SUBDIRS = Panda -# all compilers should understand ANSI C +# This avoids warnings when including the FlexIO headers CFLAGS += -DANSI diff --git a/src/make.configuration.defn b/src/make.configuration.defn index 75357f2..5457011 100644 --- a/src/make.configuration.defn +++ b/src/make.configuration.defn @@ -1,20 +1,13 @@ # make.configuration.defn for IOPanda +# $Header$ # make sure that IOPanda was configured with PUGH and MPI ifeq ($(findstring CactusPUGH/PUGH,$(THORNS)),) -.pseudo: MissingPUGHinIOPanda -MissingPUGHinIOPanda: - @echo "IOPanda: requires PUGH" - @echo "IOPanda: Please add CactusPUGH/PUGH or remove IOPanda from Thornlist !" - exit 2 + $(error "IOPanda requires PUGH. Please add CactusPUGH/PUGH or remove IOPanda from Thornlist !") endif MPI_CONFIGURED := $(shell grep -l CCTK_MPI $(CONFIG)/cctk_Extradefs.h) ifneq ("$(MPI_CONFIGURED)", "$(CONFIG)/cctk_Extradefs.h") -.pseudo: MissingMPIinIOPanda -MissingMPIinIOPanda: - @echo "IOPanda: requires MPI" - @echo "IOPanda: Please configure with MPI or remove IOPanda from Thornlist !" - exit 2 + $(error "IOPanda requires MPI. Please configure with MPI or remove IOPanda from Thornlist !") endif -- cgit v1.2.3