Index: LMDZ6/trunk/libf/phylmd/ecrad/lmdz/radiation_scheme_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/ecrad/lmdz/radiation_scheme_mod.F90	(revision 4853)
+++ LMDZ6/trunk/libf/phylmd/ecrad/lmdz/radiation_scheme_mod.F90	(revision 4911)
@@ -1,4 +1,5 @@
 ! AI mars 2021
 ! ====================== Interface between ECRAD and LMDZ ====================
+! Depart de la version IFS R.H 
 ! radiation_scheme.F90 appelee dans radlwsw_m.F90 si iflag_rttm = 2
 ! revoir toutes les parties avec "AI ATTENTION" 
@@ -45,43 +46,4 @@
      &  ecrad_cloud_cover_sw)
 
-! RADIATION_SCHEME - Interface to modular radiation scheme
-!
-! (C) Copyright 2015- ECMWF.
-!
-! This software is licensed under the terms of the Apache Licence Version 2.0
-! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
-!
-! In applying this licence, ECMWF does not waive the privileges and immunities
-! granted to it by virtue of its status as an intergovernmental organisation
-! nor does it submit to any jurisdiction.
-!
-! PURPOSE
-! -------
-!   The modular radiation scheme is contained in a separate
-!   library. This routine puts the the IFS arrays into appropriate
-!   objects, computing the additional data that is required, and sends
-!   it to the radiation scheme.  It returns net fluxes and surface
-!   flux components needed by the rest of the model. 
-!
-!   Lower case is used for variables and types taken from the
-!   radiation library
-!
-! INTERFACE
-! ---------
-!    RADIATION_SCHEME is called from RADLSWR. The
-!    SETUP_RADIATION_SCHEME routine (in the RADIATION_SETUP module)
-!    should have been run first.
-!
-! AUTHOR
-! ------
-!   Robin Hogan, ECMWF
-!   Original: 2015-09-16
-!
-! MODIFICATIONS
-! -------------
-!
-! TO DO
-! -----
-!
 !-----------------------------------------------------------------------
 
@@ -91,11 +53,4 @@
 USE RADIATION_SETUP
 USE YOMCST   , ONLY : RSIGMA ! Stefan-Boltzmann constant
-!USE RADIATION_SETUP, ONLY : SETUP_RADIATION_SCHEME, &
-!                         &  config_type, driver_config_type, &
-!                         &  NWEIGHT_UV,  IBAND_UV,  WEIGHT_UV, &
-!                         &  NWEIGHT_PAR, IBAND_PAR, WEIGHT_PAR, &
-!                         &  ITYPE_TROP_BG_AER,  TROP_BG_AER_MASS_EXT, &
-!                         &  ITYPE_STRAT_BG_AER, STRAT_BG_AER_MASS_EXT, &
-!                         &  ISolverSpartacus
 
 ! Modules from radiation library
@@ -117,9 +72,6 @@
 INTEGER(KIND=JPIM),INTENT(IN) :: KIDIA    ! Start column to process
 INTEGER(KIND=JPIM),INTENT(IN) :: KFDIA    ! End column to process
-!INTEGER, INTENT(IN) :: KIDIA, KFDIA
 INTEGER(KIND=JPIM),INTENT(IN) :: KLON     ! Number of columns
 INTEGER(KIND=JPIM),INTENT(IN) :: KLEV     ! Number of levels
-!INTEGER, INTENT(IN) :: KLON, KLEV
-!INTEGER(KIND=JPIM),INTENT(IN) :: KAEROLMDZ ! Number of aerosol types
 INTEGER(KIND=JPIM),INTENT(IN) :: KAEROSOL
 INTEGER(KIND=JPIM),INTENT(IN) :: NSW ! Numbe of bands
@@ -244,6 +196,4 @@
 type(driver_config_type),save  :: driver_config
 !!$OMP THREADPRIVATE(driver_config)
-!type(config_type)        :: rad_config
-!type(driver_config_type)  :: driver_config
 TYPE(single_level_type)   :: single_level
 TYPE(thermodynamics_type) :: thermodynamics
@@ -261,5 +211,7 @@
 
 ! Cloud overlap decorrelation length for cloud boundaries in km
-REAL(KIND=JPRB)           :: ZDECORR_LEN_KM(KLON)
+REAL(KIND=JPRB)           :: ZDECORR_LEN_M
+REAL(KIND=JPRB)           :: ZDECORR_LEN_M_1D(KLON)
+REAL(KIND=JPRB)           :: ZDECORR_LEN_M_2D(KLON,KLEV)
 
 ! Ratio of cloud overlap decorrelation length for cloud water
@@ -306,12 +258,8 @@
 ! Initialisation dans radiation_setup au 1er passage dans Ecrad
 !$OMP MASTER
-!if (.not.ok_3Deffect) then
   if (debut_ecrad) then
    call SETUP_RADIATION_SCHEME(loutput,namelist_file,rad_config,driver_config)
    debut_ecrad=.false. 
   endif 
-!else
-!   call SETUP_RADIATION_SCHEME(loutput,namelist_file,rad_config,driver_config)
-!endif
 !$OMP END MASTER
 !$OMP BARRIER 
