aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-04-16 12:26:40 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-04-16 12:26:40 +0000
commitd8aa32794e141b22fa9954b4ec3afe6b8ae50d8a (patch)
tree496e578e98b6f9ea083992580eba446c6e9e2a17
parent81d51bf07a80e0654b808e68fa138ff62f2d0c0e (diff)
Get rid of old code which isn't used anymore. Most of it went to IOHDF5Util.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@116 4825ed28-b72c-4eae-9704-e50c059e567d
-rw-r--r--src/ChooseOutput.c145
-rw-r--r--src/DumpVar.c1130
-rw-r--r--src/File.c203
-rw-r--r--src/GHExtension.c233
-rw-r--r--src/Output1D.c294
-rw-r--r--src/Output2D.c294
-rw-r--r--src/Output3D.c285
-rw-r--r--src/ParseGeometry.c157
-rw-r--r--src/RestoreFile.c580
-rw-r--r--src/Write1D.c177
-rw-r--r--src/Write2D.c184
-rw-r--r--src/Write3D.c193
12 files changed, 0 insertions, 3875 deletions
diff --git a/src/ChooseOutput.c b/src/ChooseOutput.c
deleted file mode 100644
index 7e102b2..0000000
--- a/src/ChooseOutput.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*@@
- @file ChooseOutput.c
- @author Gabrielle Allen
- @date July 6 2000
- @desc
- Choose what data to write for different IO methods in IOHDF5
- @enddesc
-
- @history
- @hauthor
- @hdesc
- @version $Header$
-@@*/
-
-#include <stdlib.h>
-
-#include "cctk.h"
-#include "cctk_Arguments.h"
-#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "ioFlexGH.h"
-
-static const char *rcsid = "$Header$";
-CCTK_FILEVERSION(CactusPUGHIO_IOHDF5_ChooseOutput_c)
-
-
-/*@@
- @routine IOFlexIO_Choose2D
- @author Gabrielle Allen
- @date July 6 2000
- @desc
- Use parameters to choose the 2D planes through the output data.
- @enddesc
-
- @history
- @hauthor
- @hdesc
- @version $Header$
-@@*/
-
-void IOFlexIO_Choose2D(CCTK_ARGUMENTS)
-{
- DECLARE_CCTK_PARAMETERS
-
- int i;
- int maxdim;
- flexioGH *myGH; /* FlexIO extension handle */
- int *origin_index; /* Specify output planes by indices */
- CCTK_REAL *origin_phys; /* Specify output planes by coordinates */
-
- myGH = (flexioGH *) cctkGH->extensions
- [CCTK_GHExtensionHandle ("IOFlexIO")];
-
- /* Set up lines to be output */
- maxdim = CCTK_MaxDim();
- origin_phys = (CCTK_REAL *)calloc(maxdim,sizeof(CCTK_REAL ));
- origin_index = (int *)calloc(maxdim,sizeof(int ));
-
- /* Set parameters using
- 1. Indices from IOFlexIO
- 2. Indices from IOUtil
- 3. Coords from IOFlexIO
- 4. Coords from IOUtil
- */
-
- if (CCTK_ParameterQueryTimesSet("out2D_yzplane_xi","IOFlexIO")>0)
- {
- origin_index[0] = out2D_yzplane_xi;
- }
- else if (CCTK_ParameterQueryTimesSet("out_yzplane_xi","IOUtil")>0)
- {
- origin_index[0] = out_yzplane_xi;
- }
- else
- {
- origin_index[0] = -1;
- if (CCTK_ParameterQueryTimesSet("out2D_yzplane_x","IOFlexIO")>0)
- {
- origin_phys[0] = out2D_yzplane_x;
- }
- else
- {
- origin_phys[0] = out_yzplane_x;
- }
- }
-
- if (CCTK_ParameterQueryTimesSet("out2D_xzplane_yi","IOFlexIO")>0)
- {
- origin_index[1] = out2D_xzplane_yi;
- }
- else if (CCTK_ParameterQueryTimesSet("out_xzplane_yi","IOUtil")>0)
- {
- origin_index[1] = out_xzplane_yi;
- }
- else
- {
- origin_index[1] = -1;
- if (CCTK_ParameterQueryTimesSet("out2D_xzplane_y","IOFlexIO")>0)
- {
- origin_phys[1] = out2D_xzplane_y;
- }
- else
- {
- origin_phys[1] = out_xzplane_y;
- }
- }
-
- if (CCTK_ParameterQueryTimesSet("out2D_xyplane_zi","IOFlexIO")>0)
- {
- origin_index[2] = out2D_xyplane_zi;
- }
- else if (CCTK_ParameterQueryTimesSet("out_xyplane_zi","IOUtil")>0)
- {
- origin_index[2] = out_xyplane_zi;
- }
- else
- {
- origin_index[2] = -1;
- if (CCTK_ParameterQueryTimesSet("out2D_xyplane_z","IOFlexIO")>0)
- {
- origin_phys[2] = out2D_xyplane_z;
- }
- else
- {
- origin_phys[2] = out_xyplane_z;
- }
- }
-
- if (myGH)
- {
- for (i=1;i<=CCTK_MaxDim();i++)
- {
- IOUtil_2DPlanes (cctkGH, i, origin_index,
- origin_phys, myGH->sp2xyz[i-1]);
- }
- }
- else
- {
- CCTK_WARN(1,"IOFlexIO_Choose2D: FlexIO GH extension not found");
- }
-
- return;
-}
-
-
diff --git a/src/DumpVar.c b/src/DumpVar.c
deleted file mode 100644
index a7de009..0000000
--- a/src/DumpVar.c
+++ /dev/null
@@ -1,1130 +0,0 @@
-/*@@
- @file DumpVar.c
- @date Fri May 21 1999
- @author Thomas Radke
- @desc
- Do the actual writing of a variable, for output or for checkpointing.
- @enddesc
- @history
- @hauthor Thomas Radke @hdate May 21 1999
- @hdesc Just copied from thorn FlexIO.
- @hendhistory
- @@*/
-
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "CactusPUGH/PUGH/src/include/pugh.h"
-#include "Hyperslab.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "ioHDF5GH.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef SGI
-#include <time.h>
-#endif
-
-#define IOTAGBASE 20000 /* This may break on more than 2000 processors */
-
-#define IOHDF5_DEBUG
-
-/* info structure describing how to dump a given CCTK variable type */
-typedef struct {
- int iohdf5_type; /* the HDF5 type to use */
- int element_size; /* size of a single data element */
-#ifdef CCTK_MPI
- MPI_Datatype mpi_type; /* the data type for MPI communication */
-#endif
-} dumpInfo_t;
-
-static char *char_time_date = NULL;
-
-/* local function prototypes */
-static void IOHDF5_DumpGS (cGH *GH, int index, int timelevel, hid_t iof,
- int iohdf5_type);
-
-static int IOHDF5_DumpGA (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- hid_t iof, dumpInfo_t *info);
-
-static int IOHDF5_getDumpData_ND (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- void **outme, int *free_outme,
- CCTK_INT *geom, int element_size);
-
-static void IOHDF5_procDump (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- void *outme, CCTK_INT *geom, int proc,
- int iohdf5_type, hid_t iof);
-
-static void IOHDF5_AddCommonAttributes (cGH *GH, int index, int timelevel,
- CCTK_INT *global_shape,
- hid_t dataset);
-
-static void IOHDF5_AddCommonAttributes_ND (cGH *GH, int index, ioHDF5Geo_t *slab_geo,
- CCTK_INT *global_shape, hid_t dataset);
-
-#ifdef CCTK_MPI
-#ifdef HAVE_PARALLEL
-static void IOHDF5_collectiveDump (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- void *outme, CCTK_INT *geom,
- int hdf5io_type, hid_t iof);
-#endif /* HAVE_PARALLEL */
-#endif /* MPI */
-
-
-
-/*@@
- @routine IOHDF5_DumpVar
- @date 16 Apr 1999
- @author Thomas Radke
- @desc
- Generic dump routine, just calls the appropriate dump routine
- @enddesc
- @calledby IOHDF5_DumpGH IOHDF5_Write3D
- @history
- @endhistory
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc global index of the variable to be dumped
- @vtype int
- @vio in
- @endvar
- @var timelevel
- @vdesc the timelevel to store
- @vtype int
- @vio in
- @endvar
- @var iof
- @vdesc the HDF5 file handle
- @vtype hid_t
- @vio in
- @endvar
-@@*/
-int IOHDF5_DumpVar (cGH *GH, int index, int timelevel, ioHDF5Geo_t *geo, hid_t iof)
-{
- pGH *pughGH;
- ioHDF5GH *h5GH;
- ioGH *ioUtilGH;
- int variable_type;
- dumpInfo_t info;
- int retval = 0;
-
- /* Get the handle for PUGH, IOUtil, and IOHDF5 extensions */
- pughGH = PUGH_pGH (GH);
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- variable_type = CCTK_VarTypeI (index);
-
- switch (variable_type) {
- case CCTK_VARIABLE_CHAR:
- info.iohdf5_type = IOHDF5_CHAR;
- info.element_size = sizeof (CCTK_CHAR);
-#ifdef CCTK_MPI
- info.mpi_type = PUGH_MPI_CHAR;
-#endif
- break;
- case CCTK_VARIABLE_INT:
- info.iohdf5_type = IOHDF5_INT;
- info.element_size = sizeof (CCTK_INT);
-#ifdef CCTK_MPI
- info.mpi_type = PUGH_MPI_INT;
-#endif
- break;
- case CCTK_VARIABLE_REAL:
- info.iohdf5_type = ioUtilGH->out_single ? IOHDF5_REAL4 : IOHDF5_REAL;
- info.element_size = ioUtilGH->out_single ?
- sizeof (CCTK_REAL4) : sizeof (CCTK_REAL);
-#ifdef CCTK_MPI
- info.mpi_type = ioUtilGH->out_single ? PUGH_MPI_REAL4 : PUGH_MPI_REAL;
-#endif
- break;
- case CCTK_VARIABLE_COMPLEX:
- info.iohdf5_type = h5GH->IOHDF5_COMPLEX;
- info.element_size = sizeof (CCTK_COMPLEX);
-#ifdef CCTK_MPI
- info.mpi_type = pughGH->PUGH_mpi_complex;
-#endif
- break;
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported variable type %d", variable_type);
- return(-1);
- }
-
- switch (CCTK_GroupTypeFromVarI (index)) {
- case CCTK_SCALAR:
- IOHDF5_DumpGS (GH, index, timelevel, iof, info.iohdf5_type);
- break;
- case CCTK_ARRAY:
- case CCTK_GF:
- retval = IOHDF5_DumpGA (GH, index, timelevel, geo, iof, &info);
- break;
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Invalid group type %d in IOHDF5_DumpVar",
- CCTK_GroupTypeFromVarI (index));
- retval = -1;
- }
- return(retval);
-}
-
-
-/*@@
- @routine IOHDF5_DumpGS
- @date May 21 1999
- @author Thomas Radke
- @desc Dumps a SCALAR type variable into a HDF5 file
- @enddesc
- @calledby IOHDF5_DumpVar
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc global index of the variable to be dumped
- @vtype int
- @vio in
- @endvar
- @var timelevel
- @vdesc the timelevel to store
- @vtype int
- @vio in
- @endvar
- @var iof
- @vdesc the HDF5 file to dump to
- @vtype hid_t
- @vio in
- @endvar
- @var iohdf5_type
- @vdesc the HDF5 datatype
- @vtype int
- @vio in
- @endvar
- @history
- @endhistory
-
-@@*/
-static void IOHDF5_DumpGS (cGH *GH, int index, int timelevel, hid_t iof,
- int iohdf5_type)
-{
- CCTK_INT global_shape [1] = {0};
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
- hid_t dataset, dataspace;
- char *name, *datasetname;
-
- /* Get the handles for IOHDF5 and IOUtil extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc)
- return;
-
- CACTUS_IOHDF5_ERROR (dataspace = H5Screate (H5S_SCALAR));
- name = CCTK_FullName (index);
- datasetname = (char *) malloc (strlen (name) + 30);
- sprintf (datasetname, "%s@%d@%d", name, GH->cctk_iteration, timelevel);
- free (name);
-
- /* if restart from recovery delete an already existing dataset
- so that it can be created as anew */
- if (h5GH->checkForExistingObjects [index]) {
- CACTUS_IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- H5Gunlink (iof, datasetname);
- CACTUS_IOHDF5_ERROR(H5Eset_auto(h5GH->printErrorFn, h5GH->printErrorFnArg));
- }
- CACTUS_IOHDF5_ERROR (dataset = H5Dcreate (iof, datasetname,
- iohdf5_type, dataspace, H5P_DEFAULT));
- free (datasetname);
- CACTUS_IOHDF5_ERROR (H5Dwrite (dataset, iohdf5_type, H5S_ALL, H5S_ALL,
- H5P_DEFAULT,
- CCTK_VarDataPtrI (GH, timelevel, index)));
-
- IOHDF5_AddCommonAttributes (GH, index, timelevel, global_shape, dataset);
-
- CACTUS_IOHDF5_ERROR (H5Dclose (dataset));
- CACTUS_IOHDF5_ERROR (H5Sclose (dataspace));
-}
-
-
-/*@@
- @routine IOHDF5_DumpGA
- @date May 21 1999
- @author Paul Walker
- @desc Dumps a GA type variable into a HDF5 file
- @enddesc
- @calledby IOHDF5_DumpVar
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc global index of the variable to be dumped
- @vtype int
- @vio in
- @endvar
- @var timelevel
- @vdesc the timelevel to store
- @vtype int
- @vio in
- @endvar
- @var iof
- @vdesc the HDF5 file to dump to
- @vtype hid_t
- @vio in
- @endvar
- @var info
- @vdesc info structure describing
- - the HDF5 datatype to store
- - the size of an element of variable
- - the MPI datatype to communicate
- @vtype dumpInfo_t
- @vio in
- @endvar
-
- @history
- @endhistory
-
-@@*/
-static int IOHDF5_DumpGA (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- hid_t iof, dumpInfo_t *info)
-{
- DECLARE_CCTK_PARAMETERS
- ioGH *ioUtilGH;
- pGH *pughGH;
- int myproc;
- int nprocs;
- int sdim;
- CCTK_INT *geom; /* Lower bounds, sizes and global shape of data */
- void *outme; /* The data pointer to dump ... */
- int free_outme; /* and whether it needs freeing */
- int retval=0;
-#ifdef CCTK_MPI
- int i, j;
- MPI_Status ms;
-#endif
-
- /* Get the handles for PUGH and IOUtil extensions */
- pughGH = PUGH_pGH (GH);
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
-
- sdim= slab_geo->sdim;
-
- /* allocate the geometry buffer */
- geom = (CCTK_INT *) malloc (3*sdim * sizeof (CCTK_INT));
-
- /* Get the pointer to the data we want to output (includes downsampling) */
- if (IOHDF5_getDumpData_ND(GH, index, timelevel, slab_geo,
- &outme, &free_outme, geom,
- info->element_size)<0)
- {
- return(-1);
- }
-
- myproc = CCTK_MyProc (GH);
- nprocs = CCTK_nProcs (GH);
-
-#ifdef CCTK_MPI
-#ifdef HAVE_PARALLEL
- if (ioUtilGH->unchunked) {
- IOHDF5_collectiveDump (GH, index, timelevel, slab_geo,
- outme, geom,
- info->iohdf5_type, iof);
- if (free_outme)
- free (outme);
- free (geom);
- return;
- }
-#endif
-#endif
-
- /* Dump data held on IO processor */
- if (myproc == ioUtilGH->ioproc) {
- IOHDF5_procDump (GH, index, timelevel, slab_geo,
- outme, geom, myproc,
- info->iohdf5_type,iof);
- }
-#ifdef CCTK_MPI
- if (myproc == ioUtilGH->ioproc) {
-
- /* Dump data from all other processors */
- for (i = myproc+1; i < myproc+ioUtilGH->ioproc_every && i < nprocs; i++) {
-
- /* Allocate temp to the right size (based on GH->ub [i] et..) */
- void *tmpd;
- int incoming;
-
- /* receive geometry */
- CACTUS_MPI_ERROR (MPI_Recv (geom, 3*sdim, PUGH_MPI_INT, i, 2*i+IOTAGBASE+1,
- pughGH->PUGH_COMM_WORLD, &ms));
-
- incoming = geom [sdim];
- for (j = 1; j < sdim; j++)
- incoming *= geom [sdim + j];
-
- /* receive data if incoming>0 */
- if (incoming>0) {
-
- tmpd = malloc (incoming * info->element_size);
- CACTUS_MPI_ERROR (MPI_Recv (tmpd, incoming, info->mpi_type, i,
- 2*i+IOTAGBASE, pughGH->PUGH_COMM_WORLD, &ms));
-
- IOHDF5_procDump (GH, index, timelevel, slab_geo,
- tmpd, geom, i,
- info->iohdf5_type, iof);
- free (tmpd);
- }
-
- } /* End loop over processors */
-
- } else {
-
- /* Send the geometry and data from the non-IO processors
- * to the IO processors
- */
-
- int outgoing = geom [sdim];
-
- for (i = 1; i < sdim; i++)
- outgoing *= geom [sdim + i];
-
- /* send geometry */
- CACTUS_MPI_ERROR (MPI_Send (geom, 3*sdim, PUGH_MPI_INT, ioUtilGH->ioproc,
- 2*myproc+IOTAGBASE+1, pughGH->PUGH_COMM_WORLD));
- if (outgoing>0) {
-
- /* send data if outgoing>0 */
- CACTUS_MPI_ERROR (MPI_Send (outme, outgoing, info->mpi_type, ioUtilGH->ioproc,
- 2*myproc+IOTAGBASE, pughGH->PUGH_COMM_WORLD));
-#ifdef IOHDF5_DEBUG
- printf ("Processor %d sent %d data points\n", myproc, outgoing);
-#endif
- }
- }
-
- CCTK_Barrier (GH);
-#endif
-
- if (free_outme)
- free (outme);
-
- free (geom);
- return(retval);
-}
-
-
-/***************************** local functions ****************************/
-
-/*@@
- @routine IOHDF5_AddCommonAttributes
- @date May 21 1999
- @author Thomas Radke
- @desc
- Add "Common" attributes, these are:
- <ul>
- <li> the variable's groupname
- <li> the grouptype
- <li> number of timelevels
- <li> the current date
- Note that the datestamp should be turned of if you are byte
- comparing two output files.
- <li> simulation time
- <li> origin
- <li> bounding box
- <li> gridspacings (both downsampled and evolution)
- <li> global grid size
- </ul>
- @enddesc
- @calledby IOHDF5_DumpGS, IOHDF5_collectiveDump, IOHDF5_procDump
- @history
- @endhistory
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc global index of the variable to be dumped
- @vtype int
- @vio in
- @endvar
- @var timelevel
- @vdesc the timelevel to store
- @vtype int
- @vio in
- @endvar
- @var global_shape
- @vdesc the global shape of the dataset
- @vtype CCTK_INT [dim]
- @vio in
- @endvar
- @var dataset
- @vdesc the dataset handle where the attributes should be attached to
- @vtype hid_t
- @vio in
- @endvar
-@@*/
-static void IOHDF5_AddCommonAttributes (cGH *GH, int index, int timelevel,
- CCTK_INT *global_shape, hid_t dataset)
-{
- DECLARE_CCTK_PARAMETERS
- int vdim;
- CCTK_INT intAttr;
- CCTK_REAL dummy;
- CCTK_REAL realAttr [6];
- char *groupname;
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
-
- /* Get the handles for IOUtil and IOHDF5 extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* get the dimension of the variable */
- vdim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (index));
-
- groupname = CCTK_GroupNameFromVarI (index);
- WRITE_ATTRIBUTE ("groupname", groupname,
- dataset, h5GH->scalarDataspace, 0, h5GH->IOHDF5_STRING);
- free (groupname);
- intAttr = CCTK_GroupTypeFromVarI (index);
- WRITE_ATTRIBUTE ("grouptype", &intAttr, dataset, h5GH->scalarDataspace, 0,
- IOHDF5_INT);
- intAttr = CCTK_NumTimeLevelsFromVarI (index);
- WRITE_ATTRIBUTE ("ntimelevels", &intAttr, dataset, h5GH->scalarDataspace, 0,
- IOHDF5_INT);
-
- if (char_time_date && out3D_datestamp)
- WRITE_ATTRIBUTE ("date", char_time_date, dataset, h5GH->scalarDataspace, 0,
- h5GH->IOHDF5_STRING);
-
- WRITE_ATTRIBUTE ("time", &GH->cctk_time, dataset, h5GH->scalarDataspace, 0,
- IOHDF5_REAL);
-
- /* NOTE: the attributes "origin", "min_ext", "max_ext", and "delta"
- are always stored as 3-dimensional points */
- CCTK_CoordRange (GH, &realAttr [0], &dummy, -1, "x", "cart3d");
- CCTK_CoordRange (GH, &realAttr [1], &dummy, -1, "y", "cart3d");
- CCTK_CoordRange (GH, &realAttr [2], &dummy, -1, "z", "cart3d");
- WRITE_ATTRIBUTE ("origin", realAttr, dataset, h5GH->arrayDataspace, 3,
- IOHDF5_REAL);
-
- CCTK_CoordRange (GH, &realAttr [0], &realAttr [3], -1, "x", "cart3d");
- CCTK_CoordRange (GH, &realAttr [1], &realAttr [4], -1, "y", "cart3d");
- CCTK_CoordRange (GH, &realAttr [2], &realAttr [5], -1, "z", "cart3d");
- WRITE_ATTRIBUTE ("min_ext", realAttr, dataset, h5GH->arrayDataspace, 3,
- IOHDF5_REAL);
- WRITE_ATTRIBUTE ("max_ext", realAttr + 3, dataset, h5GH->arrayDataspace, 3,
- IOHDF5_REAL);
-
-
- realAttr [0] = GH->cctk_delta_space [0] * ioUtilGH->downsample [0];
- realAttr [1] = GH->cctk_delta_space [1] * ioUtilGH->downsample [1];
- realAttr [2] = GH->cctk_delta_space [2] * ioUtilGH->downsample [2];
- WRITE_ATTRIBUTE ("delta", realAttr, dataset, h5GH->arrayDataspace, 3,
- IOHDF5_REAL);
-
- if (ioUtilGH->downsample [0] > 1 ||
- ioUtilGH->downsample [1] > 1 ||
- ioUtilGH->downsample [2] > 1)
- WRITE_ATTRIBUTE ("evolution_delta", GH->cctk_delta_space, dataset,
- h5GH->arrayDataspace, 3, IOHDF5_REAL);
-
- WRITE_ATTRIBUTE ("global_size", global_shape, dataset, h5GH->arrayDataspace,
- vdim, IOHDF5_INT);
-
-}
-
-static void IOHDF5_AddCommonAttributes_ND (cGH *GH, int index, ioHDF5Geo_t *geo,
- CCTK_INT *global_shape, hid_t dataset)
-{
- DECLARE_CCTK_PARAMETERS
- CCTK_INT intAttr;
- CCTK_REAL dummy;
- CCTK_REAL realAttr [6];
- char *groupname;
-
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
-
- int idim;
-
- /* Get the handles for IOUtil and IOHDF5 extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* VARIABLE INFO */
- groupname = CCTK_GroupNameFromVarI (index);
- WRITE_ATTRIBUTE ("groupname", groupname,
- dataset, h5GH->scalarDataspace, 0, h5GH->IOHDF5_STRING);
- free (groupname);
- intAttr = CCTK_GroupTypeFromVarI (index);
- WRITE_ATTRIBUTE ("grouptype", &intAttr, dataset, h5GH->scalarDataspace, 0,
- IOHDF5_INT);
-
- /* TIMLEVELS (grid) */
- intAttr = CCTK_NumTimeLevelsFromVarI (index);
- WRITE_ATTRIBUTE ("ntimelevels", &intAttr, dataset, h5GH->scalarDataspace, 0,
- IOHDF5_INT);
-
- /* DATE */
- if (char_time_date && out3D_datestamp)
- WRITE_ATTRIBUTE ("date", char_time_date, dataset, h5GH->scalarDataspace, 0,
- h5GH->IOHDF5_STRING);
-
- /* TIME (grid) */
- WRITE_ATTRIBUTE ("time", &GH->cctk_time, dataset, h5GH->scalarDataspace, 0,
- IOHDF5_REAL);
-
- /* ORIGIN (grid) */
- CCTK_CoordRange (GH, &realAttr [0], &dummy, -1, "x", "cart3d");
- CCTK_CoordRange (GH, &realAttr [1], &dummy, -1, "y", "cart3d");
- CCTK_CoordRange (GH, &realAttr [2], &dummy, -1, "z", "cart3d");
- WRITE_ATTRIBUTE ("origin", realAttr, dataset, h5GH->arrayDataspace, geo->vdim,
- IOHDF5_REAL);
-
- /* ORIGIN (slab) - slab may be offset by (slab_start) grid points */
- for (idim=0;idim<geo->sdim;idim++)
- realAttr[idim]=geo->slab_start[geo->direction[idim]]*
- GH->cctk_delta_space[geo->direction[idim]];
- WRITE_ATTRIBUTE ("origin_slab", realAttr, dataset, h5GH->arrayDataspace, geo->sdim,
- IOHDF5_REAL);
-
- /* MIN/MAX extent (grid) */
- CCTK_CoordRange (GH, &realAttr [0], &realAttr [3], -1, "x", "cart3d");
- CCTK_CoordRange (GH, &realAttr [1], &realAttr [4], -1, "y", "cart3d");
- CCTK_CoordRange (GH, &realAttr [2], &realAttr [5], -1, "z", "cart3d");
- WRITE_ATTRIBUTE ("min_ext", realAttr, dataset, h5GH->arrayDataspace, geo->vdim,
- IOHDF5_REAL);
- WRITE_ATTRIBUTE ("max_ext", realAttr + 3, dataset, h5GH->arrayDataspace, geo->vdim,
- IOHDF5_REAL);
-
- /* MIN/MAX extent (slab) - slab may be smaller than grid*/
- for (idim=0;idim<geo->sdim;idim++) {
- realAttr[idim ]=(geo->slab_start[idim]*GH->cctk_delta_space[idim]);
- realAttr[idim+3]=(geo->slab_start[idim]+geo->actlen[idim]-1)*
- (GH->cctk_delta_space[idim]*geo->downs[idim]);
- }
- WRITE_ATTRIBUTE ("min_ext_slab", realAttr, dataset, h5GH->arrayDataspace, geo->sdim,
- IOHDF5_REAL);
- WRITE_ATTRIBUTE ("max_ext_slab", realAttr + 3, dataset, h5GH->arrayDataspace, geo->sdim,
- IOHDF5_REAL);
-
- /* DELTA SPACING (grid) */
- realAttr [0] = GH->cctk_delta_space [0];
- realAttr [1] = GH->cctk_delta_space [1];
- realAttr [2] = GH->cctk_delta_space [2];
- WRITE_ATTRIBUTE ("delta", realAttr, dataset, h5GH->arrayDataspace, geo->vdim,
- IOHDF5_REAL);
-
- /* DELTA SPACING (slab) */
- for (idim=0;idim<geo->sdim;idim++)
- realAttr[idim]=GH->cctk_delta_space[geo->direction[idim]]*
- geo->downs[geo->direction[idim]];
- WRITE_ATTRIBUTE ("delta_slab", realAttr, dataset, h5GH->arrayDataspace, geo->sdim,
- IOHDF5_REAL);
-
- /* FIXME: WHAT IS THIS ? */
- if (ioUtilGH->downsample [0] > 1 ||
- ioUtilGH->downsample [1] > 1 ||
- ioUtilGH->downsample [2] > 1)
- WRITE_ATTRIBUTE ("evolution_delta", GH->cctk_delta_space, dataset,
- h5GH->arrayDataspace, 3, IOHDF5_REAL);
-
- /* GLOBAL SIZE (slab) */
- WRITE_ATTRIBUTE ("global_size_grid", GH->cctk_gsh, dataset, h5GH->arrayDataspace,
- geo->vdim, IOHDF5_INT);
-
- /* GLOBAL SIZE (slab) */
- WRITE_ATTRIBUTE ("global_size", global_shape, dataset, h5GH->arrayDataspace,
- geo->sdim, IOHDF5_INT);
-
- /* GLOBAL SIZE (slab) */
- WRITE_ATTRIBUTE ("global_size_slab", geo->actlen, dataset, h5GH->arrayDataspace,
- geo->sdim, IOHDF5_INT);
-}
-
-
-static int IOHDF5_getDumpData_ND (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- void **outme, int *free_outme,
- CCTK_INT *geom, int element_size)
-{
- ioGH *ioUtilGH;
- pGExtras *extras=NULL;
-
- CCTK_REAL4 *single_ptr;
-
- int myproc, do_downsample;
- int idim, sdim, vdim; /*iteration, slab dim, variable dim */
- int *hsizes,*hsizes_global,*hsizes_offset; /* geometry information */
- int sdir[3]; /* slab direction FIXME */
- int locdowns[3]; /* Holds the downsampling in the order
- specified in slab_geo->direction[] */
- int slabstart[3]; /* global start index for slab to extract */
- int ip;
-
- void *data = CCTK_VarDataPtrI (GH, timelevel, index);
-
-
- myproc = CCTK_MyProc (GH);
-
- /* get GH extension for IOUtil */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
-
- /* get the pointer to PUGH specific structures */
- extras = ((pGA***) PUGH_pGH(GH)->variables) [index][timelevel]->extras;
-
- /* Shortcuts */
- vdim = slab_geo->vdim;
- sdim = slab_geo->sdim;
-
- if (vdim>3) {
- CCTK_WARN(1,"Cannot treat GFs with dim>3, check with cactus support\n");
- return(-1);
- }
-
- for (idim=0;idim<sdim;idim++)
- locdowns[idim]=slab_geo->downs[slab_geo->direction[idim]];
-
- /* Set downsample flag */
- do_downsample = 0;
- for (idim = 0; idim < sdim; idim++)
- do_downsample |= locdowns[idim] > 1;
-
- /* Simple case if no downsampling and sdim==vdim */
- if ((! do_downsample)&& (sdim==vdim))
- {
- if (ioUtilGH->out_single) {
- single_ptr = (CCTK_REAL4 *) malloc (extras->npoints*sizeof (CCTK_REAL4));
- for (ip = 0; ip < extras->npoints; ip++)
- single_ptr [ip] = (CCTK_REAL4) ((CCTK_REAL *) data) [ip];
-
- *outme = single_ptr;
- *free_outme = 1;
- }
- else
- {
- *outme = data;
- *free_outme = 0;
- }
-
- for (idim = 0; idim < sdim; idim++) {
- geom [idim + 0*sdim] = extras->lb [myproc][idim];
- geom [idim + 1*sdim] = extras->lnsize [idim];
- geom [idim + 2*sdim] = extras->nsize [idim];
- }
- }
- else /* Call Hyperslab else */ {
-
- /* allocate array to hold size information of slab */
- hsizes = (int*)malloc(sdim*sizeof(int));
- hsizes_global= (int*)malloc(sdim*sizeof(int));
- hsizes_offset= (int*)malloc(sdim*sizeof(int));
-
- for (idim=0;idim<sdim;idim++) {
- hsizes[idim]=0;
- hsizes_global[idim]=0;
- hsizes_offset[idim]=0;
- }
-
- /* TEMPORARY FIX DUE TO INCONSISTENT DIR SPECIFICATION */
- /* direction vector of 1d line in 3d volume */
- if (sdim==1) {
- sdir[0] = (slab_geo->direction[0]==0) ? 1:0;
- sdir[1] = (slab_geo->direction[0]==1) ? 1:0;
- sdir[2] = (slab_geo->direction[0]==2) ? 1:0;
- }
- /* norm vector of 2d surface in 3d volume */
- else if (sdim==2)
- {
- sdir[0] = ((slab_geo->direction[0]==1)&&(slab_geo->direction[1]==2)) ? 1:0;
- sdir[1] = ((slab_geo->direction[0]==0)&&(slab_geo->direction[1]==2)) ? 1:0;
- sdir[2] = ((slab_geo->direction[0]==0)&&(slab_geo->direction[1]==1)) ? 1:0;
- }
- /* spanning directions for 3d */
- else if (sdim==3)
- {
- sdir[0] = slab_geo->direction[0];
- sdir[1] = slab_geo->direction[1];
- sdir[2] = slab_geo->direction[2];
- }
-
- /* Get the start indeces for the slab from slab_start. */
- /* Slab_start from the geo structure is not a true start index, it is currently
- used as the intersection point of three surfaces , that's why two entries
- have to be set to zero in the case of a surface (one entry for line) FIXME */
- for (idim=0;idim<vdim;idim++)
- slabstart[idim] = slab_geo->slab_start[idim];
- for (idim=0;idim<sdim;idim++)
- slabstart[slab_geo->direction[idim]]=0;
-
-
- if (Hyperslab_GetLocalHyperslab (GH, index, timelevel, sdim, slab_geo->slab_start,
- sdir, slab_geo->length, locdowns, outme,
- hsizes, hsizes_global, hsizes_offset)< 0) {
- char *fullname = CCTK_FullName (index);
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Failed to extract hyperslab for variable '%s'", fullname);
- free (fullname);
- *free_outme = 0;
- return(-1);
-
- }
-
- *free_outme = 1;
-
- for (idim = 0; idim < sdim; idim++) {
- geom [idim + 0*sdim] = hsizes_offset[idim];
- geom [idim + 1*sdim] = hsizes[idim];
- geom [idim + 2*sdim] = hsizes_global[idim];
- slab_geo->actlen[idim]= hsizes_global[idim];
- }
- }
-#ifdef IOHDF5_DEBUG
- printf ("***** %dD \n",sdim);
- printf ("Lower bound: %d", (int) geom [0]);
- for (idim = 1; idim < sdim; idim++)
- printf (" %d", (int) geom [idim]);
- printf ("\n");
- printf ("Chunk size : %d", (int) geom [1*sdim + 0]);
- for (idim = 1; idim < sdim; idim++)
- printf (" %d", (int) geom [1*sdim + idim]);
- printf ("\n");
- printf ("Global size: %d", (int) geom [2*sdim + 0]);
- for (idim = 1; idim < sdim; idim++)
- printf (" %d", (int) geom [2*sdim + idim]);
- printf ("\n");
- printf ("Downsampling: ");
- for (idim = 0; idim < sdim; idim++)
- printf (" %d", locdowns[idim]);
- printf ("\n");
- printf ("Direction: ");
- for (idim = 0; idim < sdim; idim++)
- printf (" %d",slab_geo->direction[idim]);
- printf ("\n");
- printf ("Slab Start: %d", (int) slabstart [0]);
- for (idim = 1; idim < vdim; idim++)
- printf (" %d", (int) slabstart[idim]);
- printf ("\n");
- printf ("Slab intersect cntr: %d", (int) slab_geo->slab_start[0]);
- for (idim = 1; idim < vdim; idim++)
- printf (" %d", (int) slab_geo->slab_start[idim]);
- printf ("\n");
- printf ("SlabDelta: ");
- for (idim = 0; idim < sdim; idim++)
- printf (" %f",GH->cctk_delta_space[slab_geo->direction[idim]]*locdowns[idim]);
- printf ("\n");
-#endif
-
- return(1);
-}
-
-
-/*@@
- @routine IOHDF5_procDump
- @author Thomas Radke
- @date May 21 1999
- @desc All IO processors dump the data of their group into the file,
- either as one chunk per processor or unchunked
- (depending on parameter "unchunked").
- @enddesc
- @calledby IOHDF5_DumpGA
- @history
- @endhistory
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc global index of the variable to be dumped
- @vtype int
- @vio in
- @endvar
- @var timelevel
- @vdesc the timelevel to store
- @vtype int
- @vio in
- @endvar
- @var outme
- @vdesc pointer to the chunk to dump
- @vtype void *
- @vio in
- @endvar
- @var geom
- @vdesc bounds and sizes of the output
- @vtype CCTK_INT [3*dim]
- @vio in
- @vcomment geom [0*dim..1*dim-1]: lower bounds
- geom [1*dim..2*dim-1]: (local) data sizes
- geom [2*dim..3*dim-1]: global space
- @endvar
- @var proc
- @vdesc the processor which's chunk is to be dumped
- @vtype int
- @vio in
- @endvar
- @var hdf5io_type
- @vdesc the HDF5 datatype identifier
- @vtype int
- @vio in
- @endvar
- @var iof
- @vdesc the HDF5 file handle
- @vtype hid_t
- @vio in
- @endvar
-@@*/
-static void IOHDF5_procDump (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- void *outme, CCTK_INT *geom, int proc,
- int iohdf5_type, hid_t iof)
-{
- DECLARE_CCTK_PARAMETERS
- int i, vdim,sdim, idim;
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
- hid_t group, dataset, memspace, filespace;
- char *name, datasetname [128], chunkname [138];
- hssize_t *chunk_origin;
- hsize_t *chunk_dims, *file_dims;
- int locpoints=0;
-
-
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- vdim = slab_geo->vdim;
- sdim = slab_geo->sdim;
-
- /* Check if our proc has any points to output */
- locpoints = geom [sdim];
- for (i = 1; i < sdim; i++)
- locpoints *= geom [sdim + i];
- if (locpoints<=0) return;
-
- chunk_origin = (hssize_t *) malloc (sdim * sizeof (hssize_t));
- chunk_dims = (hsize_t *) malloc (2*sdim * sizeof (hsize_t));
- file_dims = chunk_dims + sdim;
-
- /* HDF5 needs it in reverse order */
- for (i = 0; i < sdim; i++) {
- chunk_origin [i] = geom [1*sdim - 1 - i];
- chunk_dims [i] = geom [2*sdim - 1 - i];
- file_dims [i] = geom [3*sdim - 1 - i];
- }
-
- /* build the unique dataset name: eg. WAVETOY::phi@v3s01@3@1
- volume (v) 3-dim ; slab (s) spanned by 0,1 (->2-dim)
- at(@) iteration at(@) timelevel
- */
- name = CCTK_FullName (index);
- sprintf (datasetname, "%s@v%ds",name,vdim);
- for (idim=0;idim<sdim;idim++)
- sprintf (datasetname, "%s%d",datasetname, slab_geo->direction[idim]);
- sprintf (datasetname, "%s@%d@%d",datasetname, GH->cctk_iteration, timelevel);
- free (name);
-
- printf("Datasetname: >%s< \n",datasetname);
-
- /* create the memspace according to chunk dims */
- CACTUS_IOHDF5_ERROR (memspace = H5Screate_simple (sdim, chunk_dims, NULL));
-
- if (ioUtilGH->unchunked) {
-
- /* create the (global) filespace and set the hyperslab for the chunk */
- CACTUS_IOHDF5_ERROR (filespace = H5Screate_simple (sdim, file_dims, NULL));
- CACTUS_IOHDF5_ERROR (H5Sselect_hyperslab (filespace, H5S_SELECT_SET,
- chunk_origin, NULL, chunk_dims, NULL));
-
- /* the IO processor creates the dataset and adds the common attributes
- when writing its own data, otherwise the dataset is reopened */
- if (CCTK_MyProc (GH) == proc) {
- /* if restart from recovery delete an already existing dataset
- so that it can be created as anew */
- if (h5GH->checkForExistingObjects [index]) {
- CACTUS_IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- H5Gunlink (iof, datasetname);
- H5Eset_auto (h5GH->printErrorFn, h5GH->printErrorFnArg);
- }
- CACTUS_IOHDF5_ERROR (dataset = H5Dcreate (iof, datasetname,
- iohdf5_type, filespace, H5P_DEFAULT));
- IOHDF5_AddCommonAttributes_ND (GH, index, slab_geo,
- &geom [2*sdim], dataset);
- } else
- CACTUS_IOHDF5_ERROR (dataset = H5Dopen (iof, datasetname));
-
- /* write the data */
- CACTUS_IOHDF5_ERROR (H5Dwrite (dataset, iohdf5_type, memspace,
- filespace, H5P_DEFAULT, outme));
-
- /* and close the file dataspace */
- CACTUS_IOHDF5_ERROR (H5Sclose (filespace));
-
- } else {
-
- /* the IO processor creates the chunk group and adds common attributes */
- if (CCTK_MyProc (GH) == proc) {
- /* if restart from recovery delete an already existing group
- so that it can be created as anew */
- if (h5GH->checkForExistingObjects [index]) {
- CACTUS_IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- H5Gunlink (iof, datasetname);
- H5Eset_auto (h5GH->printErrorFn, h5GH->printErrorFnArg);
- }
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (iof, datasetname, 0));
- IOHDF5_AddCommonAttributes_ND (GH, index, slab_geo,
- &geom [2*sdim], group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- /* now the chunk dataset for each processor is created within the group */
- sprintf (chunkname, "%s/chunk%d", datasetname, proc - CCTK_MyProc (GH));
- printf("chunkname: >%s< \n",chunkname);
- /* create the chunk dataset and dump the chunk data */
- CACTUS_IOHDF5_ERROR (dataset = H5Dcreate (iof, chunkname,
- iohdf5_type, memspace, H5P_DEFAULT));
- CACTUS_IOHDF5_ERROR (H5Dwrite (dataset, iohdf5_type, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, outme));
-
- /* add the "origin" attribute for the chunk */
- WRITE_ATTRIBUTE ("chunk_origin", geom, dataset, h5GH->arrayDataspace, sdim,
- IOHDF5_INT);
- }
-
- /* close the dataset and the memspace */
- CACTUS_IOHDF5_ERROR (H5Dclose (dataset));
- CACTUS_IOHDF5_ERROR (H5Sclose (memspace));
-
- free (chunk_origin);
- free (chunk_dims);
-}
-
-
-#ifdef CCTK_MPI
-#ifdef HAVE_PARALLEL
-/*@@
- @routine IOHDF5_collectiveDump
- @author Thomas Radke
- @date May 21 1999
- @desc All processors dump their data into an unchunked file.
- @enddesc
- @calledby IOHDF5_DumpGA
- @history
- @endhistory
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc global index of the variable to be dumped
- @vtype int
- @vio in
- @endvar
- @var timelevel
- @vdesc the timelevel to store
- @vtype int
- @vio in
- @endvar
- @var outme
- @vdesc pointer to the chunk to dump
- @vtype void *
- @vio in
- @endvar
- @var geom
- @vdesc bounds and sizes of the output
- @vtype CCTK_INT [3*dim]
- @vio in
- @vcomment geom [0*dim..1*dim-1]: lower bounds
- geom [1*dim..2*dim-1]: (local) data sizes
- geom [2*dim..3*dim-1]: global space
- @endvar
- @var hdf5io_type
- @vdesc the HDF5 datatype identifier
- @vtype int
- @vio in
- @endvar
- @var iof
- @vdesc the HDF5 file handle
- @vtype hid_t
- @vio in
- @endvar
-@@*/
-static void IOHDF5_collectiveDump (cGH *GH, int index, int timelevel, ioHDF5Geo_t *slab_geo,
- void *outme, CCTK_INT *geom,
- int hdf5io_type, hid_t iof)
-{
- DECLARE_CCTK_PARAMETERS
- int i, dim;
- ioHDF5GH *h5GH;
- hid_t dataset, memspace, filespace;
- char *name, datasetname [128];
- hssize_t *chunk_origin;
- hsize_t *chunk_dims, *file_dims;
-
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* get the dimension of the variable */
- sdim = slab_geo->sdim;
-
- chunk_origin = (hssize_t *) malloc (sdim * sizeof (hssize_t));
- chunk_dims = (hsize_t *) malloc (2*sdim * sizeof (hsize_t));
- file_dims = chunk_dims + sdim;
-
- /* HDF5 needs it in reverse order */
- for (i = 0; i < sdim; i++) {
- chunk_origin [i] = geom [1*sdim - 1 - i];
- chunk_dims [i] = geom [2*sdim - 1 - i];
- file_dims [i] = geom [3*sdim - 1 - i];
- }
-
- /* build the unique dataset name */
- name = CCTK_FullName (index);
- sprintf (datasetname, "%s@%d@%d", name, GH->cctk_iteration, timelevel);
- free (name);
-
- /* create the memspace according to chunk dims */
- CACTUS_IOHDF5_ERROR (memspace = H5Screate_simple (sdim, chunk_dims, NULL));
-
- /* create the (global) filespace and set the hyperslab for the chunk */
- CACTUS_IOHDF5_ERROR (filespace = H5Screate_simple (sdim, file_dims, NULL));
- CACTUS_IOHDF5_ERROR (H5Sselect_hyperslab (filespace, H5S_SELECT_SET,
- chunk_origin, NULL, chunk_dims, NULL));
-
- /* the IO processor creates the dataset and adds the common attributes
- when writing its own data, otherwise the dataset is reopened */
- /* if restart from recovery delete an already existing group
- so that it can be created as anew */
- if (h5GH->checkForExistingObjects [index]) {
- CACTUS_IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- H5Gunlink (iof, datasetname);
- H5Eset_auto (h5GH->printErrorFn, h5GH->printErrorFnArg);
- }
- CACTUS_IOHDF5_ERROR (dataset = H5Dcreate (iof, datasetname,
- hdf5io_type, filespace, H5P_DEFAULT));
- if (CCTK_MyProc (GH) == 0)
- IOHDF5_AddCommonAttributes_ND (GH, index, slab_geo,
- &geom [2*sdim], dataset);
-
- /* write the data */
- CACTUS_IOHDF5_ERROR (H5Dwrite (dataset, hdf5io_type, memspace,
- filespace, H5P_DEFAULT, outme));
-
- /* and close the file dataspace */
- CACTUS_IOHDF5_ERROR (H5Sclose (filespace));
-
- /* close the dataset and the memspace */
- CACTUS_IOHDF5_ERROR (H5Dclose (dataset));
- CACTUS_IOHDF5_ERROR (H5Sclose (memspace));
-
- free (chunk_origin);
- free (chunk_dims);
-}
-#endif /* HAVE_PARALLEL */
-#endif /* MPI */
diff --git a/src/File.c b/src/File.c
deleted file mode 100644
index 01bef62..0000000
--- a/src/File.c
+++ /dev/null
@@ -1,203 +0,0 @@
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "StoreNamedData.h"
-#include "CactusPUGH/PUGH/src/include/pugh.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "ioHDF5GH.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-/*@@
- @routine IOHDF5_Get_filename_ND
- @author Paul Walker
- @date Feb 1997
- @desc Returns the filename for output
- The names of all output files are stored in the filenames database.
- The routine first searches in this database if there is already
- registered a filename for alias. If so, this name is returned.
- Otherwise it builds the filename from alias and stores it in the
- database.
- NOTE: Filenames are never stored if "out2D_septimefiles = true"
- since they are used only once.
-
- Generalized for Hyperslab extraction (GL)
- @enddesc
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @endvar
- @var name
- @vdesc alias name of variable to output
- @vtype const char *
- @vio in
- @endvar
- @var isNewFile
- @vdesc flag indicating if the file is to be created
- @vtype int
- @vio out
- @endvar
-@@*/
-
-char *IOHDF5_Get_filename_ND (cGH *GH, int index, ioHDF5Geo_t *slab_geo,
- const char *varname, int *isNewFile)
-{
- DECLARE_CCTK_PARAMETERS
- ioGH *ioUtilGH; /* handle for IOUtil extensions */
- ioHDF5GH *myGH; /* handle for IOHDF5 extensions */
- pGH *pughGH; /* handle for PUGH extensions */
- int myproc;
- char extra [256]; /* Extra stuff in fname based on mode */
- char extradir [256]; /* Extra stuff for an output dir */
- char *extrageo; /* Extra stuff for geometry information */
- char *filename; /* the return value */
- int idim;
-
- char name[128];
-
- /* get GH extensions for PUGH and IOUtil */
- pughGH = PUGH_pGH (GH);
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* To identify the slab in a volume (if sdim<vdim)
- build a string like: "012" (3d volume, spanned by xyz)
- or "12" (2d volume, spanned by yz(!) and append this to the name:
- You get something like this: phi_s12_3d */
- if (slab_geo->sdim<slab_geo->vdim) {
- extrageo = (char*) malloc((slab_geo->sdim+1)*sizeof(char));
- sprintf(extrageo,"%d",slab_geo->direction[0]);
- for (idim=1;idim<slab_geo->sdim;idim++)
- sprintf(extrageo,"%s%d",extrageo,slab_geo->direction[idim]);
- sprintf(name,"%s_s%s_%dd",varname,extrageo,slab_geo->vdim);
- free(extrageo);
- }
- /* If sdim==vdim, make it simple: e.g. phi_3d */
- else if (slab_geo->sdim==slab_geo->vdim)
- {
- sprintf(name,"%s_%dd",varname,slab_geo->vdim);
- }
- else {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Inconsitent dimensions for >%s<: slab (%dD), variable (%dD)\n",
- varname, slab_geo->sdim,slab_geo->vdim);
- return(NULL);
- }
-
- filename = (char *) GetNamedData (myGH->filenameList, name);
- if (filename != NULL)
- {
- /* set flag to indicate that file should be opened in append mode */
- *isNewFile = 0;
- return (filename);
- }
-
- extra[0] = '\0';
- extradir[0]= '\0';
-
- myproc = CCTK_MyProc (GH);
-
- if (out2D_septimefiles)
- {
- char *tmp = extra;
-
- sprintf (extra, "%s.time_%7.3f", extra, GH->cctk_time);
-
- /* And be sure to replace any spaces in the filename with an _ */
- do
- if (*tmp == ' ')
- *tmp = '_';
- while (*++tmp);
- }
-
-
- /* OUTPUT ONE FILE FOR EACH N PROCESSORS FIXME
- * -------------------------------------
- *
- * If only one output file, the single file for each variable is written
- * in the normal output dir (that is extradir = ""). Otherwise
- * a directory is created for each output variable to hold the multiple
- * files.
- */
-
- if (! ioUtilGH->unchunked && ioUtilGH->ioproc_every < CCTK_nProcs (GH))
- {
- /* Add the output processor number to the extra string */
- sprintf (extra, "%s.file_%d", extra, myproc / ioUtilGH->ioproc_every);
-
- /* If necessary create the output directory */
- if (myproc == 0)
- {
- int result;
- char *outputdir = (char *) malloc (strlen (myGH->outdir3D) +
- strlen (name) + 5);
-
- sprintf (outputdir, "%s/%s_3d", myGH->outdir3D, name);
-
- result = CCTK_CreateDirectory (0755, outputdir);
- if (result < 0)
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Problem creating 3D output directory '%s'", outputdir);
- if (result > 0)
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "3D output directory '%s' already exists", outputdir);
-
- free (outputdir);
- }
-
-#ifdef CCTK_MPI
- /* Wait for all processors to catch up */
- CCTK_Barrier (GH);
-#endif
-
- /* extradir is the relative output directory */
- sprintf (extradir, "%s_3d/", name);
-
- }
-
- /* CREATE THE COMPLETE OUTPUT FILENAME
- ----------------------------------- */
- filename = (char *) malloc (strlen (myGH->outdir2D) +
- strlen (extradir) +
- strlen (name) +
- strlen (extra) +
- (pughGH->identity_string ? strlen (pughGH->identity_string) : 0) +
- 8);
- sprintf (filename, "%s/%s%s%s%s.h5",
- myGH->outdir2D, extradir, name, extra, (pughGH->identity_string ? pughGH->identity_string : ""));
-
- /* no need to store filenames if used only once */
- if (! out2D_septimefiles)
- {
- if (myproc == ioUtilGH->ioproc)
- {
- if (ioUtilGH->recovered)
- {
- CACTUS_IOHDF5_ERROR (H5Eset_auto (NULL, NULL));
- *isNewFile = H5Fis_hdf5 (filename) <= 0;
- H5Eset_auto (myGH->printErrorFn, myGH->printErrorFnArg);
- if (! *isNewFile)
- myGH->checkForExistingObjects [index] = 1;
- }
- else
- {
- *isNewFile = 1;
- }
- }
- StoreNamedData (&myGH->filenameList, name, filename);
- }
- else
- {
- *isNewFile = 1;
- }
-
- return (filename);
-}
diff --git a/src/GHExtension.c b/src/GHExtension.c
deleted file mode 100644
index c6faa95..0000000
--- a/src/GHExtension.c
+++ /dev/null
@@ -1,233 +0,0 @@
- /*@@
- @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 <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#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;iv<numvars;iv++)
- newGH->out_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;idim<IOHDF5_MAXDIM;idim++)
- {
- IOHDF5_DefaultGeo(cctkGH, idim, &geo_default);
-
- /* Set the default HDF5 slab geometry for slab with dimension -idim-*/
- for (inum=0; inum<CCTK_NumVars(); inum++)
- myGH->out_geo[inum][idim] = geo_default;
- }
-}
diff --git a/src/Output1D.c b/src/Output1D.c
deleted file mode 100644
index f601ef3..0000000
--- a/src/Output1D.c
+++ /dev/null
@@ -1,294 +0,0 @@
- /*@@
- @file Output1D.c
- @date Tue Jan 9 1999
- @author Gabrielle Allen
- @desc
- Functions to deal 1D HDF5 output of variables
- @enddesc
- @history
- @hauthor Thomas Radke @hdate 16 Mar 1999
- @hdesc Converted to Cactus 4.0
- @hendhistory
- @@*/
-
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "ioHDF5GH.h"
-
-
-/* function prototypes */
-int IOHDF5_TimeFor1D (cGH *GH, int index);
-int IOHDF5_Output1DVarAs (cGH *GH, const char *var, const char *alias);
-static void CheckSteerableParameters (ioHDF5GH *myGH);
-static void SetOutputFlag (int index, const char *optstring, void *arg);
-
-
-/*@@
- @routine IOHDF5_Output1DGH
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Loops over all variables and outputs them if necessary
- @enddesc
- @calledby CCTK_OutputGH ("IOHDF5_1D")
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @endvar
-@@*/
-
-int IOHDF5_Output1DGH (cGH *GH)
-{
- DECLARE_CCTK_PARAMETERS
- int i;
- ioHDF5GH *myGH;
- const char *name;
- char *fullname;
- int ierr=0;
-
- /* Get the GH extension for IOHDF5 */
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- CheckSteerableParameters (myGH);
-
- if (myGH->out1D_every <= 0)
- return (0);
-
- /* Loop over all variables */
- for (i = 0; i < CCTK_NumVars (); i++)
- {
-
- if (IOHDF5_TimeFor1D (GH, i))
- {
-
- name = CCTK_VarName (i);
- fullname = CCTK_FullName (i);
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_Output1DGH: fullname / name = "
- "%s / %s", fullname, name);
-
- ierr=IOHDF5_Output1DVarAs (GH, fullname, name);
-
- free (fullname);
-
- /* Register variable as having 1D output this iteration */
- myGH->out1D_last [i] = GH->cctk_iteration;
- }
- }
- if (verbose)
- CCTK_INFO("IOHDF5_Output1DGH Done \n\n");
-
- return (ierr);
-}
-
-
-/*@@
- @routine IOHDF5_Output1DVarAs
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- unconditional output of a variable using the IOHDF5 1D output method
- @enddesc
- @calledby IOHDF5_Output1DGH, CCTK_OutputVarAsByMethod ("IOHDF5_1D")
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var fullname
- @vdesc complete name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output (used to generate output filename)
- @vtype const char *
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_Output1DVarAs (cGH *GH, const char *fullname, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int index, ierr=0;
-
- index = CCTK_VarIndex (fullname);
-
- /* first, check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No IOHDF5 1D output for '%s' (no storage)", fullname);
- return(-1);
- }
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_Output1DVarAs: fullname, alias, "
- "index = (%s, %s, %d)", fullname, alias, index);
-
- /* Do the 1D output */
- ierr=IOHDF5_Write1D (GH, index, alias);
-
- return (ierr);
-}
-
-
-/*@@
- @routine IOHDF5_TimeFor1D
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Decides if it is time to output a variable using the IOHDF5 1D output
- method
- @enddesc
- @calledby IOHDF5_Output1DGH
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable
- @vtype int
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_TimeFor1D (cGH *GH, int index)
-{
- ioHDF5GH *myGH;
-
-
- /* Get the GH extension for IOHDF5 */
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- CheckSteerableParameters (myGH);
-
- /* Check if any output was requested */
- if(myGH->out1D_every <= 0)
- return (0);
-
- /* Check this variable should be output */
- if (! (myGH->do_out1D [index] && GH->cctk_iteration % myGH->out1D_every == 0))
- return (0);
-
- /* Check variable not already output this iteration */
- if (myGH->out1D_last [index] == GH->cctk_iteration)
- {
- CCTK_WARN (2, "Already done 1D output in IOHDF5");
- return (0);
- }
-
- return (1);
-}
-
-
-/*@@
- @routine IOHDF5_TriggerOutput1D
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Triggers the output a variable using the IOHDF5 1D output
- method
- @enddesc
- @calledby CCTK scheduler
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_TriggerOutput1D (cGH *GH, int index)
-{
- DECLARE_CCTK_PARAMETERS
- ioHDF5GH *myGH;
- const char *varname;
- int ierr=0;
-
- varname = CCTK_VarName (index);
-
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_TriggerOutput1D: varname, index = "
- "(%s, %d)", varname, index);
-
- /* Do the 1D output */
- ierr=IOHDF5_Write1D (GH, index, varname);
-
- /* Register variable as having 1D output this iteration */
- myGH->out1D_last [index] = GH->cctk_iteration;
-
- return (ierr);
-}
-
-
-/**************************** local functions ******************************/
-static void CheckSteerableParameters (ioHDF5GH *myGH)
-{
- DECLARE_CCTK_PARAMETERS
- int out1D_vars_current_nset;
- static int out1D_vars_lastset = -1;
-
-
- /* How often to output */
- myGH->out1D_every = out_every > 0 ? out_every : -1;
- if (out1D_every > 0)
- myGH->out1D_every = out1D_every;
-
- /* re-parse the 'IOHDF5::out1D_vars' parameter if it was changed */
- out1D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out1D_vars",
- CCTK_THORNSTRING);
- if (out1D_vars_current_nset != out1D_vars_lastset)
- {
- memset (myGH->do_out1D, 0, CCTK_NumVars ());
- CCTK_TraverseString (out1D_vars, SetOutputFlag, myGH->do_out1D,
- CCTK_GROUP_OR_VAR);
-
- /* Save the last setting of 'out1D_vars' parameter */
- out1D_vars_lastset = out1D_vars_current_nset;
- }
-}
-
-
-/* callback for CCTK_TraverseString() to set the output flag
- for the given variable */
-static void SetOutputFlag (int index, const char *optstring, void *arg)
-{
- char *flags = (char *) arg;
-
-
- flags[index] = 1;
-
- if (optstring)
- {
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Optional string '%s' in variable name ignored", optstring);
- }
-}
diff --git a/src/Output2D.c b/src/Output2D.c
deleted file mode 100644
index 021b258..0000000
--- a/src/Output2D.c
+++ /dev/null
@@ -1,294 +0,0 @@
- /*@@
- @file Output2D.c
- @date Tue Jan 9 1999
- @author Gabrielle Allen
- @desc
- Functions to deal 2D HDF5 output of variables
- @enddesc
- @history
- @hauthor Thomas Radke @hdate 16 Mar 1999
- @hdesc Converted to Cactus 4.0
- @hendhistory
- @@*/
-
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "ioHDF5GH.h"
-
-
-/* function prototypes */
-int IOHDF5_TimeFor2D (cGH *GH, int index);
-int IOHDF5_Output2DVarAs (cGH *GH, const char *var, const char *alias);
-static void CheckSteerableParameters (ioHDF5GH *myGH);
-static void SetOutputFlag (int index, const char *optstring, void *arg);
-
-
-/*@@
- @routine IOHDF5_Output2DGH
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Loops over all variables and outputs them if necessary
- @enddesc
- @calledby CCTK_OutputGH ("IOHDF5_2D")
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @endvar
-@@*/
-
-int IOHDF5_Output2DGH (cGH *GH)
-{
- DECLARE_CCTK_PARAMETERS
- int i;
- ioHDF5GH *myGH;
- const char *name;
- char *fullname;
- int ierr=0;
-
- /* Get the GH extension for IOHDF5 */
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- CheckSteerableParameters (myGH);
-
- if (myGH->out2D_every <= 0)
- return (0);
-
- /* Loop over all variables */
- for (i = 0; i < CCTK_NumVars (); i++)
- {
-
- if (IOHDF5_TimeFor2D (GH, i))
- {
-
- name = CCTK_VarName (i);
- fullname = CCTK_FullName (i);
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_Output2DGH: fullname / name = "
- "%s / %s", fullname, name);
-
- ierr=IOHDF5_Output2DVarAs (GH, fullname, name);
-
- free (fullname);
-
- /* Register variable as having 2D output this iteration */
- myGH->out2D_last [i] = GH->cctk_iteration;
- }
- }
- if (verbose)
- CCTK_INFO("IOHDF5_Output2DGH Done \n\n");
-
- return (ierr);
-}
-
-
-/*@@
- @routine IOHDF5_Output2DVarAs
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- unconditional output of a variable using the IOHDF5 2D output method
- @enddesc
- @calledby IOHDF5_Output2DGH, CCTK_OutputVarAsByMethod ("IOHDF5_2D")
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var fullname
- @vdesc complete name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output (used to generate output filename)
- @vtype const char *
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_Output2DVarAs (cGH *GH, const char *fullname, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int index,ierr=0;
-
- index = CCTK_VarIndex (fullname);
-
- /* first, check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
- {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No IOHDF5 2D output for '%s' (no storage)", fullname);
- return(-1);
- }
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_Output2DVarAs: fullname, alias, "
- "index = (%s, %s, %d)", fullname, alias, index);
-
- /* Do the 2D output */
- ierr=IOHDF5_Write2D (GH, index, alias);
-
- return (ierr);
-}
-
-
-/*@@
- @routine IOHDF5_TimeFor2D
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Decides if it is time to output a variable using the IOHDF5 2D output
- method
- @enddesc
- @calledby IOHDF5_Output2DGH
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable
- @vtype int
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_TimeFor2D (cGH *GH, int index)
-{
- ioHDF5GH *myGH;
-
-
- /* Get the GH extension for IOHDF5 */
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- CheckSteerableParameters (myGH);
-
- /* Check if any output was requested */
- if(myGH->out2D_every <= 0)
- return (0);
-
- /* Check this variable should be output */
- if (! (myGH->do_out2D [index] && GH->cctk_iteration % myGH->out2D_every == 0))
- return (0);
-
- /* Check variable not already output this iteration */
- if (myGH->out2D_last [index] == GH->cctk_iteration)
- {
- CCTK_WARN (2, "Already done 2D output in IOHDF5");
- return (0);
- }
-
- return (1);
-}
-
-
-/*@@
- @routine IOHDF5_TriggerOutput2D
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Triggers the output a variable using the IOHDF5 2D output
- method
- @enddesc
- @calledby CCTK scheduler
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_TriggerOutput2D (cGH *GH, int index)
-{
- DECLARE_CCTK_PARAMETERS
- ioHDF5GH *myGH;
- const char *varname;
- int ierr=0;
-
- varname = CCTK_VarName (index);
-
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_TriggerOutput2D: varname, index = "
- "(%s, %d)", varname, index);
-
- /* Do the 2D output */
- ierr=IOHDF5_Write2D (GH, index, varname);
-
- /* Register variable as having 2D output this iteration */
- myGH->out2D_last [index] = GH->cctk_iteration;
-
- return (ierr);
-}
-
-
-/**************************** local functions ******************************/
-static void CheckSteerableParameters (ioHDF5GH *myGH)
-{
- DECLARE_CCTK_PARAMETERS
- int out2D_vars_current_nset;
- static int out2D_vars_lastset = 0;
-
-
- /* How often to output */
- myGH->out2D_every = out_every > 0 ? out_every : -1;
- if (out2D_every > 0)
- myGH->out2D_every = out2D_every;
-
- /* re-parse the 'IOHDF5::out2D_vars' parameter if it was changed */
- out2D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out2D_vars",
- CCTK_THORNSTRING);
- if (out2D_vars_current_nset != out2D_vars_lastset)
- {
- memset (myGH->do_out2D, 0, CCTK_NumVars ());
- CCTK_TraverseString (out2D_vars, SetOutputFlag, myGH->do_out2D,
- CCTK_GROUP_OR_VAR);
-
- /* Save the last setting of 'out2D_vars' parameter */
- out2D_vars_lastset = out2D_vars_current_nset;
- }
-}
-
-
-/* callback for CCTK_TraverseString() to set the output flag
- for the given variable */
-static void SetOutputFlag (int index, const char *optstring, void *arg)
-{
- char *flags = (char *) arg;
-
-
- flags[index] = 1;
-
- if (optstring)
- {
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Optional string '%s' in variable name ignored", optstring);
- }
-}
diff --git a/src/Output3D.c b/src/Output3D.c
deleted file mode 100644
index 5bfcfaf..0000000
--- a/src/Output3D.c
+++ /dev/null
@@ -1,285 +0,0 @@
- /*@@
- @file Output3D.c
- @date Tue Jan 9 1999
- @author Gabrielle Allen
- @desc
- Functions to deal 3D HDF5 output of variables
- @enddesc
- @history
- @hauthor Thomas Radke @hdate 16 Mar 1999
- @hdesc Converted to Cactus 4.0
- @hendhistory
- @@*/
-
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "ioHDF5GH.h"
-
-
-/* function prototypes */
-int IOHDF5_TimeFor3D (cGH *GH, int index);
-int IOHDF5_Output3DVarAs (cGH *GH, const char *var, const char *alias);
-static void CheckSteerableParameters (ioHDF5GH *myGH);
-static void SetOutputFlag (int index, const char *optstring, void *arg);
-
-
-/*@@
- @routine IOHDF5_Output3DGH
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Loops over all variables and outputs them if necessary
- @enddesc
- @calledby CCTK_OutputGH ("IOHDF5_3D")
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @endvar
-@@*/
-
-int IOHDF5_Output3DGH (cGH *GH)
-{
- DECLARE_CCTK_PARAMETERS
- int i;
- ioHDF5GH *myGH;
- const char *name;
- char *fullname;
-
- /* Get the GH extension for IOHDF5 */
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- CheckSteerableParameters (myGH);
-
- if (myGH->out3D_every <= 0)
- return (0);
-
- /* Loop over all variables */
- for (i = 0; i < CCTK_NumVars (); i++)
- {
-
- if (IOHDF5_TimeFor3D (GH, i))
- {
-
- name = CCTK_VarName (i);
- fullname = CCTK_FullName (i);
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_Output3DGH: fullname / name = "
- "%s / %s", fullname, name);
-
- IOHDF5_Output3DVarAs (GH, fullname, name);
-
- free (fullname);
-
- /* Register variable as having 3D output this iteration */
- myGH->out3D_last [i] = GH->cctk_iteration;
- }
- }
- if (verbose)
- CCTK_INFO("IOHDF5_Output3DGH Done \n\n");
-
- return (0);
-}
-
-
-/*@@
- @routine IOHDF5_Output3DVarAs
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- unconditional output of a variable using the IOHDF5 3D output method
- @enddesc
- @calledby IOHDF5_Output3DGH, CCTK_OutputVarAsByMethod ("IOHDF5_3D")
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var fullname
- @vdesc complete name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output (used to generate output filename)
- @vtype const char *
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_Output3DVarAs (cGH *GH, const char *fullname, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int index;
-
-
- index = CCTK_VarIndex (fullname);
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_Output3DVarAs: fullname, alias, "
- "index = (%s, %s, %d)", fullname, alias, index);
-
- /* Do the 3D output */
- IOHDF5_Write3D (GH, index, alias);
-
- return (0);
-}
-
-
-/*@@
- @routine IOHDF5_TimeFor3D
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Decides if it is time to output a variable using the IOHDF5 3D output
- method
- @enddesc
- @calledby IOHDF5_Output3DGH
- @history
-
- @endhistory
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable
- @vtype int
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_TimeFor3D (cGH *GH, int index)
-{
- ioHDF5GH *myGH;
-
-
- /* Get the GH extension for IOHDF5 */
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- CheckSteerableParameters (myGH);
-
- /* Check if any output was requested */
- if(myGH->out3D_every <= 0)
- return (0);
-
- /* Check this variable should be output */
- if (! (myGH->do_out3D [index] && GH->cctk_iteration % myGH->out3D_every == 0))
- return (0);
-
- /* Check variable not already output this iteration */
- if (myGH->out3D_last [index] == GH->cctk_iteration)
- {
- CCTK_WARN (2, "Already done 3D output in IOHDF5");
- return (0);
- }
-
- return (1);
-}
-
-
-/*@@
- @routine IOHDF5_TriggerOutput3D
- @date Sat March 6 1999
- @author Gabrielle Allen
- @desc
- Triggers the output a variable using the IOHDF5 3D output
- method
- @enddesc
- @calledby CCTK scheduler
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
-@@*/
-
-int IOHDF5_TriggerOutput3D (cGH *GH, int index)
-{
- DECLARE_CCTK_PARAMETERS
- ioHDF5GH *myGH;
- const char *varname;
-
- varname = CCTK_VarName (index);
-
- myGH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "IOHDF5_TriggerOutput3D: varname, index = "
- "(%s, %d)", varname, index);
-
- /* Do the 3D output */
- IOHDF5_Write3D (GH, index, varname);
-
- /* Register variable as having 3D output this iteration */
- myGH->out3D_last [index] = GH->cctk_iteration;
-
- return (0);
-}
-
-
-/**************************** local functions ******************************/
-static void CheckSteerableParameters (ioHDF5GH *myGH)
-{
- DECLARE_CCTK_PARAMETERS
- int out3D_vars_current_nset;
- static int out3D_vars_lastset = 0;
-
-
- /* How often to output */
- myGH->out3D_every = out_every > 0 ? out_every : -1;
- if (out3D_every > 0)
- myGH->out3D_every = out3D_every;
-
- /* re-parse the 'IOHDF5::out3D_vars' parameter if it was changed */
- out3D_vars_current_nset = CCTK_ParameterQueryTimesSet ("out3D_vars",
- CCTK_THORNSTRING);
- if (out3D_vars_current_nset != out3D_vars_lastset)
- {
- memset (myGH->do_out3D, 0, CCTK_NumVars ());
- CCTK_TraverseString (out3D_vars, SetOutputFlag, myGH->do_out3D,
- CCTK_GROUP_OR_VAR);
-
- /* Save the last setting of 'out3D_vars' parameter */
- out3D_vars_lastset = out3D_vars_current_nset;
- }
-}
-
-
-/* callback for CCTK_TraverseString() to set the output flag
- for the given variable */
-static void SetOutputFlag (int index, const char *optstring, void *arg)
-{
- char *flags = (char *) arg;
-
-
- flags[index] = 1;
-
- if (optstring)
- {
- CCTK_VWarn (5, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Optional string '%s' in variable name ignored", optstring);
- }
-}
diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c
deleted file mode 100644
index ac62bc3..0000000
--- a/src/ParseGeometry.c
+++ /dev/null
@@ -1,157 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "cctk.h"
-#include "cctk_Arguments.h"
-#include "cctk_Parameters.h"
-
-#include "util_String.h"
-#include "ioHDF5GH.h"
-#include "CactusBase/IOASCII/src/ioASCIIGH.h"
-
-void IOHDF5_DefaultGeo(cGH *GH, int sdim, ioHDF5Geo_t *geo) {
- DECLARE_CCTK_PARAMETERS
-
- asciiioGH *asGH;
- int idim,ti;
- const char *tmp_origin, *tmp_downs, *tmp_length;
- const char *token;
-
- asGH = (asciiioGH *) GH->extensions
- [CCTK_GHExtensionHandle ("IOASCII")];
-
- geo->vdim = -1;
- geo->sdim = -1;
-
- for (idim=0;idim<IOHDF5_MAXDIM;idim++) {
- geo->direction[idim] = idim;
- geo->slab_start[idim]= 0;
- geo->length[idim] =-1;
- geo->actlen[idim] =-1;
- geo->downs[idim] = 1;
- }
-
- /* FIXME: we use spxyz, which is hardcoded to 3D */
- for (idim=0;idim<3;idim++)
- geo->slab_start[idim]=asGH->spxyz[2][(idim+1)%3][idim];
-
- /* Parse the parameter of the requested dimension */
- switch (sdim) {
- case 1:
- tmp_origin = origin1D;
- tmp_downs = downsampling1D;
- tmp_length = length1D;
- break;
- case 2:
- tmp_origin = origin2D;
- tmp_downs = downsampling2D;
- tmp_length = length2D;
- break;
- case 3:
- tmp_origin = origin3D;
- tmp_downs = downsampling3D;
- tmp_length = length3D;
- break;
- case 4:
- tmp_origin = origin4D;
- tmp_downs = downsampling4D;
- tmp_length = length4D;
- break;
- default:
- tmp_origin = origin;
- tmp_downs = downsampling;
- tmp_length = length;
- break;
- }
-
- /* Origin, set from parameter only if parameter value .ne. -1 */
- idim=0;
- while((token = Util_StrSep(&tmp_origin,","))) {
- ti=atoi(token);
- if (ti>-1) geo->slab_start[idim++] = ti;
- }
- ti = atoi(tmp_origin);
- if (ti>-1) geo->slab_start[idim] = ti;
-
- /* Downsample */
- idim=0;
- while((token = Util_StrSep(&tmp_downs,","))) {
- geo->downs[idim++]=atoi(token);
- }
- geo->downs[idim] = atoi(tmp_downs);
-
- /* Length */
- idim=0;
- while((token = Util_StrSep(&tmp_length,","))) {
- geo->length[idim++]=atoi(token);
- }
- geo->length[idim] = atoi(tmp_length);
-}
-
-
-int NumDirection(int sdim, int vdim)
-{
- int numdir=-1;
- if (vdim==3) {
- switch (sdim) {
- case 1: return(3);
- case 2: return(3);
- case 3: return(1);
- }
- } else if (vdim==2) {
- switch (sdim) {
- case 1: return(2);
- case 2: return(1);
- }
- }
- else if (vdim==1) {
- switch (sdim) {
- case 1: return(1);
- }
- }
- else printf("Bad dimension: %d \n",vdim);
- return(numdir);
-}
-
-int SetDirection(int vdim, int sdim, int ci, int *direction)
-{
- int retval=0;
-
- if (sdim>vdim) {
- printf("SetDirection: slabdim gt vdim");
- return(-1);
- }
-
- if (vdim==3) {
- if (sdim==2) {
- switch (ci) {
- case 0: direction[0]=0; direction[1]=1; break;
- case 1: direction[0]=0; direction[1]=2; break;
- case 2: direction[0]=1; direction[1]=2; break;
- }
- }
- else if (sdim==1) {
- switch (ci) {
- case 0: direction[0]=0; break;
- case 1: direction[0]=1; break;
- case 2: direction[0]=2; break;
- }
- }
- }
- else if (vdim==2) {
- if (sdim==2) {
- direction[0]=0; direction[1]=1;
- } else if (sdim==1) {
- switch (ci) {
- case 0: direction[0]=0; break;
- case 1: direction[0]=1; break;
- }
- }
- } else retval = -1;
- return(retval);
-}
-
-
-
-
diff --git a/src/RestoreFile.c b/src/RestoreFile.c
deleted file mode 100644
index ef9db7b..0000000
--- a/src/RestoreFile.c
+++ /dev/null
@@ -1,580 +0,0 @@
- /*@@
- @file RestoreFile.c
- @date Thu Jun 18 16:34:59 1998
- @author Tom Goodale
- @desc
- Routines to restore variables from a given file
- @enddesc
- @history
- @hauthor Gabrielle Allen @hdate 19 Oct 1998
- @hdesc Changed names ready for thorn_IO
- @endhistory
- @version $Id$
- @@*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "CactusPUGH/PUGH/src/include/pugh.h"
-#include "ioHDF5GH.h"
-
-
-/* MPI tag base */
-#define STARTUPBASE 1001
-
-
-typedef struct {
- cGH *GH;
- int ioproc;
- int ioproc_every;
- int unchunked;
-} iterate_info_t;
-
-typedef struct {
- iterate_info_t *it_info;
- int element_size;
- int iohdf5_type;
-#ifdef CCTK_MPI
- MPI_Datatype mpi_type;
-#endif
-} recover_info_t;
-
-
-/* local function prototypes */
-static herr_t processDataset (hid_t group, const char *datasetname, void *arg);
-
-
- /*@@
- @routine IOHDF5i_RecoverVariables
- @date Fri Jun 19 09:19:48 1998
- @author Tom Goodale
- @desc
- Reads in data from an open HDF5 file.
- Code was originally in StartupReader.
- @enddesc
- @calledby IOHDF5_Recover
- @history
- @endhistory
- @var GH
- @vdesc Pointer to CCTK grid hierarchy
- @vtype cGH
- @vio in
- @endvar
- @var file
- @vdesc HDF5 file info structure
- @vtype fileinfo_t *
- @vio in
- @endvar
-@@*/
-int IOHDF5i_RecoverVariables (cGH *GH, fileinfo_t *file)
-{
- DECLARE_CCTK_PARAMETERS
-#ifdef CCTK_MPI
- pGH *pughGH; /* PUGH extension handle */
- int proc; /* looper */
- CCTK_INT var_info [3]; /* communication buffer for MPI */
-#endif
- iterate_info_t info; /* info to pass down to the iterator routine */
-
-
- info.GH = GH;
- info.ioproc = file->ioproc;
- info.unchunked = file->unchunked;
- info.ioproc_every = file->ioproc_every;
-
-#ifdef CCTK_MPI
- /* Get the handle for PUGH extensions */
- pughGH = PUGH_pGH (GH);
-
- /* Now process the datasets.
- All IO processors read the datasets from their checkpoint file,
- verify their contents and communicate them to the non-IO processors. */
-
- /* At first the code for the IO processors.
- This holds also for the single processor case. */
- if (CCTK_MyProc (GH) == file->ioproc) {
-#endif
-
- /* iterate over all datasets starting from "/" in the HDF5 file */
- CACTUS_IOHDF5_ERROR (H5Giterate (file->fid, "/", NULL, processDataset,
- &info));
-
-#ifdef CCTK_MPI
- /* To signal completion to the non-IO processors
- an invalid variable index is broadcasted. */
- var_info [0] = -1;
- for (proc = 1; proc < file->ioproc_every; proc++)
- for (proc = file->ioproc + 1;
- proc < file->ioproc + file->ioproc_every && proc < CCTK_nProcs (GH);
- proc++)
- CACTUS_MPI_ERROR (MPI_Send (var_info, 3, PUGH_MPI_INT, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
-
- } else {
-
- /* And here the code for non-IO processors: */
- MPI_Datatype mpi_type;
- MPI_Status ms;
- int index, timelevel, npoints;
-
- /* They don't know how many datasets there are, because the IO processors
- could skip some on the fly during their consistency checks.
- The IO Processor sends the index of the variable to be processed next.
- So, all non-IO processors execute a loop where the termination condition
- is when an invalid index was received.
- */
- while (1) {
- /* receive the next variable index from my IO processor */
- CACTUS_MPI_ERROR (MPI_Recv (var_info, 3, PUGH_MPI_INT, file->ioproc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD, &ms));
- index = var_info [0]; timelevel = var_info [1]; npoints = var_info [2];
-
- /* check for termination condition */
- if (index < 0)
- break;
-
- switch (CCTK_VarTypeI (index)) {
- case CCTK_VARIABLE_CHAR: mpi_type = PUGH_MPI_CHAR; break;
- case CCTK_VARIABLE_INT: mpi_type = PUGH_MPI_INT; break;
- case CCTK_VARIABLE_REAL: mpi_type = PUGH_MPI_REAL; break;
- case CCTK_VARIABLE_COMPLEX: mpi_type = pughGH->PUGH_mpi_complex; break;
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported datatype %d", CCTK_VarTypeI (index));
- continue;
- }
-
- /* receive following data from my IO processor */
- CACTUS_MPI_ERROR (MPI_Recv (GH->data [index][timelevel], npoints,mpi_type,
- file->ioproc, STARTUPBASE,pughGH->PUGH_COMM_WORLD,&ms));
- }
- }
-#endif /* MPI */
-
- return (0);
-}
-
-
-/**************************** local routines ****************************/
-
-/* local routine GetCommonAttributes() reads in the next dataset's attributes
- and verifies them:
-
- * checks if there is a variable with the name given by the name attribute
- * verifies that this variable still belongs to the same group
- * checks the group data info:
- - group type
- - variable type
- - ntimelevels
- - sizes (rank, dimensions) according to chunking mode
-
- If there is a mismatch a warning (warning level 2) is printed and value of 1
- is returned to indicate that this dataset should be ignored.
- If successful, the global variable index, the group type and the timelevel
- to restore are stored in {*index, *gtype, *timelevel}, and 0 is returned.
-*/
-
-static int GetCommonAttributes (cGH *GH, hid_t dataset, const char *datasetname,
- int unchunked, int *index, int *grouptype,
- int *timelevel, int is_group)
-{
- pGExtras *extras;
- cGroup groupdata;
- int i, flag, *dims;
- hid_t datatype, dataspace;
- hsize_t rank_stored, *dims_stored;
- int grouptype_stored, ndims_stored, numtimelevels_stored;
- char *groupname, groupname_stored [128], fullvarname [128];
-
- /* decompose the datasetname, ignore the iteration number */
- if (sscanf (datasetname, "%[^@]@%d@%d", fullvarname, &i, timelevel) != 3) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot parse datasetname '%s'", datasetname);
- return (1);
- }
-
- /* check if there is a matching variable */
- *index = CCTK_VarIndex (fullvarname);
- if (*index < 0) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No matching variable found for '%s'", fullvarname);
- return (1);
- }
-
- /* read and verify the group name */
- READ_ATTRIBUTE (dataset, "groupname", H5T_C_S1, groupname_stored);
- groupname = CCTK_GroupNameFromVarI (*index);
- if (! CCTK_Equals (groupname_stored, groupname)) {
- CCTK_WARN (2, "Groupnames don't match");
- return (1);
- }
- free (groupname);
-
- /* verify group type, variable type, dims, sizes and ntimelevels */
- READ_ATTRIBUTE (dataset, "grouptype", H5T_NATIVE_INT, &grouptype_stored);
- READ_ATTRIBUTE (dataset, "ntimelevels", H5T_NATIVE_INT,&numtimelevels_stored);
-
- if (CCTK_GroupData (CCTK_GroupIndex (groupname_stored), &groupdata) != 0) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot get group data for '%s'", fullvarname);
- return (1);
- }
- if (groupdata.grouptype != grouptype_stored) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Group types don't match for '%s'", fullvarname);
- return (1);
- }
- if (groupdata.numtimelevels != numtimelevels_stored) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Number of timelevels don't match for '%s'", fullvarname);
- return (1);
- }
- /* open the first chunk to determine datatype, dims and sizes
- if the dataset is a chunk group */
- if (is_group)
- CACTUS_IOHDF5_ERROR (dataset = H5Dopen (dataset, "chunk0"));
- CACTUS_IOHDF5_ERROR (datatype = H5Dget_type (dataset));
-
- /* The CCTK variable type defines do not correlate with the HDF5 defines
- so compare them explicitely here. */
- flag = (H5Tget_class (datatype) == H5T_FLOAT &&
- groupdata.vartype == CCTK_VARIABLE_REAL) ||
- (H5Tget_class (datatype) == H5T_INTEGER &&
- groupdata.vartype == CCTK_VARIABLE_INT) ||
- (H5Tget_class (datatype) == H5T_INTEGER &&
- groupdata.vartype == CCTK_VARIABLE_CHAR) ||
- (H5Tget_class (datatype) == H5T_COMPOUND &&
- groupdata.vartype == CCTK_VARIABLE_COMPLEX);
-
- CACTUS_IOHDF5_ERROR (H5Tclose (datatype));
- if (! flag) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Variable types don't match for '%s'", fullvarname);
- return (1);
- }
-
- /* verify the dims and sizes */
- CACTUS_IOHDF5_ERROR (dataspace = H5Dget_space (dataset));
- CACTUS_IOHDF5_ERROR (ndims_stored = H5Sget_simple_extent_ndims (dataspace));
- dims_stored = (hsize_t *) malloc (ndims_stored * sizeof (hsize_t));
- CACTUS_IOHDF5_ERROR (rank_stored = H5Sget_simple_extent_dims (dataspace,
- dims_stored, NULL));
- /* scalars are stored as rank 0 in HDF5 but have rank 1 in Cactus */
- if (rank_stored == 0)
- rank_stored = 1;
- CACTUS_IOHDF5_ERROR (H5Sclose (dataspace));
-
- flag = 0;
- if (groupdata.dim != rank_stored)
- flag = 1;
- switch (groupdata.grouptype) {
- case CCTK_SCALAR:
- break;
- case CCTK_ARRAY:
- case CCTK_GF:
- extras = ((pGA ***) PUGH_pGH (GH)->variables)[*index][*timelevel]->extras;
- dims = unchunked ? extras->nsize : extras->lnsize;
- for (i = 0; i < groupdata.dim; i++)
- if (dims [groupdata.dim - i - 1] != dims_stored [i])
- flag = 1;
- break;
- }
-
- free (dims_stored);
- if (flag) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Variable sizes don't match for '%s'", fullvarname);
- return (1);
- }
-
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (*index))) {
- CCTK_VWarn (2, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Can't read into variable '%s': no storage", fullvarname);
- return (1);
- }
-
- /* close the first chunk if the dataset is a chunk group */
- if (is_group)
- CACTUS_IOHDF5_ERROR (H5Dclose (dataset));
-
- *grouptype = groupdata.grouptype;
-
- return (0);
-}
-
-
-static int IOHDF5_RestoreGS (hid_t dataset, int index, int timelevel,
- recover_info_t *rec_info)
-{
- void *data;
-#ifdef CCTK_MPI
- int proc;
- CCTK_INT var_info [3];
- pGH *pughGH;
-#endif
-
-
- data = CCTK_VarDataPtrI (rec_info->it_info->GH, timelevel, index);
-
- /* read the data into the local variable ... */
- CACTUS_IOHDF5_ERROR (H5Dread (dataset, rec_info->iohdf5_type, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, data));
-
-#ifdef CCTK_MPI
- /* ... and communicate it for the MPI case */
-
- /* Get the handle for PUGH extensions */
- pughGH = PUGH_pGH (rec_info->it_info->GH);
-
- /* set the variable's index and the timelevel */
- var_info [0] = index; var_info [1] = timelevel; var_info [2] = 1;
-
- /* send info and data to the non-IO processors */
- for (proc = rec_info->it_info->ioproc + 1;
- proc < rec_info->it_info->ioproc + rec_info->it_info->ioproc_every &&
- proc < CCTK_nProcs (rec_info->it_info->GH);
- proc++) {
- CACTUS_MPI_ERROR (MPI_Send (var_info, 3, PUGH_MPI_INT, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
- CACTUS_MPI_ERROR (MPI_Send (data, 1, rec_info->mpi_type, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
- }
-#endif
-
- return (0);
-}
-
-
-static int IOHDF5_RestoreGA (hid_t dataset, int index, int timelevel,
- recover_info_t *rec_info)
-{
-#ifdef CCTK_MPI
- int proc, npoints;
- CCTK_INT var_info [3];
- pGH *pughGH;
- void *buffer, *data;
- hid_t filespace, memspace;
- pGExtras *extras;
-#endif
-
-
- /* single processor case is easy: just read the whole dataset */
- if (CCTK_nProcs (rec_info->it_info->GH) == 1) {
- CACTUS_IOHDF5_ERROR (H5Dread (dataset, rec_info->iohdf5_type, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, rec_info->it_info->GH->data [index][timelevel]));
- return (0);
- }
-
-#ifdef CCTK_MPI
-
- /* Get the handle for PUGH extensions */
- pughGH = PUGH_pGH (rec_info->it_info->GH);
-
- /* Get the pGExtras pointer as a shortcut */
- extras = ((pGA ***) pughGH->variables) [index][timelevel]->extras;
-
- /* allocate memory for the biggest chunk */
- npoints = extras->rnpoints [rec_info->it_info->ioproc + 1];
- for (proc = 2; proc < rec_info->it_info->ioproc_every; proc++)
- if (npoints < extras->rnpoints [rec_info->it_info->ioproc + proc])
- npoints = extras->rnpoints [rec_info->it_info->ioproc + proc];
- buffer = malloc (npoints * rec_info->element_size);
-
- /* set the variable's index and timelevel to restore */
- var_info [0] = index; var_info [1] = timelevel;
-
- /* now loop over the group of processors associated to each IO processor */
- for (proc = rec_info->it_info->ioproc;
- proc < rec_info->it_info->ioproc + rec_info->it_info->ioproc_every &&
- proc < CCTK_nProcs (rec_info->it_info->GH);
- proc++) {
-
- /* read own data directly into variable */
- if (proc == rec_info->it_info->ioproc)
- data = rec_info->it_info->GH->data [index][timelevel];
- else
- data = buffer;
-
- if (! rec_info->it_info->unchunked) {
- hid_t chunk;
- char chunkname [32];
-
- /* Chunked data is stored as separate chunk datasets within a group.
- So open, read and close the separate chunks here. */
- sprintf (chunkname, "chunk%d", proc - rec_info->it_info->ioproc);
- CACTUS_IOHDF5_ERROR (chunk = H5Dopen (dataset, chunkname));
- CACTUS_IOHDF5_ERROR (H5Dread (chunk, rec_info->iohdf5_type, H5S_ALL,
- H5S_ALL, H5P_DEFAULT, data));
- CACTUS_IOHDF5_ERROR (H5Dclose (chunk));
-
- } else {
- int i, dim;
- hssize_t *chunk_origin;
- hsize_t *chunk_dims;
-
- /* get the dimension of the variable */
- dim = CCTK_GroupDimI (CCTK_GroupIndexFromVarI (index));
- chunk_origin = (hssize_t *) malloc (dim * sizeof (hssize_t));
- chunk_dims = (hsize_t *) malloc (dim * sizeof (hsize_t));
-
- /* Unchunked data is read as one hyperslab per processor.
- So prepare the memspace and the filespace and read the hyperslab. */
- for (i = 0; i < dim; i++) {
- chunk_dims [dim - 1 - i] = extras->rnsize [proc][i];
- chunk_origin [dim - 1 - i] = extras->lb [proc][i];
- }
-
- CACTUS_IOHDF5_ERROR (filespace = H5Dget_space (dataset));
- CACTUS_IOHDF5_ERROR (memspace = H5Screate_simple (dim, chunk_dims, NULL));
- CACTUS_IOHDF5_ERROR (H5Sselect_hyperslab (filespace, H5S_SELECT_SET,
- chunk_origin, NULL, chunk_dims, NULL));
-
- CACTUS_IOHDF5_ERROR (H5Dread (dataset, rec_info->iohdf5_type, memspace,
- filespace, H5P_DEFAULT, data));
-
- CACTUS_IOHDF5_ERROR (H5Sclose (memspace));
- CACTUS_IOHDF5_ERROR (H5Sclose (filespace));
-
- free (chunk_dims);
- free (chunk_origin);
- }
-
- /* send the index and the data to the non-IO processors */
- if (proc != rec_info->it_info->ioproc) {
- var_info [2] = extras->rnpoints [proc];
- CACTUS_MPI_ERROR (MPI_Send (var_info, 3, PUGH_MPI_INT, proc,
- STARTUPBASE, pughGH->PUGH_COMM_WORLD));
- CACTUS_MPI_ERROR (MPI_Send (data, extras->rnpoints [proc],
- rec_info->mpi_type, proc, STARTUPBASE, pughGH->PUGH_COMM_WORLD));
- }
- }
-
- free (buffer);
-#endif
-
- return (0);
-}
-
-
-static herr_t processDataset (hid_t group, const char *datasetname, void *arg)
-{
- DECLARE_CCTK_PARAMETERS
- pGH *pughGH;
- ioGH *ioUtilGH;
- ioHDF5GH *myGH;
- int index, gtype, timelevel;
- iterate_info_t *it_info = (iterate_info_t *) arg;
- recover_info_t rec_info;
- hid_t dataset;
- H5G_stat_t object_info;
- int is_group;
-
- /* skip the global attributes and GH extensions groups */
- if (! strcmp (datasetname, GLOBAL_PARAMETERS_GROUP) ||
- ! strcmp (datasetname, GHEXTENSIONS_GROUP))
- return (0);
-
- /* Get the handle for PUGH, IOUtil, and IOHDF5 extensions */
- pughGH = PUGH_pGH (it_info->GH);
- ioUtilGH = (ioGH *) it_info->GH->extensions [CCTK_GHExtensionHandle ("IO")];
- myGH = (ioHDF5GH*) it_info->GH->extensions [CCTK_GHExtensionHandle("IOHDF5")];
-
- CACTUS_IOHDF5_ERROR (H5Gget_objinfo (group, datasetname, 0, &object_info));
- is_group = object_info.type == H5G_GROUP;
- if (is_group)
- CACTUS_IOHDF5_ERROR (dataset = H5Gopen (group, datasetname));
- else
- CACTUS_IOHDF5_ERROR (dataset = H5Dopen (group, datasetname));
-
- /* read in the dataset's attributes and verify them */
- if (GetCommonAttributes (it_info->GH, dataset, datasetname,
- it_info->unchunked, &index, &gtype, &timelevel, is_group)) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Ignoring dataset '%s'", datasetname);
- return (0);
- }
-
- /* if we read in initial data via the file reader interface
- check whether the user wants to have this variable restored */
- if (ioUtilGH->do_inVars && ! ioUtilGH->do_inVars [index]) {
- if (verbose) {
- char *varname = CCTK_FullName (index);
-
- CCTK_VInfo (CCTK_THORNSTRING, "Ignoring variable '%s' for file reader "
- "recovery", varname);
- free (varname);
- }
- return (0);
- }
-
- if (verbose) {
- char *varname = CCTK_FullName (index);
-
- CCTK_VInfo (CCTK_THORNSTRING, "Restoring variable '%s' (timelevel %d)",
- varname, timelevel);
- free (varname);
- }
-
- rec_info.it_info = it_info;
-
- switch (CCTK_VarTypeI (index)) {
- case CCTK_VARIABLE_CHAR:
- rec_info.iohdf5_type = IOHDF5_CHAR;
- rec_info.element_size = sizeof (CCTK_CHAR);
-#ifdef CCTK_MPI
- rec_info.mpi_type = PUGH_MPI_CHAR;
-#endif
- break;
- case CCTK_VARIABLE_INT:
- rec_info.iohdf5_type = IOHDF5_INT;
- rec_info.element_size = sizeof (CCTK_INT);
-#ifdef CCTK_MPI
- rec_info.mpi_type = PUGH_MPI_INT;
-#endif
- break;
- case CCTK_VARIABLE_REAL:
- rec_info.iohdf5_type = IOHDF5_REAL;
- rec_info.element_size = sizeof (CCTK_REAL);
-#ifdef CCTK_MPI
- rec_info.mpi_type = PUGH_MPI_REAL;
-#endif
- break;
- case CCTK_VARIABLE_COMPLEX:
- rec_info.iohdf5_type = myGH->IOHDF5_COMPLEX;
- rec_info.element_size = sizeof (CCTK_COMPLEX);
-#ifdef CCTK_MPI
- rec_info.mpi_type = pughGH->PUGH_mpi_complex;
-#endif
- break;
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported datatype %d", CCTK_VarTypeI (index));
- return (0);
- }
-
- /* Read in the data */
- switch (gtype) {
- case CCTK_SCALAR:
- IOHDF5_RestoreGS (dataset, index, timelevel, &rec_info);
- break;
- case CCTK_GF:
- case CCTK_ARRAY:
- IOHDF5_RestoreGA (dataset, index, timelevel, &rec_info);
- break;
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported group type %d", gtype);
- return (1);
- }
-
- if (is_group)
- CACTUS_IOHDF5_ERROR (H5Gclose (dataset));
- else
- CACTUS_IOHDF5_ERROR (H5Dclose (dataset));
-
- return (0);
-}
diff --git a/src/Write1D.c b/src/Write1D.c
deleted file mode 100644
index f92fcd2..0000000
--- a/src/Write1D.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*@@
- @file Write1D.c
- @date Fri May 21 1999
- @author Thomas Radke, Gerd Lanfermann
- @desc
- Output and trigger routines for 1D output into HDF5 files.
- @enddesc
- @hendhistory
- @@*/
-
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "StoreNamedData.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "ioHDF5GH.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-
-/* local function prototypes */
-void IOHDF5i_DumpParameters (cGH *GH, hid_t group);
-void IOHDF5i_DumpGHExtensions (cGH *GH, hid_t group);
-char *IOHDF5_Get_filename_ND (cGH *GH, int index, ioHDF5Geo_t *slab_geo,
- const char *name, int *isNewFile);
-int NumDirection(int sdim, int vdim);
-int SetDirection(int vdim, int sdim, int ci, int *direction);
-
-/*@@
- @routine Write1D
- @author Paul Walker
- @date Feb 1997
- @calledby IOHDF5_Output1DVarAs, IOHDF5_TriggerOutput1D
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
-@@*/
-int IOHDF5_Write1D (cGH *GH, int index, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int timelevel;
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
- ioHDF5Geo_t geo;
-
- hid_t fid, plist;
- int isNewFile;
- char *filename;
-
- int SDIM;
- int si,max_slabs;
-
- /* Get the handle for IO extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* The dimension of the slab - HARDCODED */
- SDIM = 1;
-
- /* Get the slab geometry for 1D slabs */
- geo = h5GH->out_geo[index][SDIM];
- /* Set geo.sdim to announce 1D output */
- geo.sdim = SDIM;
- /* get the dimension of the variable */
- geo.vdim = CCTK_GroupDimFromVarI(index);
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "HDF5 %dD-output of variable '%s', "
- "downsampling parameters (%d, %d, %d)", SDIM, alias,
- geo.downs[0],geo.downs[1], geo.downs[2]);
-
- /* get the current timelevel */
- timelevel = 0;
-
- /* Maximal number of slabs (dimension sdim) in
- given volume (dimension vdim) */
- if ((max_slabs=NumDirection(SDIM, geo.vdim))<0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot get valid number of slabs (%d) for given volume (%d).\n",
- SDIM, geo.vdim);
- return(-1);
- }
-
- /* Loop over all possible choices */
- for (si=0;si<max_slabs;si++) {
-
- /* Get the next set of slab directions */
- if (SetDirection(geo.vdim, SDIM, si, geo.direction)<0) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot set direction for slab (#%d) in given volume (%d).\n",
- si, geo.vdim);
- continue;
- }
-
- /* get the filename for output */
- filename = IOHDF5_Get_filename_ND (GH, index, &geo,
- alias, &isNewFile);
-
- /* open the output file on IO procs no parallel HDF5 */
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc)
- fid = -1;
- else
- {
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "%s HDF5 output file '%s'",
- isNewFile ? "Opening" : "Appending", filename);
-
- CACTUS_IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
-
- if (isNewFile)
- CACTUS_IOHDF5_ERROR (fid = H5Fcreate (filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, plist));
- else
- CACTUS_IOHDF5_ERROR (fid = H5Fopen (filename, H5F_ACC_RDWR, plist));
-
- H5Pclose (plist);
- }
-
-
- /* output global attributes */
- if (isNewFile && fid >= 0) {
- hid_t group;
-
- /* all GH extension variables and parameter stuff which is not
- specific to any dataset goes into dedicated groups */
- if (out1D_parameters)
- {
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GLOBAL_PARAMETERS_GROUP, 0));
- IOHDF5i_DumpParameters (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- if (verbose)
- CCTK_INFO ("Dumping GH extensions ...");
-
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GHEXTENSIONS_GROUP, 0));
- IOHDF5i_DumpGHExtensions (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- IOHDF5_DumpVar(GH, index, timelevel, &geo, fid);
-
- /* close the file */
- if (fid >= 0)
- {
- if (verbose)
- CCTK_INFO ("Closing HDF5 output file from this iteration");
- CACTUS_IOHDF5_ERROR (H5Fclose (fid));
- }
-
- /* free the filename if it was not registered for re-opening
- in IOHDF5_Get1D_filename () */
- if (out1D_septimefiles)
- free (filename);
- }
- return(1);
-}
-
diff --git a/src/Write2D.c b/src/Write2D.c
deleted file mode 100644
index 82cc448..0000000
--- a/src/Write2D.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*@@
- @file Write2D.c
- @date Fri May 21 1999
- @author Thomas Radke, Gerd Lanfermann
- @desc
- Output and trigger routines for 2D output into HDF5 files
- @enddesc
- @hendhistory
- @@*/
-
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "StoreNamedData.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "ioHDF5GH.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-
-/* local function prototypes */
-void IOHDF5i_DumpParameters (cGH *GH, hid_t group);
-void IOHDF5i_DumpGHExtensions (cGH *GH, hid_t group);
-char *IOHDF5_Get_filename_ND (cGH *GH, int index, ioHDF5Geo_t *slab_geo,
- const char *name, int *isNewFile);
-int NumDirection(int sdim, int vdim);
-int SetDirection(int vdim, int sdim, int ci, int *direction);
-
-/*@@
- @routine Write2D
- @author Paul Walker
- @date Feb 1997
- @calledby IOHDF5_Output2DVarAs, IOHDF5_TriggerOutput2D
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
-@@*/
-int IOHDF5_Write2D (cGH *GH, int index, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int timelevel;
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
- ioHDF5Geo_t geo;
-
- hid_t fid, plist;
- int isNewFile;
- char *filename;
-
- int SDIM;
- int idim;
- int si,max_slabs;
- int ierr;
-
- /* Get the handle for IO extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* The dimension of the slab - HARDCODED */
- SDIM = 2;
-
- /* Get the slab geometry for 2D slabs */
- geo = h5GH->out_geo[index][SDIM];
- /* Set geo.sdim to announce 2D output */
- geo.sdim = SDIM;
- /* get the dimension of the variable */
- geo.vdim = CCTK_GroupDimFromVarI(index);
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "HDF5 %dD-output of variable '%s', "
- "downsampling parameters (%d, %d, %d)", SDIM, alias,
- geo.downs[0], geo.downs [1], geo.downs [2]);
-
- /* get the current timelevel */
- timelevel = 0;
-
- /* Maximal number of slabs (dimension sdim) in
- given volume (dimension vdim) */
- if ((max_slabs=NumDirection(SDIM, geo.vdim))<0)
- {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot get valid number of slabs (%d) for given volume (%d).\n",
- SDIM, geo.vdim);
- return(-1);
- }
-
- /* Loop over all possible choices */
- for (si=0;si<max_slabs;si++) {
-
- /* Get the next set of slab directions */
- if (SetDirection(geo.vdim, SDIM, si, geo.direction)<0) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot set direction for slab (#%d) in given volume (%d).\n",
- si, geo.vdim);
- continue;
- }
-
- /* get the filename for output */
- if ((filename = IOHDF5_Get_filename_ND (GH, index, &geo,
- alias, &isNewFile))==NULL) {
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Cannot set filename for slab (#%d) in given volume (%d).\n",
- si, geo.vdim);
- return(-1);
- }
-
- /* open the output file on IO procs no parallel HDF5 */
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc)
- fid = -1;
- else
- {
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "%s HDF5 output file '%s'",
- isNewFile ? "Opening" : "Appending", filename);
-
- CACTUS_IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
-
- if (isNewFile)
- CACTUS_IOHDF5_ERROR (fid = H5Fcreate (filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, plist));
- else
- CACTUS_IOHDF5_ERROR (fid = H5Fopen (filename, H5F_ACC_RDWR, plist));
-
- H5Pclose (plist);
- }
-
-
- /* output global attributes */
- if (isNewFile && fid >= 0) {
- hid_t group;
-
- /* all GH extension variables and parameter stuff which is not
- specific to any dataset goes into dedicated groups */
- if (out2D_parameters)
- {
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GLOBAL_PARAMETERS_GROUP, 0));
- IOHDF5i_DumpParameters (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- if (verbose)
- CCTK_INFO ("Dumping GH extensions ...");
-
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GHEXTENSIONS_GROUP, 0));
- IOHDF5i_DumpGHExtensions (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- ierr = IOHDF5_DumpVar(GH, index, timelevel, &geo, fid);
-
- /* close the file */
- if (fid >= 0)
- {
- if (verbose)
- CCTK_INFO ("Closing HDF5 output file from this iteration");
- CACTUS_IOHDF5_ERROR (H5Fclose (fid));
- }
-
- /* free the filename if it was not registered for re-opening
- in IOHDF5_Get2D_filename () */
- if (out2D_septimefiles)
- free (filename);
- }
- return(ierr);
-}
-
diff --git a/src/Write3D.c b/src/Write3D.c
deleted file mode 100644
index 0a45589..0000000
--- a/src/Write3D.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*@@
- @file Write3D.c
- @date Fri May 21 1999
- @author Thomas Radke, Gerd Lanfermann
- @desc
- Output and trigger routines for 3D output into HDF5 files.
- Added general hyperslab extraction
- @enddesc
- @history
- @hauthor Thomas Radke @hdate May 21 1999
- @hdesc Just copied from thorn FlexIO.
- @hendhistory
- @@*/
-
-
-#include "cctk.h"
-#include "cctk_Parameters.h"
-#include "StoreNamedData.h"
-#include "CactusPUGH/PUGH/src/include/pugh.h"
-#include "CactusBase/IOUtil/src/ioGH.h"
-#include "ioHDF5GH.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-
-/* local function prototypes */
-void IOHDF5i_DumpParameters (cGH *GH, hid_t group);
-void IOHDF5i_DumpGHExtensions (cGH *GH, hid_t group);
-char *IOHDF5_Get_filename_ND (cGH *GH, int index, ioHDF5Geo_t *slab_geo,
- const char *name, int *isNewFile);
-
-
-/*@@
- @routine Write3D
- @author Paul Walker
- @date Feb 1997
- @calledby IOHDF5_Output3DVarAs, IOHDF5_TriggerOutput3D
- @var GH
- @vdesc Pointer to CCTK GH
- @vtype cGH
- @vio in
- @vcomment
- @endvar
- @var index
- @vdesc index of variable to output
- @vtype int
- @vio in
- @vcomment
- @endvar
- @var alias
- @vdesc alias name of variable to output
- @vtype const char *
- @vio in
- @vcomment
- @endvar
-@@*/
-int IOHDF5_Write3D (cGH *GH, int index, const char *alias)
-{
- DECLARE_CCTK_PARAMETERS
- int timelevel;
- ioGH *ioUtilGH;
- ioHDF5GH *h5GH;
- hid_t fid, plist;
- int isNewFile;
- char *filename;
- int ierr=0;
-
- ioHDF5Geo_t geo;
- int SDIM;
-
-
- /* Get the handle for IO extensions */
- ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
- h5GH = (ioHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("IOHDF5")];
-
- /* The dimension of the slab - HARDCODED */
- SDIM = 3;
-
- /* Get the slab geometry for 2D slabs */
- geo = h5GH->out_geo[index][SDIM];
-
- /* Set geo.sdim to announce 3d output */
- geo.sdim = SDIM;
-
- /* get the dimension of the variable */
- geo.vdim = CCTK_GroupDimFromVarI(index);
-
- /* check if variable has storage assigned */
- if (! CCTK_QueryGroupStorageI (GH, CCTK_GroupIndexFromVarI (index)))
- {
- char *fullname = CCTK_FullName (index);
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "No IOHDF5 3D output for '%s' (no storage)", fullname);
- free (fullname);
- return(-1);
- }
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "HDF5 %dD-output of variable '%s', "
- "downsampling parameters (%d, %d, %d)", SDIM, alias,
- geo.downs[0], geo.downs [1], geo.downs[2]);
-
- /* get the filename for output */
- if (!(filename = IOHDF5_Get_filename_ND (GH, index, &geo,
- alias, &isNewFile))) {
- char *fullname = CCTK_FullName (index);
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unable to construct file name for '%s'", fullname);
- free(fullname);
- return(-1);
- }
-
-
- /* open the output file on IO procs
- or - in case of parallel HDF5 - on all procs */
-#ifdef HAVE_PARALLEL
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc && ! ioUtilGH->unchunked)
-#else
- if (CCTK_MyProc (GH) != ioUtilGH->ioproc)
-#endif
- {
- fid = -1;
- }
- else
- {
-
- if (verbose)
- CCTK_VInfo (CCTK_THORNSTRING, "%s HDF5 output file '%s'",
- isNewFile ? "Opening" : "Appending", filename);
-
- CACTUS_IOHDF5_ERROR (plist = H5Pcreate (H5P_FILE_ACCESS));
-#ifdef CCTK_MPI
-#ifdef HAVE_PARALLEL
- if (ioUtilGH->unchunked)
- CACTUS_IOHDF5_ERROR (H5Pset_mpi (plist, PUGH_pGH (GH)->PUGH_COMM_WORLD,
- MPI_INFO_NULL));
-#endif
-#endif
-
- if (isNewFile)
- CACTUS_IOHDF5_ERROR (fid = H5Fcreate (filename, H5F_ACC_TRUNC,
- H5P_DEFAULT, plist));
- else
- CACTUS_IOHDF5_ERROR (fid = H5Fopen (filename, H5F_ACC_RDWR, plist));
-
- H5Pclose (plist);
- }
-
- /* get the current timelevel */
- timelevel = 0;
-
- /* output global attributes */
- if (isNewFile && fid >= 0)
- {
- hid_t group;
-
- /* all GH extension variables and parameter stuff which is not
- specific to any dataset goes into dedicated groups */
- if (out3D_parameters)
- {
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GLOBAL_PARAMETERS_GROUP, 0));
- IOHDF5i_DumpParameters (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- if (verbose)
- CCTK_INFO ("Dumping GH extensions ...");
-
- CACTUS_IOHDF5_ERROR (group = H5Gcreate (fid, GHEXTENSIONS_GROUP, 0));
- IOHDF5i_DumpGHExtensions (GH, group);
- CACTUS_IOHDF5_ERROR (H5Gclose (group));
- }
-
- /* output the data */
- ierr = IOHDF5_DumpVar (GH, index, timelevel, &geo, fid);
-
- /* close the file */
- if (fid >= 0)
- {
- if (verbose)
- CCTK_INFO ("Closing HDF5 output file from this iteration");
- CACTUS_IOHDF5_ERROR (H5Fclose (fid));
- }
-
- /* free the filename if it was not registered for re-opening
- in IOHDF5_net3D_filename () */
- if (out3D_septimefiles)
- free (filename);
-
- return(ierr);
-}
-