Re: question about closing resources in HDF5

Hi Ed,

> 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?)
    Yes.

> 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?
    Hmm, I'm a little confused - in the code below, you are calling H5Gclose(),
not H5Fclose().  Does changing that fix the problem?

    Quincey

> Ed
> 
> #include "tests.h"
> 
> #define FILE_NAME "tst_h_files.h5"
> #define GRP_NAME "Dectectives"
> 
> int
> main()
> {
>    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
>