/*@@ @file GHExtension.c @date Friday 18th September @author Gabrielle Allen @desc IO GH extension stuff. @enddesc @@*/ /* #define DEBUG_IO */ #include #include #include #include "cctk.h" #include "cctk_Parameters.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "iobasicGH.h" void *IOBasic_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { int i; iobasicGH *newGH; newGH = (iobasicGH *) malloc (sizeof (iobasicGH)); newGH->infovals = (CCTK_REAL **) malloc (CCTK_NumVars () * sizeof (CCTK_REAL *)); for (i=0;iinfovals[i] = (CCTK_REAL *) malloc (2 * sizeof (CCTK_REAL)); } newGH->do_outScalar = (char *) malloc (CCTK_NumVars () * sizeof (char)); newGH->outScalar_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); newGH->do_outInfo = (char *) malloc (CCTK_NumVars () * sizeof (char)); newGH->outInfo_last = (int *) malloc (CCTK_NumVars () * sizeof (int)); return newGH; } int IOBasic_InitGH (cGH *GH) { DECLARE_CCTK_PARAMETERS int i; iobasicGH *myGH; const cParamData *paramdata; /* get the handles for IOBasic extensions */ myGH = (iobasicGH *) GH->extensions [CCTK_GHExtensionHandle ("IOBasic")]; myGH->filenameListScalar = NULL; /* How often to output */ myGH->outInfo_every = out_every > 0 ? out_every : -1; if (outInfo_every > 0) myGH->outInfo_every = outInfo_every; myGH->outScalar_every = out_every > 0 ? out_every : -1; if (outScalar_every > 0) myGH->outScalar_every = outScalar_every; IOUtil_ParseVarsForOutput (outInfo_vars, myGH->do_outInfo); IOUtil_ParseVarsForOutput (outScalar_vars, myGH->do_outScalar); /* Check whether "outdirScalar" was set. If so take this dir otherwise default to "IO::outdir" */ paramdata = CCTK_ParameterData ("outdirScalar", CCTK_THORNSTRING); if (paramdata && paramdata->n_set > 0) { myGH->outdirScalar = strdup (outdirScalar); } else { myGH->outdirScalar = strdup (outdir); } /* create the output dir */ if (CCTK_MyProc (GH) == 0) { i = CCTK_CreateDirectory (0755,myGH->outdirScalar); if (i < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "IOBasic_InitGH: Problem creating Scalar output directory '%s'", myGH->outdirScalar); } if (i > 0) { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "IOBasic_InitGH: Scalar output directory '%s' already exists", myGH->outdirScalar); } } for (i=0; ioutScalar_last[i] = -1; myGH->outInfo_last [i] = -1; myGH->infovals[i][0] = 0.0; myGH->infovals[i][1] = 0.0; } myGH->filenameListScalar = NULL; return 0; }