From 801828ea0e4d724bca9c7bf452f0ef7fb0a444a6 Mon Sep 17 00:00:00 2001
From: Quentin Rodier <quentin.rodier@meteo.fr>
Date: Wed, 14 Dec 2022 16:39:00 +0100
Subject: [PATCH] Quentin 14/12/2022: clean MODD, remove modd_ref (not used)
 and modd_conf still present in turb

---
 src/arome/ext/aroini_micro.F90                |  3 +-
 src/arome/micro/ini_lima.F90                  |  2 +-
 src/arome/micro/ini_lima_cold_mixed.F90       |  2 +-
 src/arome/micro/ini_lima_warm.F90             |  2 +-
 src/arome/micro/ini_rain_ice.F90              |  2 +-
 src/common/aux/modd_ref.F90                   | 43 -------------------
 src/common/micro/ini_rain_ice.F90             |  1 -
 src/common/micro/ini_snow.F90                 |  7 ++-
 src/common/turb/mode_turb_hor.F90             |  2 +-
 src/common/turb/mode_turb_hor_thermo_corr.F90 | 10 ++---
 10 files changed, 15 insertions(+), 59 deletions(-)
 delete mode 100644 src/common/aux/modd_ref.F90

diff --git a/src/arome/ext/aroini_micro.F90 b/src/arome/ext/aroini_micro.F90
index 347033c9c..7bc27187a 100644
--- a/src/arome/ext/aroini_micro.F90
+++ b/src/arome/ext/aroini_micro.F90
@@ -64,6 +64,7 @@ USE MODD_RAIN_ICE_DESCR
 USE MODD_RAIN_ICE_PARAM
 USE MODD_PARAM_ICE
 USE MODD_PARAM_C1R3
+USE MODD_REF, ONLY: XTHVREFZ
 
 USE MODI_INI_RAIN_ICE
 USE MODI_INI_TIWMX
@@ -155,7 +156,7 @@ IF(PRESENT(PFRMIN))THEN
    WRITE(UNIT=KULOUT,FMT='('' UPDATED VALUES OF XFRMIN FROM NAMPARAR :'')')
    WRITE(UNIT=KULOUT,FMT='('' XFRMIN = '',40E10.3)') XFRMIN
    IF(XFRMIN(16) > 0.) THEN
-      CALL INI_SNOW(KULOUT) ! Recalculate snow parameters :  XCCS = XFRMIN(16),XCXS = XFRMIN(17)
+      CALL INI_SNOW(KULOUT,XTHVREFZ) ! Recalculate snow parameters :  XCCS = XFRMIN(16),XCXS = XFRMIN(17)
    ENDIF
 ENDIF
 
diff --git a/src/arome/micro/ini_lima.F90 b/src/arome/micro/ini_lima.F90
index 87edfc679..e6a94ef38 100644
--- a/src/arome/micro/ini_lima.F90
+++ b/src/arome/micro/ini_lima.F90
@@ -46,7 +46,7 @@ END MODULE MODI_INI_LIMA
 !              ------------
 !
 USE MODD_CST
-USE MODD_REF
+
 USE MODD_PARAM_LIMA
 USE MODD_PARAMETERS
 USE MODD_LUNIT
diff --git a/src/arome/micro/ini_lima_cold_mixed.F90 b/src/arome/micro/ini_lima_cold_mixed.F90
index d10eac301..ba7e13302 100644
--- a/src/arome/micro/ini_lima_cold_mixed.F90
+++ b/src/arome/micro/ini_lima_cold_mixed.F90
@@ -41,7 +41,7 @@ END MODULE MODI_INI_LIMA_COLD_MIXED
 !              ------------
 !
 USE MODD_CST
-USE MODD_REF
+
 USE MODD_PARAM_LIMA
 USE MODD_PARAM_LIMA_WARM
 USE MODD_PARAM_LIMA_COLD
diff --git a/src/arome/micro/ini_lima_warm.F90 b/src/arome/micro/ini_lima_warm.F90
index 367288e93..e1fce3818 100644
--- a/src/arome/micro/ini_lima_warm.F90
+++ b/src/arome/micro/ini_lima_warm.F90
@@ -40,7 +40,7 @@ END MODULE MODI_INI_LIMA_WARM
 !              ------------
 !
 USE MODD_CST
-USE MODD_REF
+
 USE MODD_PARAM_LIMA
 USE MODD_PARAM_LIMA_WARM
 USE MODD_PARAMETERS
diff --git a/src/arome/micro/ini_rain_ice.F90 b/src/arome/micro/ini_rain_ice.F90
index 3e01f18fd..709e2fd71 100644
--- a/src/arome/micro/ini_rain_ice.F90
+++ b/src/arome/micro/ini_rain_ice.F90
@@ -96,7 +96,7 @@ USE MODD_PARAMETERS
 USE MODD_PARAM_ICE
 USE MODD_RAIN_ICE_DESCR
 USE MODD_RAIN_ICE_PARAM
