From b12a40afb280832eaea2e415943ef53895ac3abc Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sat, 4 Sep 2021 15:53:58 -0400 Subject: [PATCH] Fixed problem involving setting string values of info variables. Variables 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. --- src/symba/symba_util.f90 | 4 +++- src/util/util_set.f90 | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index b68635b0e..8b8e48f47 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -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. diff --git a/src/util/util_set.f90 b/src/util/util_set.f90 index 48c0006c2..80ed89b1f 100644 --- a/src/util/util_set.f90 +++ b/src/util/util_set.f90 @@ -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 @@ -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