Index: LMDZ6/trunk/libf/phylmd/lmdz_call_cloud_optics_prop.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_call_cloud_optics_prop.F90	(revision 4715)
+++ LMDZ6/trunk/libf/phylmd/lmdz_call_cloud_optics_prop.F90	(revision 4715)
@@ -0,0 +1,127 @@
+! $Id$
+MODULE lmdz_call_cloud_optics_prop
+
+CONTAINS
+
+  SUBROUTINE call_cloud_optics_prop(klon, klev, ok_newmicro,&
+       paprs, pplay, temp, radocond, picefra, pclc, &
+    pcltau, pclemi, pch, pcl, pcm, pct, radocondwp, xflwp, xfiwp, xflwc, xfiwc, ok_aie, &
+    mass_solu_aero, mass_solu_aero_pi, pcldtaupi, distcltop, temp_cltop, re, fl, reliq, reice, &
+    reliq_pi, reice_pi, scdnc, cldncl, reffclwtop, lcc, reffclws, &
+    reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
+    icefrac_optics, dNovrN, ptconv,rnebcon, ccwcon)
+
+  ! Interface between the LMDZ physics monitor and the cloud properties calculation routines
+  ! 2023/10/02: L. Raillard, M. Coulon--Decorzens, A. Idelkadi, L. Fairhead
+  ! (E. Vignon and J.-B. Madeleine in spirit)
+  ! List of arguments
+  !------------------
+
+  USE lmdz_cloud_optics_prop_ini , ONLY : ok_cdnc
+  USE lmdz_cloud_optics_prop_ini , ONLY : bl95_b0, bl95_b1
+  USE lmdz_cloud_optics_prop_ini , ONLY : iflag_ice_thermo, ok_new_lscp
+  USE lmdz_cloud_optics_prop, ONLY : cloud_optics_prop
+  
+  USE icefrac_lsc_mod ! computes ice fraction (JBM 3/14)  
+  USE lmdz_lscp_tools, only: icefrac_lscp
+
+  IMPLICIT NONE
+  
+  ! input:
+  INTEGER, INTENT(IN) :: klon, klev      ! number of horizontal and vertical grid points
+  REAL, INTENT(IN) :: paprs(klon, klev+1)! pressure at bottom interfaces [Pa]
+  REAL, INTENT(IN) :: pplay(klon, klev)  ! pressure at the middle of layers [Pa]
+  REAL, INTENT(IN) :: temp(klon, klev)   ! temperature [K]
+  REAL, INTENT(IN) :: radocond(klon, klev) ! cloud condensed water seen by radiation [kg/kg]
+  REAL, INTENT(IN) :: picefra(klon,klev) ! ice fraction in clouds from large scale condensation scheme [-]
+  REAL, INTENT(IN) :: rnebcon(klon,klev) ! convection cloud fraction [-]
+  REAL, INTENT(IN) :: ccwcon(klon,klev)  ! condensed water from deep convection [kg/kg]
+  ! jq for the aerosol indirect effect
+  ! jq introduced by Johannes Quaas (quaas@lmd.jussieu.fr), 27/11/2003
+  REAL, INTENT(IN) :: mass_solu_aero(klon, klev)    ! total mass concentration for all soluble aerosols [ug m-3]
+  REAL, INTENT(IN) :: mass_solu_aero_pi(klon, klev) ! - (pre-industrial value)
+  REAL, INTENT(IN)  :: dNovrN(klon)         ! enhancement factor for cdnc
+  REAL, INTENT(OUT) :: distcltop(klon,klev) ! distance from large scale cloud top [m]
+  REAL, INTENT(OUT) :: temp_cltop(klon,klev)!temperature at large scale cloud top [K]
+
+  LOGICAL, INTENT(IN) :: ptconv(klon, klev) ! flag for grid points affected by deep convection
+  LOGICAL, INTENT(IN) :: ok_newmicro, ok_aie
+
+  ! inout:
+  REAL, INTENT(INOUT) :: pclc(klon, klev) ! cloud fraction for radiation [-]
+
+  ! out:
+  REAL, INTENT(OUT) :: pct(klon)      ! 2D total cloud cover [-]
+  REAL, INTENT(OUT) :: pcl(klon)      ! 2D low cloud cover [-]
+  REAL, INTENT(OUT) :: pcm(klon)      ! 2D mid cloud cover [-]
+  REAL, INTENT(OUT) :: pch(klon)      ! 2D high cloud cover [-]
+  REAL, INTENT(OUT) :: radocondwp(klon) ! total condensed water path (seen by radiation) [kg/m2]
+  REAL, INTENT(OUT) :: xflwp(klon)    ! liquid water path (seen by radiation) [kg/m2]
+  REAL, INTENT(OUT) :: xfiwp(klon)    ! ice water path (seen by radiation) [kg/m2]
+  REAL, INTENT(OUT) :: xflwc(klon, klev) ! liquid water content seen by radiation [kg/kg]
+  REAL, INTENT(OUT) :: xfiwc(klon, klev) ! ice water content seen by radiation [kg/kg]
+  REAL, INTENT(OUT) :: re(klon, klev) ! cloud droplet effective radius multiplied by fl
+  REAL, INTENT(OUT) :: fl(klon, klev) ! xliq * rneb, denominator to re; fraction of liquid water clouds
+                                      ! introduced to avoid problems in the averaging of the output
+                                      ! water clouds within a grid cell
+
+  REAL, INTENT(OUT) :: pcltau(klon, klev) ! cloud optical depth [m]
+  REAL, INTENT(OUT) :: pclemi(klon, klev) ! cloud emissivity [-]
+  REAL, INTENT(OUT) :: pcldtaupi(klon, klev) ! pre-industrial value of cloud optical thickness, ie.
+                                             ! values of optical thickness that does not account
+                                             ! for aerosol effects on cloud droplet radius [m]
+
+  REAL, INTENT(OUT) :: reliq(klon, klev)   ! liquid droplet effective radius [m] 
+  REAL, INTENT(OUT) :: reice(klon, klev)   ! ice effective radius [m]
+  REAL, INTENT(OUT) :: reliq_pi(klon, klev)! liquid droplet effective radius [m], pre-industrial
+  REAL, INTENT(OUT) :: reice_pi(klon, klev)! ice effective radius [m], pre-industrial
+  REAL, INTENT(OUT) :: scdnc(klon, klev)   ! cloud droplet number concentration, mean over the whole mesh [m-3]
+  REAL, INTENT(OUT) :: cldncl(klon)        ! cloud droplet number concentration at top of cloud [m-3]
+  REAL, INTENT(OUT) :: reffclwtop(klon)    ! effective radius of cloud droplet at top of cloud [m] 
+  REAL, INTENT(OUT) :: lcc(klon)           ! liquid Cloud Content at top of cloud [kg/kg]
+  REAL, INTENT(OUT) :: reffclws(klon, klev)! stratiform cloud droplet effective radius 
+  REAL, INTENT(OUT) :: reffclwc(klon, klev)! convective cloud droplet effective radius 
+  REAL, INTENT(OUT) :: cldnvi(klon)        ! column Integrated cloud droplet Number [/m2]
+  REAL, INTENT(OUT) :: lcc3d(klon, klev)   ! cloud fraction for liquid part only [-]
+  REAL, INTENT(OUT) :: lcc3dcon(klon, klev)! cloud fraction for liquid part only, convective clouds [-]
+  REAL, INTENT(OUT) :: lcc3dstra(klon, klev)!cloud fraction for liquid part only, stratiform clouds [-]
+  REAL, INTENT(OUT) :: icc3dcon(klon, klev)! cloud fraction for liquid part only, convective clouds [-]
+  REAL, INTENT(OUT) :: icc3dstra(klon, klev)! cloud fraction for ice part only, stratiform clouds [-] 
+  REAL, INTENT(INOUT) :: icefrac_optics(klon, klev)! ice fraction in clouds seen by radiation [-]
+
+  ! Local variables
+  !----------------
+  INTEGER :: k
+  REAL :: dzfice(klon, klev)
+
+  DO k = 1, klev
+    IF (ok_new_lscp) THEN
+      CALL icefrac_lscp(klon,temp(:,k),iflag_ice_thermo,distcltop(:,k),temp_cltop(:,k), &
+   &         icefrac_optics(:,k),dzfice(:,k))
+    ELSE
+      CALL icefrac_lsc(klon,temp(:,k),pplay(1:klon,k)/paprs(1:klon,1),icefrac_optics(:,k))
+    ENDIF
+  ENDDO
+
+
+  IF (ok_newmicro) THEN       
+    CALL cloud_optics_prop(klon, klev, paprs, pplay, temp, radocond, picefra, pclc, &
+    pcltau, pclemi, pch, pcl, pcm, pct, radocondwp, xflwp, xfiwp, xflwc, xfiwc, &
+    mass_solu_aero, mass_solu_aero_pi, pcldtaupi, distcltop, temp_cltop, re, fl, reliq, reice, &
+    reliq_pi, reice_pi, scdnc, cldncl, reffclwtop, lcc, reffclws, &
+    reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
+    icefrac_optics, dNovrN, ptconv,rnebcon, ccwcon)
+  ELSE
+    CALL nuage (paprs, pplay, &
+               temp, radocond, picefra, pclc, pcltau, pclemi, &
+               pch, pcl,pcm, pct, radocondwp, &
+               ok_aie, &
+               mass_solu_aero, mass_solu_aero_pi, &
+               bl95_b0, bl95_b1, distcltop, temp_cltop, &
+               pcldtaupi, re, fl)
+  ENDIF
+  RETURN
+
+END SUBROUTINE call_cloud_optics_prop
+
+END MODULE lmdz_call_cloud_optics_prop
Index: LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.F90	(revision 4714)
+++ LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.F90	(revision 4715)
@@ -29,6 +29,4 @@
   USE lmdz_cloud_optics_prop_ini , ONLY : zepsec, novlp, iflag_ice_thermo, ok_new_lscp
   
