LCOV - code coverage report
Current view: top level - src/io/mhdf/src - sets.c (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 144 362 39.8 %
Date: 2020-12-16 07:07:30 Functions: 15 32 46.9 %
Branches: 46 158 29.1 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
       3                 :            :  * storing and accessing finite element mesh data.
       4                 :            :  *
       5                 :            :  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
       6                 :            :  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
       7                 :            :  * retains certain rights in this software.
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  */
      15                 :            : 
      16                 :            : #include <H5Tpublic.h>
      17                 :            : #include <H5Dpublic.h>
      18                 :            : #include <H5Gpublic.h>
      19                 :            : #include <H5Spublic.h>
      20                 :            : #include <H5Ppublic.h>
      21                 :            : #include "mhdf.h"
      22                 :            : #include "util.h"
      23                 :            : #include "file-handle.h"
      24                 :            : #include "status.h"
      25                 :            : #include "names-and-paths.h"
      26                 :            : 
      27                 :         68 : int mhdf_haveSets( mhdf_FileHandle file, int* have_data, int* have_child, int* have_parent, mhdf_Status* status )
      28                 :            : {
      29                 :         68 :     FileHandle* file_ptr = (FileHandle*)file;
      30                 :            :     hid_t       root_id, set_id;
      31                 :            :     int         result;
      32                 :            :     API_BEGIN;
      33                 :            : 
      34         [ -  + ]:         68 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
      35                 :            : 
      36                 :            : #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
      37                 :         68 :     root_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT );
      38                 :            : #else
      39                 :            :     root_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP );
      40                 :            : #endif
      41         [ -  + ]:         68 :     if( root_id < 0 )
      42                 :            :     {
      43                 :          0 :         mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", ROOT_GROUP );
      44                 :          0 :         return -1;
      45                 :            :     }
      46                 :            : 
      47                 :         68 :     result = mhdf_is_in_group( root_id, SET_GROUP_NAME, status );
      48         [ -  + ]:         68 :     if( result < 1 )
      49                 :            :     {
      50                 :          0 :         H5Gclose( root_id );
      51                 :          0 :         return result;
      52                 :            :     }
      53                 :            : 
      54                 :            : #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
      55                 :         68 :     set_id = H5Gopen2( root_id, SET_GROUP_NAME, H5P_DEFAULT );
      56                 :            : #else
      57                 :            :     set_id = H5Gopen( root_id, SET_GROUP_NAME );
      58                 :            : #endif
      59                 :         68 :     H5Gclose( root_id );
      60         [ -  + ]:         68 :     if( set_id < 0 )
      61                 :            :     {
      62                 :          0 :         mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", SET_GROUP );
      63                 :          0 :         return -1;
      64                 :            :     }
      65                 :            : 
      66                 :         68 :     result = mhdf_is_in_group( set_id, SET_META_NAME, status );
      67         [ -  + ]:         68 :     if( result < 0 )
      68                 :            :     {
      69                 :          0 :         H5Gclose( set_id );
      70                 :          0 :         return result;
      71                 :            :     }
      72                 :            : 
      73         [ +  - ]:         68 :     if( have_data )
      74                 :            :     {
      75                 :         68 :         *have_data = mhdf_is_in_group( set_id, SET_DATA_NAME, status );
      76         [ -  + ]:         68 :         if( *have_data < 0 )
      77                 :            :         {
      78                 :          0 :             H5Gclose( set_id );
      79                 :          0 :             return *have_data;
      80                 :            :         }
      81                 :            :     }
      82                 :            : 
      83         [ +  - ]:         68 :     if( have_child )
      84                 :            :     {
      85                 :         68 :         *have_child = mhdf_is_in_group( set_id, SET_CHILD_NAME, status );
      86         [ -  + ]:         68 :         if( *have_child < 0 )
      87                 :            :         {
      88                 :          0 :             H5Gclose( set_id );
      89                 :          0 :             return *have_child;
      90                 :            :         }
      91                 :            :     }
      92                 :            : 
      93         [ +  - ]:         68 :     if( have_parent )
      94                 :            :     {
      95                 :         68 :         *have_parent = mhdf_is_in_group( set_id, SET_PARENT_NAME, status );
      96         [ -  + ]:         68 :         if( *have_parent < 0 )
      97                 :            :         {
      98                 :          0 :             H5Gclose( set_id );
      99                 :          0 :             return *have_parent;
     100                 :            :         }
     101                 :            :     }
     102                 :            : 
     103                 :         68 :     mhdf_setOkay( status );
     104                 :         68 :     H5Gclose( set_id );
     105                 :            :     API_END;
     106                 :         68 :     return result;
     107                 :            : }
     108                 :            : 
     109                 :         39 : hid_t mhdf_createSetMeta( mhdf_FileHandle file, long num_sets, long* first_id_out, mhdf_Status* status )
     110                 :            : {
     111                 :         39 :     FileHandle* file_ptr = (FileHandle*)file;
     112                 :            :     hid_t       table_id;
     113                 :            :     hsize_t     dims[ 2 ];
     114                 :            :     long        first_id;
     115                 :            :     API_BEGIN;
     116                 :            : 
     117         [ -  + ]:         39 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     118                 :            : 
     119                 :         39 :     dims[ 0 ] = (hsize_t)num_sets;
     120                 :         39 :     dims[ 1 ] = (hsize_t)4;
     121                 :         39 :     table_id = mhdf_create_table( file_ptr->hdf_handle, SET_META_PATH, MHDF_INDEX_TYPE, 2, dims, status );
     122         [ -  + ]:         39 :     if( table_id < 0 ) return -1;
     123                 :            : 
     124                 :         39 :     first_id = file_ptr->max_id + 1;
     125         [ -  + ]:         39 :     if( !mhdf_create_scalar_attrib( table_id, START_ID_ATTRIB, H5T_NATIVE_LONG, &first_id, status ) )
     126                 :            :     {
     127                 :          0 :         H5Dclose( table_id );
     128                 :          0 :         return -1;
     129                 :            :     }
     130                 :            : 
     131                 :         39 :     *first_id_out = first_id;
     132                 :         39 :     file_ptr->max_id += num_sets;
     133         [ -  + ]:         39 :     if( !mhdf_write_max_id( file_ptr, status ) )
     134                 :            :     {
     135                 :          0 :         H5Dclose( table_id );
     136                 :          0 :         return -1;
     137                 :            :     }
     138                 :         39 :     file_ptr->open_handle_count++;
     139                 :         39 :     mhdf_setOkay( status );
     140                 :            : 
     141                 :            :     API_END_H( 1 );
     142                 :         39 :     return table_id;
     143                 :            : }
     144                 :            : 
     145                 :        107 : hid_t mhdf_openSetMeta( mhdf_FileHandle file, long* num_sets, long* first_id_out, mhdf_Status* status )
     146                 :            : {
     147                 :        107 :     FileHandle* file_ptr = (FileHandle*)file;
     148                 :            :     hid_t       table_id;
     149                 :            :     hsize_t     dims[ 2 ];
     150                 :            :     API_BEGIN;
     151                 :            : 
     152         [ -  + ]:        107 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     153                 :            : 
     154                 :        107 :     table_id = mhdf_open_table2( file_ptr->hdf_handle, SET_META_PATH, 2, dims, first_id_out, status );
     155         [ -  + ]:        107 :     if( table_id < 0 ) return -1;
     156                 :            : 
     157                 :            :     /* If dims[1] == 3, then old format of table.
     158                 :            :      * Deal with it in mhdf_readSetMeta and mhdf_writeSetMeta
     159                 :            :      */
     160 [ -  + ][ #  # ]:        107 :     if( dims[ 1 ] != 4 && dims[ 1 ] != 3 )
     161                 :            :     {
     162                 :          0 :         mhdf_setFail( status, "Invalid format for meshset table.\n" );
     163                 :          0 :         H5Dclose( table_id );
     164                 :          0 :         return -1;
     165                 :            :     }
     166                 :            : 
     167                 :        107 :     *num_sets = dims[ 0 ];
     168                 :        107 :     file_ptr->open_handle_count++;
     169                 :        107 :     mhdf_setOkay( status );
     170                 :            :     API_END_H( 1 );
     171                 :        107 :     return table_id;
     172                 :            : }
     173                 :            : 
     174                 :         66 : hid_t mhdf_openSetMetaSimple( mhdf_FileHandle file, mhdf_Status* status )
     175                 :            : {
     176                 :         66 :     FileHandle* file_ptr = (FileHandle*)file;
     177                 :            :     hid_t       table_id;
     178                 :            :     API_BEGIN;
     179                 :            : 
     180         [ -  + ]:         66 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     181                 :            : 
     182                 :         66 :     table_id = mhdf_open_table_simple( file_ptr->hdf_handle, SET_META_PATH, status );
     183         [ -  + ]:         66 :     if( table_id < 0 ) return -1;
     184                 :            : 
     185                 :         66 :     file_ptr->open_handle_count++;
     186                 :         66 :     mhdf_setOkay( status );
     187                 :            :     API_END_H( 1 );
     188                 :         66 :     return table_id;
     189                 :            : }
     190                 :            : 
     191                 :        105 : static int mhdf_readwriteSetMeta( hid_t table_id, int read, long offset, long count, hid_t type, void* data, hid_t prop,
     192                 :            :                                   mhdf_Status* status )
     193                 :            : {
     194                 :            :     hid_t         slab_id, sslab_id, smem_id, mem_id;
     195                 :        105 :     hsize_t       offsets[ 2 ], counts[ 2 ], mcounts[ 2 ], moffsets[ 2 ] = { 0, 0 };
     196                 :        105 :     herr_t        rval = 0;
     197                 :            :     int           dims, i;
     198                 :        105 :     const int     fill_val = -1;
     199                 :        105 :     const hsize_t one = 1;
     200                 :            : 
     201                 :        105 :     mcounts[ 0 ] = count;
     202                 :        105 :     mcounts[ 1 ] = 4;
     203 [ +  - ][ -  + ]:        105 :     if( offset < 0 || count < 0 )
     204                 :            :     {
     205         [ #  # ]:          0 :         mhdf_setFail( status,
     206                 :            :                       "Invalid input for %s: "
     207                 :            :                       "offset = %ld, count = %ld\n",
     208                 :            :                       read ? "read" : "write", offset, count );
     209                 :          0 :         return 0;
     210                 :            :     }
     211                 :            : 
     212                 :        105 :     slab_id = H5Dget_space( table_id );
     213         [ -  + ]:        105 :     if( slab_id < 0 )
     214                 :            :     {
     215                 :          0 :         mhdf_setFail( status, "Internal error calling H5Dget_space." );
     216                 :          0 :         return 0;
     217                 :            :     }
     218                 :            : 
     219                 :        105 :     dims = H5Sget_simple_extent_ndims( slab_id );
     220         [ -  + ]:        105 :     if( dims != 2 )
     221                 :            :     {
     222                 :          0 :         H5Sclose( slab_id );
     223                 :          0 :         mhdf_setFail( status, "Internal error: unexpected dataset rank: %d.", dims );
     224                 :          0 :         return 0;
     225                 :            :     }
     226                 :            : 
     227                 :        105 :     dims = H5Sget_simple_extent_dims( slab_id, counts, NULL );
     228         [ -  + ]:        105 :     if( dims < 0 )
     229                 :            :     {
     230                 :          0 :         H5Sclose( slab_id );
     231                 :          0 :         mhdf_setFail( status, "Internal error calling H5Sget_simple_extend_dims." );
     232                 :          0 :         return 0;
     233                 :            :     }
     234                 :            : 
     235         [ -  + ]:        105 :     if( (unsigned long)( offset + count ) > counts[ 0 ] )
     236                 :            :     {
     237                 :          0 :         H5Sclose( slab_id );
     238         [ #  # ]:          0 :         mhdf_setFail( status, "Requested %s of rows %ld to %ld of a %ld row table.\n", read ? "read" : "write", offset,
     239                 :          0 :                       offset + count - 1, (long)counts[ dims - 1 ] );
     240                 :          0 :         return 0;
     241                 :            :     }
     242                 :        105 :     counts[ 0 ] = (hsize_t)count;
     243                 :        105 :     offsets[ 0 ] = (hsize_t)offset;
     244                 :            : 
     245         [ +  - ]:        105 :     if( count )
     246                 :        105 :         mem_id = H5Screate_simple( dims, mcounts, NULL );
     247                 :            :     else
     248                 :            :     { /* special case for 'NULL' read during collective parallel IO */
     249                 :          0 :         mem_id = H5Screate_simple( 1, &one, NULL );
     250 [ #  # ][ #  # ]:          0 :         if( mem_id && 0 > H5Sselect_none( mem_id ) )
     251                 :            :         {
     252                 :          0 :             H5Sclose( mem_id );
     253                 :          0 :             mem_id = -1;
     254                 :            :         }
     255                 :            :     }
     256         [ -  + ]:        105 :     if( mem_id < 0 )
     257                 :            :     {
     258                 :          0 :         mhdf_setFail( status, "Internal error calling H5Screate_simple." );
     259                 :          0 :         return 0;
     260                 :            :     }
     261                 :            : 
     262                 :            :     /* Normal table: 4 columns */
     263         [ +  - ]:        105 :     if( counts[ 1 ] == 4 )
     264                 :            :     {
     265                 :        105 :         offsets[ 1 ] = 0;
     266         [ +  - ]:        105 :         if( count )
     267                 :        105 :             rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
     268                 :            :         else /* special case for 'NULL' read during collective parallel IO */
     269                 :          0 :             rval = H5Sselect_none( slab_id );
     270         [ -  + ]:        105 :         if( rval < 0 )
     271                 :            :         {
     272                 :          0 :             H5Sclose( mem_id );
     273                 :          0 :             H5Sclose( slab_id );
     274                 :          0 :             mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
     275                 :          0 :             return 0;
     276                 :            :         }
     277                 :            : 
     278         [ +  + ]:        105 :         if( read )
     279                 :         66 :             rval = H5Dread( table_id, type, mem_id, slab_id, prop, data );
     280                 :            :         else
     281                 :        105 :             rval = H5Dwrite( table_id, type, mem_id, slab_id, prop, data );
     282                 :            :     }
     283                 :            :     /* Old table: 3 columns, no parent link counts */
     284         [ #  # ]:          0 :     else if( counts[ 1 ] == 3 )
     285                 :            :     {
     286                 :          0 :         rval = 0;
     287 [ #  # ][ #  # ]:          0 :         for( i = 0; i < 3 && rval >= 0; ++i )
     288                 :            :         {
     289                 :          0 :             smem_id = H5Scopy( mem_id );
     290                 :          0 :             sslab_id = H5Scopy( slab_id );
     291 [ #  # ][ #  # ]:          0 :             if( smem_id < 0 || sslab_id < 0 )
     292                 :            :             {
     293         [ #  # ]:          0 :                 if( smem_id >= 0 ) H5Sclose( smem_id );
     294                 :          0 :                 mhdf_setFail( status, "Internal error calling H5Scopy." );
     295                 :          0 :                 return 0;
     296                 :            :             }
     297                 :            : 
     298                 :          0 :             counts[ 1 ] = 1;
     299                 :          0 :             offsets[ 1 ] = i;
     300         [ #  # ]:          0 :             if( count )
     301                 :          0 :                 rval = H5Sselect_hyperslab( sslab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
     302                 :            :             else
     303                 :          0 :                 rval = H5Sselect_none( sslab_id );
     304         [ #  # ]:          0 :             if( rval < 0 )
     305                 :            :             {
     306                 :          0 :                 H5Sclose( slab_id );
     307                 :          0 :                 H5Sclose( mem_id );
     308                 :          0 :                 mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
     309                 :          0 :                 return 0;
     310                 :            :             }
     311                 :            : 
     312                 :          0 :             mcounts[ 1 ] = 1;
     313         [ #  # ]:          0 :             moffsets[ 1 ] = ( i == 2 ) ? 3 : i;
     314                 :          0 :             rval = H5Sselect_hyperslab( smem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL );
     315         [ #  # ]:          0 :             if( rval < 0 )
     316                 :            :             {
     317                 :          0 :                 H5Sclose( sslab_id );
     318                 :          0 :                 H5Sclose( slab_id );
     319                 :          0 :                 H5Sclose( mem_id );
     320                 :          0 :                 mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
     321                 :          0 :                 return 0;
     322                 :            :             }
     323                 :            : 
     324         [ #  # ]:          0 :             if( read )
     325                 :          0 :                 rval = H5Dread( table_id, type, smem_id, sslab_id, prop, data );
     326                 :            :             else
     327                 :          0 :                 rval = H5Dwrite( table_id, type, smem_id, sslab_id, prop, data );
     328                 :            : 
     329                 :          0 :             H5Sclose( sslab_id );
     330                 :          0 :             H5Sclose( smem_id );
     331                 :            :         }
     332                 :            : 
     333 [ #  # ][ #  # ]:          0 :         if( read && rval >= 0 )
     334                 :            :         {
     335                 :          0 :             mcounts[ 1 ] = 1;
     336                 :          0 :             moffsets[ 1 ] = 2;
     337                 :          0 :             H5Sselect_hyperslab( mem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL );
     338                 :          0 :             rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id );
     339                 :            :         }
     340                 :            :     }
     341                 :            :     else
     342                 :            :     {
     343                 :          0 :         H5Sclose( mem_id );
     344                 :          0 :         H5Sclose( slab_id );
     345                 :          0 :         mhdf_setFail( status, "Invalid dimension for meshset metadata table." );
     346                 :          0 :         return 0;
     347                 :            :     }
     348                 :            : 
     349                 :        105 :     H5Sclose( slab_id );
     350                 :        105 :     H5Sclose( mem_id );
     351         [ -  + ]:        105 :     if( rval < 0 )
     352                 :            :     {
     353         [ #  # ]:          0 :         mhdf_setFail( status, "Internal error calling H5D%s.", read ? "read" : "write" );
     354                 :          0 :         return 0;
     355                 :            :     }
     356                 :            : 
     357                 :        105 :     mhdf_setOkay( status );
     358                 :        105 :     return 1;
     359                 :            : }
     360                 :            : 
     361                 :          0 : void mhdf_readSetMeta( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
     362                 :            : {
     363                 :            :     API_BEGIN;
     364                 :          0 :     mhdf_readwriteSetMeta( table_id, 1, offset, count, type, data, H5P_DEFAULT, status );
     365                 :            :     API_END;
     366                 :          0 : }
     367                 :         66 : void mhdf_readSetMetaWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     368                 :            :                               mhdf_Status* status )
     369                 :            : {
     370                 :            :     API_BEGIN;
     371                 :         66 :     mhdf_readwriteSetMeta( table_id, 1, offset, count, type, data, prop, status );
     372                 :            :     API_END;
     373                 :         66 : }
     374                 :            : 
     375                 :          0 : void mhdf_writeSetMeta( hid_t table_id, long offset, long count, hid_t type, const void* data, mhdf_Status* status )
     376                 :            : {
     377                 :            :     API_BEGIN;
     378                 :          0 :     mhdf_readwriteSetMeta( table_id, 0, offset, count, type, (void*)data, H5P_DEFAULT, status );
     379                 :            :     API_END;
     380                 :          0 : }
     381                 :         39 : void mhdf_writeSetMetaWithOpt( hid_t table_id, long offset, long count, hid_t type, const void* data, hid_t prop,
     382                 :            :                                mhdf_Status* status )
     383                 :            : {
     384                 :            :     API_BEGIN;
     385                 :         39 :     mhdf_readwriteSetMeta( table_id, 0, offset, count, type, (void*)data, prop, status );
     386                 :            :     API_END;
     387                 :         39 : }
     388                 :            : 
     389                 :            : enum SetMetaCol
     390                 :            : {
     391                 :            :     CONTENT = 0,
     392                 :            :     CHILDREN = 1,
     393                 :            :     PARENTS = 2,
     394                 :            :     FLAGS = 3
     395                 :            : };
     396                 :            : 
     397                 :          0 : static int mhdf_readSetMetaColumn( hid_t table_id, enum SetMetaCol column, long offset, long count, hid_t type,
     398                 :            :                                    void* data, hid_t prop, mhdf_Status* status )
     399                 :            : {
     400                 :            :     hid_t     slab_id, mem_id;
     401                 :          0 :     hsize_t   offsets[ 2 ], counts[ 2 ], mcount = count;
     402                 :          0 :     herr_t    rval = 0;
     403                 :            :     int       dims;
     404                 :          0 :     const int fill_val = -1;
     405                 :            : 
     406 [ #  # ][ #  # ]:          0 :     if( offset < 0 || count < 0 )
     407                 :            :     {
     408                 :          0 :         mhdf_setFail( status,
     409                 :            :                       "Invalid input for reading set description column: "
     410                 :            :                       "offset = %ld, count = %ld\n",
     411                 :            :                       offset, count );
     412                 :          0 :         return 0;
     413                 :            :     }
     414                 :            : 
     415                 :            :     /* Get dimensions of table, and check against requested count and offset */
     416                 :            : 
     417                 :          0 :     slab_id = H5Dget_space( table_id );
     418         [ #  # ]:          0 :     if( slab_id < 0 )
     419                 :            :     {
     420                 :          0 :         mhdf_setFail( status, "Internal error calling H5Dget_space." );
     421                 :          0 :         return 0;
     422                 :            :     }
     423                 :            : 
     424                 :          0 :     dims = H5Sget_simple_extent_ndims( slab_id );
     425         [ #  # ]:          0 :     if( dims != 2 )
     426                 :            :     {
     427                 :          0 :         H5Sclose( slab_id );
     428                 :          0 :         mhdf_setFail( status, "Internal error: unexpected dataset rank: %d.", dims );
     429                 :          0 :         return 0;
     430                 :            :     }
     431                 :            : 
     432                 :          0 :     dims = H5Sget_simple_extent_dims( slab_id, counts, NULL );
     433         [ #  # ]:          0 :     if( dims < 0 )
     434                 :            :     {
     435                 :          0 :         H5Sclose( slab_id );
     436                 :          0 :         mhdf_setFail( status, "Internal error calling H5Sget_simple_extend_dims." );
     437                 :          0 :         return 0;
     438                 :            :     }
     439                 :            : 
     440         [ #  # ]:          0 :     if( (unsigned long)( offset + count ) > counts[ 0 ] )
     441                 :            :     {
     442                 :          0 :         H5Sclose( slab_id );
     443                 :          0 :         mhdf_setFail( status, "Requested read of rows %ld to %ld of a %ld row table.\n", offset, offset + count - 1,
     444                 :          0 :                       (long)counts[ 0 ] );
     445                 :          0 :         return 0;
     446                 :            :     }
     447                 :            : 
     448                 :            :     /* Create a slab definition for the block of memory we're reading into */
     449                 :            : 
     450                 :          0 :     mem_id = H5Screate_simple( 1, &mcount, NULL );
     451         [ #  # ]:          0 :     if( mem_id < 0 )
     452                 :            :     {
     453                 :          0 :         H5Sclose( slab_id );
     454                 :          0 :         mhdf_setFail( status, "Internal error calling H5Screate_simple." );
     455                 :          0 :         return 0;
     456                 :            :     }
     457                 :            : 
     458                 :            :     /* Old, 3-column table.
     459                 :            :      * New table is {contents, children, parents, flags}
     460                 :            :      * Old table is {contents, children, flags}
     461                 :            :      * If asking for parents, just return zeros.
     462                 :            :      * If asking for flags, fix column value.
     463                 :            :      */
     464                 :          0 :     offsets[ 1 ] = column;
     465         [ #  # ]:          0 :     if( counts[ 1 ] == 3 )
     466                 :            :     {
     467         [ #  # ]:          0 :         if( column == PARENTS )
     468                 :            :         {
     469                 :          0 :             rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id );
     470                 :          0 :             H5Sclose( mem_id );
     471                 :          0 :             H5Sclose( slab_id );
     472         [ #  # ]:          0 :             if( rval < 0 )
     473                 :            :             {
     474                 :          0 :                 mhdf_setFail( status, "Internal error calling H5Dfill" );
     475                 :          0 :                 return 0;
     476                 :            :             }
     477                 :            :             else
     478                 :            :             {
     479                 :          0 :                 mhdf_setOkay( status );
     480                 :          0 :                 return 1;
     481                 :            :             }
     482                 :            :         }
     483         [ #  # ]:          0 :         else if( column == FLAGS )
     484                 :          0 :             --offsets[ 1 ];
     485                 :            :     }
     486         [ #  # ]:          0 :     else if( counts[ 1 ] != 4 )
     487                 :            :     {
     488                 :          0 :         H5Sclose( mem_id );
     489                 :          0 :         H5Sclose( slab_id );
     490                 :          0 :         mhdf_setFail( status, "Invalid dimension for meshset metadata table." );
     491                 :          0 :         return 0;
     492                 :            :     }
     493                 :            : 
     494                 :            :     /* Create a slab defintion for the portion of the table we want to read. */
     495                 :            : 
     496                 :            :     /* offsets[1] was initialized in the above block of code. */
     497                 :          0 :     offsets[ 0 ] = (hsize_t)offset;
     498                 :          0 :     counts[ 0 ] = (hsize_t)count;
     499                 :          0 :     counts[ 1 ] = 1; /* one column */
     500         [ #  # ]:          0 :     if( count )
     501                 :          0 :         rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
     502                 :            :     else
     503                 :          0 :         rval = H5Sselect_none( slab_id );
     504         [ #  # ]:          0 :     if( rval < 0 )
     505                 :            :     {
     506                 :          0 :         H5Sclose( mem_id );
     507                 :          0 :         H5Sclose( slab_id );
     508                 :          0 :         mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." );
     509                 :          0 :         return 0;
     510                 :            :     }
     511                 :            : 
     512                 :            :     /* Read the data */
     513                 :            : 
     514                 :          0 :     rval = H5Dread( table_id, type, mem_id, slab_id, prop, data );
     515                 :          0 :     H5Sclose( mem_id );
     516                 :          0 :     H5Sclose( slab_id );
     517         [ #  # ]:          0 :     if( rval < 0 )
     518                 :            :     {
     519                 :          0 :         mhdf_setFail( status, "Internal error calling H5Dread." );
     520                 :          0 :         return 0;
     521                 :            :     }
     522                 :            : 
     523                 :          0 :     mhdf_setOkay( status );
     524                 :          0 :     return 1;
     525                 :            : }
     526                 :            : 
     527                 :          0 : void mhdf_readSetFlags( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
     528                 :            : {
     529                 :            :     API_BEGIN;
     530                 :          0 :     mhdf_readSetMetaColumn( table_id, FLAGS, offset, count, type, data, H5P_DEFAULT, status );
     531                 :            :     API_END;
     532                 :          0 : }
     533                 :          0 : void mhdf_readSetFlagsWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     534                 :            :                                mhdf_Status* status )
     535                 :            : {
     536                 :            :     API_BEGIN;
     537                 :          0 :     mhdf_readSetMetaColumn( table_id, FLAGS, offset, count, type, data, prop, status );
     538                 :            :     API_END;
     539                 :          0 : }
     540                 :            : 
     541                 :          0 : void mhdf_readSetContentEndIndices( hid_t table_id, long offset, long count, hid_t type, void* data,
     542                 :            :                                     mhdf_Status* status )
     543                 :            : {
     544                 :            :     API_BEGIN;
     545                 :          0 :     mhdf_readSetMetaColumn( table_id, CONTENT, offset, count, type, data, H5P_DEFAULT, status );
     546                 :            :     API_END;
     547                 :          0 : }
     548                 :          0 : void mhdf_readSetContentEndIndicesWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     549                 :            :                                            mhdf_Status* status )
     550                 :            : {
     551                 :            :     API_BEGIN;
     552                 :          0 :     mhdf_readSetMetaColumn( table_id, CONTENT, offset, count, type, data, prop, status );
     553                 :            :     API_END;
     554                 :          0 : }
     555                 :            : 
     556                 :          0 : void mhdf_readSetChildEndIndices( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
     557                 :            : {
     558                 :            :     API_BEGIN;
     559                 :          0 :     mhdf_readSetMetaColumn( table_id, CHILDREN, offset, count, type, data, H5P_DEFAULT, status );
     560                 :            :     API_END;
     561                 :          0 : }
     562                 :          0 : void mhdf_readSetChildEndIndicesWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     563                 :            :                                          mhdf_Status* status )
     564                 :            : {
     565                 :            :     API_BEGIN;
     566                 :          0 :     mhdf_readSetMetaColumn( table_id, CHILDREN, offset, count, type, data, prop, status );
     567                 :            :     API_END;
     568                 :          0 : }
     569                 :            : 
     570                 :          0 : void mhdf_readSetParentEndIndices( hid_t table_id, long offset, long count, hid_t type, void* data,
     571                 :            :                                    mhdf_Status* status )
     572                 :            : {
     573                 :            :     API_BEGIN;
     574                 :          0 :     mhdf_readSetMetaColumn( table_id, PARENTS, offset, count, type, data, H5P_DEFAULT, status );
     575                 :            :     API_END;
     576                 :          0 : }
     577                 :          0 : void mhdf_readSetParentEndIndicesWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     578                 :            :                                           mhdf_Status* status )
     579                 :            : {
     580                 :            :     API_BEGIN;
     581                 :          0 :     mhdf_readSetMetaColumn( table_id, PARENTS, offset, count, type, data, prop, status );
     582                 :            :     API_END;
     583                 :          0 : }
     584                 :            : 
     585                 :         38 : hid_t mhdf_createSetData( mhdf_FileHandle file_handle, long data_list_size, mhdf_Status* status )
     586                 :            : {
     587                 :            :     FileHandle* file_ptr;
     588                 :            :     hid_t       table_id;
     589                 :         38 :     hsize_t     dim = (hsize_t)data_list_size;
     590                 :            :     API_BEGIN;
     591                 :            : 
     592                 :         38 :     file_ptr = (FileHandle*)( file_handle );
     593         [ -  + ]:         38 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     594                 :            : 
     595         [ -  + ]:         38 :     if( data_list_size < 1 )
     596                 :            :     {
     597                 :          0 :         mhdf_setFail( status, "Invalid argument.\n" );
     598                 :          0 :         return -1;
     599                 :            :     }
     600                 :            : 
     601                 :         38 :     table_id = mhdf_create_table( file_ptr->hdf_handle, SET_DATA_PATH, file_ptr->id_type, 1, &dim, status );
     602                 :            : 
     603                 :            :     API_END_H( 1 );
     604                 :         38 :     return table_id;
     605                 :            : }
     606                 :            : 
     607                 :        103 : hid_t mhdf_openSetData( mhdf_FileHandle file_handle, long* data_list_size_out, mhdf_Status* status )
     608                 :            : {
     609                 :            :     FileHandle* file_ptr;
     610                 :            :     hid_t       table_id;
     611                 :            :     hsize_t     dim;
     612                 :            :     API_BEGIN;
     613                 :            : 
     614                 :        103 :     file_ptr = (FileHandle*)( file_handle );
     615         [ -  + ]:        103 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     616                 :            : 
     617         [ -  + ]:        103 :     if( !data_list_size_out )
     618                 :            :     {
     619                 :          0 :         mhdf_setFail( status, "Invalid argument.\n" );
     620                 :          0 :         return -1;
     621                 :            :     }
     622                 :            : 
     623                 :        103 :     table_id = mhdf_open_table( file_ptr->hdf_handle, SET_DATA_PATH, 1, &dim, status );
     624                 :            : 
     625                 :        103 :     *data_list_size_out = (long)dim;
     626                 :            :     API_END_H( 1 );
     627                 :        103 :     return table_id;
     628                 :            : }
     629                 :            : 
     630                 :          0 : void mhdf_writeSetData( hid_t table_id, long offset, long count, hid_t type, const void* data, mhdf_Status* status )
     631                 :            : {
     632                 :            :     API_BEGIN;
     633                 :          0 :     mhdf_write_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
     634                 :            :     API_END;
     635                 :          0 : }
     636                 :         38 : void mhdf_writeSetDataWithOpt( hid_t table_id, long offset, long count, hid_t type, const void* data, hid_t prop,
     637                 :            :                                mhdf_Status* status )
     638                 :            : {
     639                 :            :     API_BEGIN;
     640                 :         38 :     mhdf_write_data( table_id, offset, count, type, data, prop, status );
     641                 :            :     API_END;
     642                 :         38 : }
     643                 :            : 
     644                 :          0 : void mhdf_readSetData( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
     645                 :            : {
     646                 :            :     API_BEGIN;
     647                 :          0 :     mhdf_read_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
     648                 :            :     API_END;
     649                 :          0 : }
     650                 :          0 : void mhdf_readSetDataWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     651                 :            :                               mhdf_Status* status )
     652                 :            : {
     653                 :            :     API_BEGIN;
     654                 :          0 :     mhdf_read_data( table_id, offset, count, type, data, prop, status );
     655                 :            :     API_END;
     656                 :          0 : }
     657                 :            : 
     658                 :         16 : hid_t mhdf_createSetChildren( mhdf_FileHandle file_handle, long child_list_size, mhdf_Status* status )
     659                 :            : {
     660                 :            :     FileHandle* file_ptr;
     661                 :            :     hid_t       table_id;
     662                 :         16 :     hsize_t     dim = (hsize_t)child_list_size;
     663                 :            :     API_BEGIN;
     664                 :            : 
     665                 :         16 :     file_ptr = (FileHandle*)( file_handle );
     666         [ -  + ]:         16 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     667                 :            : 
     668         [ -  + ]:         16 :     if( child_list_size < 1 )
     669                 :            :     {
     670                 :          0 :         mhdf_setFail( status, "Invalid argument.\n" );
     671                 :          0 :         return -1;
     672                 :            :     }
     673                 :            : 
     674                 :         16 :     table_id = mhdf_create_table( file_ptr->hdf_handle, SET_CHILD_PATH, file_ptr->id_type, 1, &dim, status );
     675                 :            : 
     676                 :            :     API_END_H( 1 );
     677                 :         16 :     return table_id;
     678                 :            : }
     679                 :            : 
     680                 :         57 : hid_t mhdf_openSetChildren( mhdf_FileHandle file_handle, long* child_list_size, mhdf_Status* status )
     681                 :            : {
     682                 :            :     FileHandle* file_ptr;
     683                 :            :     hid_t       table_id;
     684                 :            :     hsize_t     dim;
     685                 :            :     API_BEGIN;
     686                 :            : 
     687                 :         57 :     file_ptr = (FileHandle*)( file_handle );
     688         [ -  + ]:         57 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     689                 :            : 
     690         [ -  + ]:         57 :     if( !child_list_size )
     691                 :            :     {
     692                 :          0 :         mhdf_setFail( status, "Invalid argument.\n" );
     693                 :          0 :         return -1;
     694                 :            :     }
     695                 :            : 
     696                 :         57 :     table_id = mhdf_open_table( file_ptr->hdf_handle, SET_CHILD_PATH, 1, &dim, status );
     697                 :            : 
     698                 :         57 :     *child_list_size = (long)dim;
     699                 :            :     API_END_H( 1 );
     700                 :         57 :     return table_id;
     701                 :            : }
     702                 :            : 
     703                 :         15 : hid_t mhdf_createSetParents( mhdf_FileHandle file_handle, long parent_list_size, mhdf_Status* status )
     704                 :            : {
     705                 :            :     FileHandle* file_ptr;
     706                 :            :     hid_t       table_id;
     707                 :         15 :     hsize_t     dim = (hsize_t)parent_list_size;
     708                 :            :     API_BEGIN;
     709                 :            : 
     710                 :         15 :     file_ptr = (FileHandle*)( file_handle );
     711         [ -  + ]:         15 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     712                 :            : 
     713         [ -  + ]:         15 :     if( parent_list_size < 1 )
     714                 :            :     {
     715                 :          0 :         mhdf_setFail( status, "Invalid argument.\n" );
     716                 :          0 :         return -1;
     717                 :            :     }
     718                 :            : 
     719                 :         15 :     table_id = mhdf_create_table( file_ptr->hdf_handle, SET_PARENT_PATH, file_ptr->id_type, 1, &dim, status );
     720                 :            : 
     721                 :            :     API_END_H( 1 );
     722                 :         15 :     return table_id;
     723                 :            : }
     724                 :            : 
     725                 :         55 : hid_t mhdf_openSetParents( mhdf_FileHandle file_handle, long* parent_list_size, mhdf_Status* status )
     726                 :            : {
     727                 :            :     FileHandle* file_ptr;
     728                 :            :     hid_t       table_id;
     729                 :            :     hsize_t     dim;
     730                 :            :     API_BEGIN;
     731                 :            : 
     732                 :         55 :     file_ptr = (FileHandle*)( file_handle );
     733         [ -  + ]:         55 :     if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
     734                 :            : 
     735         [ -  + ]:         55 :     if( !parent_list_size )
     736                 :            :     {
     737                 :          0 :         mhdf_setFail( status, "Invalid argument.\n" );
     738                 :          0 :         return -1;
     739                 :            :     }
     740                 :            : 
     741                 :         55 :     table_id = mhdf_open_table( file_ptr->hdf_handle, SET_PARENT_PATH, 1, &dim, status );
     742                 :            : 
     743                 :         55 :     *parent_list_size = (long)dim;
     744                 :            :     API_END_H( 1 );
     745                 :         55 :     return table_id;
     746                 :            : }
     747                 :            : 
     748                 :          0 : void mhdf_writeSetParentsChildren( hid_t table_id, long offset, long count, hid_t type, const void* data,
     749                 :            :                                    mhdf_Status* status )
     750                 :            : {
     751                 :            :     API_BEGIN;
     752                 :          0 :     mhdf_write_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
     753                 :            :     API_END;
     754                 :          0 : }
     755                 :         31 : void mhdf_writeSetParentsChildrenWithOpt( hid_t table_id, long offset, long count, hid_t type, const void* data,
     756                 :            :                                           hid_t prop, mhdf_Status* status )
     757                 :            : {
     758                 :            :     API_BEGIN;
     759                 :         31 :     mhdf_write_data( table_id, offset, count, type, data, prop, status );
     760                 :            :     API_END;
     761                 :         31 : }
     762                 :            : 
     763                 :          0 : void mhdf_readSetParentsChildren( hid_t table_id, long offset, long count, hid_t type, void* data, mhdf_Status* status )
     764                 :            : {
     765                 :            :     API_BEGIN;
     766                 :          0 :     mhdf_read_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
     767                 :            :     API_END;
     768                 :          0 : }
     769                 :          0 : void mhdf_readSetParentsChildrenWithOpt( hid_t table_id, long offset, long count, hid_t type, void* data, hid_t prop,
     770                 :            :                                          mhdf_Status* status )
     771                 :            : {
     772                 :            :     API_BEGIN;
     773                 :          0 :     mhdf_read_data( table_id, offset, count, type, data, prop, status );
     774                 :            :     API_END;
     775                 :          0 : }

Generated by: LCOV version 1.11