Index: LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.F90	(revision 4690)
+++ LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop.F90	(revision 4692)
@@ -4,18 +4,20 @@
 CONTAINS
 
-SUBROUTINE cloud_optics_prop(flag_aerosol, ok_cdnc, bl95_b0, bl95_b1, paprs, pplay, t, pqlwp, picefra, pclc, &
+SUBROUTINE cloud_optics_prop(klon, klev, paprs, pplay, t, pqlwp, picefra, pclc, &
     pcltau, pclemi, pch, pcl, pcm, pct, pctlwp, xflwp, xfiwp, xflwc, xfiwc, &
-    mass_solu_aero, mass_solu_aero_pi, pcldtaupi, latitude_deg, distcltop, temp_cltop, re, fl, reliq, reice, &
-    reliq_pi, reice_pi)
-
-  USE dimphy
-  USE phys_local_var_mod, ONLY: scdnc, cldncl, reffclwtop, lcc, reffclws, &
-      reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
-      zfice, dNovrN, ptconv
-  USE phys_state_var_mod, ONLY: rnebcon, clwcon
+    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,  & 
+    zfice, dNovrN, ptconv,rnebcon, clwcon)
+
+  USE lmdz_cloud_optics_prop_ini , ONLY : flag_aerosol, ok_cdnc
+  USE lmdz_cloud_optics_prop_ini , ONLY : lunout
+  USE lmdz_cloud_optics_prop_ini , ONLY : bl95_b0, bl95_b1
+  USE lmdz_cloud_optics_prop_ini , ONLY : latitude_deg
+  USE lmdz_cloud_optics_prop_ini , ONLY : iflag_t_glace
+  USE lmdz_cloud_optics_prop_ini , ONLY : cdnc_max, cdnc_max_m3
+  USE lmdz_cloud_optics_prop_ini , ONLY : cdnc_min, cdnc_min_m3
+
   USE icefrac_lsc_mod ! computes ice fraction (JBM 3/14)
-  USE lmdz_lscp_ini, only: iflag_t_glace
-  USE ioipsl_getin_p_mod, ONLY : getin_p
-  USE print_control_mod, ONLY: lunout
   USE lmdz_lscp_tools, only: icefrac_lscp
 
@@ -63,4 +65,5 @@
   ! ======================================================================
 
+
   include "YOMCST.h"
   include "nuage.h"
@@ -69,4 +72,5 @@
   include "clesphys.h"
 
+  
   ! choix de l'hypothese de recouvrement nuageuse via radopt.h (IM, 19.07.2016)
   ! !novlp=1: max-random
@@ -80,4 +84,46 @@
   INTEGER flag_max
 