-  USE icefrac_lsc_mod ! computes ice fraction (JBM 3/14)
-  USE lmdz_lscp_tools, only: icefrac_lscp
 
 
@@ -112,5 +110,5 @@
   REAL, INTENT(OUT) :: icc3dcon(klon, klev)! cloud fraction for liquid part only, convective clouds [-]
   REAL, INTENT(OUT) :: icc3dstra(klon, klev)! cloud fraction for ice part only, stratiform clouds [-] 
-  REAL, INTENT(OUT) :: icefrac_optics(klon, klev)! ice fraction in clouds seen by radiation [-]
+  REAL, INTENT(INOUT) :: icefrac_optics(klon, klev)! ice fraction in clouds seen by radiation [-]
 
   ! Local variables
@@ -196,9 +194,9 @@
 
 
-      IF (ok_new_lscp) THEN
-          CALL icefrac_lscp(klon,temp(:,k),iflag_ice_thermo,distcltop(:,k),temp_cltop(:,k),icefrac_optics(:,k),dzfice(:,k))
-      ELSE
-          CALL icefrac_lsc(klon,temp(:,k),pplay(:,k)/paprs(:,1),icefrac_optics(:,k))
-      ENDIF
+!!$      IF (ok_new_lscp) THEN
+!!$          CALL icefrac_lscp(klon,temp(:,k),iflag_ice_thermo,distcltop(:,k),temp_cltop(:,k),icefrac_optics(:,k),dzfice(:,k))
+!!$      ELSE
+!!$          CALL icefrac_lsc(klon,temp(:,k),pplay(:,k)/paprs(:,1),icefrac_optics(:,k))
+!!$      ENDIF
 
       DO i = 1, klon
