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

Commit

Permalink
Fixed problem involving setting string values of info variables. Vari…
Browse files Browse the repository at this point in the history
…ables were not being replaced properly because only part of the strings were being replaced. Fixed by always printing NAMELEN-length strings to the string info variables.
  • Loading branch information
daminton committed Sep 4, 2021
1 parent 840ed47 commit b12a40a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/symba/symba_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ module subroutine symba_util_rearray_pl(self, system, param)

! Reset all of the status flags for this body
pl%status(1:npl) = ACTIVE
pl%info(1:npl)%status = "ACTIVE"
do i = 1, npl
call pl%info(i)%set_value(status="ACTIVE")
end do
pl%ldiscard(1:npl) = .false.
pl%lcollision(1:npl) = .false.
pl%lmask(1:npl) = .true.
Expand Down
18 changes: 12 additions & 6 deletions src/util/util_set.f90
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,24 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig
real(DP), dimension(:), intent(in), optional :: discard_xh !! The heliocentric distance vector at the time of the particle's discard
real(DP), dimension(:), intent(in), optional :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard
integer(I4B), intent(in), optional :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved)
! Internals
character(len=NAMELEN) :: lenstr
character(len=:), allocatable :: fmtlabel

write(lenstr, *) NAMELEN
fmtlabel = "(A" // trim(adjustl(lenstr)) // ")"

if (present(name)) then
self%name = name
write(self%name, fmtlabel) trim(adjustl(name))
end if
if (present(particle_type)) then
self%particle_type = particle_type
write(self%particle_type, fmtlabel) trim(adjustl(particle_type))
end if
if (present(status)) then
write(self%status, fmtlabel) trim(adjustl(status))
end if
if (present(origin_type)) then
self%origin_type = origin_type
write(self%origin_type, fmtlabel) trim(adjustl(origin_type))
end if
if (present(origin_time)) then
self%origin_time = origin_time
Expand All @@ -138,9 +147,6 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig
if (present(discard_time)) then
self%discard_time = discard_time
end if
if (present(status)) then
self%status = status
end if
if (present(discard_xh)) then
self%discard_xh(:) = discard_xh(:)
end if
Expand Down

0 comments on commit b12a40a

Please sign in to comment.