2006-03-07 00:11:11 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2006-03-07 00:11:11 +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 *
|
2017-04-15 00:54:16 +08:00
|
|
|
* the COPYING file, which can be found at the root of the source code *
|
|
|
|
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
|
|
|
|
* If you do not have access to either file, you may request a copy from *
|
|
|
|
* help@hdfgroup.org. *
|
2006-03-07 00:11:11 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2006-04-13 05:21:38 +08:00
|
|
|
#include "hdf5.h"
|
2006-04-20 12:49:06 +08:00
|
|
|
#include "hdf5_hl.h"
|
2006-04-13 05:21:38 +08:00
|
|
|
|
2006-03-07 00:11:11 +08:00
|
|
|
|
|
|
|
#define RANK 2
|
|
|
|
#define DIM_DATA 12
|
|
|
|
#define DIM1_SIZE 3
|
|
|
|
#define DIM2_SIZE 4
|
|
|
|
#define DIM0 0
|
|
|
|
#define DIM1 1
|
|
|
|
|
|
|
|
#define DSET_NAME "Mydata"
|
|
|
|
#define DS_1_NAME "Yaxis"
|
|
|
|
#define DS_2_NAME "Xaxis"
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
hid_t fid; /* file ID */
|
|
|
|
hid_t did; /* dataset ID */
|
|
|
|
hid_t dsid; /* DS dataset ID */
|
|
|
|
int rank = RANK; /* rank of data dataset */
|
|
|
|
int rankds = 1; /* rank of DS dataset */
|
|
|
|
hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
|
|
|
|
int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */
|
|
|
|
hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
|
|
|
|
hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
|
|
|
|
float s1_wbuf[DIM1_SIZE] = {10,20,30}; /* data of DS 1 dataset */
|
|
|
|
int s2_wbuf[DIM2_SIZE] = {10,20,50,100}; /* data of DS 2 dataset */
|
|
|
|
|
|
|
|
|
|
|
|
/* create a file using default properties */
|
|
|
|
if ((fid=H5Fcreate("ex_ds1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* make a dataset */
|
|
|
|
if (H5LTmake_dataset_int(fid,DSET_NAME,rank,dims,buf)<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* make a DS dataset for the first dimension */
|
|
|
|
if (H5LTmake_dataset_float(fid,DS_1_NAME,rankds,s1_dim,s1_wbuf)<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* make a DS dataset for the second dimension */
|
|
|
|
if (H5LTmake_dataset_int(fid,DS_2_NAME,rankds,s2_dim,s2_wbuf)<0)
|
|
|
|
goto out;
|
|
|
|
|
2006-06-27 22:45:06 +08:00
|
|
|
|
2006-03-07 00:11:11 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* attach the DS_1_NAME dimension scale to DSET_NAME at dimension 0
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* get the dataset id for DSET_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
|
|
|
if ((did = H5Dopen2(fid,DSET_NAME, H5P_DEFAULT))<0)
|
2006-03-07 00:11:11 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* get the DS dataset id */
|
[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
|
|
|
if ((dsid = H5Dopen2(fid,DS_1_NAME, H5P_DEFAULT))<0)
|
2006-03-07 00:11:11 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* attach the DS_1_NAME dimension scale to DSET_NAME at dimension index 0 */
|
|
|
|
if (H5DSattach_scale(did,dsid,DIM0)<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* close DS id */
|
|
|
|
if (H5Dclose(dsid)<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* attach the DS_2_NAME dimension scale to DSET_NAME
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* get the DS dataset id */
|
[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
|
|
|
if ((dsid = H5Dopen2(fid,DS_2_NAME, H5P_DEFAULT))<0)
|
2006-03-07 00:11:11 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* attach the DS_2_NAME dimension scale to DSET_NAME as the 2nd dimension (index 1) */
|
|
|
|
if (H5DSattach_scale(did,dsid,DIM1)<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* close DS id */
|
|
|
|
if (H5Dclose(dsid)<0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* close file */
|
|
|
|
H5Fclose(fid);
|
2006-06-27 22:45:06 +08:00
|
|
|
|
2006-03-07 00:11:11 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
printf("Error on return function...Exiting\n");
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|