Index: LMDZ6/trunk/libf/phylmd/nuage.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/nuage.F90	(revision 4714)
+++ LMDZ6/trunk/libf/phylmd/nuage.F90	(revision 4715)
@@ -120,12 +120,14 @@
         ENDIF
 
-        IF ((.NOT. ptconv(i,k)) .AND. ok_new_lscp .AND. ok_icefra_lscp) THEN
-        ! EV: take the ice fraction directly from the lscp code
-        ! consistent only for non convective grid points
-        ! critical for mixed phase clouds
-            DO i=1,klon
-            zfice(i)=picefra(i,k)
-            ENDDO
+    IF (ok_new_lscp .AND. ok_icefra_lscp) THEN
+    ! EV: take the ice fraction directly from the lscp code
+    ! consistent only for non convective grid points
+    ! critical for mixed phase clouds
+        DO i=1,klon
+        IF (.NOT. ptconv(i,k)) THEN
+           zfice(i)=picefra(i,k)
         ENDIF
+        ENDDO
+    ENDIF 
 
 
Index: LMDZ6/trunk/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 4714)
+++ LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 4715)
@@ -78,5 +78,5 @@
     USE wxios, ONLY: g_ctx, wxios_set_context
     USE lmdz_lscp, ONLY : lscp
-    USE lmdz_cloud_optics_prop, ONLY : cloud_optics_prop
+    USE lmdz_call_cloud_optics_prop, ONLY : call_cloud_optics_prop
     USE lmdz_lscp_old, ONLY : fisrtilp
     USE lmdz_wake_ini, ONLY : wake_ini
