From 5db7d8f621c7c3af8a99c96e1b14b072475afb90 Mon Sep 17 00:00:00 2001
From: Christian Ethe <christian.ethe@ipsl.fr>
Date: Thu, 16 Mar 2023 13:55:07 +0000
Subject: [PATCH] Resolve "Bugfix on PISCES and sette updating"

---
 sette/sette_reference-configurations.sh | 36 +++++++++++++++++++++++++
 src/TOP/PISCES/P4Z/p4zlys.F90           | 22 +++++++--------
 src/TOP/PISCES/P4Z/p4zsms.F90           |  2 +-
 src/TOP/oce_trc.F90                     |  1 +
 4 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/sette/sette_reference-configurations.sh b/sette/sette_reference-configurations.sh
index ddaa5e99..7958cd93 100755
--- a/sette/sette_reference-configurations.sh
+++ b/sette/sette_reference-configurations.sh
@@ -184,6 +184,15 @@ if [ ${DO_RESTART} == "1" ] ;  then
     set_namelist namelist_cfg jpnj 4
     set_namelist namelist_cfg sn_cfctl%l_runstat .true.
     set_namelist namelist_cfg sn_cfctl%l_trcstat .true.
+    set_namelist namelist_top_cfg ln_trcbc  .false.
+    # put ln_ironsed, ln_hydrofe to false
+    # if not you need input files, and for tests is not necessary
+    set_namelist namelist_pisces_cfg ln_varpar .false.
+    set_namelist namelist_pisces_cfg ln_ironsed .false.
+    set_namelist namelist_pisces_cfg ln_ironice .false.
+    set_namelist namelist_pisces_cfg ln_hydrofe .false.
+    # put ln_pisdmp to false : no restoring to global mean value
+    set_namelist namelist_pisces_cfg ln_pisdmp .false.
     set_namelist_opt namelist_cfg ln_timing ${USING_TIMING} .true. .false.
     set_namelist_opt namelist_cfg nn_hls ${USING_EXTRA_HALO} 3 2
     set_namelist_opt namelist_cfg nn_comm ${USING_COLLECTIVES} 2 1
@@ -211,6 +220,15 @@ if [ ${DO_RESTART} == "1" ] ;  then
     set_namelist namelist_cfg sn_cfctl%l_trcstat .true.
     set_namelist namelist_top_cfg ln_rsttr .true.
     set_namelist namelist_top_cfg nn_rsttr 2
+        set_namelist namelist_top_cfg ln_trcbc  .false.
+    # put ln_ironsed, ln_hydrofe to false
+    # if not you need input files, and for tests is not necessary
+    set_namelist namelist_pisces_cfg ln_varpar .false.
+    set_namelist namelist_pisces_cfg ln_ironsed .false.
+    set_namelist namelist_pisces_cfg ln_ironice .false.
+    set_namelist namelist_pisces_cfg ln_hydrofe .false.
+    # put ln_pisdmp to false : no restoring to global mean value
+    set_namelist namelist_pisces_cfg ln_pisdmp .false.
     set_namelist namelist_cfg cn_ocerst_in \"GYREPIS_LONG_${ITRST}_restart\"
     set_namelist namelist_top_cfg cn_trcrst_in \"GYREPIS_LONG_${ITRST}_restart_trc\"
     set_namelist_opt namelist_cfg ln_timing ${USING_TIMING} .true. .false.
@@ -251,6 +269,15 @@ if [ ${DO_REPRO} == "1" ] ;  then
     set_namelist namelist_cfg jpnj 4
     set_namelist namelist_cfg sn_cfctl%l_runstat .true.
     set_namelist namelist_cfg sn_cfctl%l_trcstat .true.
+        set_namelist namelist_top_cfg ln_trcbc  .false.
+    # put ln_ironsed, ln_hydrofe to false
+    # if not you need input files, and for tests is not necessary
+    set_namelist namelist_pisces_cfg ln_varpar .false.
+    set_namelist namelist_pisces_cfg ln_ironsed .false.
+    set_namelist namelist_pisces_cfg ln_ironice .false.
+    set_namelist namelist_pisces_cfg ln_hydrofe .false.
+    # put ln_pisdmp to false : no restoring to global mean value
+    set_namelist namelist_pisces_cfg ln_pisdmp .false.
     set_namelist_opt namelist_cfg ln_timing ${USING_TIMING} .true. .false.
     set_namelist_opt namelist_cfg nn_hls ${USING_EXTRA_HALO} 3 2
     set_namelist_opt namelist_cfg nn_comm ${USING_COLLECTIVES} 2 1
@@ -278,6 +305,15 @@ if [ ${DO_REPRO} == "1" ] ;  then
     set_namelist namelist_cfg jpnj 2
     set_namelist namelist_cfg sn_cfctl%l_runstat .true.
     set_namelist namelist_cfg sn_cfctl%l_trcstat .true.
+    set_namelist namelist_top_cfg ln_trcbc  .false.
+    # put ln_ironsed, ln_hydrofe to false
+    # if not you need input files, and for tests is not necessary
+    set_namelist namelist_pisces_cfg ln_varpar .false.
+    set_namelist namelist_pisces_cfg ln_ironsed .false.
+    set_namelist namelist_pisces_cfg ln_ironice .false.
+    set_namelist namelist_pisces_cfg ln_hydrofe .false.
+    # put ln_pisdmp to false : no restoring to global mean value
+    set_namelist namelist_pisces_cfg ln_pisdmp .false.
     set_namelist_opt namelist_cfg ln_timing ${USING_TIMING} .true. .false.
     set_namelist_opt namelist_cfg nn_hls ${USING_EXTRA_HALO} 3 2
     set_namelist_opt namelist_cfg nn_comm ${USING_COLLECTIVES} 2 1
diff --git a/src/TOP/PISCES/P4Z/p4zlys.F90 b/src/TOP/PISCES/P4Z/p4zlys.F90
index 7745ec24..d67060f1 100644
--- a/src/TOP/PISCES/P4Z/p4zlys.F90
+++ b/src/TOP/PISCES/P4Z/p4zlys.F90
@@ -87,7 +87,7 @@ CONTAINS
       ENDIF
       !
       DO_3D( 0, 0, 0, 0, 1, jpkm1)
-         zhinit(ji,jj,jk) = hi(ji,jj,jk) / ( rhd(ji,jj,jk) + 1._wp )
+         zhinit(ji,jj,jk) = hi(ji,jj,jk) * 1000._wp / ( rhop(ji,jj,jk) + rtrn )
       END_3D
       !
       !     -------------------------------------------
@@ -99,7 +99,7 @@ CONTAINS
       DO_3D( 0, 0, 0, 0, 1, jpkm1)
          zco3(ji,jj,jk) = tr(ji,jj,jk,jpdic,Kbb) * ak13(ji,jj,jk) * ak23(ji,jj,jk) / (zhi(ji,jj,jk)**2   &
             &             + ak13(ji,jj,jk) * zhi(ji,jj,jk) + ak13(ji,jj,jk) * ak23(ji,jj,jk) + rtrn )
-         hi  (ji,jj,jk) = zhi(ji,jj,jk) * ( rhd(ji,jj,jk) + 1._wp )
+         hi  (ji,jj,jk) = zhi(ji,jj,jk) * rhop(ji,jj,jk) / 1000._wp
       END_3D
 
       !     ---------------------------------------------------------
@@ -111,9 +111,9 @@ CONTAINS
       DO_3D( 0, 0, 0, 0, 1, jpkm1)
 
          ! DEVIATION OF [CO3--] FROM SATURATION VALUE
-         ! Salinity dependance in zomegaca and divide by rhd to have good units
+         ! Salinity dependance in zomegaca and divide by rhop to have good units
          zcalcon  = calcon * ( salinprac(ji,jj,jk) / 35._wp )
-         zrhd    = rhd(ji,jj,jk) + 1._wp
+         zrhd    = rhop(ji,jj,jk) / 1000._wp
          zomegaca = ( zcalcon * zco3(ji,jj,jk) ) / ( aksp(ji,jj,jk) * zrhd + rtrn )
 
          ! SET DEGREE OF UNDER-/SUPERSATURATION
@@ -203,8 +203,8 @@ CONTAINS
          ENDIF
          IF( iom_use( "CO3sat" ) ) THEN  ! calcite saturation
              DO_3D( 0, 0, 0, 0, 1, jpkm1)
-                zrhd  = rhd(ji,jj,jk) + 1._wp
-                zw3d(ji,jj,jk) = aksp(ji,jj,jk) * zrhd / ( calcon * ( salinprac(ji,jj,jk) / 35._wp ) + rtrn )  &
+                zrhd  = rhop(ji,jj,jk) / 1000._wp
+                zw3d(ji,jj,jk) = aksp(ji,jj,jk) / zrhd / ( calcon * ( salinprac(ji,jj,jk) / 35._wp ) + rtrn )  &
                  &            * 1.e+3 * tmask(ji,jj,jk)
              END_3D
              CALL iom_put( "CO3sat", zw3d )
@@ -250,7 +250,7 @@ CONTAINS
       ENDIF
       !
       DO_3D( 0, 0, 0, 0, 1, jpkm1)
-         zhinit(ji,jj,jk) = hi(ji,jj,jk) / ( rhd(ji,jj,jk) + 1._wp )
+         zhinit(ji,jj,jk) = hi(ji,jj,jk) * 1000._wp / ( rhop(ji,jj,jk) + rtrn )
       END_3D
       !
       !     -------------------------------------------
@@ -262,7 +262,7 @@ CONTAINS
       DO_3D( 0, 0, 0, 0, 1, jpkm1)
          zco3(ji,jj,jk) = tr(ji,jj,jk,jpdic,Kbb) * ak13(ji,jj,jk) * ak23(ji,jj,jk) / (zhi(ji,jj,jk)**2   &
             &             + ak13(ji,jj,jk) * zhi(ji,jj,jk) + ak13(ji,jj,jk) * ak23(ji,jj,jk) + rtrn )
-         hi  (ji,jj,jk) = zhi(ji,jj,jk) * ( rhd(ji,jj,jk) + 1._wp )
+         hi  (ji,jj,jk) = zhi(ji,jj,jk) * rhop(ji,jj,jk) / 1000._wp
       END_3D
 
       !     ---------------------------------------------------------
@@ -276,7 +276,7 @@ CONTAINS
          ! DEVIATION OF [CO3--] FROM SATURATION VALUE
          ! Salinity dependance in zomegaca and divide by rhd to have good units
          zcalcon  = calcon * ( salinprac(ji,jj,jk) / 35._wp )
-         zrhd    = rhd(ji,jj,jk) + 1._wp
+         zrhd    = rhop(ji,jj,jk) / 1000._wp
          zomegaca = ( zcalcon * zco3(ji,jj,jk) ) / ( aksp(ji,jj,jk) * zrhd + rtrn )
 
          ! SET DEGREE OF UNDER-/SUPERSATURATION
@@ -330,8 +330,8 @@ CONTAINS
          ENDIF
          IF( iom_use( "CO3sat" ) ) THEN  ! calcite saturation
              DO_3D( 0, 0, 0, 0, 1, jpkm1)
-                zrhd  = rhd(ji,jj,jk) + 1._wp
-                zw3d(ji,jj,jk) = aksp(ji,jj,jk) * zrhd / ( calcon * ( salinprac(ji,jj,jk) / 35._wp ) + rtrn )  &
+                zrhd  = rhop(ji,jj,jk) / 1000._wp
+                zw3d(ji,jj,jk) = aksp(ji,jj,jk) / zrhd / ( calcon * ( salinprac(ji,jj,jk) / 35._wp ) + rtrn )  &
                  &            * 1.e+3 * tmask(ji,jj,jk)
              END_3D
              CALL iom_put( "CO3sat", zw3d ) 
diff --git a/src/TOP/PISCES/P4Z/p4zsms.F90 b/src/TOP/PISCES/P4Z/p4zsms.F90
index 18527c6b..ab808d3e 100644
--- a/src/TOP/PISCES/P4Z/p4zsms.F90
+++ b/src/TOP/PISCES/P4Z/p4zsms.F90
@@ -455,10 +455,10 @@ CONTAINS
             CALL iom_rstput( kt, nitrst, numrtw, 'Thetanano' , thetanano(:,:,:)  )
          ENDIF
 
+         CALL iom_rstput( kt, nitrst, numrtw, 'Consfe3', consfe3(:,:,:) ) ! Si max concentration
          IF ( ln_p4z .OR. ln_p5z ) THEN
             CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:)    )
             CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:) )
-            CALL iom_rstput( kt, nitrst, numrtw, 'Consfe3', consfe3(:,:,:) ) ! Si max concentration
             CALL iom_rstput( kt, nitrst, numrtw, 'sized', sized(:,:,:) )  ! Size of diatoms
          ENDIF
          IF( ln_p5z ) CALL iom_rstput( kt, nitrst, numrtw, 'sizep', sizep(:,:,:) )  ! Size of picophytoplankton
diff --git a/src/TOP/oce_trc.F90 b/src/TOP/oce_trc.F90
index f7c3b550..9bfda6b9 100644
--- a/src/TOP/oce_trc.F90
+++ b/src/TOP/oce_trc.F90
@@ -38,6 +38,7 @@ MODULE oce_trc
    USE oce , ONLY :   vv     =>    vv     !: j-horizontal velocity (m s-1)
    USE oce , ONLY :   ww     =>    ww     !: vertical velocity (m s-1)  
    USE oce , ONLY :   ts     =>    ts     !: 4D array contaning ( tn, sn )
+   USE oce , ONLY :   rhop   =>    rhop   !: potential density (no units)
    USE oce , ONLY :   rhd    =>    rhd    !: in situ density anomalie rhd=(rho-rho0)/rho0 (no units)
    USE oce , ONLY :   hdiv   =>    hdiv   !: horizontal divergence (1/s)
    USE oce , ONLY :   ssh    =>    ssh    !: sea surface height at t-point [m]   
-- 
GitLab