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

Commit

Permalink
Fixed memory allocation issue in the orbital element conversion method
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Aug 24, 2021
1 parent 25b27a9 commit e66ca96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1660,8 +1660,6 @@ module subroutine io_write_frame_system(self, iu, param)
call pl%write_frame(iu, param)
call tp%write_frame(iu, param)

deallocate(cb, pl, tp)

close(iu, err = 667, iomsg = errmsg)

return
Expand Down
21 changes: 11 additions & 10 deletions src/orbel/orbel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module subroutine orbel_el2xv_vec(self, cb)
if (self%nbody == 0) return

call self%set_mu(cb)
do i = 1, self%nbody
do concurrent (i = 1:self%nbody)
call orbel_el2xv(self%mu(i), self%a(i), self%e(i), self%inc(i), self%capom(i), &
self%omega(i), self%capm(i), self%xh(:, i), self%vh(:, i))
end do
Expand Down Expand Up @@ -288,7 +288,7 @@ real(DP) pure function orbel_flon(e,icapn)
end if

return
end function orbel_flon
end function orbel_flon


!**********************************************************************
Expand Down Expand Up @@ -358,7 +358,7 @@ real(DP) pure function orbel_fget(e,capn)

!write(*,*) 'fget : returning without complete convergence'
return
end function orbel_fget
end function orbel_fget


!**********************************************************************
Expand Down Expand Up @@ -878,18 +878,19 @@ module subroutine orbel_xv2el_vec(self, cb)
if (self%nbody == 0) return

call self%set_mu(cb)
if (.not.allocated(self%a)) allocate(self%a(self%nbody))
if (.not.allocated(self%e)) allocate(self%e(self%nbody))
if (.not.allocated(self%inc)) allocate(self%inc(self%nbody))
if (.not.allocated(self%capom)) allocate(self%capom(self%nbody))
if (.not.allocated(self%omega)) allocate(self%omega(self%nbody))
if (.not.allocated(self%capm)) allocate(self%capm(self%nbody))
do i = 1, self%nbody
if (allocated(self%a)) deallocate(self%a); allocate(self%a(self%nbody))
if (allocated(self%e)) deallocate(self%e); allocate(self%e(self%nbody))
if (allocated(self%inc)) deallocate(self%inc); allocate(self%inc(self%nbody))
if (allocated(self%capom)) deallocate(self%capom); allocate(self%capom(self%nbody))
if (allocated(self%omega)) deallocate(self%omega); allocate(self%omega(self%nbody))
if (allocated(self%capm)) deallocate(self%capm); allocate(self%capm(self%nbody))
do concurrent (i = 1:self%nbody)
call orbel_xv2el(self%mu(i), self%xh(:, i), self%vh(:, i), self%a(i), self%e(i), self%inc(i), &
self%capom(i), self%omega(i), self%capm(i))
end do
end subroutine orbel_xv2el_vec


module pure subroutine orbel_xv2el(mu, x, v, a, e, inc, capom, omega, capm)
!! author: David A. Minton
!!
Expand Down

0 comments on commit e66ca96

Please sign in to comment.