-USE MODD_REF
+
 !
 USE MODI_GAMMA
 USE MODI_GAMMA_INC
diff --git a/src/common/aux/modd_ref.F90 b/src/common/aux/modd_ref.F90
deleted file mode 100644
index c616ef13d..000000000
--- a/src/common/aux/modd_ref.F90
+++ /dev/null
@@ -1,43 +0,0 @@
-!     ######spl
-      MODULE MODD_REF
-!     ###############
-!
-!!****  *MODD_REF* - declaration of reference state  profile
-!!
-!!    PURPOSE
-!!    -------
-!       The purpose of this declarative module is to declare  the vertical
-!     profile of  the reference state, used for the anelastic
-!     approximation.
-!
-!!
-!!**  IMPLICIT ARGUMENTS
-!!    ------------------
-!!      None
-!!
-!!    REFERENCE
-!!    ---------
-!!      Book2 of documentation of Meso-NH (module MODD_REF)
-!!      Technical Specifications Report of the Meso-NH (chapters 2 and 3)
-!!
-!!    AUTHOR
-!!    ------
-!!      V. Ducrocq   *Meteo France*
-!!
-!!    MODIFICATIONS
-!!    -------------
-!!      Original   07/06/94
-!-------------------------------------------------------------------------------
-!
-!*       0.   DECLARATIONS
-!             ------------
-!
-IMPLICIT NONE
-!
-!  temperature parameter used in INI_RAIN_ICE,
-!  set to constant value 300k for AROME
-REAL,SAVE, DIMENSION(2) :: XTHVREFZ=300.     ! Thetav(z) for reference
-                                             ! state without orography
-LOGICAL, SAVE   ::LCOUPLES ! AUTOCOUPLED ATMS-OCEAN LES VERSION
-!
-END MODULE MODD_REF
diff --git a/src/common/micro/ini_rain_ice.F90 b/src/common/micro/ini_rain_ice.F90
index daf8625c1..2287dfbc5 100644
--- a/src/common/micro/ini_rain_ice.F90
+++ b/src/common/micro/ini_rain_ice.F90
@@ -91,7 +91,6 @@ USE MODD_PARAMETERS
 USE MODD_PARAM_ICE
 USE MODD_RAIN_ICE_DESCR
 USE MODD_RAIN_ICE_PARAM
-USE MODD_REF
 !
 USE MODI_GAMMA
 USE MODI_GAMMA_INC
diff --git a/src/common/micro/ini_snow.F90 b/src/common/micro/ini_snow.F90
index 4461cac46..8ff219640 100644
--- a/src/common/micro/ini_snow.F90
+++ b/src/common/micro/ini_snow.F90
@@ -1,5 +1,5 @@
 !     ######spl
-      SUBROUTINE INI_SNOW ( KLUOUT )
+      SUBROUTINE INI_SNOW ( KLUOUT, PTHVREFZ )
       USE PARKIND1, ONLY : JPRB
       USE YOMHOOK , ONLY : LHOOK, DR_HOOK
 !     ###########################################################
@@ -50,7 +50,6 @@ USE MODD_PARAMETERS
 USE MODD_PARAM_ICE
 USE MODD_RAIN_ICE_DESCR
 USE MODD_RAIN_ICE_PARAM
-USE MODD_REF
 !
 USE MODI_GAMMA
 USE MODI_GAMMA_INC
@@ -70,7 +69,7 @@ IMPLICIT NONE
 !
 !
 INTEGER,                 INTENT(IN) :: KLUOUT   ! Logical unit number for prints
-
+REAL, DIMENSION(:) :: PTHVREFZ
 !*       0.2   Declarations of local variables :
 !
 INTEGER :: IKB                ! Coordinates of the first physical
@@ -88,7 +87,7 @@ IF (LHOOK) CALL DR_HOOK('INI_RAIN_ICE',0,ZHOOK_HANDLE)
 XCCS = XFRMIN(16)
 XCXS = XFRMIN(17)
 IKB = 1 + JPVEXT
-ZRHO00 = XP00/(XRD*XTHVREFZ(IKB))
+ZRHO00 = XP00/(XRD*PTHVREFZ(IKB))
 !     recalculate ini_rain_ice stuff:
 
 !     3.4    Constants for shape parameter
diff --git a/src/common/turb/mode_turb_hor.F90 b/src/common/turb/mode_turb_hor.F90
index dfa971d9f..c4a03a1be 100644
--- a/src/common/turb/mode_turb_hor.F90
+++ b/src/common/turb/mode_turb_hor.F90
@@ -279,7 +279,7 @@ REAL, DIMENSION(:,:,:),   INTENT(INOUT) ::  PSIGS
       IF (KSPLT==1)                                                  &
       CALL      TURB_HOR_THERMO_CORR(D,CST,TURBN,TLES,               &
                       KRR, KRRL, KRRI,                               &
-                      OOCEAN,OCOMPUTE_SRC,                           &
+                      OOCEAN,OCOMPUTE_SRC,O2D,                       &
                       TPFILE,                                        &
                       PINV_PDXX,PINV_PDYY,                           &
                       PDXX,PDYY,PDZZ,PDZX,PDZY,                      &
diff --git a/src/common/turb/mode_turb_hor_thermo_corr.F90 b/src/common/turb/mode_turb_hor_thermo_corr.F90
index 33d7fbd49..6c00603ea 100644
--- a/src/common/turb/mode_turb_hor_thermo_corr.F90
+++ b/src/common/turb/mode_turb_hor_thermo_corr.F90
@@ -8,7 +8,7 @@ IMPLICIT NONE
 CONTAINS
       SUBROUTINE TURB_HOR_THERMO_CORR(D,CST,TURBN,TLES,              &
                       KRR, KRRL, KRRI,                               &
-                      OOCEAN,OCOMPUTE_SRC,                           &
+                      OOCEAN,OCOMPUTE_SRC,O2D,                       &
                       TPFILE,                                        &
                       PINV_PDXX,PINV_PDYY,                           &
                       PDXX,PDYY,PDZZ,PDZX,PDZY,                      &
@@ -60,7 +60,6 @@ CONTAINS
 !          ------------
 !
 USE MODD_CST, ONLY : CST_t
-USE MODD_CONF
 USE MODD_CTURB
 USE MODD_FIELD,          ONLY: TFIELDDATA, TYPEREAL
 USE MODD_DIMPHYEX,   ONLY: DIMPHYEX_t
@@ -99,6 +98,7 @@ INTEGER,                INTENT(IN)   :: KRRL          ! number of liquid water v
 INTEGER,                INTENT(IN)   :: KRRI          ! number of ice water var.
 LOGICAL,                INTENT(IN)   ::  OOCEAN       ! switch for Ocean model version
 LOGICAL,                INTENT(IN)   ::  OCOMPUTE_SRC ! flag to define dimensions of SIGS and SRCT variables
+LOGICAL,                INTENT(IN)   ::  O2D          ! Logical for 2D model version (modd_conf)
 TYPE(TFILEDATA),          INTENT(IN)    ::  TPFILE       ! Output file
 !
 REAL, DIMENSION(:,:,:),   INTENT(IN)    ::  PINV_PDXX   ! 1./PDXX
@@ -175,7 +175,7 @@ IF ( ( KRRL > 0 .AND. TURBN%LSUBG_COND) .OR. ( TURBN%LTURB_FLX .AND. TPFILE%LOPE
 !*       8.1  <THl THl>
 !
   ! Computes the horizontal variance <THl THl>
-  IF (.NOT. L2D) THEN
+  IF (.NOT. O2D) THEN
     ZFLX(:,:,:) = XCTV * PLM(:,:,:) * PLEPS(:,:,:) *                           &
        ( GX_M_M(PTHLM,PDXX,PDZZ,PDZX)**2 + GY_M_M(PTHLM,PDYY,PDZZ,PDZY)**2 )
   ELSE
@@ -243,7 +243,7 @@ IF ( ( KRRL > 0 .AND. TURBN%LSUBG_COND) .OR. ( TURBN%LTURB_FLX .AND. TPFILE%LOPE
 !*       8.3  <THl Rnp>
 !
     ! Computes the horizontal correlation <THl Rnp>
-    IF (.NOT. L2D) THEN
+    IF (.NOT. O2D) THEN
       ZFLX(:,:,:)=                                                               &
             PLM(:,:,:) * PLEPS(:,:,:) *                                          &
             (GX_M_M(PTHLM,PDXX,PDZZ,PDZX) * GX_M_M(PRM(:,:,:,1),PDXX,PDZZ,PDZX)  &
@@ -331,7 +331,7 @@ IF ( ( KRRL > 0 .AND. TURBN%LSUBG_COND) .OR. ( TURBN%LTURB_FLX .AND. TPFILE%LOPE
 !*       8.4  <Rnp Rnp>
 !
     ! Computes the horizontal variance <Rnp Rnp>
-    IF (.NOT. L2D) THEN
+    IF (.NOT. O2D) THEN
       ZFLX(:,:,:) = XCHV * PLM(:,:,:) * PLEPS(:,:,:) *                      &
            ( GX_M_M(PRM(:,:,:,1),PDXX,PDZZ,PDZX)**2 +                       &
              GY_M_M(PRM(:,:,:,1),PDYY,PDZZ,PDZY)**2 )
-- 
GitLab