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

Commit

Permalink
Fixed bad array deallocations in setup, and fixed bad array range pro…
Browse files Browse the repository at this point in the history
…blem in reading in old frames.
  • Loading branch information
daminton committed Aug 19, 2021
1 parent 7182995 commit ba6f482
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1196,9 +1196,12 @@ module function io_read_frame_system(self, iu, param) result(ierr)
integer(I4B) :: ierr !! Error code: returns 0 if the read is successful
! Internals
character(len=STRMAX) :: errmsg
integer(I4B) :: npl, ntp

ierr = io_read_hdr(iu, param%t, self%pl%nbody, self%tp%nbody, param%out_form, param%out_type)
ierr = io_read_hdr(iu, param%t, npl, ntp, param%out_form, param%out_type)
if (is_iostat_end(ierr)) return ! Reached the end of the frames
call self%pl%setup(npl, param)
call self%tp%setup(ntp, param)

if (ierr /= 0) then
write(errmsg, *) "Cannot read frame header."
Expand Down
10 changes: 5 additions & 5 deletions src/setup/setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,18 @@ module subroutine setup_pl(self, n, param)
end if

if (param%lrotation) then
if (allocated(self%rot)) deallocate(self%rhill)
if (allocated(self%Ip)) deallocate(self%rhill)
if (allocated(self%rot)) deallocate(self%rot)
if (allocated(self%Ip)) deallocate(self%Ip)
allocate(self%rot(NDIM, n))
allocate(self%Ip(NDIM, n))
self%rot(:,:) = 0.0_DP
self%Ip(:,:) = 0.0_DP
end if

if (param%ltides) then
if (allocated(self%k2)) deallocate(self%rhill)
if (allocated(self%Q)) deallocate(self%rhill)
if (allocated(self%tlag)) deallocate(self%rhill)
if (allocated(self%k2)) deallocate(self%k2)
if (allocated(self%Q)) deallocate(self%Q)
if (allocated(self%tlag)) deallocate(self%tlag)
allocate(self%k2(n))
allocate(self%Q(n))
allocate(self%tlag(n))
Expand Down

0 comments on commit ba6f482

Please sign in to comment.