From ba6f4824aeb7d66e1b58563d2f2571a7415cc970 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 19 Aug 2021 12:15:09 -0400 Subject: [PATCH] Fixed bad array deallocations in setup, and fixed bad array range problem in reading in old frames. --- src/io/io.f90 | 5 ++++- src/setup/setup.f90 | 10 +++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/io/io.f90 b/src/io/io.f90 index e2171b169..f7532e7b9 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -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." diff --git a/src/setup/setup.f90 b/src/setup/setup.f90 index 7ee72fd3b..0a2664feb 100644 --- a/src/setup/setup.f90 +++ b/src/setup/setup.f90 @@ -264,8 +264,8 @@ 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 @@ -273,9 +273,9 @@ module subroutine setup_pl(self, n, param) 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))