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

Commit

Permalink
Lots of fiddly maintenence to get restarts cleaned up and repeatable.…
Browse files Browse the repository at this point in the history
… Dealing with a tricky case where all mass values are the same. The WHM sort on ih3 messed up the order on the restart. Also removed NUL character from strings saved by NetCDF
  • Loading branch information
daminton committed Jan 7, 2023
1 parent 2ed62ee commit d58f672
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
13 changes: 12 additions & 1 deletion src/helio/helio_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ module subroutine helio_util_setup_initialize_system(self, param)
class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters

call whm_util_setup_initialize_system(self, param)
call swiftest_util_setup_initialize_system(self, param)
call self%pl%h2b(self%cb)
call self%tp%h2b(self%cb)
call self%pl%sort("mass", ascending=.false.)

! Make sure that the discard list gets allocated initially
call self%tp_discards%setup(0, param)
call self%pl%set_mu(self%cb)
call self%tp%set_mu(self%cb)

if (param%lgr .and. param%in_type == "ASCII") then !! pseudovelocity conversion for NetCDF input files is handled by NetCDF routines
call self%pl%v2pv(param)
call self%tp%v2pv(param)
end if

call self%pl%flatten(param)

return
Expand Down
19 changes: 19 additions & 0 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,25 @@ module subroutine swiftest_io_netcdf_write_info_cb(self, nc, param)
return
end subroutine swiftest_io_netcdf_write_info_cb

module subroutine swiftest_io_remove_nul_char(string)
!! author: David A. Minton
!!
!! Remove spaces and trailing NUL characters that are introduced by NetCDF strings
implicit none
! Arguments
character(len=*), intent(inout) :: string !! String to make upper case
! Internals
integer(I4B) :: pos

pos = index(string, achar(0)) - 1
if (pos > 0) then
string = trim(adjustl(string(1:pos)))
else
string = trim(adjustl(string))
end if

return
end subroutine swiftest_io_remove_nul_char

module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, iomsg)
!! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott
Expand Down
13 changes: 9 additions & 4 deletions src/swiftest/swiftest_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,10 @@ module subroutine swiftest_io_netcdf_write_info_cb(self, nc, param)
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine swiftest_io_netcdf_write_info_cb

module subroutine swiftest_io_write_discard(self, param)
module subroutine swiftest_io_remove_nul_char(string)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine swiftest_io_write_discard
character(len=*), intent(inout) :: string !! String to remove nul characters from
end subroutine swiftest_io_remove_nul_char

module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, iomsg)
implicit none
Expand Down Expand Up @@ -861,6 +860,12 @@ module subroutine swiftest_io_toupper(string)
character(*), intent(inout) :: string !! String to make upper case
end subroutine swiftest_io_toupper

module subroutine swiftest_io_write_discard(self, param)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
end subroutine swiftest_io_write_discard

module subroutine swiftest_io_write_frame_system(self, param)
implicit none
class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object
Expand Down
12 changes: 8 additions & 4 deletions src/swiftest/swiftest_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2411,16 +2411,20 @@ module subroutine swiftest_util_set_particle_info(self, name, particle_type, sta
fmtlabel = "(A" // trim(adjustl(lenstr)) // ")"

if (present(name)) then
write(self%name, fmtlabel) trim(adjustl(name))
write(self%name, fmtlabel) name
call swiftest_io_remove_nul_char(self%name)
end if
if (present(particle_type)) then
write(self%particle_type, fmtlabel) trim(adjustl(particle_type))
write(self%particle_type, fmtlabel) particle_type
call swiftest_io_remove_nul_char(self%particle_type)
end if
if (present(status)) then
write(self%status, fmtlabel) trim(adjustl(status))
write(self%status, fmtlabel) status
call swiftest_io_remove_nul_char(self%status)
end if
if (present(origin_type)) then
write(self%origin_type, fmtlabel) trim(adjustl(origin_type))
write(self%origin_type, fmtlabel) origin_type
call swiftest_io_remove_nul_char(self%origin_type)
end if
if (present(origin_time)) then
self%origin_time = origin_time
Expand Down

0 comments on commit d58f672

Please sign in to comment.