From bf48b7d1210bf19597c7d2f8f383176a4b72b927 Mon Sep 17 00:00:00 2001 From: Oscar Rodriguez Date: Tue, 9 Apr 2024 11:07:27 +0200 Subject: [PATCH 1/2] explicit initialization of request time variable --- src/neptune.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/neptune.f90 b/src/neptune.f90 index b55433f..dc67002 100644 --- a/src/neptune.f90 +++ b/src/neptune.f90 @@ -597,6 +597,7 @@ subroutine propagate_set( & propCounterAtReset = 0.0d0 lastPropCounterSuccess = 0.0d0 diff = 0.d0 + request_time=0.d0 if(isControlled()) then if(hasToReturn()) return From 8a7178ee070b687adf53909e85b7b3bfd3985820 Mon Sep 17 00:00:00 2001 From: Oscar Rodriguez Date: Tue, 9 Apr 2024 11:10:10 +0200 Subject: [PATCH 2/2] handle reset status in integrator even if intermediate outputs are not selected --- src/neptune.f90 | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/neptune.f90 b/src/neptune.f90 index dc67002..e05cbc8 100644 --- a/src/neptune.f90 +++ b/src/neptune.f90 @@ -971,25 +971,23 @@ subroutine propagate_set( & return end if - if(neptune%output%get_output_switch() .or. neptune%getStoreDataFlag()) then ! this has only to be done in a mode, where output is requested... - if((.not. flag_backward .and. (lastPropCounterSuccess < lastPropCounter)) .or. & - ( flag_backward .and. (lastPropCounterSuccess > lastPropCounter))) then - ! This is the usual case when the intergator cannot go on and needs a valid state to restart from. - state_out = last_state_out - prop_counter = lastPropCounter - else if ((.not. flag_backward .and. (prop_counter > request_time)) .or. & - ( flag_backward .and. (prop_counter < request_time))) then - ! This case may happen when the integrator oversteps the requested time - ! and usually would start interpolation. Though, due to integration issues - ! he never gets to the point of interpolation but sets the prop_counter anyway. - ! This leads to an invalid state, which is also written to output at a time, - ! which was not even requested. - state_out = last_state_out - prop_counter = lastPropCounter - end if - call message(' Resetting to: '//toString(epochs(1)%mjd + prop_counter/86400.d0)//'('//toString(prop_counter), LOGFILE) - call message(' ... restoring state vector: '//toString(state_out%r(1))//', '//toString(state_out%r(2))//', '//toString(state_out%r(3))//', '//toString(state_out%v(1))//', '//toString(state_out%v(2))//', '//toString(state_out%v(3)), LOGFILE) + if((.not. flag_backward .and. (lastPropCounterSuccess < lastPropCounter)) .or. & + ( flag_backward .and. (lastPropCounterSuccess > lastPropCounter))) then + ! This is the usual case when the intergator cannot go on and needs a valid state to restart from. + state_out = last_state_out + prop_counter = lastPropCounter + else if ((.not. flag_backward .and. (prop_counter > request_time)) .or. & + ( flag_backward .and. (prop_counter < request_time))) then + ! This case may happen when the integrator oversteps the requested time + ! and usually would start interpolation. Though, due to integration issues + ! he never gets to the point of interpolation but sets the prop_counter anyway. + ! This leads to an invalid state, which is also written to output at a time, + ! which was not even requested. + state_out = last_state_out + prop_counter = lastPropCounter end if + call message(' Resetting to: '//toString(epochs(1)%mjd + prop_counter/86400.d0)//'('//toString(prop_counter), LOGFILE) + call message(' ... restoring state vector: '//toString(state_out%r(1))//', '//toString(state_out%r(2))//', '//toString(state_out%r(3))//', '//toString(state_out%v(1))//', '//toString(state_out%v(2))//', '//toString(state_out%v(3)), LOGFILE) else if((.not. flag_backward .and. (prop_counter > propCounterAtReset)) .or. & ( flag_backward .and. (prop_counter < propCounterAtReset))) then ! reset 'nresets' flag nresets = 0