@@ -1844,4 +1844,20 @@
                              RCPD, RLSTT, RLVTT, RLMLT, &
                              RVTMP2, RTT,RD,RG)
+       ! Test de coherence sur oc_cdnc utilisé uniquement par cloud_optics_prop
+       IF (ok_newmicro) then
+          IF (iflag_rrtm.EQ.1) THEN
+#ifdef CPP_RRTM
+             IF (ok_cdnc.AND.NRADLP.NE.3) THEN
+             abort_message='RRTM choix incoherent NRADLP doit etre egal a 3 ' &
+                  // 'pour ok_cdnc' 
+             CALL abort_physic(modname,abort_message,1)
+             ENDIF
+#else
+
+             abort_message='You should compile with -rrtm if running with '//'iflag_rrtm=1'
+             CALL abort_physic(modname,abort_message,1)
+#endif
+          ENDIF
+       ENDIF   
        CALL cloud_optics_prop_ini(klon, prt_level, lunout, flag_aerosol, &
                                   & ok_cdnc, bl95_b0, &
@@ -4387,23 +4403,9 @@
        ENDIF
 
-       IF (ok_newmicro) then
-! AI          IF (iflag_rrtm.NE.0) THEN 
-          IF (iflag_rrtm.EQ.1) THEN
-#ifdef CPP_RRTM
-             IF (ok_cdnc.AND.NRADLP.NE.3) THEN
-             abort_message='RRTM choix incoherent NRADLP doit etre egal a 3 ' &
-                  // 'pour ok_cdnc' 
-             CALL abort_physic(modname,abort_message,1)
-             ENDIF
-#else
-
-             abort_message='You should compile with -rrtm if running with '//'iflag_rrtm=1'
-             CALL abort_physic(modname,abort_message,1)
-#endif
-          ENDIF
-          CALL cloud_optics_prop(klon, klev, &
+       !Rajout appel a interface calcul proprietes optiques des nuages
+       CALL call_cloud_optics_prop(klon, klev, ok_newmicro, &
                paprs, pplay, t_seri, radocond, picefra, cldfra, &
                cldtau, cldemi, cldh, cldl, cldm, cldt, cldq, &
-               flwp, fiwp, flwc, fiwc, &
+               flwp, fiwp, flwc, fiwc, ok_aie, &
                mass_solu_aero, mass_solu_aero_pi, &
                cldtaupi, distcltop, temp_cltop, re, fl, ref_liq, ref_ice, &
@@ -4411,13 +4413,5 @@
                reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
                zfice, dNovrN, ptconv, rnebcon, clwcon)
-       ELSE
-          CALL nuage (paprs, pplay, &
-               t_seri, radocond, picefra, cldfra, cldtau, cldemi, &
-               cldh, cldl, cldm, cldt, cldq, &
-               ok_aie, &
-               mass_solu_aero, mass_solu_aero_pi, &
-               bl95_b0, bl95_b1, distcltop, temp_cltop, &
-               cldtaupi, re, fl)
-       ENDIF
+
        !
        !IM betaCRF
Index: LMDZ6/trunk/libf/phylmdiso/lmdz_call_cloud_optics_prop.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/lmdz_call_cloud_optics_prop.F90	(revision 4715)
+++ LMDZ6/trunk/libf/phylmdiso/lmdz_call_cloud_optics_prop.F90	(revision 4715)
@@ -0,0 +1,1 @@
+link ../phylmd/lmdz_call_cloud_optics_prop.F90
Index: LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 4714)
+++ LMDZ6/trunk/libf/phylmdiso/physiq_mod.F90	(revision 4715)
@@ -78,5 +78,5 @@
     USE wxios, ONLY: g_ctx, wxios_set_context
     USE lmdz_lscp, ONLY : lscp
-    USE lmdz_cloud_optics_prop, ONLY : cloud_optics_prop
+    USE lmdz_call_cloud_optics_prop, ONLY : call_cloud_optics_prop
     USE lmdz_lscp_old, ONLY : fisrtilp
     USE lmdz_wake_ini, ONLY : wake_ini
@@ -1932,4 +1932,20 @@
                              RCPD, RLSTT, RLVTT, RLMLT, &
                              RVTMP2, RTT,RD,RG)
