/*@@ @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" /* local function prototypes */ static void SetupSliceCenter (cGH *GH); void *IOFlexIO_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { DECLARE_CCTK_PARAMETERS int i, numvars; flexioGH *newGH; numvars = CCTK_NumVars (); newGH = (flexioGH *) malloc (sizeof (flexioGH)); newGH->do_out2D = (char *) malloc (numvars * sizeof (char)); newGH->do_out3D = (char *) malloc (numvars * sizeof (char)); newGH->out2D_last = (int *) malloc (numvars * sizeof (int)); newGH->out3D_last = (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; flexioGH *myGH; const cParamData *paramdata; /* get the handle for IOFlexIO extensions */ myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; /* How often to output */ myGH->out2D_every = out_every > 0 ? out_every : -1; myGH->out3D_every = out_every > 0 ? out_every : -1; if (out2D_every > 0) { myGH->out2D_every = out2D_every; } if (out3D_every > 0) { myGH->out3D_every = out3D_every; } ParseVarsForOutput (out2D_vars, myGH->do_out2D); ParseVarsForOutput (out3D_vars, myGH->do_out3D); /* Check whether "outdir2D" and/or "outdir3D" was set. If so take these dirs otherwise default to "IO::outdir" */ paramdata = CCTK_ParameterData ("outdir2D", CCTK_THORNSTRING); if (paramdata && paramdata->n_set > 0) { myGH->outdir2D = strdup (outdir2D); } else { myGH->outdir2D = strdup (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 directories */ if (CCTK_MyProc (GH) == 0) { i = CCTK_mkdir (myGH->outdir2D); if (i < 0) CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating IOFlexIO 2D output directory '%s'", myGH->outdir2D); if (i > 0) CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "2D IOFlexIO output directory '%s' already exists", myGH->outdir2D); i = CCTK_mkdir (myGH->outdir3D); if (i < 0) CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating IOFlexIO 3D output directory '%s'", myGH->outdir3D); if (i > 0) CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "3D IOFlexIO output directory '%s' already exists", myGH->outdir3D); } for (i=0; iout2D_last [i] = myGH->out3D_last [i] = -1; } myGH->filenameList2D = NULL; myGH->fileList_3D = NULL; /* set up 2D planes to plot */ SetupSliceCenter (GH); /* create timers if timing info was requested */ if (print_timing_info) { myGH->dumpVarsTimer = CCTK_TimerCreateI (); myGH->dumpParamsTimer = CCTK_TimerCreateI (); myGH->checkpointTotalTimer = CCTK_TimerCreateI (); myGH->recoverVarsTimer = CCTK_TimerCreateI (); myGH->recoverParamsTimer = CCTK_TimerCreateI (); myGH->recoverTotalTimer = CCTK_TimerCreateI (); if (myGH->dumpVarsTimer < 0) { CCTK_WARN (1, "Could not create timer. Timing info on dumping datasets " "will not be available."); } if (myGH->dumpParamsTimer < 0) { CCTK_WARN (1, "Could not create timer. Timing info on dumping parameters" " will not be available."); } if (myGH->checkpointTotalTimer < 0) { CCTK_WARN (1, "Could not create timer ! Timing info on total checkpoint " "time will not be available."); } if (myGH->recoverVarsTimer < 0) { CCTK_WARN (1, "Could not create timer ! Timing info on recovering " "datasets will not be available."); } if (myGH->recoverParamsTimer < 0) { CCTK_WARN (1, "Could not create timer ! Timing info on recovering " " parameters will not be available."); } if (myGH->recoverTotalTimer < 0) { CCTK_WARN (1, "Could not create timer ! Timing info on total recovery " "time will not be available."); } CCTK_TimerResetI (myGH->checkpointTotalTimer); CCTK_TimerResetI (myGH->recoverTotalTimer); } return (0); } #if 0 int IOFlexIO_Terminate (cGH *GH) { DECLARE_CCTK_PARAMETERS if (print_timing_info) { CCTK_TimerDestroyI (myGH->dumpVarsTimer); CCTK_TimerDestroyI (myGH->dumpParamsTimer); CCTK_TimerDestroyI (myGH->checkpointTotalTimer); CCTK_TimerDestroyI (myGH->recoverVarsTimer); CCTK_TimerDestroyI (myGH->recoverParamsTimer); CCTK_TimerDestroyI (myGH->recoverTotalTimer); } return (0); } #endif /****************************************************************************/ /* local routines */ /****************************************************************************/ static void SetupSliceCenter (cGH *GH) { DECLARE_CCTK_PARAMETERS int dim; int slice_center; pGH *pughGH; flexioGH *myGH; /* Get the handles for PUGH and IOFlexIO extensions */ pughGH = PUGH_pGH (GH); myGH = (flexioGH *) GH->extensions [CCTK_GHExtensionHandle ("IOFlexIO")]; slice_center=1; if ( CCTK_Equals (domain, "octant") || CCTK_Equals (domain, "quadrant") || CCTK_Equals (domain, "bitant")) { slice_center=0; } if (slice_center) { /* For NONE octant mode: the center for slicings */ /* is moved to the center index */ /* (unless nx,ny,nz=1) */ for (dim = 0; dim < pughGH->dim; dim++) { if (pughGH->GFExtras[dim]->lnsize [dim] == 1) { myGH->sp2xyz [dim] = 0; } else { myGH->sp2xyz [dim] = pughGH->GFExtras[dim]->nsize [dim]/2 - pughGH->GFExtras[dim]->lb [pughGH->myproc][dim]; } } } /* for octant mode, the slicing center is the index 1 or zero*/ else { for (dim = 0; dim < GH->cctk_dim; dim++) { if (pughGH->GFExtras[dim]->lnsize [dim] == 1) { myGH->sp2xyz [dim] = 0; } else { myGH->sp2xyz [dim] = 1 - pughGH->GFExtras[dim]->lb [pughGH->myproc][dim]; } } } /* In quadrant mode x and y are like full, but z is like octant */ if (CCTK_Equals (domain, "quadrant")) { if (pughGH->GFExtras[2]->lnsize [2] == 1) { myGH->sp2xyz[2] = 0; } else { myGH->sp2xyz[2] = pughGH->GFExtras[2]->lnsize [2]/2 - pughGH->GFExtras[2]->lb [pughGH->myproc][2]; } } if (CCTK_Equals (domain, "bitant")) { if (pughGH->GFExtras[2]->lnsize [0] == 1) { myGH->sp2xyz[0] = 0; } else { myGH->sp2xyz[0] = myGH->sp2xyz[0]/2 - pughGH->GFExtras[2]->lb [pughGH->myproc][0]; } if (pughGH->GFExtras[2]->lnsize [1] == 1) { myGH->sp2xyz[1] = 0; } else { myGH->sp2xyz[1] = pughGH->GFExtras[2]->lnsize [1]/2 - pughGH->GFExtras[2]->lb [pughGH->myproc][1]; } } }