@@ -341,6 +289,4 @@
 
 print*,'************* THERMO (input) ************************************'
-! Set thermodynamic profiles: simply copy over the half-level
-! pressure and temperature
 ! AI
 ! pressure_hl > paprs
@@ -416,14 +362,34 @@
 !CALL CLOUD_OVERLAP_DECORR_LEN(KIDIA, KFDIA, KLON, PGEMU, YRERAD%NDECOLAT, &
 !     &    ZDECORR_LEN_KM, PDECORR_LEN_RATIO=ZDECORR_LEN_RATIO)
-! AI valeur dans namelist
-! rad_config%cloud_inhom_decorr_scaling = ZDECORR_LEN_RATIO
-!AI ATTENTION meme valeur que dans offline
-! A mettre dans namelist
-ZDECORR_LEN_KM = driver_config%overlap_decorr_length
-DO JLON = KIDIA,KFDIA
-  CALL cloud%set_overlap_param(thermodynamics, &
-       &                 ZDECORR_LEN_KM(JLON), &
+CALL CALCUL_CLOUD_OVERLAP_DECORR_LEN &
+     & (KIDIA, KFDIA, KLON, KLEV, &
+     &  driver_config, &
+     &  thermodynamics%pressure_hl, &
+     &  ZDECORR_LEN_M_2D)
+
+ if (driver_config%kdecolat.eq.0) then
+  ZDECORR_LEN_M = ZDECORR_LEN_M_2D(1,1)       
+  DO JLON = KIDIA,KFDIA
+   CALL cloud%set_overlap_param(thermodynamics, &
+       &                 ZDECORR_LEN_M, &
        &                 istartcol=JLON, iendcol=JLON)
-ENDDO
+  ENDDO
+ else if (driver_config%kdecolat.eq.1.or.driver_config%kdecolat.eq.2) then
+  ZDECORR_LEN_M_1D = ZDECORR_LEN_M_2D(:,1)
+  DO JLON = KIDIA,KFDIA
+   CALL cloud%set_overlap_param(thermodynamics, &
+       &                 ZDECORR_LEN_M_1D, &
+       &                 istartcol=JLON, iendcol=JLON)
+  ENDDO
+ else if (driver_config%kdecolat.eq.3) then
+  DO JLON = KIDIA,KFDIA
+   CALL cloud%set_overlap_param_var2D(thermodynamics, &
+       &                 ZDECORR_LEN_M_2D, KLEV, &
+       &                 istartcol=JLON, iendcol=JLON)
+  ENDDO
+ endif
+
+
+
 ! IFS :
 ! Cloud water content fractional standard deviation is configurable
@@ -936,5 +902,7 @@
 
 ! Cloud overlap decorrelation length for cloud boundaries in km
-REAL(KIND=JPRB)           :: ZDECORR_LEN_KM(KLON)
+REAL(KIND=JPRB)           :: ZDECORR_LEN_M
+REAL(KIND=JPRB)           :: ZDECORR_LEN_M_1D(KLON)
+REAL(KIND=JPRB)           :: ZDECORR_LEN_M_2D(KLON,KLEV)
 
 ! Ratio of cloud overlap decorrelation length for cloud water
@@ -1095,10 +1063,32 @@
 !AI ATTENTION meme valeur que dans offline
 ! A mettre dans namelist
-ZDECORR_LEN_KM = driver_config%overlap_decorr_length
-DO JLON = KIDIA,KFDIA
-  CALL cloud%set_overlap_param(thermodynamics, &
-       &                 ZDECORR_LEN_KM(JLON), &
+   CALL CALCUL_CLOUD_OVERLAP_DECORR_LEN &
+     & (KIDIA, KFDIA, KLON, KLEV, &
+     &  driver_config, &
+     &  thermodynamics%pressure_hl , &
+     &  ZDECORR_LEN_M_2D)
+
+ if (driver_config%kdecolat.eq.0) then
+  ZDECORR_LEN_M = ZDECORR_LEN_M_2D(1,1)
+  DO JLON = KIDIA,KFDIA
+   CALL cloud%set_overlap_param(thermodynamics, &
+       &                 ZDECORR_LEN_M, &
        &                 istartcol=JLON, iendcol=JLON)
-ENDDO
+  ENDDO
+ else if (driver_config%kdecolat.eq.1.or.driver_config%kdecolat.eq.2) then
+  ZDECORR_LEN_M_1D = ZDECORR_LEN_M_2D(:,1)
+  DO JLON = KIDIA,KFDIA
+   CALL cloud%set_overlap_param(thermodynamics, &
+       &                 ZDECORR_LEN_M_1D, &
+       &                 istartcol=JLON, iendcol=JLON)
+  ENDDO
+ else if (driver_config%kdecolat.eq.3) then
+  DO JLON = KIDIA,KFDIA
+   CALL cloud%set_overlap_param_var2D(thermodynamics, &
+       &                 ZDECORR_LEN_M_2D, KLEV, &
+       &                 istartcol=JLON, iendcol=JLON)
+  ENDDO
+ endif
+   
 ! IFS :
 ! Cloud water content fractional standard deviation is configurable
