From fd7835caf85ffeb6551eb87291a4fb01a866963a Mon Sep 17 00:00:00 2001
From: Antoine Cyril David Hoffmann <ahoffman@spcpc606.epfl.ch>
Date: Fri, 3 Jul 2020 18:25:38 +0200
Subject: [PATCH] correction to end at tmax and not tmax+dt

---
 src/control.F90 | 9 +++++----
 src/tesend.F90  | 4 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/control.F90 b/src/control.F90
index 6ee07ac6..a3f0009d 100644
--- a/src/control.F90
+++ b/src/control.F90
@@ -15,13 +15,13 @@ SUBROUTINE control
 
 
   call daytim('Start at ')
-  
+
   !                   1.2     Define data specific to run
   WRITE(*,*) 'Load basic data...'
   CALL basic_data
   WRITE(*,*) '...basic data loaded.'
 
-  
+
   !                   1.3   Read input parameters from input file
   WRITE(*,*) 'Read input parameters...'
   CALL readinputs
@@ -43,7 +43,7 @@ SUBROUTINE control
   WRITE(*,*) '...initial diagnostics done'
   !
   CALL FLUSH(stdout)
-  
+
   !________________________________________________________________________________
   !              2.   Main loop
   DO
@@ -53,9 +53,10 @@ SUBROUTINE control
      time  = time  + dt
 
      CALL tesend
-     CALL diagnose(step)
      IF( nlend ) EXIT ! exit do loop
 
+     CALL diagnose(step)
+
      ! CALL write_restart ! if want to write a restart file every so often (in case of crash)
   END DO
   !________________________________________________________________________________
diff --git a/src/tesend.F90 b/src/tesend.F90
index 132ed8d2..121637b6 100644
--- a/src/tesend.F90
+++ b/src/tesend.F90
@@ -16,7 +16,7 @@ SUBROUTINE tesend
 
   !________________________________________________________________________________
   !                   2.  Test on NRUN
-  nlend = step .GE. nrun 
+  nlend = step .GT. nrun 
   IF ( nlend ) THEN 
      WRITE(*,'(/a)') 'NRUN steps done'
      RETURN
@@ -25,7 +25,7 @@ SUBROUTINE tesend
 
   !________________________________________________________________________________
   !                   3.  Test on TMAX
-  nlend = time .GE. tmax
+  nlend = time .GT. tmax
   IF ( nlend ) THEN 
      WRITE(*,'(/a)') 'TMAX reached'
      RETURN
-- 
GitLab