+  ! List of arguments:
+  INTEGER, INTENT(IN) :: klon, klev
+  REAL, INTENT(IN) :: paprs(klon, klev+1)
+  REAL, INTENT(IN) :: pplay(klon, klev)
+  REAL, INTENT(IN) :: t(klon, klev)
+  REAL, INTENT(INOUT) :: pclc(klon, klev)
+  REAL, INTENT(IN) :: pqlwp(klon, klev), picefra(klon,klev)
+  REAL, INTENT(IN) :: rnebcon(klon,klev), clwcon(klon,klev)
+  REAL, INTENT(OUT) :: pcltau(klon, klev)
+  REAL, INTENT(OUT) :: pclemi(klon, klev)
+  REAL, INTENT(OUT) :: pcldtaupi(klon, klev)
+
+  REAL, INTENT(OUT) :: pct(klon)
+  REAL, INTENT(OUT) :: pcl(klon)
+  REAL, INTENT(OUT) :: pcm(klon)
+  REAL, INTENT(OUT) :: pch(klon)
+  REAL, INTENT(OUT) :: pctlwp(klon)
+
+  REAL, INTENT(OUT) :: distcltop(klon,klev)
+  REAL, INTENT(OUT) :: temp_cltop(klon,klev)
+  REAL, INTENT(OUT) :: xflwp(klon), xfiwp(klon)
+  REAL, INTENT(OUT) :: xflwc(klon, klev), xfiwc(klon, klev)
+  ! 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(OUT) :: re(klon, klev) ! cloud droplet effective radius [um]
+  REAL, INTENT(OUT) :: fl(klon, klev) ! xliq * rneb (denominator to re; fraction of liquid water clouds
+  ! within the grid cell)
+  ! Abderrahmane oct 2009
+  REAL, INTENT(OUT) :: reliq(klon, klev), reice(klon, klev)
+  REAL, INTENT(OUT) :: reliq_pi(klon, klev), reice_pi(klon, klev)
+  !
+  REAL, INTENT(OUT) :: scdnc(klon, klev), cldncl(klon), reffclwtop(klon)
+  REAL, INTENT(OUT) :: lcc(klon), reffclws(klon, klev)
+  REAL, INTENT(OUT) :: reffclwc(klon, klev), cldnvi(klon), lcc3d(klon, klev)
+  REAL, INTENT(OUT) :: lcc3dcon(klon, klev), lcc3dstra(klon, klev), icc3dcon(klon, klev)
+  REAL, INTENT(OUT) :: icc3dstra(klon, klev), zfice(klon, klev)
+  REAL, INTENT(IN)  :: dNovrN(klon)
+  LOGICAL, INTENT(IN) :: ptconv(klon, klev)
+
+  ! Local variables
   ! threshold PARAMETERs
   REAL thres_tau, thres_neb
@@ -87,22 +133,4 @@
   REAL tcc(klon), ftmp(klon), lcc_integrat(klon), height(klon)
 
-  REAL paprs(klon, klev+1)
-  REAL pplay(klon, klev)
-  REAL t(klon, klev)
-  REAL pclc(klon, klev)
-  REAL pqlwp(klon, klev), picefra(klon,klev)
-  REAL pcltau(klon, klev)
-  REAL pclemi(klon, klev)
-  REAL pcldtaupi(klon, klev)
-  REAL latitude_deg(klon)
-
-  REAL pct(klon)
-  REAL pcl(klon)
-  REAL pcm(klon)
-  REAL pch(klon)
-  REAL pctlwp(klon)
-
-  REAL distcltop(klon,klev)
-  REAL temp_cltop(klon,klev)
   LOGICAL lo
 
@@ -118,6 +146,4 @@
 
   INTEGER i, k
-  REAL xflwp(klon), xfiwp(klon)
-  REAL xflwc(klon, klev), xfiwc(klon, klev)
 
   REAL radius
@@ -145,19 +171,8 @@
   ! jq introduced by Johannes Quaas (quaas@lmd.jussieu.fr), 27/11/2003
   ! jq
-  REAL mass_solu_aero(klon, klev) ! total mass concentration for all soluble aerosols [ug m-3]
-  REAL mass_solu_aero_pi(klon, klev) ! - " - (pre-industrial value)
   REAL cdnc(klon, klev) ! cloud droplet number concentration [m-3]
-  REAL re(klon, klev) ! cloud droplet effective radius [um]
   REAL cdnc_pi(klon, klev) ! cloud droplet number concentration [m-3] (pi value)
   REAL re_pi(klon, klev) ! cloud droplet effective radius [um] (pi value)
 
-  REAL fl(klon, klev) ! xliq * rneb (denominator to re; fraction of liquid water clouds
-  ! within the grid cell)
-
-  INTEGER flag_aerosol
-  LOGICAL ok_cdnc
-  REAL bl95_b0, bl95_b1 ! Parameter in B&L 95-Formula
-
-  ! jq-end
   ! IM cf. CR:parametres supplementaires
   REAL dzfice(klon,klev)
@@ -175,14 +190,4 @@
   REAL d_rei_dt
 
