diff options
-rw-r--r-- | param.ccl | 39 | ||||
-rw-r--r-- | src/GHExtension.c | 40 | ||||
-rw-r--r-- | src/Output2D.c | 5 | ||||
-rw-r--r-- | src/Output3D.c | 7 | ||||
-rw-r--r-- | src/ioFlexGH.h | 8 |
5 files changed, 75 insertions, 24 deletions
@@ -6,6 +6,31 @@ ############################################################################# private: + +######################## +# How often to do output +######################## +INT output2d_every "How often to do 2D output, overrides output_every" +{ + -1:* :: +} -1 +INT output3d_every "How often to do 3D output, overrides output_every" +{ + -1:* :: +} -1 + + +#################### +# Output directories +#################### +STRING outdir2d "Name of IO 2D output directory, overrides outdir" +{ +} "outdir" +STRING outdir3d "Name of IO 3D output directory, overrides outdir" +{ +} "outdir" + + ########################## # What variables to output ########################## @@ -39,12 +64,6 @@ shares: IO EXTEND STRING outdir "Name of IO output directory" { } "." -EXTEND STRING outdir2d "Name of IO 2D output directory, overrides outdir" -{ -} "outdir" -EXTEND STRING outdir3d "Name of IO 3D output directory, overrides outdir" -{ -} "outdir" ######################## @@ -54,14 +73,6 @@ EXTEND INT output_every "How often to do IO output" { -1:* :: } -1 -EXTEND INT output2d_every "How often to do 2D output, overrides output_every" -{ - -1:* :: -} -1 -EXTEND INT output3d_every "How often to do 3D output, overrides output_every" -{ - -1:* :: -} -1 ################ diff --git a/src/GHExtension.c b/src/GHExtension.c index 67e4908..b11e7ab 100644 --- a/src/GHExtension.c +++ b/src/GHExtension.c @@ -58,15 +58,53 @@ int IOFlexIO_InitGH (cGH *GH) DECLARE_CCTK_PARAMETERS int i; ioGH *ioUtilGH; - flexioGH *myGH; + flexioGH *myGH; /* get the handles for IOUtil and IOFlexIO extensions */ ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; + /* How often to output */ + myGH->IO_2Devery = output_every; + myGH->IO_3Devery = output_every; + if (output2d_every > 0) + myGH->IO_2Devery = output2d_every; + if (output3d_every > 0) + myGH->IO_3Devery = output3d_every; + InitIONum (myGH->IO_2Dnum, output2D); InitIONum (myGH->IO_3Dnum, output3D); + /* Deal with the output directories */ + myGH->outpfx_2D = outdir; + myGH->outpfx_3D = outdir; + if (!CCTK_Equals(outdir2d,"outdir")) + myGH->outpfx_2D = outdir2d; + if (!CCTK_Equals(outdir3d,"outdir")) + myGH->outpfx_3D = outdir3d; + + /* Create the output directories */ + if (myGH->IO_2Devery > 0) { + if (CCTK_MyProc (GH) == 0) { + char *command = (char *) malloc (1024 * sizeof (char)); + + sprintf (command, "mkdir -p %s", myGH->outpfx_2D); + if (system (command) < 0) + CCTK_WARN (1,"Problem creating IO 2D directory"); + free (command); + } + } + if (myGH->IO_3Devery > 0) { + if (CCTK_MyProc (GH) == 0) { + char *command = (char *) malloc (1024 * sizeof (char)); + + sprintf (command, "mkdir -p %s", myGH->outpfx_3D); + if (system (command) < 0) + CCTK_WARN (1,"Problem creating IO 3D directory"); + free (command); + } + } + for (i=0; i<CCTK_NumVars(); i++) myGH->IO_2Dlast [i] = myGH->IO_3Dlast [i] = -1; diff --git a/src/Output2D.c b/src/Output2D.c index b79b8c7..c380a2e 100644 --- a/src/Output2D.c +++ b/src/Output2D.c @@ -21,7 +21,6 @@ #include "GHExtensions.h" #include "WarnLevel.h" #include "Comm.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioFlexGH.h" @@ -186,16 +185,14 @@ int IOFlexIO_Output2DVarAs (cGH *GH, const char *fullname, const char *alias) int IOFlexIO_TimeFor2D (cGH *GH, int index) { - ioGH *ioUtilGH; flexioGH *myGH; /* Get the GH extension for IOUtil and IOFlexIO */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; /* Check this GF should be output */ if (! (CCTK_GroupTypeFromVarI (index) == GROUP_GF && myGH->IO_2Dnum [index] != 0 - && GH->cctk_iteration % ioUtilGH->IO_2Devery == 0)) + && GH->cctk_iteration % myGH->IO_2Devery == 0)) return (0); /* Check GF not already output this iteration */ diff --git a/src/Output3D.c b/src/Output3D.c index 8fc6265..7fafa35 100644 --- a/src/Output3D.c +++ b/src/Output3D.c @@ -22,7 +22,6 @@ #include "GHExtensions.h" #include "WarnLevel.h" #include "Comm.h" -#include "CactusBase/IOUtil/src/ioGH.h" #include "ioFlexGH.h" int IOFlexIO_Output3DVarAs (cGH *GH, const char *var, const char *alias); @@ -189,16 +188,14 @@ int IOFlexIO_Output3DVarAs (cGH *GH, const char *fullname, const char *alias) int IOFlexIO_TimeFor3D (cGH *GH, int index) { - ioGH *ioUtilGH; flexioGH *myGH; - /* Get the GH extension for IOUtil and IOFlexIO */ - ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")]; + /* Get the GH extension for IOFlexIO */ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; /* Check this GF should be output */ if (! (myGH->IO_3Dnum [index] != 0 && - GH->cctk_iteration % ioUtilGH->IO_3Devery == 0)) + GH->cctk_iteration % myGH->IO_3Devery == 0)) return (0); /* Check GF not already output this iteration */ diff --git a/src/ioFlexGH.h b/src/ioFlexGH.h index 68a576e..3513476 100644 --- a/src/ioFlexGH.h +++ b/src/ioFlexGH.h @@ -70,6 +70,14 @@ typedef struct IOFlexIOGH { int *IO_2Dnum; int *IO_3Dnum; + /* How often to output */ + int IO_2Devery; + int IO_3Devery; + + /* Directory in which to output */ + char *outpfx_2D; + char *outpfx_3D; + /* The last iteration output */ int *IO_2Dlast; int *IO_3Dlast; |