1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
!> @defgroup FH5DS Fortran High Level Dimension Scales (H5DS) Interface
!!
!! @see H5DS, C-HL API
!!
!! @see @ref H5DS_UG, User Guide
!!
!> @ingroup FH5DS
!!
!! @brief This module contains Fortran interfaces for H5DS
!
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
! Copyright by The HDF Group. *
! 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://www.hdfgroup.org/licenses. *
! If you do not have access to either file, you may request a copy from *
! help@hdfgroup.org. *
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
! _____ __ __ _____ ____ _____ _______ _ _ _______
! |_ _| \/ | __ \ / __ \| __ \__ __|/\ | \ | |__ __|
! **** | | | \ / | |__) | | | | |__) | | | / \ | \| | | | ****
! **** | | | |\/| | ___/| | | | _ / | | / /\ \ | . ` | | | ****
! **** _| |_| | | | | | |__| | | \ \ | |/ ____ \| |\ | | | ****
! |_____|_| |_|_| \____/|_| \_\ |_/_/ \_\_| \_| |_|
!
! If you add a new function here then you MUST add the function name to the
! Windows dll file 'hdf5_hl_fortrandll.def.in' in the hl/fortran/src directory.
! This is needed for Windows based operating systems.
!
MODULE H5DS
USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR, C_FLOAT, C_DOUBLE, C_LOC, C_CHAR
USE h5fortran_types
USE hdf5
CONTAINS
!>
!! \ingroup FH5DS
!!
!! \brief Convert dataset \p dsid to a dimension scale, with optional name, \p dimname.
!!
!! \param dsid The dataset to be made a Dimemsion Scale.
!! \param errcode \fortran_error
!! \param dimname The dimension name
!!
!! See C API: @ref H5DSset_scale()
!!
SUBROUTINE H5DSset_scale_f( dsid, errcode, dimname)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: dsid
CHARACTER(LEN=*), INTENT(in), OPTIONAL :: dimname
INTEGER :: errcode
INTEGER(SIZE_T) :: dimname_len ! length of dimname (if present)
INTERFACE
INTEGER FUNCTION H5DSset_scale_c(dsid, dimname, dimname_len) &
BIND(C,NAME='h5dsset_scale_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: dsid
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(in) :: dimname
INTEGER(SIZE_T), INTENT(in) :: dimname_len
END FUNCTION H5DSset_scale_c
END INTERFACE
IF(PRESENT(dimname))THEN
dimname_len = LEN(dimname)
errcode = H5DSset_scale_c(dsid, dimname, dimname_len )
ELSE
errcode = H5DSset_scale_c(dsid, " ", INT(0,SIZE_T) )
ENDIF
END SUBROUTINE H5DSset_scale_f
!>
!! \ingroup FH5DS
!!
!! \brief Attach dimension scale dsid to dimension \p idx of dataset \p did.
!!
!! \param did The dataset.
!! \param dsid The scale to be attached.
!! \param idx The dimension of \p did that \p dsid is associated with.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSattach_scale()
!!
SUBROUTINE H5DSattach_scale_f( did, dsid, idx, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER(hid_t), INTENT(in) :: dsid
INTEGER , INTENT(in) :: idx
INTEGER :: errcode
INTEGER :: c_idx
INTERFACE
INTEGER FUNCTION H5DSattach_scale_c(did, dsid, idx) &
BIND(C,NAME='h5dsattach_scale_c')
IMPORT :: HID_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER(hid_t), INTENT(in) :: dsid
INTEGER , INTENT(in) :: idx
END FUNCTION H5DSattach_scale_c
END INTERFACE
c_idx = idx -1 ! account for C-dimensions starting at 0
errcode = H5DSattach_scale_c( did, dsid, c_idx)
END SUBROUTINE H5DSattach_scale_f
!>
!! \ingroup FH5DS
!!
!! \brief Detach dimension scale dsid from the dimension idx of dataset \p did.
!!
!! \param did The dataset.
!! \param dsid The scale to be detached.
!! \param idx The dimension of \p did to detach.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSdetach_scale()
!!
SUBROUTINE H5DSdetach_scale_f( did, dsid, idx, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER(hid_t), INTENT(in) :: dsid
INTEGER , INTENT(in) :: idx
INTEGER :: errcode
INTEGER :: c_idx
INTERFACE
INTEGER FUNCTION H5DSdetach_scale_c(did, dsid, idx) &
BIND(C,NAME='h5dsdetach_scale_c')
IMPORT :: HID_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER(hid_t), INTENT(in) :: dsid
INTEGER , INTENT(in) :: idx
END FUNCTION H5DSdetach_scale_c
END INTERFACE
c_idx = idx - 1 ! account for C-dimensions starting at 0
errcode = H5DSdetach_scale_c( did, dsid, c_idx)
END SUBROUTINE H5DSdetach_scale_f
!>
!! \ingroup FH5DS
!!
!! \brief Report if dimension scale dsid is currently attached to dimension idx of dataset did.
!!
!! \param did The dataset.
!! \param dsid The scale to be attached.
!! \param idx The dimension of \p did that \p dsid is associated with.
!! \param is_attached If dimension scale \p dsid is currently attached to dimension \p idx of dataset \p did.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSis_attached()
!!
SUBROUTINE H5DSis_attached_f( did, dsid, idx, is_attached, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER(hid_t), INTENT(in) :: dsid
INTEGER , INTENT(in) :: idx
LOGICAL , INTENT(out) :: is_attached
INTEGER :: errcode
INTEGER :: c_is_attached
INTEGER :: c_idx
INTERFACE
INTEGER FUNCTION H5DSis_attached_c(did, dsid, idx, c_is_attached) &
BIND(C,NAME='h5dsis_attached_c')
IMPORT :: HID_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER(hid_t), INTENT(in) :: dsid
INTEGER , INTENT(in) :: idx
INTEGER , INTENT(out) :: c_is_attached
END FUNCTION H5DSis_attached_c
END INTERFACE
c_idx = idx - 1 ! account for C-dimensions starting at 0
errcode = H5DSis_attached_c(did, dsid, c_idx, c_is_attached)
is_attached = .FALSE. ! default
IF(c_is_attached.GT.0)THEN
is_attached = .TRUE.
ELSE IF(errcode.LT.0)THEN
errcode = -1
ENDIF
END SUBROUTINE H5DSis_attached_f
!
! H5DSiterate_scales: Implement in F2003
!
!>
!! \ingroup FH5DS
!!
!! \brief Determines whether \p did is a Dimension Scale.
!!
!! \param did The data set to query.
!! \param is_scale If is a Dimension Scale.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSis_scale()
!!
SUBROUTINE H5DSis_scale_f( did, is_scale, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
LOGICAL , INTENT(out) :: is_scale
INTEGER , INTENT(out) :: errcode
INTEGER :: c_is_scale
INTERFACE
INTEGER FUNCTION H5DSis_scale_c(did,c_is_scale) &
BIND(C,NAME='h5dsis_scale_c')
IMPORT :: HID_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER, INTENT(out) :: c_is_scale
END FUNCTION H5DSis_scale_c
END INTERFACE
errcode = H5DSis_scale_c(did, c_is_scale)
is_scale = .FALSE. ! default
IF(c_is_scale.GT.0)THEN
is_scale = .TRUE.
ELSE IF(errcode.LT.0)THEN
errcode = -1
ENDIF
END SUBROUTINE H5DSis_scale_f
!>
!! \ingroup FH5DS
!!
!! \brief Set label for the dimension \p idx of \p did to the value \p label.
!!
!! \param did The data set.
!! \param idx The dimension.
!! \param label The label.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSset_label()
!!
SUBROUTINE H5DSset_label_f( did, idx, label, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER , INTENT(in) :: idx
CHARACTER(LEN=*), INTENT(in) :: label
INTEGER :: errcode ! Error code
INTEGER(SIZE_T) :: label_len ! Length of label
INTEGER :: c_idx
INTERFACE
INTEGER FUNCTION H5DSset_label_c(did, idx, label, label_len) &
BIND(C,NAME='h5dsset_label_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER , INTENT(in) :: idx
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(in) :: label
INTEGER(SIZE_T), INTENT(in) :: label_len
END FUNCTION H5DSset_label_c
END INTERFACE
c_idx = idx - 1
label_len = LEN(label)
errcode = H5DSset_label_c(did, c_idx, label, label_len)
END SUBROUTINE H5DSset_label_f
!>
!! \ingroup FH5DS
!!
!! \brief Read the \p label for dimension \p idx of \p did into buffer \p label.
!!
!! \param did The dataset.
!! \param idx The dimension.
!! \param label The label.
!! \param size The length of the \p label buffer.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSget_label()
!!
SUBROUTINE H5DSget_label_f( did, idx, label, size, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER , INTENT(in) :: idx
CHARACTER(LEN=*), INTENT(INOUT) :: label
INTEGER(size_t) , INTENT(INOUT) :: size
INTEGER :: errcode
INTEGER :: c_idx
INTERFACE
INTEGER FUNCTION H5DSget_label_c(did, idx, label, size) &
BIND(C,NAME='h5dsget_label_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER , INTENT(in) :: idx
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(INOUT) :: label
INTEGER(SIZE_T), INTENT(inout) :: size
END FUNCTION H5DSget_label_c
END INTERFACE
c_idx = idx - 1
errcode = H5DSget_label_c(did, c_idx, label, size)
END SUBROUTINE H5DSget_label_f
!>
!! \ingroup FH5DS
!!
!! \brief Read the name of scale \p did into buffer name.
!!
!! \param did Dimension scale identifier.
!! \param name Buffer to contain the returned name.
!! \param size Size in bytes, of the name buffer.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSget_scale_name()
!!
SUBROUTINE H5DSget_scale_name_f(did, name, size, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
CHARACTER(LEN=*), INTENT(INOUT) :: name
INTEGER(size_t) , INTENT(INOUT) :: size
INTEGER :: errcode
INTERFACE
INTEGER FUNCTION H5DSget_scale_name_c(did, name, size) &
bind(c,name='h5dsget_scale_name_c')
IMPORT :: C_CHAR
IMPORT :: HID_T, SIZE_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
CHARACTER(KIND=C_CHAR), DIMENSION(*), INTENT(INOUT) :: name
INTEGER(SIZE_T), INTENT(inout) :: size
END FUNCTION H5DSget_scale_name_c
END INTERFACE
errcode = H5DSget_scale_name_c(did, name, size)
END SUBROUTINE H5DSget_scale_name_f
!>
!! \ingroup FH5DS
!!
!! \brief Determines how many Dimension Scales are attached to dimension idx of \p did.
!!
!! \param did The dataset to query.
!! \param idx The dimension of \p did to query.
!! \param num_scales Number of Dimension Scales associated with \p did.
!! \param errcode \fortran_error
!!
!! See C API: @ref H5DSget_num_scales()
!!
SUBROUTINE H5DSget_num_scales_f( did, idx, num_scales, errcode)
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER , INTENT(in) :: idx
INTEGER , INTENT(INOUT) :: num_scales
INTEGER :: errcode
INTEGER :: c_idx
INTERFACE
INTEGER FUNCTION H5DSget_num_scales_c(did, idx, num_scales) &
BIND(C,NAME='h5dsget_num_scales_c')
IMPORT :: HID_T
IMPLICIT NONE
INTEGER(hid_t), INTENT(in) :: did
INTEGER , INTENT(in) :: idx
INTEGER , INTENT(INOUT) :: num_scales
END FUNCTION H5DSget_num_scales_c
END INTERFACE
c_idx = idx - 1
errcode = H5DSget_num_scales_c(did, c_idx, num_scales)
END SUBROUTINE H5DSget_num_scales_f
END MODULE h5ds
|