Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed bug that caused out of array bounds error
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed May 11, 2023
1 parent 1da2306 commit 912b052
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/netcdf_io/netcdf_io_implementations.f90
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module subroutine netcdf_io_find_tslot(self, t, tslot)
integer(I4B), intent(out) :: tslot !! The index of the time slot where this data belongs
! Internals
real(DP), dimension(:), allocatable :: tvals
integer(I4B) :: i


if (.not.self%lfile_is_open) return
Expand All @@ -75,11 +76,12 @@ module subroutine netcdf_io_find_tslot(self, t, tslot)
else
allocate(tvals(1))
tvals(1) = huge(1.0_DP)
self%max_tslot = 1
end if

tslot = 1
do
if ((t <= tvals(tslot)) .or. (tslot > self%max_tslot)) exit
do i = 1, self%max_tslot
if (t <= tvals(tslot)) exit
tslot = tslot + 1
end do
self%max_tslot = max(self%max_tslot, tslot)
Expand Down

0 comments on commit 912b052

Please sign in to comment.