Skip to content

Commit

Permalink
write: check matching shape for existing disk variable
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Feb 24, 2020
1 parent 78228c4 commit 4caf8e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/tests/test_array.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ subroutine test_write_array(path)
if(ierr/=0) error stop
call h5f%write('/nan', nan, ierr)
if(ierr/=0) error stop
!> test writing wrong size
call h5f%write('/int32-1d', [-1], ierr)
if(ierr==0) error stop 'did not error for write array shape mismatch'

call h5f%finalize(ierr)
if(ierr/=0) error stop

Expand Down
2 changes: 2 additions & 0 deletions src/write.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
if (check(ierr, 'ERROR: setup_write: ' // dname // ' check exist ' // self%filename)) return

if(exists) then
call hdf_shape_check(self, dname, dims, ierr)
if (ierr/=0) return
!> open dataset
call h5dopen_f(self%lid, dname, did, ierr)
if (check(ierr, 'ERROR: setup_write: open ' // dname // ' ' // self%filename)) return
Expand Down

0 comments on commit 4caf8e5

Please sign in to comment.