-  ! Abderrahmane oct 2009
-  REAL reliq(klon, klev), reice(klon, klev)
-  REAL reliq_pi(klon, klev), reice_pi(klon, klev)
-
-  REAL,SAVE :: cdnc_min=-1.
-  REAL,SAVE :: cdnc_min_m3
-  !$OMP THREADPRIVATE(cdnc_min,cdnc_min_m3)
-  REAL,SAVE :: cdnc_max=-1.
-  REAL,SAVE :: cdnc_max_m3
-  !$OMP THREADPRIVATE(cdnc_max,cdnc_max_m3)
 
   ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -198,14 +203,4 @@
   ! on impose 0.71 quand on est proche de 0.71
 
-  if (first) THEN
-      call getin_p('cdnc_min',cdnc_min)
-      cdnc_min_m3=cdnc_min*1.E6
-      IF (cdnc_min_m3<0.) cdnc_min_m3=20.E6 ! astuce pour retrocompatibilite
-      write(lunout,*)'cdnc_min=', cdnc_min_m3/1.E6
-      call getin_p('cdnc_max',cdnc_max)
-      cdnc_max_m3=cdnc_max*1.E6
-      IF (cdnc_max_m3<0.) cdnc_max_m3=1000.E6 ! astuce pour retrocompatibilite
-      write(lunout,*)'cdnc_max=', cdnc_max_m3/1.E6
-  ENDIF
 
   d_rei_dt = (rei_max-rei_min)/81.4
Index: LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop_ini.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop_ini.F90	(revision 4692)
+++ LMDZ6/trunk/libf/phylmd/lmdz_cloud_optics_prop_ini.F90	(revision 4692)
@@ -0,0 +1,56 @@
+MODULE lmdz_cloud_optics_prop_ini
+  IMPLICIT NONE
+
+  SAVE
+
+  INTEGER, PROTECTED :: prt_level, lunout
+  INTEGER, PROTECTED :: flag_aerosol
+  INTEGER, PROTECTED :: iflag_t_glace=0
+  LOGICAL, PROTECTED ::ok_cdnc
+  REAL, PROTECTED :: bl95_b0, bl95_b1 ! Parameter in B&L 95-Formula
+  REAL, ALLOCATABLE :: latitude_deg(:)
+  !$OMP THREADPRIVATE(latitude_deg)
+  REAL, PROTECTED :: cdnc_max=-1.
+  REAL, PROTECTED :: cdnc_max_m3=-1.
+  REAL, PROTECTED :: cdnc_min=-1.
+  REAL, PROTECTED :: cdnc_min_m3=-1.
+  
+CONTAINS
+
+  SUBROUTINE cloud_optics_prop_ini(klon, prt_level_in, lunout_in, flag_aerosol_in, &
+       & ok_cdnc_in, bl95_b0_in, &
+       & bl95_b1_in, latitude_deg_in)
+
+    USE ioipsl_getin_p_mod, ONLY : getin_p
+
+    IMPLICIT NONE
+    INTEGER, INTENT(IN) :: klon
+    INTEGER, INTENT(IN) :: prt_level_in, lunout_in
+    INTEGER, INTENT(IN) :: flag_aerosol_in
+    LOGICAL, INTENT(IN) :: ok_cdnc_in
+    REAL, INTENT(IN) :: bl95_b0_in, bl95_b1_in
+    REAL, INTENT(IN) :: latitude_deg_in(klon)
+
+    ALLOCATE(latitude_deg(klon))
+
+    prt_level = prt_level_in
+    lunout = lunout_in
+    flag_aerosol = flag_aerosol_in
+    ok_cdnc = ok_cdnc_in
+    bl95_b0 = bl95_b0_in
+    bl95_b1 = bl95_b1_in
+    latitude_deg(:) = latitude_deg_in(:)
+    call getin_p('cdnc_min',cdnc_min)
+    cdnc_min_m3=cdnc_min*1.E6
+    IF (cdnc_min_m3<0.) cdnc_min_m3=20.E6 ! astuce pour retrocompatibilite
+    write(lunout,*)'cdnc_min=', cdnc_min_m3/1.E6
+    call getin_p('cdnc_max',cdnc_max)
+    cdnc_max_m3=cdnc_max*1.E6
+    IF (cdnc_max_m3<0.) cdnc_max_m3=1000.E6 ! astuce pour retrocompatibilite
+    write(lunout,*)'cdnc_max=', cdnc_max_m3/1.E6
+    CALL getin_p('iflag_t_glace',iflag_t_glace)      
+    write(lunout,*)'iflag_t_glace= ',iflag_t_glace
+    
+  END SUBROUTINE cloud_optics_prop_ini
+
+END MODULE lmdz_cloud_optics_prop_ini
Index: LMDZ6/trunk/libf/phylmd/lmdz_thermcell_main.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/lmdz_thermcell_main.F90	(revision 4690)
+++ LMDZ6/trunk/libf/phylmd/lmdz_thermcell_main.F90	(revision 4692)
@@ -197,5 +197,5 @@
       ENDIF
 !
