|
| 1 | +program test |
| 2 | + |
| 3 | +use hdf5 |
| 4 | +use h5fortran |
| 5 | +use, intrinsic :: iso_fortran_env, only: stderr=>error_unit |
| 6 | + |
| 7 | +implicit none |
| 8 | + |
| 9 | +type(hdf5_file) :: h |
| 10 | +character(*), parameter :: fn = 'test_intent.h5' |
| 11 | +integer :: intent(5), exp(5), i |
| 12 | + |
| 13 | +call H5open_f(i) |
| 14 | +if(i /= 0) error stop "H5open_f failed [0]" |
| 15 | + |
| 16 | +exp = [H5F_ACC_RDWR_F, H5F_ACC_RDONLY_F, H5F_ACC_RDONLY_F, H5F_ACC_RDWR_F, H5F_ACC_RDWR_F] |
| 17 | + |
| 18 | +!> These are the only two possiblities for the intent of a file |
| 19 | +print '(a,i0)', "H5F_ACC_RDONLY_F = ", H5F_ACC_RDONLY_F |
| 20 | +print '(a,i0)', "H5F_ACC_RDWR_F = ", H5F_ACC_RDWR_F |
| 21 | + |
| 22 | +call h % open(fn, action='w', debug=.true.) |
| 23 | +intent(1) = h % intent() |
| 24 | +call h % close() |
| 25 | + |
| 26 | +call h % open(fn, debug=.true.) |
| 27 | +intent(2) = h % intent() |
| 28 | +call h % close() |
| 29 | + |
| 30 | +call h % open(fn, action='r', debug=.true.) |
| 31 | +intent(3) = h % intent() |
| 32 | +call h % close() |
| 33 | + |
| 34 | +call h % open(fn, action='r+', debug=.true.) |
| 35 | +intent(4) = h % intent() |
| 36 | +call h % close() |
| 37 | + |
| 38 | +call h % open(fn, action='rw', debug=.true.) |
| 39 | +intent(5) = h % intent() |
| 40 | +call h % close() |
| 41 | + |
| 42 | +call H5close_f(i) |
| 43 | +if (i /= 0) error stop "H5close() failed" |
| 44 | + |
| 45 | +if (any(intent /= exp)) then |
| 46 | + write(stderr, '(a)') 'test_intent: intent does not match expected values' |
| 47 | + write(stderr, '(5i0)') intent |
| 48 | + write(stderr, '(5i0)') exp |
| 49 | + error stop 'intent test failed' |
| 50 | +else |
| 51 | + print '(a)', 'OK: intent matches expected values' |
| 52 | +end if |
| 53 | + |
| 54 | +end program |
0 commit comments