diff options
Diffstat (limited to 'src/GHExtension.c')
-rw-r--r-- | src/GHExtension.c | 61 |
1 files changed, 33 insertions, 28 deletions
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; i<CCTK_NumVars(); i++) - myGH->IO_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); } |