+       ! Test de coherence sur oc_cdnc utilisé uniquement par cloud_optics_prop
+       IF (ok_newmicro) then
+          IF (iflag_rrtm.EQ.1) THEN
+#ifdef CPP_RRTM
+             IF (ok_cdnc.AND.NRADLP.NE.3) THEN
+             abort_message='RRTM choix incoherent NRADLP doit etre egal a 3 ' &
+                  // 'pour ok_cdnc' 
+             CALL abort_physic(modname,abort_message,1)
+             ENDIF
+#else
+
+             abort_message='You should compile with -rrtm if running with '//'iflag_rrtm=1'
+             CALL abort_physic(modname,abort_message,1)
+#endif
+          ENDIF
+       ENDIF   
        CALL cloud_optics_prop_ini(klon, prt_level, lunout, flag_aerosol, &
                                   & ok_cdnc, bl95_b0, &
@@ -5577,23 +5593,9 @@
        ENDIF
 
-       IF (ok_newmicro) then
-! AI          IF (iflag_rrtm.NE.0) THEN 
-          IF (iflag_rrtm.EQ.1) THEN
-#ifdef CPP_RRTM
-             IF (ok_cdnc.AND.NRADLP.NE.3) THEN
-             abort_message='RRTM choix incoherent NRADLP doit etre egal a 3 ' &
-                  // 'pour ok_cdnc' 
-             CALL abort_physic(modname,abort_message,1)
-             ENDIF
-#else
-
-             abort_message='You should compile with -rrtm if running with '//'iflag_rrtm=1'
-             CALL abort_physic(modname,abort_message,1)
-#endif
-          ENDIF
-          CALL cloud_optics_prop(klon, klev, &
+       !Rajout appel a interface calcul proprietes optiques des nuages
+       CALL call_cloud_optics_prop(klon, klev, ok_newmicro, &
                paprs, pplay, t_seri, radocond, picefra, cldfra, &
                cldtau, cldemi, cldh, cldl, cldm, cldt, cldq, &
-               flwp, fiwp, flwc, fiwc, &
+               flwp, fiwp, flwc, fiwc, ok_aie, &
                mass_solu_aero, mass_solu_aero_pi, &
                cldtaupi, distcltop, temp_cltop, re, fl, ref_liq, ref_ice, &
@@ -5601,13 +5603,5 @@
                reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
                zfice, dNovrN, ptconv, rnebcon, clwcon)
-       ELSE
-          CALL nuage (paprs, pplay, &
-               t_seri, radocond, picefra, cldfra, cldtau, cldemi, &
-               cldh, cldl, cldm, cldt, cldq, &
-               ok_aie, &
-               mass_solu_aero, mass_solu_aero_pi, &
-               bl95_b0, bl95_b1, distcltop, temp_cltop, &
-               cldtaupi, re, fl)
-       ENDIF
+
        !
        !IM betaCRF
