Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #50 #51

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ auto-tests = false
auto-examples = false
external-modules = ["hdf5", "h5lt"]

# HDF5 >= 1.10.6
# link = ["hdf5_hl_fortran", "hdf5_fortran", "hdf5_hl", "hdf5"]

# HDF5 < 1.10.6, and distros that rename the old way such as Ubuntu 22.04
link = ["hdf5hl_fortran", "hdf5_fortran", "hdf5_hl", "hdf5"]

[install]
library = true

Expand Down Expand Up @@ -80,3 +74,6 @@ main = "test_string.f90"
[[test]]
name = "version"
main = "test_version.f90"

[dependencies]
hdf5 = '*'
5 changes: 3 additions & 2 deletions src/utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@
write(stderr,*) "ERROR:h5fortran:get_slice: memory size /= dataset size: check variable slice (index). " // &
" Dset_dims:", ddims, "C Mem_dims:", c_mem_dims, "mem_dims:", mem_dims, "rank(mem_dims):", rank(mem_dims)
error stop "ERROR:h5fortran:get_slice " // dset_name
elseif(any(iend-1 > ddims)) then
write(stderr,*) "ERROR:h5fortran:get_slice: iend: ", iend, ' > dset_dims: ', ddims
elseif(any(iend-istart > ddims)) then
write(stderr,*) "ERROR:h5fortran:get_slice: slice bigger than dataset: check variable slice (index). " // &
" Dset_dims:", ddims, "C Mem_dims:", c_mem_dims, "mem_dims:", mem_dims, "rank(mem_dims):", rank(mem_dims)
error stop "ERROR:h5fortran:get_slice " // dset_name
endif

Expand Down
8 changes: 5 additions & 3 deletions src/write.f90
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@

if (present(istart)) then
if(any(istart < 1)) error stop 'ERROR:h5fortran:create: istart must be >= 1'
if(any(iend <= istart)) error stop 'ERROR:h5fortran:create: iend must be > istart'
if(any(iend < istart)) error stop 'ERROR:h5fortran:create: iend must be >= istart'

call H5Sget_simple_extent_ndims_f(filespace_id, drank, ier)
call estop(ier, "create:H5Sget_simple_extent_ndims", self%filename, dname)

allocate(ddims(drank), maxdims(drank))

call H5Sget_simple_extent_dims_f(filespace_id, ddims, maxdims, ier)
if (ier /= drank) error stop 'ERROR:h5fortran:create: H5Sget_simple_extent_dims: ' // dname // ' in ' // self%filename
if (ier /= drank) &
error stop 'ERROR:h5fortran:create: H5Sget_simple_extent_dims: ' // dname // ' in ' // self%filename

if(any(iend > ddims)) error stop 'ERROR:h5fortran:create: iend > dset_dims' // dname // ' in ' // self%filename
if(any(iend - istart > ddims)) &
error stop 'ERROR:h5fortran:create: iend - istart > dset_dims' // dname // ' in ' // self%filename
else
if (size(mem_dims) == 0) then
!! scalar
Expand Down