Skip to content

Commit 5a6cb3b

Browse files
committed
hdf5_file: mostly intent(in)
1 parent 3a00121 commit 5a6cb3b

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/interface.f90

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ module h5mpi
9090
module subroutine hdf_create(self, dname, dtype, mem_dims, dset_dims, filespace, memspace, dset_id, &
9191
istart, iend, chunk_size, compact)
9292

93-
class(hdf5_file), intent(inout) :: self
93+
class(hdf5_file), intent(in) :: self
9494
character(*), intent(in) :: dname
9595
integer(HID_T), intent(in) :: dtype
9696
integer(HSIZE_T), dimension(:), intent(in) :: mem_dims, dset_dims
@@ -111,14 +111,14 @@ end subroutine get_hdf5_config
111111
interface !< writer.f90
112112

113113
module subroutine h5write_scalar(self, dname, value, compact)
114-
class(hdf5_file), intent(inout) :: self
114+
class(hdf5_file), intent(in) :: self
115115
character(*), intent(in) :: dname
116116
class(*), intent(in) :: value
117117
logical, intent(in), optional :: compact
118118
end subroutine h5write_scalar
119119

120120
module subroutine ph5write_1d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
121-
class(hdf5_file), intent(inout) :: self
121+
class(hdf5_file), intent(in) :: self
122122
character(*), intent(in) :: dname
123123
class(*), intent(in) :: value(:)
124124
class(*), intent(in), dimension(1), optional :: dset_dims !< integer or integer(HSIZE_T) full disk shape (not just per worker)
@@ -128,7 +128,7 @@ module subroutine ph5write_1d(self, dname, value, dset_dims, istart, iend, chunk
128128
end subroutine ph5write_1d
129129

130130
module subroutine ph5write_2d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
131-
class(hdf5_file), intent(inout) :: self
131+
class(hdf5_file), intent(in) :: self
132132
character(*), intent(in) :: dname
133133
class(*), intent(in) :: value(:,:)
134134
class(*), intent(in), dimension(2), optional :: dset_dims
@@ -138,7 +138,7 @@ module subroutine ph5write_2d(self, dname, value, dset_dims, istart, iend, chunk
138138
end subroutine ph5write_2d
139139

140140
module subroutine ph5write_3d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
141-
class(hdf5_file), intent(inout) :: self
141+
class(hdf5_file), intent(in) :: self
142142
character(*), intent(in) :: dname
143143
class(*), intent(in) :: value(:,:,:)
144144
class(*), intent(in), dimension(3), optional :: dset_dims
@@ -148,7 +148,7 @@ module subroutine ph5write_3d(self, dname, value, dset_dims, istart, iend, chunk
148148
end subroutine ph5write_3d
149149

150150
module subroutine ph5write_4d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
151-
class(hdf5_file), intent(inout) :: self
151+
class(hdf5_file), intent(in) :: self
152152
character(*), intent(in) :: dname
153153
class(*), intent(in) :: value(:,:,:,:)
154154
class(*), intent(in), dimension(4), optional :: dset_dims
@@ -158,7 +158,7 @@ module subroutine ph5write_4d(self, dname, value, dset_dims, istart, iend, chunk
158158
end subroutine ph5write_4d
159159

160160
module subroutine ph5write_5d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
161-
class(hdf5_file), intent(inout) :: self
161+
class(hdf5_file), intent(in) :: self
162162
character(*), intent(in) :: dname
163163
class(*), intent(in) :: value(:,:,:,:,:)
164164
class(*), intent(in), dimension(5), optional :: dset_dims
@@ -168,7 +168,7 @@ module subroutine ph5write_5d(self, dname, value, dset_dims, istart, iend, chunk
168168
end subroutine ph5write_5d
169169

170170
module subroutine ph5write_6d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
171-
class(hdf5_file), intent(inout) :: self
171+
class(hdf5_file), intent(in) :: self
172172
character(*), intent(in) :: dname
173173
class(*), intent(in) :: value(:,:,:,:,:,:)
174174
class(*), intent(in), dimension(6), optional :: dset_dims
@@ -178,7 +178,7 @@ module subroutine ph5write_6d(self, dname, value, dset_dims, istart, iend, chunk
178178
end subroutine ph5write_6d
179179

180180
module subroutine ph5write_7d(self, dname, value, dset_dims, istart, iend, chunk_size, compact)
181-
class(hdf5_file), intent(inout) :: self
181+
class(hdf5_file), intent(in) :: self
182182
character(*), intent(in) :: dname
183183
class(*), intent(in) :: value(:,:,:,:,:,:,:)
184184
class(*), intent(in), dimension(7), optional :: dset_dims
@@ -423,7 +423,7 @@ subroutine ph5close(self, close_hdf5_interface)
423423
!! close_hdf5_interface is when you know you have exactly one HDF5 file in your
424424
!! application, if true it closes ALL files, even those invoked directly from HDF5.
425425

426-
class(hdf5_file), intent(inout) :: self
426+
class(hdf5_file), intent(in) :: self
427427
logical, intent(in), optional :: close_hdf5_interface
428428

429429
integer :: ierr, i
@@ -515,7 +515,7 @@ end function has_parallel_compression
515515
subroutine destructor(self)
516516
!! Close file and handle if user forgets to do so
517517

518-
type(hdf5_file), intent(inout) :: self
518+
type(hdf5_file), intent(in) :: self
519519

520520
if (.not. self%is_open()) return
521521

@@ -798,21 +798,15 @@ end subroutine hdf_shape_check
798798

799799
integer(HSIZE_T) function hdf_filesize(self)
800800
!! returns the size of the HDF5 file in bytes
801-
class(hdf5_file), intent(inout) :: self
801+
class(hdf5_file), intent(in) :: self
802802

803803
integer :: ierr
804804

805-
logical :: close_self
806-
807-
close_self = .not. self%is_open()
808-
809-
if (close_self) call self%open(self%filename, action="r", mpi=.false.)
805+
if(.not. self%is_open()) error stop 'h5fortran:filesize: file handle is not open: ' // self%filename
810806

811807
call h5fget_filesize_f(self%file_id, hdf_filesize, ierr)
812808
if(ierr/=0) error stop "ERROR:h5fortran: could not get file size " // self%filename
813809

814-
if(close_self) call self%close()
815-
816810
end function hdf_filesize
817811

818812

src/write/write.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100

101101
subroutine set_deflate(self, dims, dcpl, chunk_size)
102-
class(hdf5_file), intent(inout) :: self
102+
class(hdf5_file), intent(in) :: self
103103
integer(HSIZE_T), intent(in) :: dims(:)
104104
integer(HID_T), intent(out) :: dcpl
105105
integer, intent(in), optional :: chunk_size(:)

0 commit comments

Comments
 (0)