extern med_err _MEDfichierMonter(med_idt pid, const char *nom, med_idt fid) { med_err _ret = 0; if (H5Fmount(pid,nom,fid,H5P_DEFAULT) < 0) _ret = -1; return _ret; }
static VALUE rb_H5Fmount (VALUE mod, VALUE v_loc_id, VALUE v_name, VALUE v_child_id, VALUE v_plist_id) { herr_t status; status = H5Fmount(NUM2INT(v_loc_id), StringValuePtr(v_name), NUM2INT(v_child_id), NUM2INT(v_plist_id)); if ( status < 0 ) rb_hdf5_raise("can't mount HDF5 file"); return INT2NUM(status); }
//-------------------------------------------------------------------------- // Function: CommonFG::mount ///\brief Mounts the file \a child onto this group. ///\param name - IN: Name of the group ///\param child - IN: File to mount ///\param plist - IN: Property list to use ///\exception H5::FileIException or H5::GroupIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void CommonFG::mount( const char* name, H5File& child, PropList& plist ) const { // Obtain identifiers for C API hid_t plist_id = plist.getId(); hid_t child_id = child.getId(); // Call C routine H5Fmount to do the mouting herr_t ret_value = H5Fmount( getLocId(), name, child_id, plist_id ); // Raise exception if H5Fmount returns negative value if( ret_value < 0 ) { throwException("mount", "H5Fmount failed"); } }
/****if* H5Ff/h5fmount_c * NAME * h5fmount_c * PURPOSE * Call H5Fmount to mount the file * INPUTS * loc_id - Identifier for file or group * dsetname - name of dataset * namelen - dsetname length * file_id - file identifier for the file to be mounted * acc_prp - identifier of access property list * RETURNS * 0 on success, -1 on failure * AUTHOR * Xiangyang Su * Monday, October 25, 1999 * HISTORY */ int_f nh5fmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hid_t_f *acc_prp) /******/ { int ret_value = -1; char *c_name; int_f c_namelen; hid_t c_loc_id; hid_t c_file_id; hid_t c_acc_prp; htri_t status; /* * Define access property */ c_acc_prp = *acc_prp; /* if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT; */ c_loc_id = *loc_id; c_file_id = *file_id; /* * Convert FORTRAN name to C name */ c_namelen = *namelen; c_name = (char *)HD5f2cstring(dsetname, (size_t)c_namelen); if (c_name == NULL) return ret_value; /* * Call H5Fmount function. */ status = H5Fmount(c_loc_id, c_name, c_file_id, c_acc_prp); if (status >= 0) ret_value = 0; HDfree(c_name); return ret_value; }
int main(void) { hid_t fid1, fid2, gid; /* Files and group identifiers */ hid_t did, tid, sid; /* Dataset and datatype identifiers */ herr_t status; hsize_t dims[] = {NX,NY}; /* Dataset dimensions */ int i, j; int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */ /* * Initialization of buffer matrix "bm" */ for(i =0; i<NX; i++) { for(j = 0; j<NY; j++) bm[i][j] = i + j; } /* * Create first file and a group in it. */ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); gid = H5Gcreate(fid1, "/G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* * Close group and file */ H5Gclose(gid); H5Fclose(fid1); /* * Create second file and dataset "D" in it. */ fid2 = H5Fcreate (FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); dims[0] = NX; dims[1] = NY; sid = H5Screate_simple (RANK, dims, NULL); did = H5Dcreate (fid2, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); /* * Write data to the dataset. */ status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm); /* * Close all identifiers. */ H5Sclose(sid); H5Dclose(did); H5Fclose(fid2); /* * Reopen both files */ fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT); fid2 = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT); /* * Mount second file under G in the first file. */ H5Fmount(fid1, "/G", fid2, H5P_DEFAULT); /* * Access dataset D in the first file under /G/D name. */ did = H5Dopen(fid1,"/G/D", H5P_DEFAULT); tid = H5Dget_type(did); status = H5Dread(did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm_out); /* * Print out the data. */ for(i=0; i<NX; i++){ for(j=0; j<NY; j++) printf(" %d", bm_out[i][j]); printf("\n"); } /* * Close all identifers */ H5Tclose(tid); H5Dclose(did); /* * Unmounting second file */ H5Funmount(fid1, "/G"); /* * Close both files */ H5Fclose(fid1); H5Fclose(fid2); return 0; }