-print*,'thermcell_main debut'
+!print*,'thermcell_main debut'
 !     write(lunout,*)'WARNING thermcell_main f0=max(f0,1.e-2)'
      do ig=1,ngrid
@@ -821,5 +821,5 @@
       if (prt_level.ge.1) print*,'thermcell_main FIN  OK'
 
-print*,'thermcell_main fin'
+!print*,'thermcell_main fin'
  RETURN
       end subroutine thermcell_main
Index: LMDZ6/trunk/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 4690)
+++ LMDZ6/trunk/libf/phylmd/physiq_mod.F90	(revision 4692)
@@ -90,4 +90,5 @@
     USE lmdz_ratqs_main, ONLY : ratqs_main
     USE lmdz_ratqs_ini, ONLY : ratqs_ini
+    USE lmdz_cloud_optics_prop_ini, ONLY : cloud_optics_prop_ini
     USE phys_output_var_mod, ONLY :      cloudth_sth,cloudth_senv,cloudth_sigmath,cloudth_sigmaenv
 
@@ -357,5 +358,8 @@
        zxfluxt,zxfluxq 
        !
-      USE output_physiqex_mod, ONLY: output_physiqex
+       USE phys_local_var_mod, ONLY: scdnc, cldncl, reffclwtop, lcc, reffclws, &
+       reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
+       zfice, dNovrN, ptconv
+       USE output_physiqex_mod, ONLY: output_physiqex
 
 
@@ -1840,5 +1844,7 @@
                              RCPD, RLSTT, RLVTT, RLMLT, &
                              RVTMP2, RTT,RD,RG)
-
+       CALL cloud_optics_prop_ini(klon, prt_level, lunout, flag_aerosol, &
+                                  & ok_cdnc, bl95_b0, &
+                                  & bl95_b1, latitude_deg)
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
@@ -4395,11 +4401,13 @@
 #endif
           ENDIF
-          CALL cloud_optics_prop(flag_aerosol, ok_cdnc, bl95_b0, bl95_b1, &
+          CALL cloud_optics_prop(klon, klev, &
                paprs, pplay, t_seri, radocond, picefra, cldfra, &
                cldtau, cldemi, cldh, cldl, cldm, cldt, cldq, &
                flwp, fiwp, flwc, fiwc, &
                mass_solu_aero, mass_solu_aero_pi, &
-               cldtaupi, latitude_deg, distcltop, temp_cltop, re, fl, ref_liq, ref_ice, &
-               ref_liq_pi, ref_ice_pi)
+               cldtaupi, distcltop, temp_cltop, re, fl, ref_liq, ref_ice, &
+               ref_liq_pi, ref_ice_pi, scdnc, cldncl, reffclwtop, lcc, reffclws, &
+               reffclwc, cldnvi, lcc3d, lcc3dcon, lcc3dstra, icc3dcon, icc3dstra,  & 
+               zfice, dNovrN, ptconv, rnebcon, clwcon)
        ELSE
           CALL nuage (paprs, pplay, &
