2004-02-10 23:42:55 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2004-02-10 23:42:55 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2004-02-10 23:42:55 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
|
|
|
* This program shows the concept of "mounting files".
|
1999-06-26 02:11:08 +08:00
|
|
|
* Program creates one file with group G in it, and another
|
|
|
|
* file with dataset D. Then second file is mounted in the first one
|
2005-08-14 04:53:35 +08:00
|
|
|
* under the "mounting point" G. Dataset D is accessed in the first file
|
|
|
|
* under name /G/D and data is printed out.
|
1999-06-26 02:11:08 +08:00
|
|
|
*/
|
|
|
|
|
2001-04-04 02:33:07 +08:00
|
|
|
#include "hdf5.h"
|
1999-06-26 02:11:08 +08:00
|
|
|
|
|
|
|
#define FILE1 "mount1.h5"
|
|
|
|
#define FILE2 "mount2.h5"
|
|
|
|
|
|
|
|
#define RANK 2
|
|
|
|
#define NX 4
|
|
|
|
#define NY 5
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
int main(void)
|
1999-06-26 02:11:08 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
hid_t fid1, fid2, gid; /* Files and group identifiers */
|
2005-08-14 04:53:35 +08:00
|
|
|
hid_t did, tid, sid; /* Dataset and datatype identifiers */
|
1999-06-26 02:11:08 +08:00
|
|
|
|
|
|
|
herr_t status;
|
|
|
|
hsize_t dims[] = {NX,NY}; /* Dataset dimensions */
|
|
|
|
|
|
|
|
int i, j;
|
|
|
|
int bm[NX][NY], bm_out[NX][NY]; /* Data buffers */
|
|
|
|
|
|
|
|
/*
|
2005-08-14 04:53:35 +08:00
|
|
|
* Initialization of buffer matrix "bm"
|
1999-06-26 02:11:08 +08:00
|
|
|
*/
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
for(i =0; i < NX; i++)
|
|
|
|
for(j = 0; j < NY; j++)
|
1999-06-26 02:11:08 +08:00
|
|
|
bm[i][j] = i + j;
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Create first file and a group in it.
|
|
|
|
*/
|
|
|
|
fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
2007-08-24 04:25:25 +08:00
|
|
|
gid = H5Gcreate2(fid1, "/G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
1999-06-26 02:11:08 +08:00
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
|
|
|
* Close group and file
|
1999-06-26 02:11:08 +08:00
|
|
|
*/
|
|
|
|
H5Gclose(gid);
|
|
|
|
H5Fclose(fid1);
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* 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);
|
[svn-r14199] Description:
Add H5Dcreate to API versioned routines, replacing internal usage with
H5Dcreate2
Fix thread-safe error stack initialization for API versioned error
stack printing routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-12 00:24:11 +08:00
|
|
|
did = H5Dcreate2(fid2, "D", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
1999-06-26 02:11:08 +08:00
|
|
|
/*
|
|
|
|
* Write data to the dataset.
|
|
|
|
*/
|
|
|
|
status = H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, bm);
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Close all identifiers.
|
|
|
|
*/
|
|
|
|
H5Sclose(sid);
|
|
|
|
H5Dclose(did);
|
|
|
|
H5Fclose(fid2);
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Reopen both files
|
|
|
|
*/
|
|
|
|
fid1 = H5Fopen(FILE1, H5F_ACC_RDONLY, H5P_DEFAULT);
|
|
|
|
fid2 = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Mount second file under G in the first file.
|
|
|
|
*/
|
|
|
|
H5Fmount(fid1, "/G", fid2, H5P_DEFAULT);
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Access dataset D in the first file under /G/D name.
|
|
|
|
*/
|
[svn-r14193] Description:
Make H5Dopen versioned and change all internal usage to use H5Dopen2
Add simple regression test for H5Dopen1
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-09 03:59:36 +08:00
|
|
|
did = H5Dopen2(fid1, "/G/D", H5P_DEFAULT);
|
1999-06-26 02:11:08 +08:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Close all identifers
|
|
|
|
*/
|
|
|
|
H5Tclose(tid);
|
|
|
|
H5Dclose(did);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
|
|
/*
|
1999-06-26 02:11:08 +08:00
|
|
|
* Unmounting second file
|
|
|
|
*/
|
|
|
|
H5Funmount(fid1, "/G");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Close both files
|
|
|
|
*/
|
|
|
|
H5Fclose(fid1);
|
|
|
|
H5Fclose(fid2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|