From 7a308bf34c39c6f7a5e248965ee1786dde0e9458 Mon Sep 17 00:00:00 2001 From: tradke Date: Fri, 28 Apr 2000 16:32:55 +0000 Subject: Bringing IOPanda to a more up-to-date state. Still developmental. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOPanda/trunk@7 38c3d835-c875-442e-b0fe-21c19ce1d001 --- param.ccl | 130 +++++++------------------------ schedule.ccl | 2 +- src/DumpVar.c | 182 +++++++++++++++++++++++--------------------- src/GHExtension.c | 61 ++++++++------- src/Output3D.c | 143 +++++++++++++++------------------- src/Panda/c_interface.C | 2 +- src/Panda/make.code.defn | 6 +- src/Panda/os-detected | 2 +- src/Startup.c | 14 ++++ src/ioPandaGH.h | 19 ++--- src/make.configuration.defn | 10 ++- 11 files changed, 253 insertions(+), 318 deletions(-) diff --git a/param.ccl b/param.ccl index 89690e3..4e88262 100644 --- a/param.ccl +++ b/param.ccl @@ -1,8 +1,8 @@ -# Parameter definitions for thorn IOFlexIO +# Parameter definitions for thorn IOPanda ############################################################################# -### declare IOFlexIO parameters +### declare IOPanda parameters ############################################################################# private: @@ -10,10 +10,6 @@ private: ######################## # How often to do output ######################## -INT out2D_every "How often to do 2D output, overrides out_every" -{ - -1:* :: -} -1 INT out3D_every "How often to do 3D output, overrides out_every" { -1:* :: @@ -23,36 +19,19 @@ INT out3D_every "How often to do 3D output, overrides out_every" #################### # Output directories #################### -STRING outdir2D "Name of IO 2D output directory, overrides outdir" -{ - .* :: A regex which matces everything -} "outdir" STRING outdir3D "Name of IO 3D output directory, overrides outdir" { .* :: A regex which matces everything -} "outdir" +} "." ########################## # What variables to output ########################## -STRING out2D_vars "Variables to output in 2D FlexIO file format" +STRING out3D_vars "Variables to output in 3D Panda file format" { - .* :: A regex which matces everything -} "" -STRING out3D_vars "Variables to output in 3D FlexIO file format" -{ - .* :: A regex which matces everything + .* :: A regex which matches everything } "" -################ -# Various things -################ -LOGICAL checkpoint "Do checkpointing with IOFlexIO" -{ -} "no" -LOGICAL out3d_reuse_filehandles "Reuse file handles by closing files after each write operation." -{ -} "no" ############################################################################# @@ -63,111 +42,56 @@ shares: IO #################### # Output directories #################### -EXTEND STRING outdir "Name of IO output directory" +USES STRING outdir "" { -} "." +} ######################## # How often to do output ######################## -EXTEND INT out_every "How often to do IO output" +USES INT out_every "" { - -1:* :: -} -1 + : :: +} ################ # various things ################ -EXTEND LOGICAL verbose "Give extended screen output in IO?" +USES LOGICAL verbose "" { -} "no" -EXTEND LOGICAL out3D_datestamp "Write date as attribute to IO 3D output file?" +} +USES LOGICAL out3D_datestamp "" { -} "yes" -EXTEND LOGICAL out3D_parameters "Write parameters to IO 3D output file?" +} +USES LOGICAL out3D_parameters "" { -} "yes" -EXTEND LOGICAL out3D_structures "Write structures to IO 3D output file?" -{ -} "yes" +} ####################### # Specific to 3D output ####################### -EXTEND KEYWORD out3D_mode "Which mode for 3D IO" +USES KEYWORD out3D_mode "" { - "proc" :: "every processor writes its share of data into a separate file" - "np" :: "data is collected and written by every N'th processor into a separate file, where N is specified by the parameter ioproc_every" - "onefile" :: "all output is written into a single file by processor 0" -} "proc" +} -EXTEND INT out3D_procs "Do IO on every N processors." +USES INT out3D_procs "" { - 1:* :: "Must be a positive integer" -} 8 -EXTEND LOGICAL out3D_septimefiles "Write one file per time slice, as opposed to all data in one file" + : :: +} +USES LOGICAL out3D_septimefiles "" { -} "no" -EXTEND LOGICAL out3D_unchunked "Don't write data in chunks." +} +USES LOGICAL out3D_unchunked "" { -} "no" +} ############################################## # Downsampling parameters (only for 3D output) ############################################## -EXTEND INT out3D_downsample_x "Factor by which to downsample output in x direction. Point (0,0,0) is always included." -{ - 1:* :: "Must be a positive integer" -} 1 -EXTEND INT out3D_downsample_y "Factor by which to downsample output in y direction. Point (0,0,0) is always included." +USES LOGICAL out3D_single "" { - 1:* :: "Must be a positive integer" -} 1 -EXTEND INT out3D_downsample_z "Factor by which to downsample output in z direction. Point (0,0,0) is always included." -{ - 1:* :: "Must be a positive integer" -} 1 -EXTEND LOGICAL out3D_single "Output 3D data in single precision ? This parameter is ignored for Cactus compiled with single precision" -{ -} "no" - - -################################### -# Checkpointing/recovery parameters -################################### -EXTEND LOGICAL checkpoint_ID "Checkpoint initial data ?" -{ -} "no" -EXTEND LOGICAL checkpoint_keep_all "Keep all checkpoint files ?" -{ -} "no" -EXTEND LOGICAL recover "Recover from a checkpoint file ?" -{ -} "no" -EXTEND INT checkpoint_every "Checkpoint every x iterations" -{ - -1:* :: "negative values disable checkpointing" -} -1 -EXTEND INT checkpoint_keep "How many checkpoint files to keep" -{ - 1:* :: "1 overwrites the latest checkpoint file" -} 1 -EXTEND STRING checkpoint_file "File name for regular checkpoint" -{ -} "checkpoint" -EXTEND STRING checkpoint_ID_file "File name for initial data checkpoint" -{ -} "checkpointID" -EXTEND STRING recover_file "File name of recovery file" -{ -} "checkpoint" -EXTEND STRING checkpoint_dir "Output directory for checkpoint files" -{ -} "." -EXTEND STRING recovery_dir "Directory to look for the recovery file" -{ -} "." +} diff --git a/schedule.ccl b/schedule.ccl index 6329547..3e53fb4 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -4,7 +4,7 @@ ######################################################################## ### register IOPanda routines ######################################################################## -schedule IOPanda_Startup at STARTUP after IOUtil_Startup +schedule IOPanda_Startup at STARTUP after (IOUtil_Startup Driver_Startup) { LANG:C } "IOPanda startup routine" diff --git a/src/DumpVar.c b/src/DumpVar.c index f17a8a1..726eb0a 100644 --- a/src/DumpVar.c +++ b/src/DumpVar.c @@ -11,16 +11,10 @@ #include #include -#ifdef SGI -#include -#endif #include "cctk.h" -#include "cctk_DefineThorn.h" #include "cctk_Parameters.h" -#ifdef CACTUSPUGH_PUGH #include "CactusPUGH/PUGH/src/include/pugh.h" -#endif #include "CactusBase/IOUtil/src/ioGH.h" #include "ioPandaGH.h" @@ -32,17 +26,16 @@ static char *char_time_date = NULL; void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme, - int *free_outme, CCTK_INT4 bnd [9], int element_size) + int *free_outme, CCTK_INT4 *geom, int element_size) { DECLARE_CCTK_PARAMETERS - int i; - int myproc; + int i, myproc, do_downsample, dim; ioGH *ioUtilGH; - pGH *pughGH; CCTK_REAL4 *single_ptr; CCTK_REAL *real_ptr; CCTK_CHAR *char_ptr; CCTK_INT *int_ptr; + pGExtras *extras; void *data = CCTK_VarDataPtrI (GH, timelevel, index); /* to make the compiler happy */ @@ -51,19 +44,39 @@ void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme, char_ptr = NULL; int_ptr = NULL; + /* get the handle for IOUtil GH extensions */ ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; - pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")]; - myproc = CCTK_MyProc (GH); + /* get the pGExtras pointer as a shortcut */ + extras = ((pGA ***) PUGH_pGH (GH)->variables) [index][timelevel]->extras; + + /* get the dimension of the variable */ + dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (index)); + + 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 (index); - if (ioUtilGH->downsample_x == 1 && - ioUtilGH->downsample_y == 1 && - ioUtilGH->downsample_z == 1) { + 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 (pughGH->npoints*sizeof (CCTK_REAL4)); + single_ptr = (CCTK_REAL4 *) malloc (extras->npoints*sizeof (CCTK_REAL4)); - for (i = 0; i < pughGH->npoints; i++) + for (i = 0; i < extras->npoints; i++) single_ptr [i] = (CCTK_REAL4) ((CCTK_REAL *) data) [i]; *outme = single_ptr; @@ -73,74 +86,65 @@ void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme, *free_outme = 0; } - for (i = 0; i < 3; i++) { - bnd [i] = GH->cctk_lbnd[i]; /* the bounds */ - bnd [i+3] = GH->cctk_lsh[i]; /* the sizes */ - bnd [i+6] = GH->cctk_gsh[i]; /* the global space */ + /* 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 i, j, k, l; - /* Downsampling code ... */ - bnd [6] = GH->cctk_gsh[0] / ioUtilGH->downsample_x; - if (GH->cctk_gsh[0] % ioUtilGH->downsample_x) - bnd [6]++; - bnd [7] = GH->cctk_gsh[1] / ioUtilGH->downsample_y; - if (GH->cctk_gsh[1] % ioUtilGH->downsample_y) - bnd [7]++; - bnd [8] = GH->cctk_gsh[2] / ioUtilGH->downsample_z; - if (GH->cctk_gsh[2] % ioUtilGH->downsample_z) - bnd [8]++; - - if (verbose) - printf ("Downsampled sizes (%d, %d, %d) -> (%d, %d, %d)\n", - GH->cctk_gsh[0], GH->cctk_gsh[1], GH->cctk_gsh[2], - (int) bnd [6], (int) bnd [7], (int) bnd [8]); - - /* Now figure out the local downsampling */ - /* The local starts are the lb modded into the downsample */ + /* downsampled global shape */ for (i = 0; i < 3; i++) { - int downsample; + geom [i + 6] = extras->nsize [i] / ioUtilGH->downsample [i]; + if (extras->nsize [i] % ioUtilGH->downsample [i]) + geom [i + 6]++; + } - if (i == 0) - downsample = ioUtilGH->downsample_x; - else if (i == 1) - downsample = ioUtilGH->downsample_y; - else - downsample = ioUtilGH->downsample_z; + 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]); - bnd [i] = GH->cctk_lbnd[i] / downsample; - start [i] = bnd [i] * downsample; + /* 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] < - GH->cctk_lbnd[i] + pughGH->ownership [PUGH_VERTEXCTR][i][0]) { - start [i] += downsample; - bnd [i] ++; + extras->lb [myproc][i] + extras->ownership [PUGH_NO_STAGGER][0][i]) { + start [i] += ioUtilGH->downsample [i]; + geom [i] ++; } - end [i] = ((GH->cctk_lbnd [i] + - pughGH->ownership [PUGH_VERTEXCTR][i][1] - 1) / downsample) - * downsample; - bnd [i+3] = (end [i] - start [i]) / downsample + 1; + 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) { - printf ("Downsample ranges (%d, %d, %d) -> (%d, %d, %d)\n", - start [0], start [1], start [2], - end [0], end [1], end [2]); - printf ("Local size/bound (%d, %d, %d) (%d, %d, %d)\n", - (int) bnd [3], (int) bnd [4], (int) bnd [5], - (int) bnd [0], (int) bnd [1], (int) bnd [2]); + 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] -= GH->cctk_lbnd [i]; - end [i] -= GH->cctk_lbnd [i]; + start [i] -= extras->lb [myproc][i]; + end [i] -= extras->lb [myproc][i]; } - *outme = malloc (bnd [3] * bnd [4] * bnd [5] * element_size); + *outme = malloc (geom [3] * geom [4] * geom [5] * element_size); *free_outme = 1; /* I hate it to repeat the loops for each case label @@ -149,18 +153,18 @@ void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme, switch (CCTK_VarTypeI (index)) { case CCTK_VARIABLE_CHAR: char_ptr = (CCTK_CHAR *) *outme; - for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample_z) - for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample_y) - for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample_x) - char_ptr [l++] = ((CCTK_CHAR *) data) [DI (pughGH, i, j, k)]; + 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_CHAR *) 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_z) - for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample_y) - for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample_x) - int_ptr [l++] = ((CCTK_INT *) data) [DI (pughGH, i, j, k)]; + 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: @@ -168,14 +172,14 @@ void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme, single_ptr = (CCTK_REAL4 *) *outme; else real_ptr = (CCTK_REAL *) *outme; - for (k = start [2]; k <= end [2]; k += ioUtilGH->downsample_z) - for (j = start [1]; j <= end [1]; j += ioUtilGH->downsample_y) - for (i = start [0]; i <= end [0]; i += ioUtilGH->downsample_x) + 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) [DI (pughGH, i, j, k)]); + (((CCTK_REAL *) data) [DATINDEX (extras, i, j, k)]); else - real_ptr [l++] = ((CCTK_REAL *) data) [DI (pughGH, i, j, k)]; + real_ptr [l++] = ((CCTK_REAL *) data) [DATINDEX (extras, i, j, k)]; break; default: @@ -184,14 +188,18 @@ void IOPanda_getDumpData (cGH *GH, int index, int timelevel, void **outme, } } - if (verbose) { - printf ("Global size: %d %d %d\n", - (int) bnd [6], (int) bnd [7], (int) bnd [8]); - printf ("Lower bound: %d %d %d\n", - (int) bnd [0], (int) bnd [1], (int) bnd [2]); - printf ("Chunk size : %d %d %d\n", - (int) bnd [3], (int) bnd [4], (int) bnd [5]); - } +#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 index 02aa021..b68459e 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -17,10 +17,8 @@ #include "cctk.h" #include "cctk_DefineThorn.h" #include "cctk_Parameters.h" -#ifdef CACTUSPUGH_PUGH -#include "CactusPUGH/PUGH/src/include/pugh.h" -#endif #include "CactusBase/IOUtil/src/ioGH.h" +#include "CactusPUGH/PUGH/src/include/pugh.h" #include "ioPandaGH.h" void Panda_Create(int, int); @@ -33,8 +31,8 @@ void *IOPanda_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) numvars = CCTK_NumVars (); newGH = (pandaGH *) malloc (sizeof (pandaGH)); - newGH->IO_3Dnum = (int *) malloc (numvars * sizeof (int)); - newGH->IO_3Dlast = (int *) malloc (numvars * sizeof (int)); + newGH->do_out3D = (char *) malloc (numvars * sizeof (char)); + newGH->out3D_last = (int *) malloc (numvars * sizeof (int)); return (newGH); } @@ -45,42 +43,49 @@ int IOPanda_InitGH (cGH *GH) int i; ioGH *ioUtilGH; pandaGH *myGH; + const cParamData *paramdata; + /* 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->IO_3Devery = out_every; + myGH->out3D_every = out_every > 0 ? out_every : -1; if (out3D_every > 0) - myGH->IO_3Devery = out3D_every; + myGH->out3D_every = out3D_every; - InitIONum (myGH->IO_3Dnum, out3D_vars); + ParseVarsForOutput (out3D_vars, myGH->do_out3D); /* Deal with the output directories */ - myGH->outpfx_3D = outdir; - if (!CCTK_Equals(outdir3D,"outdir")) - myGH->outpfx_3D = outdir3D; - - /* Create the output directories */ - if (myGH->IO_3Devery > 0) { - if (CCTK_MyProc (GH) == 0) { - FILE *fp; - - if (CCTK_mkdir (myGH->outpfx_3D) != 0) - CCTK_WARN (2,"Problem creating IO 3D directory"); - fp = fopen("FILEPREFIX", "w"); - fprintf(fp, "%s", myGH->outpfx_3D); - fclose(fp); - } + /* Check whether "outdir3D" was set. + If so take this dir otherwise default to "IO::outdir" */ + paramdata = CCTK_ParameterData ("outdir3D", CCTK_THORNSTRING); + if (paramdata && paramdata->n_set > 0) + myGH->outdir3D = strdup (outdir3D); + else + myGH->outdir3D = strdup (outdir); + + /* create the output dir */ + if (CCTK_MyProc (GH) == 0) { + FILE *fp; + + i = CCTK_mkdir (myGH->outdir3D); + if (i < 0) + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Problem creating IOPanda 3D output directory '%s'", myGH->outdir3D); + else if (i > 0) + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "IOPanda 3D output directory '%s' already exists", myGH->outdir3D); + fp = fopen ("FILEPREFIX", "w"); + fprintf (fp, "%s", myGH->outdir3D); + fclose (fp); } - for (i=0; iIO_3Dlast [i] = -1; - - myGH->fileList_3D = NULL; + for (i = 0; i < CCTK_NumVars (); i++) + myGH->out3D_last [i] = -1; - Panda_Create(ioUtilGH->ioproc_every, 1); + Panda_Create (ioUtilGH->ioproc_every, 1); return (0); } diff --git a/src/Output3D.c b/src/Output3D.c index ea97b62..c7ef26a 100644 --- a/src/Output3D.c +++ b/src/Output3D.c @@ -9,24 +9,17 @@ @@*/ #include -#include #include #include #include "cctk.h" #include "cctk_Parameters.h" -#include "cctk_DefineThorn.h" -#include "ioPandaGH.h" -#include "Panda/c_interface.h" #include "CactusBase/IOUtil/src/ioGH.h" -#ifdef CACTUSPUGH_PUGH #include "CactusPUGH/PUGH/src/include/pugh.h" -#endif -#ifdef SGI -#include -#endif - #include "external/IEEEIO/src/IOProtos.h" +#include "ioPandaGH.h" +#include "Panda/c_interface.h" + int IOPanda_Output3DVarAs (cGH *GH, const char *var, const char *alias); int IOPanda_TimeFor3D (cGH *GH, int index); @@ -43,10 +36,9 @@ void IOPanda_IEEEIOStructDump (cGH *GH, char *fname); @enddesc @calls CCTK_GHExtensionHandle CCTK_NumVars - CCTK_ImplementationFromVar CCTK_VarName IOPanda_TimeFor3D - IOPanda_Output3DVarAs + IOPanda_Timestep @calledby @history @@ -63,41 +55,30 @@ int IOPanda_Output3DGH (cGH *GH) { int i; pandaGH *myGH; - char *implementation; - char *name; - char *fullname; DECLARE_CCTK_PARAMETERS /* Get the GH extension for IOPanda */ myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")]; - if (myGH->IO_3Devery <= 0) - return; + if (myGH->out3D_every <= 0) + return (0); /* Loop over all variables */ for (i = 0; i < CCTK_NumVars (); i++) { if (IOPanda_TimeFor3D (GH, i)) { - implementation = CCTK_ImpFromVarI (i); - name = CCTK_VarName (i); - fullname = (char *) malloc (strlen (implementation) + - strlen (name) + 3); - assert (fullname); - sprintf (fullname, "%s::%s", implementation, name); - if (verbose) { + char *fullname = CCTK_FullName (i); + printf ("IOPanda Output3DGH : \n"); - printf (" fullname/name = %s/%s\n", fullname, name); + printf (" index/fullname = %d/%s\n", i, fullname); + free (fullname); } - IOPanda_Output3DVarAs (GH, fullname, name); - - free (fullname); + /* Do the 3D output */ + IOPanda_Timestep (GH, i, CCTK_VarName (i)); - /* Register another 3D output for this GF */ - myGH->IO_3Dnum [i]++; - - /* Register GF as having 3D output this iteration */ - myGH->IO_3Dlast [i] = GH->cctk_iteration; + /* Register variable as having 3D output this iteration */ + myGH->out3D_last [i] = GH->cctk_iteration; } } @@ -144,18 +125,12 @@ int IOPanda_Output3DVarAs (cGH *GH, const char *fullname, const char *alias) { DECLARE_CCTK_PARAMETERS int index; - pandaGH *myGH; index = CCTK_VarIndex(fullname); - /* Get the GH extension for IOPanda */ - myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")]; - if (verbose) { printf ("\nIn IOPanda Output3DVarAs\n-------------------\n"); - printf (" Fullname = -%s-\n", fullname); - printf (" Alias = -%s-\n", alias); - printf (" Index = %d\n", index); + printf (" index/fullname/alias = %d/%s/%s\n", index, fullname, alias); } /* Do the 3D output */ @@ -173,11 +148,6 @@ int IOPanda_Output3DVarAs (cGH *GH, const char *fullname, const char *alias) Decides if it is time to output a variable using the IOPanda 3D output method @enddesc - @calls CCTK_GHExtensionHandle - CCTK_GroupTypeFromVarI - CCTK_WARN - CCTK_QueryGroupStorageI - CCTK_GroupNameFromVarI @calledby IOPanda_Output3DGH @history @@ -203,28 +173,18 @@ int IOPanda_TimeFor3D (cGH *GH, int index) /* Get the GH extension for IOPanda */ myGH = (pandaGH *) GH->extensions [CCTK_GHExtensionHandle ("IOPanda")]; - /* Check this GF should be output */ - if (! (myGH->IO_3Dnum [index] != 0 && - GH->cctk_iteration % myGH->IO_3Devery == 0)) + /* Check this variable should be output */ + if (! (myGH->do_out3D [index] && GH->cctk_iteration % myGH->out3D_every == 0)) return (0); - /* Check GF not already output this iteration */ - if (myGH->IO_3Dlast [index] == GH->cctk_iteration) { - CCTK_WARN (2, "Already done 3D output in IOPanda"); - return (0); - } - - /* Check GF has storage */ - if (! CCTK_QueryGroupStorageI (GH, - CCTK_GroupIndexFromVarI(index))) { - char *fullname = CCTK_FullName (index); - char *msg = (char *) malloc (80 + strlen (fullname)); + /* Check variable not already output this iteration */ + if (myGH->out3D_last [index] == GH->cctk_iteration) { + char *fullname = CCTK_FullName (index); - sprintf (msg, "No IOPandaIO 3D output for '%s' (no storage)", fullname); - CCTK_WARN (2, msg); - free (fullname); - free (msg); - return (0); + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "Already done IOPanda 3D output for '%s'", fullname); + free (fullname); + return (0); } return (1); @@ -264,7 +224,7 @@ int IOPanda_TriggerOutput3D (cGH *GH, int index) { DECLARE_CCTK_PARAMETERS pandaGH *myGH; - char *varname; + const char *varname; varname = CCTK_VarName (index); @@ -273,23 +233,19 @@ int IOPanda_TriggerOutput3D (cGH *GH, int index) if (verbose) { printf("\nIn IOPanda TriggerOutput3D\n---------------------\n"); - printf(" Index = %d\n", index); - printf(" Variable = -%s-\n", varname); + printf(" index/name = %d/%s\n", index, varname); } /* Do the 3D output */ IOPanda_Timestep (GH, index, varname); - /* Register another 3D output for this GF */ - myGH->IO_3Dnum [index]++; - - /* Register GF as having 3D output this iteration */ - myGH->IO_3Dlast [index] = GH->cctk_iteration; + /* Register variable as having 3D output this iteration */ + myGH->out3D_last [index] = GH->cctk_iteration; return (0); } -void IOPanda_Timestep(cGH *GH, int index, const char *alias) +void IOPanda_Timestep (cGH *GH, int index, const char *alias) { DECLARE_CCTK_PARAMETERS void *data; @@ -307,8 +263,19 @@ void IOPanda_Timestep(cGH *GH, int index, const char *alias) return; } + /* check if variable has storage assigned */ + if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index))) { + char *fullname = CCTK_FullName (index); + + CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, + "No IOPanda 3D output for '%s' (no storage)", fullname); + free (fullname); + return; + } + + /* get the handles for PUGH and IOUtil GH extensions */ + pughGH = PUGH_pGH (GH); ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; - pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")]; ainfo.name_ = (char *)alias; @@ -342,8 +309,11 @@ void IOPanda_Timestep(cGH *GH, int index, const char *alias) } } + /* FIXME: rank */ ainfo.mem_rank_ = 3; - tmp2[0] = pughGH->nprocz; tmp2[1] = pughGH->nprocy; tmp2[2] = pughGH->nprocx; + 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; @@ -361,12 +331,18 @@ void IOPanda_Timestep(cGH *GH, int index, const char *alias) IOPanda_getDumpData(GH, index, timelevel, &data, &free_flag, bnd, ainfo.esize_); ainfo.data_ = (char *)data; - ainfo.stencil_width_ = pughGH->nghostzones; + /*** FIXME: asymmetric ghostzones */ + ainfo.stencil_width_ = GH->cctk_nghostzones [0]; PandaTimestep(&ainfo); + if (free_flag) + free (data); + IOPanda_AddCommonAttributes(GH, index, timelevel, ainfo.size_, ainfo.name_); - if (PandaIsNewFile(ainfo.name_)) IOPanda_IEEEIOStructDump(GH, ainfo.name_); + + if (PandaIsNewFile(ainfo.name_)) + IOPanda_IEEEIOStructDump(GH, ainfo.name_); } void IOPanda_AddCommonAttributes (cGH *GH, int index, int timelevel, @@ -425,14 +401,15 @@ void IOPanda_AddCommonAttributes (cGH *GH, int index, int timelevel, Panda_WriteAttribute (fname, "min_ext",FLOAT64,3,d3_to_IO); Panda_WriteAttribute (fname, "max_ext",FLOAT64, 3,d3_to_IO+3); - d3_to_IO [0] = GH->cctk_delta_space [0] * ioUtilGH->downsample_x; - d3_to_IO [1] = GH->cctk_delta_space [1] * ioUtilGH->downsample_y; - d3_to_IO [2] = GH->cctk_delta_space [2] * ioUtilGH->downsample_z; + /* 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_x > 1 || - ioUtilGH->downsample_y > 1 || - ioUtilGH->downsample_z > 1) { + 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]; diff --git a/src/Panda/c_interface.C b/src/Panda/c_interface.C index b6085d6..571e166 100644 --- a/src/Panda/c_interface.C +++ b/src/Panda/c_interface.C @@ -106,7 +106,7 @@ void PandaTimestep(ArrayInfo *ptr) ptr->data_, ptr->stencil_width_); global_bear->app_barrier(); - printf("---------------- Panda Timestep -------------------\n"); +// printf("---------------- Panda Timestep -------------------\n"); //printf("name %s rank %d size %d %d %d esize %d mem_layout %d %d %d disk_layout %d stencil_width_ %d\n", ptr->name_, ptr->rank_, ptr->size_[0], ptr->size_[1], ptr->size_[2], ptr->esize_, ptr->mem_layout_[0], ptr->mem_layout_[1], ptr->mem_layout_[2], ptr->disk_layout_[0], ptr->stencil_width_); array->timestep(); diff --git a/src/Panda/make.code.defn b/src/Panda/make.code.defn index dd9edc3..0604ab6 100644 --- a/src/Panda/make.code.defn +++ b/src/Panda/make.code.defn @@ -2,6 +2,8 @@ SRCS = App_Info.C Array.C ArrayDistribution.C ArrayLayout.C Attribute.C Chunk.C SUBDIRS = +FILEPREFIX=\"bla\" + # The 9000 names of the cygwin tools and T3E... TMPUN := $(shell uname) ifeq ($(TMPUN), CYGWIN32_95) @@ -21,7 +23,7 @@ endif # 64 Bit Irix ifeq ($(UNAME), IRIX64) -CXXFLAGS += -DANSI -DFILEPREFIX -ptused +CXXFLAGS += -DANSI -DFILEPREFIX=${FILEPREFIX} -ptused endif @@ -49,7 +51,7 @@ endif # Linux ifeq ($(UNAME), Linux) -CXXFLAGS += -DANSI +CXXFLAGS += -DANSI -DFILEPREFIX=${FILEPREFIX} endif diff --git a/src/Panda/os-detected b/src/Panda/os-detected index 4f378d7..8b13789 100644 --- a/src/Panda/os-detected +++ b/src/Panda/os-detected @@ -1 +1 @@ -irix + diff --git a/src/Startup.c b/src/Startup.c index 2f9ada8..38ad63b 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -51,6 +51,20 @@ void IOPanda_Startup (void) int IO_GHExtension; int IOMethod; + + if (CCTK_GHExtensionHandle ("IO") < 0) + { + CCTK_WARN (1, "Thorn IOUtil was not activated. " + "No IOPanda IO methods will be enabled."); + return; + } + if (CCTK_GHExtensionHandle ("PUGH") < 0) + { + CCTK_WARN (1, "Thorn PUGH was not activated. " + "No IOPanda IO methods will be enabled."); + return; + } + IO_GHExtension = CCTK_RegisterGHExtension ("IOPanda"); CCTK_RegisterGHExtensionSetupGH (IO_GHExtension, IOPanda_SetupGH); CCTK_RegisterGHExtensionInitGH (IO_GHExtension, IOPanda_InitGH); diff --git a/src/ioPandaGH.h b/src/ioPandaGH.h index f4da8d7..b4c20a8 100644 --- a/src/ioPandaGH.h +++ b/src/ioPandaGH.h @@ -14,19 +14,16 @@ typedef struct IOPandaGH { - /* The number of times output */ - int *IO_3Dnum; + /* the number of times to output */ + int out3D_every; - /* How often to output */ - int IO_3Devery; + /* flags indicating output for var [i] */ + char *do_out3D; - /* Directory in which to output */ - char *outpfx_3D; + /* directory in which to output */ + char *outdir3D; - /* The last iteration output */ - int *IO_3Dlast; - - /* filename database for opened files */ - pNamedData *fileList_3D; + /* the last iteration output for var [i] */ + int *out3D_last; } pandaGH; diff --git a/src/make.configuration.defn b/src/make.configuration.defn index 448649e..b051521 100644 --- a/src/make.configuration.defn +++ b/src/make.configuration.defn @@ -1,6 +1,6 @@ # make.configuration.defn for IOPanda -# make sure that IOPanda was configured in with MPI and IEEEIO +# make sure that IOPanda was configured in with MPI, PUGH, and IEEEIO ifeq ($(findstring external/IEEEIO,$(THORNS)),) .pseudo: MissingIEEEIOinIOPanda @@ -10,6 +10,14 @@ MissingIEEEIOinIOPanda: exit 2 endif +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 +endif + ifeq ($(strip $(MPI_LIBS)), ) $(NAME): MissingMPIinIOPanda .pseudo: MissingMPIinIOPanda -- cgit v1.2.3