From 96ea7f15028920b13787948342dfd79d33426fd0 Mon Sep 17 00:00:00 2001
From: Guillaume Samson <guillaume.samson@mercator-ocean.fr>
Date: Thu, 15 Sep 2022 09:13:47 +0000
Subject: [PATCH] Resolve "ABL restartability issue"

---
 cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg         |  1 +
 cfgs/SHARED/namelist_ref                          |  1 +
 sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI |  2 +-
 src/ABL/ablrst.F90                                | 12 ++++++------
 src/ABL/sbcabl.F90                                | 11 +++++------
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg b/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
index c8353d3a..4b17c102 100644
--- a/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
+++ b/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
@@ -117,6 +117,7 @@
 !-----------------------------------------------------------------------
 &namsbc_abl    !   Atmospheric Boundary Layer formulation           (ln_abl = T)
 !-----------------------------------------------------------------------
+   cn_dom           = 'dom_cfg_abl_L25Z10'
 /
 !-----------------------------------------------------------------------
 &namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
diff --git a/cfgs/SHARED/namelist_ref b/cfgs/SHARED/namelist_ref
index ae9d42ee..dcd680dd 100644
--- a/cfgs/SHARED/namelist_ref
+++ b/cfgs/SHARED/namelist_ref
@@ -326,6 +326,7 @@
    nn_dyn_restore = 0         ! restoring option for dynamical ABL variables: = 0 no restoring
                               !                                               = 1 equatorial restoring
                               !                                               = 2 global restoring
+   rn_vfac       = 0.
    rn_ldyn_min   =  4.5       ! dynamics nudging magnitude inside the ABL [hour] (~3 rn_Dt)
    rn_ldyn_max   =  1.5       ! dynamics nudging magnitude above  the ABL [hour] (~1 rn_Dt)
    rn_ltra_min   =  4.5       ! tracers  nudging magnitude inside the ABL [hour] (~3 rn_Dt)
diff --git a/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI b/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI
index 6b7afeac..481b788c 100644
--- a/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI
+++ b/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI
@@ -42,7 +42,7 @@
 # modules to load
 module purge
 module use /home/ext/mr/smer/samsong/modules
-module load gcc/9.2.0 intel/2018.5.274 intelmpi/2018.5.274 phdf5/1.8.18 netcdf_par/4.7.1_V2 xios/3.0/r2399_intel-impi
+module load gcc/9.2.0 intel/2018.5.274 intelmpi/2018.5.274 phdf5/1.8.18 netcdf_par/4.7.1_V2 xios/trunk/rev2320-impi
 export XIO_HOME=${XIOS_DIR}
 
 # Don't remove neither change the following line
diff --git a/src/ABL/ablrst.F90 b/src/ABL/ablrst.F90
index 29445c59..925234b3 100644
--- a/src/ABL/ablrst.F90
+++ b/src/ABL/ablrst.F90
@@ -200,15 +200,15 @@ CONTAINS
          &                   '   control of time parameter  nrstdt' )
 
       ! --- mandatory fields --- ! 
-      CALL iom_get( numrar, jpdom_auto,   'u_abl',   u_abl(:,:,:,nt_n      ), cd_type = 'U', psgn = -1._wp )
-      CALL iom_get( numrar, jpdom_auto,   'v_abl',   v_abl(:,:,:,nt_n      ), cd_type = 'V', psgn = -1._wp )
-      CALL iom_get( numrar, jpdom_auto,   't_abl',  tq_abl(:,:,:,nt_n,jp_ta) )
+      CALL iom_get( numrar, jpdom_auto,   'u_abl',   u_abl(:,:,:,nt_n      ), cd_type = 'T', psgn = -1._wp )
+      CALL iom_get( numrar, jpdom_auto,   'v_abl',   v_abl(:,:,:,nt_n      ), cd_type = 'T', psgn = -1._wp )
+      CALL iom_get( numrar, jpdom_auto,   't_abl',  tq_abl(:,:,:,nt_n,jp_ta), kfill = jpfillcopy )
       CALL iom_get( numrar, jpdom_auto,   'q_abl',  tq_abl(:,:,:,nt_n,jp_qa) )
       CALL iom_get( numrar, jpdom_auto, 'tke_abl', tke_abl(:,:,:,nt_n      ) )
-      CALL iom_get( numrar, jpdom_auto, 'avm_abl', avm_abl(:,:,:           ) )
+      CALL iom_get( numrar, jpdom_auto, 'avm_abl', avm_abl(:,:,:           ), kfill = jpfillcopy )
       CALL iom_get( numrar, jpdom_auto, 'avt_abl', avt_abl(:,:,:           ) )
-      CALL iom_get( numrar, jpdom_auto,'mxld_abl',mxld_abl(:,:,:           ) )
-      CALL iom_get( numrar, jpdom_auto,    'pblh',    pblh(:,:             ) )
+      CALL iom_get( numrar, jpdom_auto,'mxld_abl',mxld_abl(:,:,:           ), kfill = jpfillcopy )
+      CALL iom_get( numrar, jpdom_auto,    'pblh',    pblh(:,:             ), kfill = jpfillcopy )
 
       IF(.NOT.lrxios) CALL iom_delay_rst( 'READ', 'ABL', numrar )   ! read only abl delayed global communication variables
 
diff --git a/src/ABL/sbcabl.F90 b/src/ABL/sbcabl.F90
index f087614e..c3977c5b 100644
--- a/src/ABL/sbcabl.F90
+++ b/src/ABL/sbcabl.F90
@@ -270,6 +270,11 @@ CONTAINS
       nt_n = 1; nt_a = 2
 
       ! initialize ABL from data or restart
+      u_abl  (:,:,:,nt_a     ) = 0._wp
+      v_abl  (:,:,:,nt_a     ) = 0._wp
+      tq_abl (:,:,:,nt_a,:   ) = 0._wp
+      tke_abl(:,:,:,nt_a     ) = 0._wp
+
       IF( ln_rstart_abl ) THEN
          CALL abl_rst_read
       ELSE
@@ -279,16 +284,10 @@ CONTAINS
           v_abl(:,:,:,nt_n      ) = sf(jp_wndj)%fnow(:,:,:)
          tq_abl(:,:,:,nt_n,jp_ta) = sf(jp_tair)%fnow(:,:,:)
          tq_abl(:,:,:,nt_n,jp_qa) = sf(jp_humi)%fnow(:,:,:)
-
          tke_abl(:,:,:,nt_n     ) = tke_min
          avm_abl(:,:,:          ) = avm_bak
          avt_abl(:,:,:          ) = avt_bak
          pblh   (:,:            ) = ghw_abl( 3 )  !<-- assume that the pbl contains 3 grid points
-         u_abl  (:,:,:,nt_a     ) = 0._wp
-         v_abl  (:,:,:,nt_a     ) = 0._wp
-         tq_abl (:,:,:,nt_a,:   ) = 0._wp
-         tke_abl(:,:,:,nt_a     ) = 0._wp
-
          mxlm_abl(:,:,:         ) = mxl_min
          mxld_abl(:,:,:         ) = mxl_min
       ENDIF
-- 
GitLab