From 08bbfcc753bed61cc36671d54f3029cc8b7a63fc Mon Sep 17 00:00:00 2001 From: David A Minton Date: Wed, 4 Jan 2023 22:13:14 -0500 Subject: [PATCH] Allow the swiftest log file to be appended on a restart --- src/base/base_module.f90 | 2 +- src/swiftest/swiftest_driver.f90 | 2 +- src/swiftest/swiftest_io.f90 | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/base/base_module.f90 b/src/base/base_module.f90 index 732045594..fe2f0710b 100644 --- a/src/base/base_module.f90 +++ b/src/base/base_module.f90 @@ -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 diff --git a/src/swiftest/swiftest_driver.f90 b/src/swiftest/swiftest_driver.f90 index 4d8279326..b82a7bd37 100644 --- a/src/swiftest/swiftest_driver.f90 +++ b/src/swiftest/swiftest_driver.f90 @@ -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, & diff --git a/src/swiftest/swiftest_io.f90 b/src/swiftest/swiftest_io.f90 index d88402be2..ba53fde8f 100644 --- a/src/swiftest/swiftest_io.f90 +++ b/src/swiftest/swiftest_io.f90 @@ -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) @@ -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. @@ -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)