|
40 | 40 | integer(HID_T) :: fapl !< file access property list |
41 | 41 | integer :: file_mode |
42 | 42 |
|
| 43 | +if(present(ok)) ok = .true. |
| 44 | + |
43 | 45 | if(self%is_open()) then |
44 | | - write(stderr,*) 'h5fortran:open: file handle already open: '//self%filename |
| 46 | + write(stderr, '(a)') 'NOTICE:h5fortran:open: file handle already open: '//self%filename |
45 | 47 | return |
46 | 48 | endif |
47 | 49 |
|
|
76 | 78 | if (.not. hdf5_is_initialized()) then |
77 | 79 | if(self%debug) print '(a)', 'TRACE:h5fortran:h5open: initializing HDF5 library' |
78 | 80 | call H5open_f(ier) |
79 | | - call estop(ier, 'h5open:H5open HDF5 library initialize', filename) |
| 81 | + call estop(ier, 'h5open:H5open HDF5 library initialize', filename, ok=ok) |
| 82 | + if (present(ok)) then |
| 83 | + if (.not. ok) return |
| 84 | + endif |
80 | 85 | endif |
81 | 86 |
|
82 | 87 | if(self%debug) then |
83 | 88 | call H5Eset_auto_f(1, ier) |
84 | 89 | else |
85 | 90 | call H5Eset_auto_f(0, ier) |
86 | 91 | endif |
87 | | -call estop(ier, 'h5open:H5Eset_auto: HDF5 library set traceback', filename) |
| 92 | +call estop(ier, 'h5open:H5Eset_auto: HDF5 library set traceback', filename, ok=ok) |
| 93 | +if (present(ok)) then |
| 94 | + if(.not. ok) return |
| 95 | +endif |
88 | 96 |
|
89 | 97 | select case(laction) |
90 | 98 | case('r') |
|
100 | 108 | case ('w') |
101 | 109 | file_mode = H5F_ACC_TRUNC_F |
102 | 110 | case default |
103 | | - error stop 'ERROR:h5fortran:open Unsupported action ' // laction // ' for ' // filename |
| 111 | + call estop(ier, 'ERROR:h5fortran:open Unsupported action ' // laction, filename, ok=ok) |
| 112 | + if (present(ok)) then |
| 113 | + if(.not. ok) return |
| 114 | + endif |
| 115 | + |
104 | 116 | end select |
105 | 117 |
|
106 | 118 | fapl = H5P_DEFAULT_F |
|
117 | 129 | error stop "ERROR:h5fortran:open: action=" // laction // " not an HDF5 file: " // filename |
118 | 130 | endif |
119 | 131 | call H5Fopen_f(filename, file_mode, self%file_id, ier, access_prp=fapl) |
120 | | - call estop(ier, "h5open:H5Fopen", filename) |
| 132 | + call estop(ier, "h5open:H5Fopen", filename, ok=ok) |
| 133 | + if (present(ok)) then |
| 134 | + if(.not. ok) return |
| 135 | + endif |
121 | 136 | elseif(file_mode == H5F_ACC_TRUNC_F) then |
122 | 137 | call H5Fcreate_f(filename, file_mode, self%file_id, ier, access_prp=fapl) |
123 | | - call estop(ier, "h5open:H5Fcreate", filename) |
| 138 | + call estop(ier, "h5open:H5Fcreate", filename, ok=ok) |
| 139 | + if (present(ok)) then |
| 140 | + if(.not. ok) return |
| 141 | + endif |
124 | 142 | else |
125 | 143 | error stop "ERROR:h5fortran:open: Unsupported file mode: " // filename |
126 | 144 | endif |
|
408 | 426 | write(bufi, "(i0)") ier |
409 | 427 | buf = trim(buf) // trim(filename) // " code=" // trim(bufi) |
410 | 428 |
|
411 | | -error stop trim(buf) |
| 429 | +if(present(ok)) then |
| 430 | + ok = .false. |
| 431 | +else |
| 432 | + error stop trim(buf) |
| 433 | +endif |
412 | 434 |
|
413 | 435 | end procedure estop |
414 | 436 |
|
|
0 commit comments