Re: question about closing resources in HDF5

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.


I'm trying to use H5Pset_fclose_degree, but it's not working for me
the way I expect. In the very simple program below, I create a file,
first setting fclose_degree to SEMI. (That's supposed to be called on
the file access property list, correct?)

Then I create a group, and close the file without closing the group
first. I expect H5Fclose to give me an error, since I haven't closed
the group. Instead, it behaves as if H5F_CLOSE_SEMI hadn't been used
at all.

In fact, the H5Fclose returns zero.

Am I missing something here?


#include "tests.h"

#define FILE_NAME "tst_h_files.h5"
#define GRP_NAME "Dectectives"

   hid_t fileid, grpid, access_plist;

   printf("*** Checking HDF5 file creates and opens...");

   /* Set the access list so that closes will fail if something is
    * still open in the file. */
   if ((access_plist = H5Pcreate(H5P_FILE_ACCESS)) < 0) ERR;
   if (H5Pset_fclose_degree(access_plist, H5F_CLOSE_SEMI)) ERR;

   /* Open file and create group. */
   if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, 
                           access_plist)) < 0) ERR;
   if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;

   /* This H5Fclose should fail, because I didn't close the group. */
   if (H5Gclose(grpid) >= 0) ERR;

Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: