Example #1
0
int main(){
  hid_t fprop;
  hid_t fid;
  hid_t vol_id = H5VL_memvol_init();
  herr_t status;

  hid_t g1, g2;
  hid_t plist;

  char name[1024];

  fprop = H5Pcreate(H5P_FILE_ACCESS);
  H5Pset_vol(fprop, vol_id, &fprop);

  fid = H5Fcreate("test", H5F_ACC_TRUNC, H5P_DEFAULT, fprop);
  H5VLget_plugin_name(fid, name, 1024);
  printf ("Using VOL %s\n", name);

  g1 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  H5Gclose(g1);

  g2 = H5Gcreate2(fid, "g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  g1 = H5Gcreate2(g2, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  H5Gclose(g1);
  H5Gclose(g2);

  // is this allowed?
  //g3 = H5Gcreate2(fid, "g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  //H5Gclose(g3);

  printf("Testing additional functions\n");
  g1 = H5Gopen2(fid, "g1", H5P_DEFAULT );
  plist = H5Gget_create_plist(g1);
  H5G_info_t group_info;
  H5Gget_info(g1, & group_info );

  H5Gget_info_by_idx(fid, "g1",  H5_INDEX_CRT_ORDER,  H5_ITER_NATIVE, 0, & group_info, H5P_DEFAULT ) ;
  H5Gget_info_by_idx(fid, "g1",  H5_INDEX_NAME,  H5_ITER_NATIVE, 0, & group_info, H5P_DEFAULT ) ;
  H5Gget_info_by_name(fid, "g1", & group_info, H5P_DEFAULT);
  H5Pclose(plist);

  status = H5Gclose(g1);
  g1 = H5Gopen2(fid, "g2", H5P_DEFAULT );
  H5Gclose(g1);
  //g1 = H5Gopen2(fid, "INVALID", H5P_DEFAULT );
  //H5Gclose(g1);

  g1 =  H5Gcreate_anon( fid, H5P_DEFAULT, H5P_DEFAULT );
  H5Gclose(g1);

  H5Fclose(fid);
  H5VL_memvol_finalize();


  printf("Status: %d\n", status);

  return 0;
}
Example #2
0
/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Gget_create_plist
 * Signature: (J)J
 */
JNIEXPORT jlong JNICALL
Java_hdf_hdf5lib_H5_H5Gget_1create_1plist(JNIEnv *env, jclass cls, jlong loc_id)
{
    hid_t plist_id = H5Gget_create_plist((hid_t)loc_id);

    if (plist_id < 0)
        h5libraryError(env);

    return (jlong)plist_id;
} /* end Java_hdf_hdf5lib_H5_H5Gget_1create_1plist */
int h5repack_cmp_pl(const char *fname1,
                     const char *fname2)
{
    int           ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
    hid_t         fid1=-1;         /* file ID */
    hid_t         fid2=-1;         /* file ID */
    hid_t         dset1=-1;        /* dataset ID */
    hid_t         dset2=-1;        /* dataset ID */
    hid_t         gid=-1;          /* group ID */
    hid_t         dcpl1=-1;        /* dataset creation property list ID */
    hid_t         dcpl2=-1;        /* dataset creation property list ID */
    hid_t         gcplid=-1;       /* group creation property list */
    unsigned      crt_order_flag1; /* group creation order flag */
    unsigned      crt_order_flag2; /* group creation order flag */
    trav_table_t  *trav=NULL;
    int           ret=1;
    unsigned int  i;

   /*-------------------------------------------------------------------------
    * open the files
    *-------------------------------------------------------------------------
    */

    /* disable error reporting */
    H5E_BEGIN_TRY
    {

        /* Open the files */
        if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
        {
            error_msg("<%s>: %s\n", fname1, H5FOPENERROR );
            return -1;
        }
        if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
        {
            error_msg("<%s>: %s\n", fname2, H5FOPENERROR );
            H5Fclose(fid1);
            return -1;
        }
        /* enable error reporting */
    } H5E_END_TRY;

   /*-------------------------------------------------------------------------
    * get file table list of objects
    *-------------------------------------------------------------------------
    */
    trav_table_init(&trav);
    if(h5trav_gettable(fid1, trav) < 0)
        HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");

   /*-------------------------------------------------------------------------
    * traverse the suppplied object list
    *-------------------------------------------------------------------------
    */
    for(i = 0; i < trav->nobjs; i++)
    {

        if(trav->objs[i].type == H5TRAV_TYPE_GROUP)
        {

            if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
            if ((gcplid = H5Gget_create_plist(gid)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
            if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
            if (H5Pclose(gcplid) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
            if (H5Gclose(gid) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");

            if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
            if ((gcplid = H5Gget_create_plist(gid)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
            if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
            if (H5Pclose(gcplid) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
            if (H5Gclose(gid) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");

            if (crt_order_flag1 != crt_order_flag2) {
                error_msg("property lists for <%s> are different\n",trav->objs[i].name);
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
            }

        }



        else if(trav->objs[i].type == H5TRAV_TYPE_DATASET)
        {
            if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
            if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
            if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
            if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");

           /*-------------------------------------------------------------------------
            * compare the property lists
            *-------------------------------------------------------------------------
            */
            if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");

            if(ret == 0) {
                error_msg("property lists for <%s> are different\n",trav->objs[i].name);
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
            }

           /*-------------------------------------------------------------------------
            * close
            *-------------------------------------------------------------------------
            */
            if(H5Pclose(dcpl1) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
            if(H5Pclose(dcpl2) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
            if(H5Dclose(dset1) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
            if(H5Dclose(dset2) < 0)
                HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
        } /*if*/
    } /*i*/

   /*-------------------------------------------------------------------------
    * free
    *-------------------------------------------------------------------------
    */

    trav_table_free(trav);

   /*-------------------------------------------------------------------------
    * close
    *-------------------------------------------------------------------------
    */

    H5Fclose(fid1);
    H5Fclose(fid2);

    return ret;

/*-------------------------------------------------------------------------
* error
*-------------------------------------------------------------------------
*/
done:
    H5E_BEGIN_TRY
    {
        H5Pclose(dcpl1);
        H5Pclose(dcpl2);
        H5Dclose(dset1);
        H5Dclose(dset2);
        H5Fclose(fid1);
        H5Fclose(fid2);
        H5Pclose(gcplid);
        H5Gclose(gid);
        trav_table_free(trav);
    } H5E_END_TRY;

    return ret_value;
}
Example #4
0
File: group.cpp Project: gcross/HDF
// Constructors }}}
// Informational {{{
GroupCreationProperties Group::getCopyOfCreationProperties() const {
    return GroupCreationProperties(assertSuccess(
        "getting group creation properties",
        H5Gget_create_plist(getId())
    ));
}