/*@@ @file GHExtension.c @date Fri May 21 1999 @author Thomas Radke @desc IOFlexIO GH extension stuff. @enddesc @history @hauthor Thomas Radke @hdate May 21 1999 @hdesc Just copied from thorn IO. @endhistory @@*/ /*#define DEBUG_IO*/ #include #include #include #include "cctk.h" #include "cctk_parameters.h" #include "CactusPUGH/PUGH/src/include/pugh.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "ioFlexGH.h" void *IOFlexIO_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { int i, numvars; flexioGH *newGH; numvars = CCTK_NumVars (); newGH = (flexioGH *) malloc (sizeof (flexioGH)); newGH->IO_2Dnum = (int *) malloc (numvars * sizeof (int)); newGH->IO_3Dnum = (int *) malloc (numvars * sizeof (int)); newGH->IO_2Dlast = (int *) malloc (numvars * sizeof (int)); newGH->IO_3Dlast = (int *) malloc (numvars * sizeof (int)); newGH->IEEEfname_3D = (char **) malloc (numvars * sizeof (char **)); for (i = 0; i < numvars; i++) newGH->IEEEfname_3D [i] = (char *) malloc (512 * sizeof (char)); newGH->IEEEfile_3D = (IOFile *) malloc (numvars * sizeof (IOFile)); return (newGH); } int IOFlexIO_InitGH (cGH *GH) { DECLARE_CCTK_PARAMETERS int i; ioGH *ioUtilGH; 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 = out_every; myGH->IO_3Devery = out_every; if (out2D_every > 0) myGH->IO_2Devery = out2D_every; if (out3D_every > 0) myGH->IO_3Devery = out3D_every; InitIONum (myGH->IO_2Dnum, out2D_vars); InitIONum (myGH->IO_3Dnum, out3D_vars); /* 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 (CCTK_MyProc (GH) == 0) { if (myGH->IO_2Devery > 0 && strcmp (myGH->outpfx_2D, ".")) if (CCTK_mkdir (myGH->outpfx_2D) != 0) CCTK_WARN (2,"Problem creating IO 2D directory"); if (myGH->IO_3Devery > 0 && strcmp (myGH->outpfx_3D, ".")) if (CCTK_mkdir (myGH->outpfx_3D) != 0) CCTK_WARN (2,"Problem creating IO 3D directory"); } for (i=0; iIO_2Dlast [i] = myGH->IO_3Dlast [i] = -1; myGH->out3d_reuse_filehandles = out3d_reuse_filehandles; /* Only have reuse for chunked data */ if (myGH->out3d_reuse_filehandles && ioUtilGH->unchunked) { CCTK_WARN (2, "Cannot reuse handles with unchunked data. " "Ignoring parameter 'out3d_reuse_filehandles'"); myGH->out3d_reuse_filehandles = 0; } /* Only have reuse if not one file per slice */ if (myGH->out3d_reuse_filehandles && out3D_septimefiles) { CCTK_WARN (2, "Cannot reuse handles with 'out3D_septimefiles = yes'. " "Ignoring parameter 'out3d_reuse_filehandles'"); myGH->out3d_reuse_filehandles = 0; } myGH->filenameList2D = NULL; myGH->fileList_3D = NULL; return (0); }