Thank you, Scot. I also discovered to use "sizeof()" instead of "H5OFFSETOF" & "c_loc" combination.
Regards, Ekin On 4 February 2014 20:51, Scot Breitenfeld <[email protected]> wrote: > Assuming you have some derived type and array: > > > > TYPE CmpField_struct > INTEGER :: a > REAL :: b > REAL :: c > ENDTYPE CmpField_struct > > TYPE(CmpField_struct), DIMENSION(1), TARGET :: cf > > > You can get the offset of a, b, or c of the derived type by: > > > offset = H5OFFSETOF(C_LOC(cf(1)),C_LOC(cf(1)%a)) > offset = H5OFFSETOF(C_LOC(cf(1)),C_LOC(cf(1)%b)) > offset = H5OFFSETOF(C_LOC(cf(1)),C_LOC(cf(1)%c)) > > > Scot > > > ------------------------------ > *From:* Hdf-forum <[email protected]> on behalf of > Ekin Akoglu <[email protected]> > *Sent:* Tuesday, February 04, 2014 1:05 PM > *To:* HDF Users Discussion List > *Subject:* [Hdf-forum] Creating compound datatype with single dimension > > > Hi all, > > Below is an excerpt from the HDF5 Fortran API example named > h5ex_t_cmpd_F03.f90 > (http://www.hdfgroup.org/ftp/HDF5/examples/examples-by-api/hdf5-examples/1_8/FORTRAN/H5T/h5ex_t_cmpd_F03.f90). > > After data were initialized, h5tcreate_f is called with H5OFFSETOF. If wdata > has more than one dimension, c_loc with H5OFFSETOF is enough to create the > compund datatype. My question is, assuming that wdata has only one dimension, > i.e. wdata(1), how should I formulate the second c_loc command in H5OFFSETOF? > > here is the excerpt: > > ! Initialize data. > > ! > wdata(1)%serial_no = 1153 > wdata(1)%location = "Exterior (static)" > wdata(1)%temperature = 53.23_real_kind_15 > wdata(1)%pressure = 24.57_real_kind_15 > wdata(2)%serial_no = 1184 > wdata(2)%location = "Intake" > wdata(2)%temperature = 55.12_real_kind_15 > wdata(2)%pressure = 22.95_real_kind_15 > wdata(3)%serial_no = 1027 > wdata(3)%location = "Intake manifold" > wdata(3)%temperature = 103.55_real_kind_15 > wdata(3)%pressure = 31.23_real_kind_15 > wdata(4)%serial_no = 1313 > wdata(4)%location = "Exhaust manifold" > wdata(4)%temperature = 1252.89_real_kind_15 > wdata(4)%pressure = 84.11_real_kind_15 > ! > ! Create a new file using the default properties. > ! > CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file, hdferr) > ! > ! Create the compound datatype for memory. > ! > CALL h5tcreate_f(H5T_COMPOUND_F, H5OFFSETOF(C_LOC(wdata(1)), > C_LOC(wdata(2))), memtype, hdferr) > > > Thank you in advance. > > Regards, > > Ekin > > _______________________________________________ > Hdf-forum is for HDF software users discussion. > [email protected] > > http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org > >
_______________________________________________ Hdf-forum is for HDF software users discussion. [email protected] http://mail.lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
