From f11299667fb86982998d1985ec4860eb4cfaaf3c Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 20 Nov 2000 22:39:26 +0000 Subject: Realized that these obsolete files are still there. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOStreamedHDF5/trunk@54 0888f3d4-9f52-45d2-93bc-d00801ff5e46 --- src/DumpVar.c | 365 --------------------------------------------------- src/ParseGeometry.c | 347 ------------------------------------------------ src/ParseVars.c | 208 ----------------------------- src/StreamedHDF5GH.h | 164 ----------------------- 4 files changed, 1084 deletions(-) delete mode 100644 src/DumpVar.c delete mode 100644 src/ParseGeometry.c delete mode 100644 src/ParseVars.c delete mode 100644 src/StreamedHDF5GH.h diff --git a/src/DumpVar.c b/src/DumpVar.c deleted file mode 100644 index 8cb0a2e..0000000 --- a/src/DumpVar.c +++ /dev/null @@ -1,365 +0,0 @@ -/*@@ - @file DumpVar.c - @date Fri May 21 1999 - @author Thomas Radke / Gerd Lanfermann - @desc - Do the actual writing of a variable. - @enddesc - @history - @hauthor Thomas Radke @hdate May 21 1999 - @hdesc Just copied from thorn FlexIO. - @hendhistory - @@*/ - - -#include -#include - -#include "cctk.h" -#include "cctk_Parameters.h" -#include "CactusBase/IOUtil/src/ioGH.h" -#include "CactusPUGH/PUGHSlab/src/PUGHSlab.h" -#include "StreamedHDF5GH.h" - - -/*#define StreamedHDF5_DEBUG 1 */ - -/* local function prototypes */ -static void StreamedHDF5_Dump (cGH *GH, int index, int timelevel, void *outme, - int hdim, int *hsizes, int hdf5_type, hid_t fid); -static void StreamedHDF5_AddCommonAttributes (cGH *GH, int hdim, hid_t dataset); -static int GetHDF5type (StreamedHDF5GH *myGH, int vtype, hid_t *hdf5_type); - -/*@@ - @routine StreamedHDF5_DumpVar - @date 16 Apr 1999 - @author Thomas Radke - @desc - Generic dump routine, just calls the appropriate dump routine - Extracts the data with Hyperslab. - @enddesc - @calledby StreamedHDF5_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 fid - @vdesc the HDF5 file handle - @vtype hid_t - @vio in - @endvar -@@*/ -int StreamedHDF5_DumpVar (cGH *GH, int index, int timelevel, hid_t fid) -{ - DECLARE_CCTK_PARAMETERS - void *data; - int *hsizes; - hid_t hdf5_type; - StreamedHDF5GH *myGH; - StreamGeo_t geo; - int vtype; - - int sdir[3] = {0,0,0}; - - - /* Get the handle for StreamedHDF5 extensions */ - myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")]; - - vtype = CCTK_VarTypeI (index); - if (GetHDF5type (myGH, vtype, &hdf5_type) < 0) - { - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Unsupported variable type %d", vtype); - return (-1); - } - /* shortcut to the slab geometry */ - geo = myGH->geo_output[index]; - - /* get the dimension of the variable */ - - hsizes = (int*)malloc(geo.sdim*sizeof(int)); - - data = NULL; - - /* TEMPORARY FIX DUE TO INCONSISTENT DIR SPECIFICATION */ - /* direction vector of 1d line in 3d volume */ - if (geo.sdim==1) { - sdir[0] = (geo.direction[0]==0) ? 1:0; - sdir[1] = (geo.direction[0]==1) ? 1:0; - sdir[2] = (geo.direction[0]==2) ? 1:0; - } - /* norm vector of 2d surface in 3d volume */ - else if (geo.sdim==2) - { - sdir[0] = ((geo.direction[0]==1)&&(geo.direction[1]==2)) ? 1:0; - sdir[1] = ((geo.direction[0]==0)&&(geo.direction[1]==2)) ? 1:0; - sdir[2] = ((geo.direction[0]==0)&&(geo.direction[1]==1)) ? 1:0; - } - /* spanning directions for 3d */ - else if (geo.sdim==3) - { - sdir[0] = geo.direction[0]; - sdir[1] = geo.direction[1]; - sdir[2] = geo.direction[2]; - } - else - { - char *fullname = CCTK_FullName (index); - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "No 0-dim extraction possible: '%s'", fullname); - free (fullname); - return (-1); - } - - if (Hyperslab_GetHyperslab (GH, 0, index, timelevel, geo.sdim, geo.origin, - sdir, geo.length, geo.downs, - &data, hsizes) < 0) - { - char *fullname = CCTK_FullName (index); - - - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, - "Failed to extract hyperslab for variable '%s'", fullname); - free (fullname); - return (-1); - } - - if (fid >= 0) - { - StreamedHDF5_Dump (GH, index, timelevel, data, geo.sdim, hsizes, hdf5_type, fid); - } - - if (data) - { - free (data); - } - if (hsizes) - { - free (hsizes); - } - - return (0); -} - - -/***************************** local functions ****************************/ - -static int GetHDF5type (StreamedHDF5GH *myGH, int vtype, hid_t *hdf5_type) -{ - int retval = 0; - - - switch (vtype) - { - case CCTK_VARIABLE_CHAR: - *hdf5_type = IOHDF5_CHAR; - break; - case CCTK_VARIABLE_INT: - *hdf5_type = IOHDF5_INT; - break; - case CCTK_VARIABLE_REAL: - *hdf5_type = IOHDF5_REAL; - break; - case CCTK_VARIABLE_COMPLEX: - *hdf5_type = myGH->IOHDF5_COMPLEX; - break; - default: - retval = -1; - break; - } - - return (retval); -} - - -/*@@ - @routine StreamedHDF5_AddCommonAttributes - @date May 21 1999 - @author Thomas Radke - @desc - Add "Common" attributes, these are: -
    -
  • the variable's groupname -
  • the grouptype -
  • number of timelevels -
  • the current date - Note that the datestamp should be turned of if you are byte - comparing two output files. -
  • simulation time -
  • origin -
  • bounding box -
  • gridspacings (both downsampled and evolution) -
  • global grid size -
