1 /* 2 Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC. 3 LLNL-CODE-425250. 4 All rights reserved. 5 6 This file is part of Silo. For details, see silo.llnl.gov. 7 8 Redistribution and use in source and binary forms, with or without 9 modification, are permitted provided that the following conditions 10 are met: 11 12 * Redistributions of source code must retain the above copyright 13 notice, this list of conditions and the disclaimer below. 14 * Redistributions in binary form must reproduce the above copyright 15 notice, this list of conditions and the disclaimer (as noted 16 below) in the documentation and/or other materials provided with 17 the distribution. 18 * Neither the name of the LLNS/LLNL nor the names of its 19 contributors may be used to endorse or promote products derived 20 from this software without specific prior written permission. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE 26 LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR 27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 35 This work was produced at Lawrence Livermore National Laboratory under 36 Contract No. DE-AC52-07NA27344 with the DOE. 37 38 Neither the United States Government nor Lawrence Livermore National 39 Security, LLC nor any of their employees, makes any warranty, express 40 or implied, or assumes any liability or responsibility for the 41 accuracy, completeness, or usefulness of any information, apparatus, 42 product, or process disclosed, or represents that its use would not 43 infringe privately-owned rights. 44 45 Any reference herein to any specific commercial products, process, or 46 services by trade name, trademark, manufacturer or otherwise does not 47 necessarily constitute or imply its endorsement, recommendation, or 48 favoring by the United States Government or Lawrence Livermore 49 National Security, LLC. The views and opinions of authors expressed 50 herein do not necessarily state or reflect those of the United States 51 Government or Lawrence Livermore National Security, LLC, and shall not 52 be used for advertising or product endorsement purposes. 53 */ 54 /* 55 * Programmer: Robb Matzke <matzke@llnl.gov> 56 * Tuesday, February 9, 1999 57 * 58 * Purpose: This header file is included by all silo-hdf5 source files 59 * and contains constants and prototypes that should be visible 60 * to the SILO/HDF5 driver but not to the application. 61 * 62 * Note: This file can be included even if HDF5 is not available. 63 */ 64 #ifndef SILO_HDF5_PRIVATE_H 65 #define SILO_HDF5_PRIVATE_H 66 #include "config.h" 67 #include "silo_private.h" 68 #include "silo_drivers.h" 69 #if defined(HAVE_HDF5_H) && defined(HAVE_LIBHDF5) 70 71 #include "hdf5.h" 72 73 #define NDSETTAB 30 74 75 /* The private version of the DBfile structure is defined here */ 76 typedef struct DBfile_hdf5 { 77 DBfile_pub pub; /*public stuff */ 78 hid_t fid; /*hdf5 file identifier */ 79 hid_t cwg; /*current working group */ 80 char *cwg_name; /*full name of cwg or NULL */ 81 hid_t link; /*link group */ 82 char *dsettab[NDSETTAB]; /*circular buffer of datasets */ 83 char compname[NDSETTAB][32]; /*component names for datasets */ 84 int dsettab_ins; /*next insert location */ 85 int dsettab_rem; /*next remove location */ 86 hid_t T_char; /*target DB_CHAR type */ 87 hid_t T_short; /*target DB_SHORT type */ 88 hid_t T_int; /*target DB_INT type */ 89 hid_t T_long; /*target DB_LONG type */ 90 hid_t T_llong; /*target DB_LONG_LONG type */ 91 hid_t T_float; /*target DB_FLOAT type */ 92 hid_t T_double; /*target DB_DOUBLE type */ 93 hid_t T_str256; /*target 256-char string */ 94 hid_t (*T_str)(char*); /*target character string */ 95 } DBfile_hdf5; 96 97 #ifndef SILO_NO_CALLBACKS 98 99 /* File operations */ 100 SILO_CALLBACK int db_hdf5_Close (DBfile *); 101 SILO_CALLBACK int db_hdf5_Filters(DBfile *_dbfile, FILE *stream); 102 103 /* Directory operations */ 104 SILO_CALLBACK int db_hdf5_MkDir(DBfile *_dbfile, char const *name); 105 SILO_CALLBACK int db_hdf5_SetDir(DBfile *_dbfile, char const *name); 106 SILO_CALLBACK int db_hdf5_GetDir(DBfile *_dbfile, char *name/*out*/); 107 SILO_CALLBACK int db_hdf5_CpDir(DBfile *_dbfile, char const *srcDir, 108 DBfile *dstFile, char const *dstDir); 109 SILO_CALLBACK int db_hdf5_NewToc(DBfile *_dbfile); 110 111 /* Variable inquiries */ 112 SILO_CALLBACK int db_hdf5_InqVarExists (DBfile *_dbfile, char const *varname); 113 SILO_CALLBACK int db_hdf5_GetVarLength(DBfile *_dbfile, char const *name); 114 SILO_CALLBACK int db_hdf5_GetVarByteLength(DBfile *_dbfile, char const *name); 115 SILO_CALLBACK int db_hdf5_GetVarType(DBfile *_dbfile, char const *name); 116 SILO_CALLBACK int db_hdf5_GetVarDims(DBfile *_dbfile, char const *varname, int maxdims, 117 int *dims/*out*/); 118 119 /* Variable I/O */ 120 SILO_CALLBACK void *db_hdf5_GetVar(DBfile *_dbfile, char const *name); 121 SILO_CALLBACK int db_hdf5_ReadVar (DBfile *, char const *, void *); 122 SILO_CALLBACK int db_hdf5_ReadVarSlice (DBfile *, char const *, int const *, int const *, int const *, 123 int, void *); 124 SILO_CALLBACK int db_hdf5_Write( 125 DBfile *dbfile, 126 char const *array_name, 127 void const *data, 128 int const *dims, 129 int ndims, 130 int datatype 131 ); 132 SILO_CALLBACK int db_hdf5_WriteSlice( 133 DBfile *dbfile, 134 char const *array_name, 135 void const *data, 136 int datatype, 137 int const *offsets, 138 int const *lengths, 139 int const *strides, 140 int const *dims, 141 int ndims 142 ); 143 144 /* Low-level object functions */ 145 SILO_CALLBACK DBobject *db_hdf5_GetObject(DBfile *_dbfile, char const *name); 146 SILO_CALLBACK int db_hdf5_GetComponentNames(DBfile *_dbfile, char const *objname, 147 char ***comp_names, char ***file_names); 148 SILO_CALLBACK int db_hdf5_WriteObject(DBfile *_dbfile, DBobject const *obj, int flags); 149 SILO_CALLBACK int db_hdf5_WriteComponent(DBfile *_dbfile, DBobject *obj, 150 char const *compname, char const *prefix, 151 char const *datatype, void const *data, int rank, 152 long const _size[]); 153 SILO_CALLBACK int db_hdf5_GetComponentType(DBfile *_dbfile, char const *objname, 154 char const *compname); 155 SILO_CALLBACK void *db_hdf5_GetComponent(DBfile *_dbfile, char const *objname, 156 char const *compname); 157 SILO_CALLBACK void *db_hdf5_GetComponentStuff(DBfile *_dbfile, char const *objname, 158 char const *compname, int *just_get_datatype); 159 SILO_CALLBACK DBObjectType db_hdf5_InqVarType(DBfile *_dbfile, char const *name); 160 SILO_CALLBACK int db_hdf5_InqMeshName(DBfile *_dbfile, char const *name, 161 char *meshname/*out*/); 162 163 /* Curves */ 164 SILO_CALLBACK int db_hdf5_PutCurve( 165 DBfile *_dbfile, 166 char const *name, 167 void const *xvals, 168 void const *yvals, 169 int dtype, 170 int npts, 171 DBoptlist const *opts 172 ); 173 SILO_CALLBACK DBcurve *db_hdf5_GetCurve(DBfile *_dbfile, char const *name); 174 175 /* Csgmeshes */ 176 SILO_CALLBACK int db_hdf5_PutCsgmesh(DBfile *_dbfile, char const *name, int ndims, 177 int nbounds, int const *typeflags, 178 int const *bndids/*optional*/, 179 void const *coeffs, int lcoeffs, int datatype, 180 double const *extents, char const *zonel_name, 181 DBoptlist const *optlist); 182 SILO_CALLBACK DBcsgmesh *db_hdf5_GetCsgmesh(DBfile *_dbfile, char const *name); 183 SILO_CALLBACK int db_hdf5_PutCsgvar(DBfile *_dbfile, char const *vname, char const *meshname, 184 int nvars, char const * const *varnames, void const * const *vars, 185 int nvals, int datatype, int centering, DBoptlist const *optlist); 186 SILO_CALLBACK DBcsgvar *db_hdf5_GetCsgvar(DBfile *_dbfile, char const *name); 187 SILO_CALLBACK int db_hdf5_PutCSGZonelist(DBfile *_dbfile, char const *name, int nregs, 188 int const *typeflags, 189 int const *leftids, int const *rightids, 190 void const *xforms, int lxforms, int datatype, 191 int nzones, int const *zonelist, DBoptlist const *optlist); 192 SILO_CALLBACK DBcsgzonelist *db_hdf5_GetCSGZonelist(DBfile *_dbfile, char const *name); 193 194 /* Defvars */ 195 SILO_CALLBACK int db_hdf5_PutDefvars( 196 DBfile *dbfile, char const *name, 197 int ndefs, 198 char const * const *names, 199 int const *types, 200 char const * const *defns, 201 DBoptlist const * const *opts 202 ); 203 SILO_CALLBACK DBdefvars *db_hdf5_GetDefvars(DBfile *_dbfile, char const *name); 204 205 /* Quadmeshes */ 206 SILO_CALLBACK int db_hdf5_PutQuadmesh(DBfile *_dbfile, char const *name, 207 char const * const *coordnames, DBVCP2_t coords, 208 int const *dims, int ndims, int datatype, 209 int coordtype, DBoptlist const *optlist); 210 SILO_CALLBACK DBquadmesh *db_hdf5_GetQuadmesh (DBfile *_dbfile, char const *name); 211 SILO_CALLBACK int db_hdf5_PutQuadvar(DBfile *_dbfile, char const *name, char const *meshname, 212 int nvars, char const * const *varnames, 213 DBVCP2_t vars, int const *dims, 214 int ndims, DBVCP2_t mixvars, 215 int mixlen, int datatype, int centering, 216 DBoptlist const *optlist); 217 SILO_CALLBACK DBquadvar *db_hdf5_GetQuadvar(DBfile *_dbfile, char const *name); 218 219 /* Unstructured meshes */ 220 SILO_CALLBACK int db_hdf5_PutUcdmesh(DBfile *_dbfile, char const *name, int ndims, 221 char const * const *coordnames, 222 DBVCP2_t coords, int nnodes, 223 int nzones, char const *zlname, char const *flname, 224 int datatype, DBoptlist const *optlist); 225 SILO_CALLBACK int db_hdf5_PutUcdsubmesh(DBfile *_dbfile, char const *name, 226 char const *parentmesh, int nzones, char const *zlname, 227 char const *flname, DBoptlist const *optlist); 228 SILO_CALLBACK DBucdmesh *db_hdf5_GetUcdmesh(DBfile *_dbfile, char const *name); 229 SILO_CALLBACK int db_hdf5_PutUcdvar(DBfile *_dbfile, char const *name, char const *meshname, 230 int nvars, char const * const *varnames, 231 DBVCP2_t vars, int nels, 232 DBVCP2_t mixvars, int mixlen, 233 int datatype, int centering, 234 DBoptlist const *optlist); 235 SILO_CALLBACK DBucdvar *db_hdf5_GetUcdvar(DBfile *_dbfile, char const *name); 236 SILO_CALLBACK int db_hdf5_PutFacelist( 237 DBfile *_dbfile, 238 char const *name, 239 int nfaces, 240 int ndims, 241 int const *nodelist, 242 int lnodelist, 243 int origin, 244 int const *zoneno, 245 int const *shapesize, 246 int const *shapecnt, 247 int nshapes, 248 int const *types, 249 int const *typelist, 250 int ntypes 251 ); 252 SILO_CALLBACK DBfacelist *db_hdf5_GetFacelist(DBfile *_dbfile, char const *name); 253 SILO_CALLBACK int db_hdf5_PutZonelist(DBfile *_dbfile, char const *name, int nzones, 254 int ndims, int const *nodelist, int lnodelist, 255 int origin, int const *shapesize, int const *shapecnt, 256 int nshapes); 257 SILO_CALLBACK int db_hdf5_PutZonelist2(DBfile *_dbfile, char const *name, int nzones, 258 int ndims, int const *nodelist, int lnodelist, 259 int origin, int lo_offset, int hi_offset, 260 int const *shapetype, int const *shapesize, 261 int const *shapecnt, int nshapes, 262 DBoptlist const *optlist); 263 SILO_CALLBACK int db_hdf5_PutPHZonelist(DBfile *_dbfile, char const *name, 264 int nfaces, int const *nodecnt, int lnodelist, int const *nodelist, 265 char const *extface, 266 int nzones, int const *facecnt, int lfacelist, int const *facelist, 267 int origin, int lo_offset, int hi_offset, 268 DBoptlist const *optlist); 269 SILO_CALLBACK DBzonelist *db_hdf5_GetZonelist(DBfile *_dbfile, char const *name); 270 SILO_CALLBACK DBphzonelist *db_hdf5_GetPHZonelist(DBfile *_dbfile, char const *name); 271 272 /* Materials */ 273 SILO_CALLBACK int db_hdf5_PutMaterial( 274 DBfile *_dbfile, 275 char const *name, 276 char const *mname, 277 int nmat, 278 int const *matnos, 279 int const *matlist, 280 int const *dims, 281 int ndims, 282 int const *mix_next, 283 int const *mix_mat, 284 int const *mix_zone, 285 void const *mix_vf, 286 int mixlen, 287 int datatype, 288 DBoptlist const *optlist 289 ); 290 SILO_CALLBACK DBmaterial *db_hdf5_GetMaterial(DBfile *_dbfile, char const *name); 291 SILO_CALLBACK int db_hdf5_PutMatspecies(DBfile *_dbfile, char const *name, char const *matname, 292 int nmat, int const *nmatspec, int const *speclist, 293 int const *dims, int ndims, int nspecies_mf, 294 void const *species_mf, int const *mix_speclist, 295 int mixlen, int datatype, 296 DBoptlist const *optlist); 297 SILO_CALLBACK DBmatspecies *db_hdf5_GetMatspecies(DBfile *_dbfile, char const *name); 298 299 /* Point meshes */ 300 SILO_CALLBACK int db_hdf5_PutPointmesh(DBfile *_dbfile, char const *name, int ndims, 301 DBVCP2_t coords, int nels, int datatype, 302 DBoptlist const *optlist); 303 SILO_CALLBACK DBpointmesh *db_hdf5_GetPointmesh(DBfile *_dbfile, char const *name); 304 SILO_CALLBACK int db_hdf5_PutPointvar(DBfile *_dbfile, char const *name, char const *meshname, 305 int nvars, DBVCP2_t vars, int nels, 306 int datatype, DBoptlist const *optlist); 307 SILO_CALLBACK DBmeshvar *db_hdf5_GetPointvar(DBfile *_dbfile, char const *name); 308 309 /* Multiblock meshes */ 310 SILO_CALLBACK int db_hdf5_PutMultimesh(DBfile *_dbfile, char const *name, int nmesh, 311 char const *const *meshnames, int const *meshtypes, 312 DBoptlist const *optlist); 313 SILO_CALLBACK int db_hdf5_PutMultimeshadj( 314 DBfile *_dbfile, 315 char const *name, 316 int nmesh, 317 int const *meshtypes, 318 int const *nneighbors, 319 int const *neighbors, 320 int const *back, 321 int const *lnodelists, 322 int const * const *nodelists, 323 int const *lzonelists, 324 int const * const *zonelists, 325 DBoptlist const *optlist 326 ); 327 SILO_CALLBACK DBmultimesh *db_hdf5_GetMultimesh(DBfile *_dbfile, char const *name); 328 SILO_CALLBACK DBmultimeshadj *db_hdf5_GetMultimeshadj(DBfile *_dbfile, char const *name, int nmesh, 329 int const *block_map); 330 SILO_CALLBACK int db_hdf5_PutMultivar(DBfile *_dbfile, char const *name, int nvars, 331 char const * const *varnames, int const *vartypes, 332 DBoptlist const *optlist); 333 SILO_CALLBACK DBmultivar *db_hdf5_GetMultivar(DBfile *_dbfile, char const *name); 334 SILO_CALLBACK int db_hdf5_PutMultimat(DBfile *_dbfile, char const *name, int nmats, 335 char const * const *matnames, DBoptlist const *optlist); 336 SILO_CALLBACK DBmultimat *db_hdf5_GetMultimat(DBfile *_dbfile, char const *name); 337 SILO_CALLBACK int db_hdf5_PutMultimatspecies(DBfile *_dbfile, char const *name, int nspec, 338 char const * const *specnames, DBoptlist const *optlist); 339 SILO_CALLBACK DBmultimatspecies *db_hdf5_GetMultimatspecies(DBfile *_dbfile, 340 char const *name); 341 342 /* Compound arrays */ 343 SILO_CALLBACK int db_hdf5_PutCompoundarray( 344 DBfile *_dbfile, 345 char const *name, 346 char const * const *elmtnames, 347 int const *elmtlen, 348 int nelmts, 349 void const *values, 350 int nvalues, 351 int datatype, 352 DBoptlist const *optlist 353 ); 354 SILO_CALLBACK DBcompoundarray *db_hdf5_GetCompoundarray( 355 DBfile *_dbfile, 356 char const *name 357 ); 358 359 /* Mrgtree objects */ 360 SILO_CALLBACK int db_hdf5_PutMrgtree(DBfile *_dbfile, char const *name, char const *mesh_name, 361 DBmrgtree const *tree, DBoptlist const *optlist); 362 SILO_CALLBACK DBmrgtree *db_hdf5_GetMrgtree(DBfile *_dbfile, char const *name); 363 364 /* groupel maps */ 365 SILO_CALLBACK int db_hdf5_PutGroupelmap(DBfile *_dbfile, char const *map_name, 366 int num_segments, int const *groupel_types, int const *segment_lengths, 367 int const *segment_ids, int const * const *segment_data, void const * const *segment_fracs, 368 int fracs_data_type, DBoptlist const *opts); 369 SILO_CALLBACK DBgroupelmap *db_hdf5_GetGroupelmap(DBfile *dbfile, char const *name); 370 371 /* mrgvars */ 372 SILO_CALLBACK int db_hdf5_PutMrgvar(DBfile *dbfile, char const *name, 373 char const *mrgt_name, 374 int ncomps, char const * const *compnames, 375 int nregns, char const * const *reg_pnames, 376 int datatype, void const * const *data, DBoptlist const *opts); 377 SILO_CALLBACK DBmrgvar *db_hdf5_GetMrgvar(DBfile *dbfile, char const *name); 378 379 SILO_CALLBACK int db_hdf5_FreeCompressionResources(DBfile *_dbfile, 380 char const *meshname); 381 382 SILO_CALLBACK int db_hdf5_SortObjectsByOffset(DBfile *_dbfile, int nobjs, 383 char const *const *const names, int *ordering); 384 385 #endif /* !SILO_NO_CALLBACKS */ 386 387 #endif /* defined(HAVE_HDF5_H) && defined(HAVE_LIBHDF5) */ 388 #endif /* !SILO_HDF5_PRIVATE_H */ 389