diff options
author | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2000-11-24 13:36:35 +0000 |
---|---|---|
committer | tradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668> | 2000-11-24 13:36:35 +0000 |
commit | 96308d59c7372fe2f091fe01d91e96b77e9638df (patch) | |
tree | 5338672572e269e78ab17695e6f76e106e17f1be /src/DumpVar.c | |
parent | 1a0a15f53107a75d60a8476cbe9888ca01805388 (diff) |
Renamed 'index' variables into 'vindex' to suppress gcc warnings about
hiding global routine index(3).
Removed old code to convert output data into single-precision if requested
(IO::out3D_single = "yes"). Now the Hyperslab interface is used to do that,
where it also works in combination with downsampling.
This is quite handy especially for visualizing streamed HDF5 output.
NOTE: I'm using the new hyperslab interface from CactusPUGH/PUGHSlab now
so you need to update this thorn as well.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@10 7842ec3a-9562-4be5-9c5b-06ba18f2b668
Diffstat (limited to 'src/DumpVar.c')
-rw-r--r-- | src/DumpVar.c | 236 |
1 files changed, 98 insertions, 138 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c index b12b5d4..adfad6b 100644 --- a/src/DumpVar.c +++ b/src/DumpVar.c @@ -14,7 +14,7 @@ #include "cctk.h" #include "cctk_Parameters.h" #include "CactusPUGH/PUGH/src/include/pugh.h" -#include "CactusPUGH/PUGHSlab/src/PUGHSlab.h" +#include "CactusPUGH/PUGHSlab/src/NewPUGHSlab.h" #include "CactusBase/IOUtil/src/ioGH.h" #include "ioHDF5UtilGH.h" @@ -37,28 +37,27 @@ typedef struct /* local function prototypes */ static int IOHDF5Util_DumpGS (cGH *GH, - int index, + int vindex, int timelevel, int iohdf5_type, int check_exisiting_objects, hid_t file); static int IOHDF5Util_DumpGA (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, dumpInfo *info, int check_exisiting_objects, hid_t file); static int IOHDF5Util_getDumpData (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, void **outme, int *free_outme, - CCTK_INT *geom, - int element_size); + CCTK_INT *geom); static void IOHDF5Util_procDump (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, void *outme, @@ -70,7 +69,7 @@ static void IOHDF5Util_procDump (cGH *GH, #ifdef CCTK_MPI #ifdef HAVE_PARALLEL static void IOHDF5Util_collectiveDump (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, void *outme, @@ -98,7 +97,7 @@ static void IOHDF5Util_collectiveDump (cGH *GH, @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc index of the variable to be dumped @vtype int @vio in @@ -135,7 +134,7 @@ static void IOHDF5Util_collectiveDump (cGH *GH, @endreturndesc @@*/ int IOHDF5Util_DumpVar (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, hid_t file, @@ -154,7 +153,7 @@ int IOHDF5Util_DumpVar (cGH *GH, ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); myGH = (ioHDF5UtilGH *) CCTK_GHExtension (GH, "IOHDF5Util"); - switch (CCTK_VarTypeI (index)) + switch (CCTK_VarTypeI (vindex)) { case CCTK_VARIABLE_CHAR: info.iohdf5_type = IOHDF5_CHAR; @@ -192,20 +191,20 @@ int IOHDF5Util_DumpVar (cGH *GH, default: CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, "Unsupported variable datatype '%s'", - CCTK_VarTypeName (CCTK_VarTypeI (index))); + CCTK_VarTypeName (CCTK_VarTypeI (vindex))); return (-1); } /* now branch to the appropriate dump routine */ - gtype = CCTK_GroupTypeFromVarI (index); + gtype = CCTK_GroupTypeFromVarI (vindex); if (gtype == CCTK_SCALAR) { - retval = IOHDF5Util_DumpGS (GH, index, timelevel, info.iohdf5_type, + retval = IOHDF5Util_DumpGS (GH, vindex, timelevel, info.iohdf5_type, check_exisiting_objects, file); } else if (gtype == CCTK_ARRAY || gtype == CCTK_GF) { - retval = IOHDF5Util_DumpGA (GH, index, timelevel, slab, &info, + retval = IOHDF5Util_DumpGA (GH, vindex, timelevel, slab, &info, check_exisiting_objects, file); } else @@ -231,7 +230,7 @@ int IOHDF5Util_DumpVar (cGH *GH, @vtype cGH @vio in @endvar - @var index + @var vindex @vdesc index of the variable to be dumped @vtype int @vio in @@ -265,7 +264,7 @@ int IOHDF5Util_DumpVar (cGH *GH, @endreturndesc @@*/ static int IOHDF5Util_DumpGS (cGH *GH, - int index, + int vindex, int timelevel, int iohdf5_type, int check_exisiting_objects, @@ -276,7 +275,7 @@ static int IOHDF5Util_DumpGS (cGH *GH, hid_t dataset; char *fullname; char *datasetname; - CCTK_INT global_shape[1] = {0}; + static CCTK_INT global_shape[1] = {0}; /* Get the handles for IOHDF5Util and IOUtil extensions */ @@ -288,7 +287,7 @@ static int IOHDF5Util_DumpGS (cGH *GH, return (0); } - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); datasetname = (char *) malloc (strlen (fullname) + 80); sprintf (datasetname, "%s timelevel %d at iteration %d", fullname, timelevel, GH->cctk_iteration); @@ -305,9 +304,9 @@ static int IOHDF5Util_DumpGS (cGH *GH, IOHDF5_ERROR (dataset = H5Dcreate (file, datasetname, iohdf5_type, myGH->scalar_dataspace, H5P_DEFAULT)); IOHDF5_ERROR (H5Dwrite (dataset, iohdf5_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, - CCTK_VarDataPtrI (GH, timelevel, index))); + CCTK_VarDataPtrI (GH, timelevel, vindex))); - IOHDF5Util_DumpCommonAttributes (GH, index, timelevel, global_shape, + IOHDF5Util_DumpCommonAttributes (GH, vindex, timelevel, global_shape, NULL, dataset); IOHDF5_ERROR (H5Dclose (dataset)); @@ -336,7 +335,7 @@ static int IOHDF5Util_DumpGS (cGH *GH, @vtype cGH @vio in @endvar - @var index + @var vindex @vdesc index of the variable to be dumped @vtype int @vio in @@ -379,7 +378,7 @@ static int IOHDF5Util_DumpGS (cGH *GH, @endreturndesc @@*/ static int IOHDF5Util_DumpGA (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, dumpInfo *info, @@ -412,8 +411,8 @@ static int IOHDF5Util_DumpGA (cGH *GH, geom = (CCTK_INT *) malloc (3 * slab->sdim * sizeof (CCTK_INT)); /* Get the pointer to the data we want to output (includes downsampling) */ - retval = IOHDF5Util_getDumpData (GH, index, timelevel, slab, &outme, - &free_outme, geom, info->element_size); + retval = IOHDF5Util_getDumpData (GH, vindex, timelevel, slab, &outme, + &free_outme, geom); if (retval < 0) { return (retval); @@ -426,7 +425,7 @@ static int IOHDF5Util_DumpGA (cGH *GH, #ifdef HAVE_PARALLEL if (ioUtilGH->unchunked) { - IOHDF5Util_collectiveDump (GH, index, timelevel, slab, outme, geom, + IOHDF5Util_collectiveDump (GH, vindex, timelevel, slab, outme, geom, info->iohdf5_type, file); if (free_outme) { @@ -441,7 +440,7 @@ static int IOHDF5Util_DumpGA (cGH *GH, /* Dump data held on IO processor */ if (myproc == ioUtilGH->ioproc) { - IOHDF5Util_procDump (GH, index, timelevel, slab, outme, geom, + IOHDF5Util_procDump (GH, vindex, timelevel, slab, outme, geom, myproc, info->iohdf5_type, check_exisiting_objects, file); } @@ -470,7 +469,7 @@ static int IOHDF5Util_DumpGA (cGH *GH, 2*i + IOTAGBASE, pughGH->PUGH_COMM_WORLD, &ms)); - IOHDF5Util_procDump (GH, index, timelevel, slab, tmpd, geom, i, + IOHDF5Util_procDump (GH, vindex, timelevel, slab, tmpd, geom, i, info->iohdf5_type, check_exisiting_objects, file); free (tmpd); } @@ -525,25 +524,21 @@ static int IOHDF5Util_DumpGA (cGH *GH, /* local functions */ /**************************************************************************/ static int IOHDF5Util_getDumpData (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, void **outme, int *free_outme, - CCTK_INT *geom, - int element_size) + CCTK_INT *geom) { ioGH *ioUtilGH; - pGExtras *extras=NULL; - CCTK_REAL4 *single_ptr; - int myproc, do_downsample; + int myproc; int i, 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->direction[] */ int slabstart[3]; /* global start index for slab to extract */ - int ip; void *data; char *fullname; @@ -553,10 +548,6 @@ static int IOHDF5Util_getDumpData (cGH *GH, /* get GH extension for IOUtil */ ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO"); - /* get the pointer to PUGH specific structures */ - extras = ((pGA***) PUGH_pGH(GH)->variables)[index][timelevel]->extras; - data = CCTK_VarDataPtrI (GH, timelevel, index); - /* Shortcuts */ vdim = slab->vdim; sdim = slab->sdim; @@ -571,104 +562,73 @@ static int IOHDF5Util_getDumpData (cGH *GH, for (i=0;i<sdim;i++) locdowns[i]=slab->downsample[slab->direction[i]]; - /* Set downsample flag */ - do_downsample = 0; - for (i = 0; i < sdim; i++) - do_downsample |= locdowns[i] > 1; + /* allocate array to hold size information of slab */ + hsizes = (int *) malloc (3 * sdim * sizeof (int)); + hsizes_global = hsizes + 1*sdim; + hsizes_offset = hsizes + 2*sdim; - /* Simple case if no downsampling and sdim==vdim */ - if (! do_downsample && sdim==vdim) + /* TEMPORARY FIX DUE TO INCONSISTENT DIR SPECIFICATION */ + /* direction vector of 1d line in 3d volume */ + if (sdim == 1) { - 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 (i = 0; i < sdim; i++) { - geom[i + 0*sdim] = extras->lb[myproc][i]; - geom[i + 1*sdim] = extras->lnsize[i]; - geom[i + 2*sdim] = extras->nsize[i]; - } + sdir[0] = slab->direction[0] == 0; + sdir[1] = slab->direction[0] == 1; + sdir[2] = slab->direction[0] == 2; } - else /* Call Hyperslab else */ - { - - /* allocate array to hold size information of slab */ - hsizes = (int *) malloc (3 * sdim * sizeof (int)); - hsizes_global = hsizes + 1*sdim; - hsizes_offset = hsizes + 2*sdim; + /* norm vector of 2d surface in 3d volume */ + else if (sdim==2) + { + sdir[0] = slab->direction[0] == 1 && slab->direction[1] == 2; + sdir[1] = slab->direction[0] == 0 && slab->direction[1] == 2; + sdir[2] = slab->direction[0] == 0 && slab->direction[1] == 1; + } + /* spanning directions for 3d */ + else if (sdim==3) + { + sdir[0] = slab->direction[0]; + sdir[1] = slab->direction[1]; + sdir[2] = slab->direction[2]; + } + + /* Get the start indeces for the slab from origin. */ + /* 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 (i = 0; i < vdim; i++) + { + slabstart[i] = slab->origin[i]; + } + for (i = 0; i < sdim; i++) + { + slabstart[slab->direction[i]] = 0; + } - /* TEMPORARY FIX DUE TO INCONSISTENT DIR SPECIFICATION */ - /* direction vector of 1d line in 3d volume */ - if (sdim == 1) - { - sdir[0] = slab->direction[0] == 0; - sdir[1] = slab->direction[0] == 1; - sdir[2] = slab->direction[0] == 2; - } - /* norm vector of 2d surface in 3d volume */ - else if (sdim==2) - { - sdir[0] = slab->direction[0] == 1 && slab->direction[1] == 2; - sdir[1] = slab->direction[0] == 0 && slab->direction[1] == 2; - sdir[2] = slab->direction[0] == 0 && slab->direction[1] == 1; - } - /* spanning directions for 3d */ - else if (sdim==3) - { - sdir[0] = slab->direction[0]; - sdir[1] = slab->direction[1]; - sdir[2] = slab->direction[2]; - } - - /* Get the start indeces for the slab from origin. */ - /* 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 (i = 0; i < vdim; i++) - { - slabstart[i] = slab->origin[i]; - } - for (i = 0; i < sdim; i++) - { - slabstart[slab->direction[i]] = 0; - } + if (NewHyperslab_GetLocalHyperslab (GH, vindex, timelevel, sdim, CCTK_VARIABLE_REAL4, NULL, slab->origin, + sdir, slab->length, locdowns, outme, + hsizes, hsizes_global, hsizes_offset) < 0) + { + fullname = CCTK_FullName (vindex); + CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed to extract hyperslab for variable '%s'", fullname); + free (fullname); + *free_outme = 0; + return (-1); + } - if (Hyperslab_GetLocalHyperslab (GH, index, timelevel, sdim, slab->origin, - sdir, slab->length, locdowns, outme, - hsizes, hsizes_global, hsizes_offset) < 0) - { - 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; - *free_outme = 1; + for (i = 0; i < sdim; i++) + { + geom[i + 0*sdim] = hsizes_offset[i]; + geom[i + 1*sdim] = hsizes[i]; + geom[i + 2*sdim] = hsizes_global[i]; + slab->actlen[i] = hsizes_global[i]; + } - for (i = 0; i < sdim; i++) - { - geom[i + 0*sdim] = hsizes_offset[i]; - geom[i + 1*sdim] = hsizes[i]; - geom[i + 2*sdim] = hsizes_global[i]; - slab->actlen[i] = hsizes_global[i]; - } + free (hsizes); - free (hsizes); - } #ifdef DEBUG_ME printf ("***** %dD \n",sdim); printf ("Lower bound: %d", (int) geom[0]); @@ -726,7 +686,7 @@ static int IOHDF5Util_getDumpData (cGH *GH, @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc global index of the variable to be dumped @vtype int @vio in @@ -766,7 +726,7 @@ static int IOHDF5Util_getDumpData (cGH *GH, @endvar @@*/ static void IOHDF5Util_procDump (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, void *outme, @@ -820,7 +780,7 @@ static void IOHDF5Util_procDump (cGH *GH, /* build the unique dataset name from the variable's full name, the timelevel and the current iteration number */ - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); datasetname = (char *) malloc (strlen (fullname) + 80); sprintf (datasetname, "%s timelevel %d at iteration %d", fullname, timelevel, GH->cctk_iteration); @@ -850,7 +810,7 @@ static void IOHDF5Util_procDump (cGH *GH, { IOHDF5_ERROR (dataset = H5Dcreate (file, datasetname, iohdf5_type, filespace, H5P_DEFAULT)); - IOHDF5Util_DumpCommonAttributes (GH, index, timelevel, &geom[2*sdim], + IOHDF5Util_DumpCommonAttributes (GH, vindex, timelevel, &geom[2*sdim], slab, dataset); } else @@ -880,7 +840,7 @@ static void IOHDF5Util_procDump (cGH *GH, if (proc == myproc) { IOHDF5_ERROR (group = H5Gcreate (file, datasetname, 0)); - IOHDF5Util_DumpCommonAttributes (GH, index, timelevel, &geom[2*sdim], + IOHDF5Util_DumpCommonAttributes (GH, vindex, timelevel, &geom[2*sdim], slab, group); IOHDF5_ERROR (H5Gclose (group)); } @@ -930,7 +890,7 @@ static void IOHDF5Util_procDump (cGH *GH, @vtype cGH * @vio in @endvar - @var index + @var vindex @vdesc global index of the variable to be dumped @vtype int @vio in @@ -965,7 +925,7 @@ static void IOHDF5Util_procDump (cGH *GH, @endvar @@*/ static void IOHDF5Util_collectiveDump (cGH *GH, - int index, + int vindex, int timelevel, ioHDF5Geo_t *slab, void *outme, @@ -1001,7 +961,7 @@ static void IOHDF5Util_collectiveDump (cGH *GH, } /* build the unique dataset name */ - fullname = CCTK_FullName (index); + fullname = CCTK_FullName (vindex); datasetname = (char *) malloc (strlen (fullname) + 80); sprintf (datasetname, "%s timelevel %d at iteration %d", fullname, timelevel, GH->cctk_iteration); @@ -1028,7 +988,7 @@ static void IOHDF5Util_collectiveDump (cGH *GH, H5P_DEFAULT)); if (CCTK_MyProc (GH) == 0) { - IOHDF5Util_DumpCommonAttributes (GH, index, timelevel, &geom[2*sdim], + IOHDF5Util_DumpCommonAttributes (GH, vindex, timelevel, &geom[2*sdim], slab, dataset); } |