- @enddesc - @calledby StreamedHDF5_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 dataset - @vdesc the dataset handle where the attributes should be attached to - @vtype hid_t - @vio in - @endvar -@@*/ -static void StreamedHDF5_AddCommonAttributes (cGH *GH, int hdim, hid_t dataset) -{ - DECLARE_CCTK_PARAMETERS - CCTK_REAL realAttr [6]; - StreamedHDF5GH *myGH; - CCTK_REAL dummy; - - /* Get the handles for IOUtil and StreamedHDF5 extensions */ - myGH = (StreamedHDF5GH *) GH->extensions [CCTK_GHExtensionHandle ("StreamedHDF5")]; - - WRITE_ATTRIBUTE ("time", &GH->cctk_time, dataset, myGH->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, myGH->arrayDataspace, hdim, - 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, myGH->arrayDataspace, hdim, - IOHDF5_REAL); - WRITE_ATTRIBUTE ("max_ext", realAttr + 3, dataset, myGH->arrayDataspace, hdim, - IOHDF5_REAL); - - WRITE_ATTRIBUTE ("delta", GH->cctk_delta_space, dataset, myGH->arrayDataspace, - hdim, IOHDF5_REAL); -} - - -/*@@ - @routine StreamedHDF5_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 StreamedHDF5_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 fid - @vdesc the HDF5 file handle - @vtype hid_t - @vio in - @endvar -@@*/ -static void StreamedHDF5_Dump (cGH *GH, int index, int timelevel, void *outme, - int hdim, int *hsizes, int hdf5_type, hid_t fid) -{ - DECLARE_CCTK_PARAMETERS - int i; - hid_t dataset, memspace; - char *name, *datasetname; - hsize_t *dims; - - - dims = (hsize_t *) malloc (hdim * sizeof (hsize_t)); - - /* HDF5 needs it in reverse order */ - for (i = 0; i < hdim; i++) - { - dims [i] = hsizes [hdim - 1 - i]; - } - - /* build the unique dataset name */ - name = CCTK_FullName (index); - datasetname = (char *) malloc (strlen (name) + 30); /* 30 chars should be - enough for 2 ints */ - 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 (hdim, dims, NULL)); - - /* create the dataset */ - CACTUS_IOHDF5_ERROR (dataset = H5Dcreate (fid, datasetname, hdf5_type, - memspace, H5P_DEFAULT)); - /* write the data */ - CACTUS_IOHDF5_ERROR (H5Dwrite (dataset, hdf5_type, H5S_ALL, H5S_ALL, - H5P_DEFAULT, outme)); - - StreamedHDF5_AddCommonAttributes (GH, hdim, dataset); - - /* close the dataset and the memspace */ - CACTUS_IOHDF5_ERROR (H5Dclose (dataset)); - CACTUS_IOHDF5_ERROR (H5Sclose (memspace)); - - free (datasetname); - free (dims); -} diff --git a/src/ParseGeometry.c b/src/ParseGeometry.c deleted file mode 100644 index 2241f6c..0000000 --- a/src/ParseGeometry.c +++ /dev/null @@ -1,347 +0,0 @@ - -#include -#include -#include - -#include "cctk.h" -#include "cctk_Arguments.h" -#include "cctk_Parameters.h" -#include "cctk_GNU.h" -#include "util_String.h" - -#include "StreamedHDF5GH.h" - -/* Do not apply the USE marcro, parser will get confused - by curly braces in quoted strings */ - -/* CCTK_NO_AUTOUSE_MACRO */ - -/*$#define HEAVYDEBUG$*/ - - -int GeometryParserH5stream(const char *before, char **outname, StreamGeo_t *geo) -{ - DECLARE_CCTK_PARAMETERS - - regmatch_t pmatch[3],gmatch[6]; - int matched, ierr=0,retval=0, verb=0, deb=0; - - const char *argument; - char *varname=NULL, *geo_s=NULL; - const char *token=NULL; - char *dim_s=NULL, *ori_s=NULL, *dir_s=NULL; - char *len_s=NULL, *down_s=NULL; - - int dim = 0, idim, iidim; - int index; - - char info[8000]; - - /* Debugging switches */ - if (CCTK_Equals(h5verbose,"debug")) { - deb =1; - verb =1; - } - if (CCTK_Equals(h5verbose,"yes")) - verb =1; - - sprintf(info,"\n\nHDF5stream GeometryParser \nargument: >%s<\n",before); - - if((matched = CCTK_RegexMatch(before, - "([A-Za-z][A-Za-z0-9_]*::[A-Za-z][A-Za-z0-9_]*)\\[?(.*)?\\]?", 3, pmatch)) != 0) { - if (matched<0) CCTK_WARN(1,"Error matching in GeometryParser"); -#ifdef HEAVYDEBUG - printf("matched %d rm_so/rm_eo: %d %d; %d %d\n", - matched, - (int)pmatch[1].rm_so,(int)pmatch[1].rm_eo, - (int)pmatch[2].rm_so,(int)pmatch[2].rm_eo); -#endif - - if(pmatch[1].rm_so != -1 && - (pmatch[1].rm_eo-pmatch[1].rm_so > 0)) - { - varname = (char*) malloc((int)(pmatch[1].rm_eo-pmatch[1].rm_so+1) - *sizeof(char)); - strncpy(varname,before+pmatch[1].rm_so, - (int)(pmatch[1].rm_eo-pmatch[1].rm_so)); - varname[(int)(pmatch[1].rm_eo-pmatch[1].rm_so)]='\0'; - - *outname = varname; - sprintf(info,"%sOUTNAME : >%s< \n",info,*outname); - - if ((index = CCTK_VarIndex(varname))>=0) { - geo->vdim = CCTK_GroupDimI(CCTK_GroupIndexFromVarI(index)); - } - else - { - sprintf(info,"%sOUTNAME : no appropriate gridfunction found:>%s< \n", - info,*outname); - geo->vdim = -1; - } - } - else - { - CCTK_WARN(1,"No variable name found in StreamedHDF5::out_vars"); - retval = -1; - return(retval); - } - - if(pmatch[2].rm_so != -1 && - (pmatch[2].rm_eo-pmatch[2].rm_so > 0)) - { - geo_s = (char*) malloc((int)(pmatch[2].rm_eo-pmatch[2].rm_so+1) - *sizeof(char)); - strncpy(geo_s,before+pmatch[2].rm_so, - (int)(pmatch[2].rm_eo-pmatch[2].rm_so)); - geo_s[(int)(pmatch[2].rm_eo-pmatch[2].rm_so)]='\0'; - sprintf(info,"%sGEOMETRY: >%s< \n",info,geo_s); - } else { - sprintf(info,"%sGEOMETRY: No geometry specified -> use default\n",info); - } - } - else { - retval=-1; - return(retval); - } - - /* Pattern match the hyperslab string geo_s*/ - if (geo_s) { - if((matched = CCTK_RegexMatch(geo_s, - "\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\},\\{(.*)\\}", - 6, gmatch)) != 0) - { - - /* SLAB DIMENSION */ - if(gmatch[1].rm_so != -1 && - (gmatch[1].rm_eo-gmatch[1].rm_so > 0)) - { - dim_s = (char*) malloc((int)(gmatch[1].rm_eo-gmatch[1].rm_so+1) - *sizeof(char)); - strncpy(dim_s,geo_s+gmatch[1].rm_so, - (int)(gmatch[1].rm_eo-gmatch[1].rm_so)); - dim_s[(int)(gmatch[1].rm_eo-gmatch[1].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDIMENSION: >%s< \n",info,dim_s); - - dim = atoi(dim_s); - geo->sdim = dim; - } - else { - if (deb) - sprintf(info,"%s","DIMENSION: No dimension\n"); - retval = -1; - } - free(dim_s); - - /* DIRECTION */ - ierr = -1; - if(gmatch[2].rm_so != -1 && - (gmatch[2].rm_eo-gmatch[2].rm_so > 0)) - { - dir_s = (char*) malloc((int)(gmatch[2].rm_eo-gmatch[2].rm_so+1) - *sizeof(char)); - strncpy(dir_s,geo_s+gmatch[2].rm_so, - (int)(gmatch[2].rm_eo-gmatch[2].rm_so)); - dir_s[(int)(gmatch[2].rm_eo-gmatch[2].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDIRECTION: >%s< \n",info,dir_s); - - idim = 0; - argument = dir_s; - while((token = Util_StrSep(&argument,","))) { - geo->direction[idim++]=atoi(token); - } - geo->direction[idim] = atoi(argument); - if (idim==dim-1) ierr = 0; - } - if (ierr<0) { - sprintf(info,"%sDIRECTION: dimension not consistent: >%s< (Use default)\n", - info,dir_s); - } - free(dir_s); - - /* ORIGIN */ - ierr = -1; - if(gmatch[3].rm_so != -1 && - (gmatch[3].rm_eo-gmatch[3].rm_so > 0)) - { - ori_s = (char*) malloc((int)(gmatch[3].rm_eo-gmatch[3].rm_so+1) - *sizeof(char)); - strncpy(ori_s,geo_s+gmatch[3].rm_so, - (int)(gmatch[3].rm_eo-gmatch[3].rm_so)); - ori_s[(int)(gmatch[3].rm_eo-gmatch[3].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDIRECTION: >%s< \n",info,ori_s); - - idim=0; - argument = ori_s; - while((token = Util_StrSep(&argument,","))) { - geo->origin[idim++]=atoi(token); - } - geo->origin[idim] = atoi(argument); - if (idim==(geo->vdim-1)) ierr = 0; - else if (idim==0) { - for (iidim=1;iidimvdim;iidim++) - geo->origin[iidim] = geo->origin[0]; - ierr = 0; - } - } - if (ierr<0) { - sprintf(info,"%sORIGIN: dimension not consistent: >%s< \n", - info,ori_s); - ierr = -1; - } - free(ori_s); - - /* LENGTH */ - ierr = -1; - if(gmatch[4].rm_so != -1 && - (gmatch[4].rm_eo-gmatch[4].rm_so > 0)) - { - len_s = (char*) malloc((int)(gmatch[4].rm_eo-gmatch[4].rm_so+1) - *sizeof(char)); - strncpy(len_s,geo_s+gmatch[4].rm_so, - (int)(gmatch[4].rm_eo-gmatch[4].rm_so)); - len_s[(int)(gmatch[4].rm_eo-gmatch[4].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sLENGTH: >%s< \n",info,len_s); - - idim = 0; - argument = len_s; - while((token = Util_StrSep(&argument,","))) { - geo->length[idim++]=atoi(token); - } - geo->length[idim] = atoi(argument); - if (idim==dim-1) ierr = 0; - else if (idim==0) { - for (iidim=1;iidimlength[iidim] = geo->length[0]; - ierr = 0; - } - } - if (ierr<0) { - sprintf(info,"%sLENGTH: dimension not consistent: >%s< (Use Default)\n", - info,len_s); - } - free(len_s); - - - /* DOWNSAMPLING */ - ierr = -1; - if(gmatch[5].rm_so != -1 && - (gmatch[5].rm_eo-gmatch[5].rm_so > 0)) { - - down_s = (char*) malloc((int)(gmatch[5].rm_eo-gmatch[5].rm_so+1) - *sizeof(char)); - strncpy(down_s,geo_s+gmatch[5].rm_so, - (int)(gmatch[5].rm_eo-gmatch[5].rm_so)); - down_s[(int)(gmatch[5].rm_eo-gmatch[5].rm_so)]='\0'; - - if (deb) - sprintf(info,"%sDOWNSAMPLING: >%s< \n",info,down_s); - - - idim=0; - argument = down_s; - while((token = Util_StrSep(&argument,","))) { - geo->downs[idim++]=atoi(token); - } - geo->downs[idim] = atoi(argument); - if (idim==dim-1) ierr =0; - else if (idim==0) { - for (iidim=1;iidimdowns[iidim] = geo->downs[0]; - ierr = 0; - } - } - if (ierr<0) { - sprintf(info,"%sDOWNSAMPLING: dimension not consistent: >%s< \n", - info,down_s); - ierr =-1; - } - free(down_s); - } - if (geo_s) free(geo_s); - } - - if (verb) { - sprintf(info, "%sGeometry Data: \n",info); - sprintf(info, "%s Argument/Slab dimension: %d / %d \n", - info,geo->vdim,geo->sdim); - sprintf(info, "%s Origin: ",info); - for (idim=0;idimvdim;idim++) - sprintf(info,"%s %d ",info,geo->origin[idim]); - sprintf(info,"%s\n Downs : ",info); - for (idim=0;idimsdim;idim++) - sprintf(info,"%s %d ",info,geo->downs[idim]); - sprintf(info,"%s\n Length: ",info); - for (idim=0;idimsdim;idim++) - sprintf(info,"%s %d ",info,geo->length[idim]); - sprintf(info,"%s\n Dirs : ",info); - for (idim=0;idimsdim;idim++) - sprintf(info,"%s %d ",info,geo->direction[idim]); - sprintf(info,"%s\n\n",info); - - printf("%s",info); - } - - USE_CCTK_PARAMETERS - - return(retval); -} - -void SetDefaultGeoH5stream(StreamGeo_t *geo) { - DECLARE_CCTK_PARAMETERS - - int idim; - const char *argument, *token; - - geo->vdim = -1; - geo->sdim = slabdim; - - /* Origin */ - idim=0; - argument = origin; - while((token = Util_StrSep(&argument,","))) { - geo->origin[idim++]=atoi(token); - } - geo->downs[idim] = atoi(argument); - - /* Direction */ - idim=0; - argument = direction; - while((token = Util_StrSep(&argument,","))) { - geo->direction[idim++]=atoi(token); - } - geo->downs[idim] = atoi(argument); - - /* Downsample */ - idim=0; - argument = origin; - while((token = Util_StrSep(&argument,","))) { - geo->downs[idim++]=atoi(token); - } - geo->downs[idim] = atoi(argument); - - /* Length */ - idim=0; - argument = origin; - while((token = Util_StrSep(&argument,","))) { - geo->length[idim++]=atoi(token); - } - geo->length[idim] = atoi(argument); - - for (idim=0;idimdirection[idim] = idim; - geo->origin[idim] = 0; - geo->length[idim] =-1; - geo->downs[idim] = 1; - } - - USE_CCTK_PARAMETERS -} - diff --git a/src/ParseVars.c b/src/ParseVars.c deleted file mode 100644 index 87143ba..0000000 --- a/src/ParseVars.c +++ /dev/null @@ -1,208 +0,0 @@ - /*@@ - @file GHExtension.c - @date Tue 9th Feb 1999 - @author Gabrielle Allen - @desc - IOUtil GH extension stuff. - @enddesc - @history - @endhistory - @@*/ - -/*#define DEBUG_IO*/ - -#include -#include -#include - -#include "cctk.h" -#include "util_String.h" -#include "cctk_Parameters.h" - -#include "StreamedHDF5GH.h" - - -static char *rcsid = "$Header$"; - - -/* =============================================================== - utility routines used by other IO thorns - ===============================================================*/ - - /*@@ - @routine IOUtil_ParseVarsForOutput - @date Sat March 6 1999 - @author Gabrielle Allen - @desc - Sets each flag in the do_output[] do_output to true - if var[i] could be found in the list of variable names. - var_list my also contain group names of variables as well as the - special keyword "all" which indicates that output is requested - on all variables. - @enddesc - @history - @endhistory - @var var_list - @vdesc list of variables and/or group names - @vtype const char * - @vio in - @endvar - @var do_output - @vdesc do_output of flags indicating output was requested for var[i] - @vtype char [] - @vio out - @endvar -@@*/ - -int ParseVarsForOutputH5stream (StreamedHDF5GH *h5GH, const char *var_list) -{ - char *outname=NULL; - char *before=NULL; - char *after=NULL; - char *splitstring; - int first,groupnum,i,last,index,varnum; - StreamGeo_t geo_tmp; - int ierr=0; - - /* First initialise every variable to no output */ - for (i=0; ido_output[i] = 0; - } - - /* Initialize geometry structure with default */ - - SetDefaultGeoH5stream(&geo_tmp); - - splitstring = (char *) var_list; - - /* split string at blanks */ - while(Util_SplitString(&before,&after,splitstring," ")==0) { - -#ifdef DEBUG_IO - printf(" String is -%s-\n",splitstring); - printf(" Split is -%s- and -%s-\n",before,after); -#endif - - if (CCTK_Equals(before," ")) continue; - - if (strlen(before) > 0) - { - /* Extract geometry information */ - ierr=GeometryParserH5stream(before, &outname, &geo_tmp); - if ((ierr<0)||(outname==NULL)) { - CCTK_WARN(1,"GeometryParserH5stream failed."); - return(-1); - } - - /* Look for any special tokens */ - if (CCTK_Equals(outname,"all")) - { - int ilab; - for (ilab=0;ilabgeo_output[ilab]= geo_tmp; - h5GH->do_output[ilab] = 1; - } - } - else - { - /* See if this name is implementation::variable */ - varnum = CCTK_VarIndex(outname); - if ( varnum < 0 ) - { - /* See if this name is implementation::group */ - groupnum = CCTK_GroupIndex(outname); - if (groupnum < 0) - { - char *msg; - msg = (char *)malloc((100+strlen(outname))*sizeof(char)); - sprintf(msg,"Ignoring <%s> in IO string (invalid token)",outname); - CCTK_WARN(2,msg); - free(msg); - } - else - { - /* We have a group so now need all the variables in the group */ - first = CCTK_FirstVarIndexI(groupnum); - last = first+CCTK_NumVarsInGroupI(groupnum)-1; - for (index=first;index<=last;index++) { - h5GH->geo_output[index]=geo_tmp; - h5GH->do_output[index] =1; - } - } - } - else - { - h5GH->geo_output[varnum]= geo_tmp; - h5GH->do_output[varnum] = 1; - } - } - } - if(before) - { - free(before); - before = NULL; - } - if(outname) - { - free(outname); - outname = NULL; - } - if(splitstring != var_list) - { - free(splitstring); - } - - splitstring = after; - - } - - if (strlen(splitstring)>0) { - - /* Extract geometry information */ - ierr=GeometryParserH5stream(splitstring, &outname, &geo_tmp); - if (ierr<0) printf("GeometryParser failed: >%s<\n",before); - - /* Special cases */ - if (CCTK_Equals(outname,"all")) { - int ilab; - for (ilab=0;ilabgeo_output[ilab]=geo_tmp; - h5GH->do_output [ilab]=1; - } - } else { - - varnum = CCTK_VarIndex(outname); - if (varnum < 0) { - groupnum = CCTK_GroupIndex(outname); - if (groupnum < 0) { - char *msg; - msg = (char *)malloc((100+strlen(outname))*sizeof(char)); - sprintf(msg,"Ignoring %s in IO string (invalid token)",outname); - CCTK_WARN(2,msg); - free(msg); - } else { - /* We have a group so now need all the variables in the group */ - first = CCTK_FirstVarIndexI(groupnum); - last = first+CCTK_NumVarsInGroupI(groupnum)-1; - for (index=first;index<=last;index++) { - h5GH->geo_output[index]=geo_tmp; - h5GH->do_output[index] =1; - } - } - } - else { - h5GH->geo_output[varnum]=geo_tmp; - h5GH->do_output[varnum] =1; - } - } - } - - if (before) free(before); - if (after) free(after); - if(splitstring != var_list) - { - free(splitstring); - } - return(0); -} diff --git a/src/StreamedHDF5GH.h b/src/StreamedHDF5GH.h deleted file mode 100644 index 4317db4..0000000 --- a/src/StreamedHDF5GH.h +++ /dev/null @@ -1,164 +0,0 @@ - /*@@ - @header StreamedHDF5GH.h - @date Fri May 21 1999 - @author Thomas Radke - @desc - The extensions to the GH structure from StreamedHDF5. - @history - @hauthor Thomas Radke @hdate May 21 1999 - @hdesc Just copied from thorn FlexIO. - @endhistory - @@*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#include "StoreNamedData.h" - - -/* names of the (empty) groups that hold GH extensions or global parameters */ -#define GHEXTENSIONS_GROUP "GHextensions_group" -#define GLOBAL_PARAMETERS_GROUP "global_parameters_group" -#define GLOBAL_PARAMETERS "global_parameters" - -/*****************************************************************************/ -/* some useful macros */ -/*****************************************************************************/ -/* Check error flags from HDF5 calls */ -#define CACTUS_IOHDF5_ERROR(fn_call) \ - do { \ - size_t strlen(const char *str); \ - \ - int error_code = fn_call; \ - \ - if (error_code < 0) \ - CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING, \ - "HDF5 call '%s' returned error code %d\n", \ - #fn_call, error_code); \ - } while (0) - -/* macro for writing an attribute */ -#define WRITE_ATTRIBUTE(name, value, dataset, dataspace, dim, datatype) \ - do { \ - hid_t attr; \ - void *val = value; \ - hsize_t arrayDim = dim; \ - \ - if (H5Tget_class (datatype) == H5T_STRING) { \ - int len = strlen ((char *) val); \ - \ - if (len == 0) /* HDF5 doesn't like zero-len strings */ \ - len++; \ - CACTUS_IOHDF5_ERROR (H5Tset_size (datatype, len)); \ - } \ - if (arrayDim > 0) \ - CACTUS_IOHDF5_ERROR (H5Sset_extent_simple (dataspace, 1, \ - &arrayDim, NULL)); \ - CACTUS_IOHDF5_ERROR (attr = H5Acreate (dataset, name, datatype, \ - dataspace, H5P_DEFAULT)); \ - CACTUS_IOHDF5_ERROR (H5Awrite (attr, datatype, val)); \ - CACTUS_IOHDF5_ERROR (H5Aclose (attr)); \ - } while (0); - -/* macro for reading an attribute */ -#define READ_ATTRIBUTE(dataset, attrname, requested_type, buffer) \ - { hid_t attr, attrtype; \ - hsize_t asize = 0; \ - \ - if ((attr = H5Aopen_name (dataset, attrname)) < 0) \ - CCTK_WARN (1, "Can't find " attrname " attribute"); \ - if (requested_type == H5T_C_S1) { \ - CACTUS_IOHDF5_ERROR (attrtype = H5Aget_type (attr)); \ - CACTUS_IOHDF5_ERROR (asize = H5Tget_size (attrtype)); \ - if (asize + 1 >= sizeof (buffer)) \ - CCTK_WARN (1, "Can't read " attrname " attribute (too long)");\ - } else \ - attrtype = requested_type; \ - if (H5Aread (attr, attrtype, buffer) < 0) \ - CCTK_WARN (1, "Can't read " attrname " attribute"); \ - if (requested_type == H5T_C_S1) { \ - ((char *) buffer) [asize] = 0; \ - CACTUS_IOHDF5_ERROR (H5Tclose (attrtype)); \ - } \ - CACTUS_IOHDF5_ERROR (H5Aclose (attr)); \ - } - - -/* define the HDF5 datatypes according to CCTK_??? datatypes */ -#define IOHDF5_REAL4 H5T_NATIVE_FLOAT - -#ifdef CCTK_REAL_PRECISION_16 -#define IOHDF5_REAL H5T_NATIVE_LDOUBLE -#elif CCTK_REAL_PRECISION_8 -#define IOHDF5_REAL H5T_NATIVE_DOUBLE -#elif CCTK_REAL_PRECISION_4 -#define IOHDF5_REAL H5T_NATIVE_FLOAT -#endif - -#define IOHDF5_INT (sizeof (CCTK_INT) == sizeof (int) ? \ - H5T_NATIVE_INT : H5T_NATIVE_SHORT) -#define IOHDF5_INT4 (sizeof (int) == 4 ? \ - H5T_NATIVE_INT : H5T_NATIVE_SHORT) -#define IOHDF5_CHAR H5T_NATIVE_CHAR - -#define STREAM_MAXDIM 5 - -/* Geometry information structure for output variable */ -typedef struct -{ - int vdim; - int sdim; - int direction[STREAM_MAXDIM]; - int origin[STREAM_MAXDIM]; - int length[STREAM_MAXDIM]; - int downs[STREAM_MAXDIM]; -} StreamGeo_t; - - -/* StreamedHDF5 GH extension structure */ -typedef struct StreamedHDF5GH -{ - /* how often to output */ - int out_every; - - /* flags indicating output for var [i] */ - char *do_output; - StreamGeo_t *geo_output; - - /* the last iteration output */ - int *out_last; - - /* variables holding the original error printing routine and its argument */ - H5E_auto_t printErrorFn; - void *printErrorFnArg; - - /* predefined dataspaces for writing scalar and array attributes */ - hid_t scalarDataspace, arrayDataspace; - - /* predefined datatype for writing CCTK_COMPLEX types */ - hid_t IOHDF5_COMPLEX; - - /* predefined datatype for writing C string string attributes */ - hid_t IOHDF5_STRING; - - /* the socket to pass to the Stream VFD */ - int socket; - -} StreamedHDF5GH; - -/* function prototypes */ -void StreamedHDF5_Write (cGH *GH, int index, const char *alias); -void StreamedHDF5_DumpParams (cGH *GH, hid_t group); -void StreamedHDF5_DumpGHExtensions (cGH *GH, hid_t group); -int StreamedHDF5_DumpVar (cGH *GH, int index, int timelevel, hid_t iof); -int ParseVarsForOutputH5stream (StreamedHDF5GH *h5GH, const char *var_list); -void SetDefaultGeoH5stream(StreamGeo_t *geo); -int GeometryParserH5stream(const char *before, char **outname, StreamGeo_t *geo); - -#ifdef __cplusplus -} // extern "C" { -#endif -- cgit v1.2.3