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

Commit

Permalink
Allow the swiftest log file to be appended on a restart
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Jan 5, 2023
1 parent 794a1d0 commit 08bbfcc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/base/base_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module base
!> User defined parameters that are read in from the parameters input file.
!> Each paramter is initialized to a default values.
type, abstract :: base_parameters
character(len=:), allocatable :: integrator !! Symbolic name of the nbody integrator used
character(len=:), allocatable :: integrator !! Name of the nbody integrator used
character(len=:), allocatable :: param_file_name !! The name of the parameter file
integer(I4B) :: maxid = -1 !! The current maximum particle id number
integer(I4B) :: maxid_collision = 0 !! The current maximum collision id number
Expand Down
2 changes: 1 addition & 1 deletion src/swiftest/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ program swiftest_driver
!> Read in the user-defined parameters file and the initial conditions of the nbody_system
allocate(swiftest_parameters :: param)
param%integrator = trim(adjustl(integrator))
call param%set_display(display_style)
param%display_style = trim(adjustl(display_style))
call param%read_in(param_file_name)

associate(t0 => param%t0, &
Expand Down
9 changes: 6 additions & 3 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +2163,8 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i
end select

iostat = 0

call param%set_display(param%display_style)

! Print the contents of the parameter file to standard output
call param%writer(unit = param%display_unit, iotype = "none", v_list = [0], iostat = iostat, iomsg = iomsg)
Expand Down Expand Up @@ -2737,7 +2739,6 @@ module subroutine swiftest_io_read_in_param(self, param_file_name)

! Read in name of parameter file
self%param_file_name = trim(adjustl(param_file_name))
write(self%display_unit, *) 'Parameter input file is ' // self%param_file_name

!! todo: Currently this procedure does not work in user-defined derived-type input mode
!! as the newline characters are ignored in the input file when compiled in ifort.
Expand All @@ -2762,14 +2763,16 @@ module subroutine swiftest_io_set_display_param(self, display_style)
class(swiftest_parameters), intent(inout) :: self !! Current run configuration parameters
character(*), intent(in) :: display_style !! Style of the output display
! Internals
character(STRMAX) :: errmsg
character(STRMAX) :: errmsg
logical :: fileExists

select case(display_style)
case ('STANDARD')
self%display_unit = OUTPUT_UNIT !! stdout from iso_fortran_env
self%log_output = .false.
case ('COMPACT', 'PROGRESS')
if (self%lrestart) then
inquire(SWIFTEST_LOG_FILE, exist=fileExists)
if (self%lrestart.and.fileExists) then
open(unit=SWIFTEST_LOG_OUT, file=SWIFTEST_LOG_FILE, status="OLD", position="APPEND", err = 667, iomsg = errmsg)
else
open(unit=SWIFTEST_LOG_OUT, file=SWIFTEST_LOG_FILE, status="REPLACE", err = 667, iomsg = errmsg)
Expand Down

0 comments on commit 08bbfcc

Please sign in to comment.