Source
/* attach the DS_2_NAME dimension scale to DSET_NAME as the 2nd dimension (index 1) */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* 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 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. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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;