From 56d36e7b49b28317fe7adc8a5090d4202bc84c3d Mon Sep 17 00:00:00 2001
From: Sibylle TECHENE <techenes@irene191.c-irene.tgcc.ccc.cea.fr>
Date: Sat, 19 Feb 2022 13:23:25 +0100
Subject: [PATCH] RK3: store ssh at Kaa after swap in order to get an approx of
 ssh slope for external mode ww computation of next time step

---
 src/OCE/stprk3.F90 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/OCE/stprk3.F90 b/src/OCE/stprk3.F90
index 139cd57c..087b8e55 100644
--- a/src/OCE/stprk3.F90
+++ b/src/OCE/stprk3.F90
@@ -209,8 +209,10 @@ CONTAINS
       CALL stp_RK3_stg( 3, kstp, Nbb, Nnn, Nrhs, Naa )
       !
       Nrhs = Nbb   ;   Nbb  = Naa   ;   Naa  = Nrhs    ! Swap: Nnn unchanged, Nbb <==> Naa
-    
-      ! Swap time levels 
+
+      ! linear extrapolation of ssh to compute ww at the beginning of the next time-step
+      ! ssh(n+1) = 2*ssh(n) - ssh(n-1)    
+      ssh(:,:,Naa) = 2*ssh(:,:,Nbb) - ssh(:,:,Naa)
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! diagnostics and outputs
@@ -241,7 +243,7 @@ CONTAINS
 !!jc: That would be better, but see comment above
 !!
 !!====>>>> to be modified for RK3
-      IF( lrst_oce   )   CALL rst_write    ( kstp, Nbb, Nnn )   ! write output ocean restart file
+      IF( lrst_oce   )   CALL rst_write    ( kstp, Nbb, Nnn, Naa )   ! write output ocean restart file
       IF( ln_sto_eos )   CALL sto_rst_write( kstp )   ! write restart file for stochastic parameters
 
 #if defined key_agrif
-- 
GitLab