/*@@ @file GHExtension.c @date Fri May 21 1999 @author Thomas Radke @desc IOHDF5 GH extension stuff. @enddesc @history @hauthor Thomas Radke @hdate May 21 1999 @hdesc Just copied from thorn FlexIO. @endhistory @@*/ /*#define DEBUG_IO*/ #include #include #include #include "cctk.h" #include "cctk_Parameters.h" #include "cctk_Arguments.h" #include "ioHDF5GH.h" void IOHDF5_DefaultGeo(cGH *GH, int sdim, ioHDF5Geo_t *geo); void *IOHDF5_SetupGH (tFleshConfig *config, int convergence_level, cGH *GH) { int numvars,iv; ioHDF5GH *newGH; numvars = CCTK_NumVars (); newGH = (ioHDF5GH *) malloc (sizeof (ioHDF5GH)); newGH->do_out1D = (char *) malloc (numvars * sizeof (char)); newGH->do_out2D = (char *) malloc (numvars * sizeof (char)); newGH->do_out3D = (char *) malloc (numvars * sizeof (char)); newGH->out1D_last = (int *) malloc (numvars * sizeof (int)); newGH->out2D_last = (int *) malloc (numvars * sizeof (int)); newGH->out3D_last = (int *) malloc (numvars * sizeof (int)); newGH->checkForExistingObjects = (char *) calloc (numvars, 1); /* Allocate geometry structure for each grid variable/array */ newGH->out_geo = (ioHDF5Geo_t**) malloc(IOHDF5_MAXDIM * sizeof (ioHDF5Geo_t)); for (iv=0;ivout_geo[iv] = (ioHDF5Geo_t*) malloc(IOHDF5_MAXDIM * sizeof (ioHDF5Geo_t)); /* save the original error printing routine and its argument */ CACTUS_IOHDF5_ERROR (H5Eget_auto (&newGH->printErrorFn, &newGH->printErrorFnArg)); /* predefine dataspaces for writing scalar and array attributes */ /* the dimension of the array dataspace is set when used */ CACTUS_IOHDF5_ERROR (newGH->scalarDataspace = H5Screate (H5S_SCALAR)); CACTUS_IOHDF5_ERROR (newGH->arrayDataspace = H5Screate (H5S_SIMPLE)); /* predefine a IOHDF5_COMPLEX datatype */ CACTUS_IOHDF5_ERROR (newGH->IOHDF5_COMPLEX = H5Tcreate (H5T_COMPOUND, sizeof (CCTK_COMPLEX))); CACTUS_IOHDF5_ERROR (H5Tinsert (newGH->IOHDF5_COMPLEX, "real", offsetof (CCTK_COMPLEX, Re), IOHDF5_REAL)); CACTUS_IOHDF5_ERROR (H5Tinsert (newGH->IOHDF5_COMPLEX, "imag", offsetof (CCTK_COMPLEX, Im), IOHDF5_REAL)); /* predefine a C string datatype */ CACTUS_IOHDF5_ERROR (newGH->IOHDF5_STRING = H5Tcopy (H5T_C_S1)); return (newGH); } int IOHDF5_InitGH (cGH *GH) { DECLARE_CCTK_PARAMETERS int i; ioHDF5GH *myGH; myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")]; /* How often to output */ myGH->out1D_every = out_every > 0 ? out_every : -1; if (out1D_every > 0) { myGH->out1D_every = out1D_every; } myGH->out2D_every = out_every > 0 ? out_every : -1; if (out2D_every > 0) { myGH->out2D_every = out2D_every; } myGH->out3D_every = out_every > 0 ? out_every : -1; if (out3D_every > 0) { myGH->out3D_every = out3D_every; } /* Check whether "outdir2D" and/or "outdir3D" was set. If so take these dirs otherwise default to "IO::outdir" */ if (CCTK_ParameterQueryTimesSet ("outdir1D", CCTK_THORNSTRING) > 0) { myGH->outdir1D = strdup (outdir1D); } else { myGH->outdir1D = strdup (outdir); } if (CCTK_ParameterQueryTimesSet ("outdir2D", CCTK_THORNSTRING) > 0) { myGH->outdir2D = strdup (outdir2D); } else { myGH->outdir2D = strdup (outdir); } if (CCTK_ParameterQueryTimesSet ("outdir3D", CCTK_THORNSTRING) > 0) { myGH->outdir3D = strdup (outdir3D); } else { myGH->outdir3D = strdup (outdir); } /* Create the output directories */ if (CCTK_MyProc (GH) == 0) { i = CCTK_CreateDirectory (0755, myGH->outdir1D); if (i < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating HDF5 1D output directory '%s'", myGH->outdir1D); } else if (i > 0) { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "HDF5 1D output directory '%s' already exists", myGH->outdir1D); } i = CCTK_CreateDirectory (0755, myGH->outdir2D); if (i < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating HDF5 2D output directory '%s'", myGH->outdir2D); } else if (i > 0) { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "HDF5 2D output directory '%s' already exists", myGH->outdir2D); } i = CCTK_CreateDirectory (0755, myGH->outdir3D); if (i < 0) { CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Problem creating HDF5 3D output directory '%s'", myGH->outdir3D); } else if (i > 0) { CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING, "HDF5 3D output directory '%s' already exists", myGH->outdir3D); } } for (i = 0; i < CCTK_NumVars (); i++) { myGH->out2D_last [i] = myGH->out3D_last [i] = -1; myGH->out1D_last [i] = myGH->out3D_last [i] = -1; } /* FIXME default geometry should be set ehre, but has to be done outside currently, because it needs spxyz and needs to scheduled at BASEGRID */ myGH->filenameList = NULL; /* create timers if timing info was requested */ myGH->print_timing_info = print_timing_info; if (myGH->print_timing_info) { for (i = 0; i < 4; i++) { if ((myGH->timers[i] = CCTK_TimerCreateI ()) < 0) { break; } } if (i != 4) { CCTK_WARN (1, "Could not create timers for checkpoint/recovery ! " "No timer information will be available."); while (--i >= 0) { CCTK_TimerDestroyI (myGH->timers[i]); } myGH->print_timing_info = 0; } else { CCTK_TimerResetI (myGH->timers[2]); CCTK_TimerResetI (myGH->timers[3]); } } return (0); } void SliceCenterSetup(CCTK_ARGUMENTS) { DECLARE_CCTK_PARAMETERS int inum,idim; ioHDF5Geo_t geo_default; ioHDF5GH *myGH; myGH = (ioHDF5GH *) cctkGH->extensions [CCTK_GHExtensionHandle ("IOHDF5")]; /* Loop over all slab dimension */ for (idim=0;idimout_geo[inum][idim] = geo_default; } }