|
12 | 12 | h5tcopy_f, h5tclose_f, h5tset_size_f, &
|
13 | 13 | H5S_SCALAR_F, &
|
14 | 14 | H5D_COMPACT_F, &
|
15 |
| -H5F_SCOPE_GLOBAL_F |
| 15 | +H5F_SCOPE_GLOBAL_F, & |
| 16 | +H5F_ACC_RDWR_F, H5F_ACC_TRUNC_F, H5F_ACC_EXCL_F |
16 | 17 |
|
17 | 18 |
|
18 |
| -use h5lt, only: h5ltpath_valid_f |
19 |
| - |
20 | 19 | implicit none
|
21 | 20 |
|
22 | 21 | contains
|
|
60 | 59 | integer(HSIZE_T), dimension(:), allocatable :: ddims, maxdims
|
61 | 60 | character(:), allocatable :: emsg
|
62 | 61 |
|
| 62 | +if(.not. self%is_open()) error stop "ERROR:h5fortran:create: file is not open: " // self%filename |
| 63 | + |
| 64 | +if(self%file_mode == -1) error stop "ERROR:h5fortran:create: file mode is not set, call h5f % open() first" |
| 65 | + |
| 66 | + |
| 67 | +if(all(self%file_mode /= [H5F_ACC_RDWR_F, H5F_ACC_TRUNC_F, H5F_ACC_EXCL_F])) then |
| 68 | + write(stderr, '(3a,i0,2a)') "ERROR:h5fortran:create(", dname, "): file mode is not writable: ", & |
| 69 | + self%file_mode, " in file: ", self%filename |
| 70 | + error stop |
| 71 | +endif |
| 72 | + |
63 | 73 |
|
64 | 74 | call H5Tcopy_f(dtype, dtype_id, ier)
|
65 | 75 | call estop(ier, "create:H5Tcopy", self%filename, dname)
|
|
176 | 186 | endif
|
177 | 187 |
|
178 | 188 | !> create dataset
|
179 |
| -call h5dcreate_f(self%file_id, dname, type_id=dtype_id, space_id=filespace_id, dset_id=dset_id, hdferr=ier, dcpl_id=dcpl) |
180 |
| -call estop(ier, "create:H5Dcreate", self%filename, dname) |
| 189 | +!! https://portal.hdfgroup.org/documentation/hdf5/latest/_l_b_dset_create.html |
| 190 | +!! https://support.hdfgroup.org/documentation/hdf5/latest/group___f_h5_d.html#ga5422721017b75f11b6b018a09fa24797 |
| 191 | +call H5Dcreate_f(self%file_id, dname, type_id=dtype_id, space_id=filespace_id, dset_id=dset_id, hdferr=ier, dcpl_id=dcpl) |
| 192 | +if(ier /= 0) then |
| 193 | + write(stderr,'(4a)') "ERROR:h5fortran:create: H5Dcreate(", dname, ") in file: ", self%filename |
| 194 | + write(stderr,'(a,i0,a,i0,a,i0,a,i0)') "H5Dcreate error code: ", ier, " dtype_id: ", dtype_id, " space_id: ", & |
| 195 | + filespace_id, " dset_id: ", dset_id |
| 196 | + if (dcpl /= H5P_DEFAULT_F) write(stderr,'(a,i0)') "H5Dcreate dcpl_id: ", dcpl |
| 197 | + if (dtype_id == H5T_NATIVE_CHARACTER) write(stderr,'(a,i0)') "H5Dcreate charlen: ", charlen |
| 198 | + |
| 199 | + |
| 200 | + error stop |
| 201 | + |
| 202 | +endif |
181 | 203 |
|
182 | 204 | !> free resources
|
183 |
| -call h5pclose_f(dcpl, ier) |
| 205 | +call H5Pclose_f(dcpl, ier) |
184 | 206 | call estop(ier, "create:H5Pclose", self%filename, dname)
|
185 | 207 |
|
186 | 208 | end procedure hdf_create
|
|
0 commit comments