Hi Victor,
On Jul 12, 2010, at 9:56 AM, Victor Eijkhout wrote:
> I'm trying to get two datasets into one file, and I'm clearly doing something
> wrong. Can someone point out the obvious to me?
Hmm, looks OK. What is "wrong" with what you are getting?
Quincey
> #include "myh5defs.h"
> #define FILE "wdset.h5"
>
> main() {
>
> hid_t file_id, dataset, dataspace; /* identifiers */
> hid_t parmset,parmspace;
> hsize_t dims[2];
> herr_t status;
> double data[24]; int i,parm;
>
> /* Create a new file using default properties. */
> file_id = H5Fcreate(FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
>
> /* Create the dataset. */
> dims[0] = 4; dims[1] = 6;
> dataspace = H5Screate_simple(2, dims, NULL);
> dataset = H5Dcreate
> (file_id, "/dset", H5T_NATIVE_DOUBLE, dataspace, H5P_DEFAULT);
>
> /* Add a descriptive parameter */
> parmspace = H5Screate(H5S_SCALAR);
> parmset = H5Dcreate
> (file_id,"/parm",H5T_NATIVE_INT,parmspace,H5P_DEFAULT);
>
> /* Write data to file */
> for (i=0; i<24; i++) data[i] = i+.5;
> status = H5Dwrite
> (dataset,H5T_NATIVE_DOUBLE,H5S_ALL,H5S_ALL,H5P_DEFAULT,
> data); H5REPORT(status);
>
> /* write parameter value */
> parm = 37;
> status = H5Dwrite
> (parmset,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,
> &parm); H5REPORT(status);
>
> /* End access to the dataset and release resources used by it. */
> status = H5Dclose(dataset);
> status = H5Dclose(parmset);
>
> /* Terminate access to the data space. */
> status = H5Sclose(dataspace);
> status = H5Sclose(parmspace);
>
> /* Close the file. */
> status = H5Fclose(file_id);
> }
>
>
>
> Output:
>
> %% h5dump wdset.h5
> HDF5 "wdset.h5" {
> GROUP "/" {
> DATASET "dset" {
> DATATYPE H5T_IEEE_F64LE
> DATASPACE SIMPLE { ( 4, 6 ) / ( 4, 6 ) }
> DATA {
> (0,0): 0.5, 1.5, 2.5, 3.5, 4.5, 5.5,
> (1,0): 6.5, 7.5, 8.5, 9.5, 10.5, 11.5,
> (2,0): 12.5, 13.5, 14.5, 15.5, 16.5, 17.5,
> (3,0): 18.5, 19.5, 20.5, 21.5, 22.5, 23.5
> }
> }
> DATASET "parm" {
> DATATYPE H5T_STD_I32LE
> DATASPACE SCALAR
> DATA {
> (0): 0
> }
> }
> }
> }
>
>
> Writing either dataset on its own works correctly.
>
> Victor.
> _______________________________________________
> Hdf-forum is for HDF software users discussion.
> [email protected]
> http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org
_______________________________________________
Hdf-forum is for HDF software users discussion.
[email protected]
http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org