Index: LMDZ6/branches/Amaury_dev/libf/phylmd/calcul_divers.h
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/calcul_divers.h	(revision 5144)
+++ 	(revision )
@@ -1,87 +1,0 @@
-
-! $Id$
-
-! itap : nombre de pas de temps de la physique
-! itapm1 : somme du nombre de pas de temps du/des mois precedent/s.
-! (itap - itapm1) : nombre de pas de temps du mois courant
-
-! Ne pas modifier les IFs ci-dessous impliquant itapm1,
-! autrement les resultats seront faux !!
-
-! Ici on utilise MOD(itap - itapm1,NINT(mth_len*un_jour/phys_tstep)).EQ.1)
-! pour detecter le debut de chaque mois lorsque  l on tourne par an.
-
-! IM, 26.05.2023
-
-
-! Initialisations itapm1 du premier mois
-      IF(itap.EQ.1) THEN
-         itapm1=0
-!        PRINT*,'initialisation itap=1 itapm1 ',itapm1
-      ENDIF
-
-! Initialisation debut de mois
-      IF(itap.EQ.itapm1+1) THEN
-         ndayrain_mth(:)=0.
-!        PRINT*,'Initialisation ndayrain_mth ',itap
-      ENDIF
-
-! Initialisation debut de chaque jour
-      IF(MOD(itap,NINT(un_jour/phys_tstep)).EQ.1) THEN
-        nday_rain(:)=0.
-!       PRINT*,'initialisation mois suivants day_rain itap',itap
-      ENDIF
-
-! Calcul a chaque pas de temps de la physique
-         DO i = 1, klon
-            total_rain(i)=rain_fall(i)+snow_fall(i)  
-            IF(total_rain(i).GT.0.) nday_rain(i)=1.
-         ENDDO
-
-! Cumul en fin de journee
-      IF(MOD(itap,NINT(un_jour/phys_tstep)).EQ.0) THEN
-         DO i = 1, klon
-            ndayrain_mth(i)=ndayrain_mth(i)+nday_rain(i)
-         ENDDO
-      ENDIF
-
-! Initialisation fin de mois
-! Ne pas changer le IF ci-dessous, car le compteur itapm1 est augmente
-! apres, dans la boucle !!!
-! IM, 260523
-      IF(MOD(itap-itapm1,NINT(mth_len*un_jour/phys_tstep)).EQ.0) THEN
-        itapm1=itapm1+NINT(mth_len*un_jour/phys_tstep)
-!       PRINT*,'fmois i i1 mjt',itap,itapm1,mth_len,un_jour,phys_tstep
-      ENDIF
-
-! calcul temperatures minimale et maximale moyennees sur le mois 
-
-!initialisation debut de mois pour les fichiers mensuels annuels
-  IF(itap.EQ.itapm1+1) THEN
-     t2m_min_mon=0.
-     t2m_max_mon=0.
-  ENDIF
-
-!initialisation debut de journee pour les fichiers mensuels annuels
-  IF(MOD(itap,NINT(un_jour/phys_tstep)).EQ.1) THEN
-     zt2m_min_mon=zt2m
-     zt2m_max_mon=zt2m
-  ENDIF
-
-!calcul sur tous les pas de temps pour les fichiers mensuels annuels
-     DO i = 1, klon
-        zt2m_min_mon(i)=MIN(zt2m(i),zt2m_min_mon(i))
-        zt2m_max_mon(i)=MAX(zt2m(i),zt2m_max_mon(i))
-     ENDDO
-
-!fin journee
-  IF(MOD(itap,NINT(un_jour/phys_tstep)).EQ.0) THEN
-   t2m_min_mon=t2m_min_mon+zt2m_min_mon 
-   t2m_max_mon=t2m_max_mon+zt2m_max_mon 
-  ENDIF
-
-!fin mois
-  IF(itap==itapm1) THEN
-   t2m_min_mon=t2m_min_mon/mth_len
-   t2m_max_mon=t2m_max_mon/mth_len
-  ENDIF
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/dimphy.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/dimphy.F90	(revision 5144)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/dimphy.F90	(revision 5151)
@@ -2,25 +2,21 @@
 
 MODULE dimphy
+  
+  IMPLICIT NONE; PRIVATE
+  PUBLIC klon, kdlon, kfdia, kidia, klev, klevp1, klevm1, kflev, &
+          init_dimphy, init_dimphy1D, zmasq
 
-  INTEGER, SAVE :: klon
-  INTEGER, SAVE :: kdlon
-  INTEGER, SAVE :: kfdia
-  INTEGER, SAVE :: kidia
-  INTEGER, SAVE :: klev
-  INTEGER, SAVE :: klevp1
-  INTEGER, SAVE :: klevm1
-  INTEGER, SAVE :: kflev
+  INTEGER :: klon, kdlon, kfdia, kidia, klev, klevp1, klevm1, kflev
 
   !$OMP THREADPRIVATE(klon,kfdia,kidia,kdlon)
-  REAL, SAVE, ALLOCATABLE, DIMENSION(:) :: zmasq
+  REAL, ALLOCATABLE, DIMENSION(:) :: zmasq
   !$OMP THREADPRIVATE(zmasq)
 
 CONTAINS
 
-  SUBROUTINE Init_dimphy(klon0, klev0)
+  SUBROUTINE init_dimphy(klon0, klev0)
     IMPLICIT NONE
 
-    INTEGER, INTENT(IN) :: klon0
-    INTEGER, INTENT(IN) :: klev0
+    INTEGER, INTENT(IN) :: klon0, klev0
 
     klon = klon0
@@ -37,7 +33,7 @@
     zmasq = 0.
 
-  END SUBROUTINE Init_dimphy
+  END SUBROUTINE init_dimphy
 
-  SUBROUTINE Init_dimphy1D(klon0, klev0)
+  SUBROUTINE init_dimphy1D(klon0, klev0)
     ! 1D special version of dimphy without ALLOCATE(zmasq)
     ! which will be allocated in iniphysiq
@@ -56,5 +52,5 @@
     kflev = klev
 
-  END SUBROUTINE Init_dimphy1D
+  END SUBROUTINE init_dimphy1D
 
 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_calcul_divers.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_calcul_divers.f90	(revision 5151)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/lmdz_calcul_divers.f90	(revision 5151)
@@ -0,0 +1,105 @@
+MODULE lmdz_calcul_divers
+  IMPLICIT NONE; PRIVATE
+  PUBLIC calcul_divers
+
+CONTAINS
+
+  SUBROUTINE calcul_divers(itap, itapm1, un_jour)
+    ! IM, 26.05.2023
+    ! Ne pas modifier les IFs ci-dessous impliquant itapm1,
+    ! autrement les resultats seront faux !!
+    !
+    ! On utilise MOD(itap - itapm1,NINT(mth_len*un_jour/phys_tstep)).EQ.1)
+    ! pour detecter le debut de chaque mois lorsque l'on tourne par an.
+
+    ! itap : nombre de pas de temps de la physique
+    ! itapm1 : somme du nombre de pas de temps du/des mois precedent/s.
+    ! (itap - itapm1) : nombre de pas de temps du mois courant
+    USE dimphy, ONLY: klon
+    USE phys_state_var_mod, ONLY: phys_tstep, ndayrain_mth, nday_rain, total_rain, rain_fall, snow_fall
+    USE phys_local_var_mod, ONLY: t2m_min_mon, t2m_max_mon, zt2m_min_mon, zt2m_max_mon, zt2m
+    USE phys_cal_mod, ONLY: mth_len
+
+    IMPLICIT NONE
+
+    INTEGER, INTENT(IN) :: itap
+    INTEGER, INTENT(INOUT) :: itapm1
+    REAL, INTENT(IN) :: un_jour
+
+    INTEGER :: i
+
+    ! Initialisations itapm1 du premier mois
+    IF(itap==1) THEN
+      itapm1 = 0
+      !        PRINT*,'initialisation itap=1 itapm1 ',itapm1
+    ENDIF
+
+    ! Initialisation debut de mois
+    IF(itap==itapm1 + 1) THEN
+      ndayrain_mth(:) = 0.
+      !        PRINT*,'Initialisation ndayrain_mth ',itap
+    ENDIF
+
+    ! Initialisation debut de chaque jour
+    IF(MOD(itap, NINT(un_jour / phys_tstep))==1) THEN
+      nday_rain(:) = 0.
+      !       PRINT*,'initialisation mois suivants day_rain itap',itap
+    ENDIF
+
+    ! Calcul a chaque pas de temps de la physique
+    DO i = 1, klon
+      total_rain(i) = rain_fall(i) + snow_fall(i)
+      IF(total_rain(i)>0.) nday_rain(i) = 1.
+    ENDDO
+
+    ! Cumul en fin de journee
+    IF(MOD(itap, NINT(un_jour / phys_tstep))==0) THEN
+      DO i = 1, klon
+        ndayrain_mth(i) = ndayrain_mth(i) + nday_rain(i)
+      ENDDO
+    ENDIF
+
+    ! Initialisation fin de mois
+    ! Ne pas changer le IF ci-dessous, car le compteur itapm1 est augmente
+    ! apres, dans la boucle !!!
+    ! IM, 260523
+    IF(MOD(itap - itapm1, NINT(mth_len * un_jour / phys_tstep))==0) THEN
+      itapm1 = itapm1 + NINT(mth_len * un_jour / phys_tstep)
+      !       PRINT*,'fmois i i1 mjt',itap,itapm1,mth_len,un_jour,phys_tstep
+    ENDIF
+
+    ! calcul temperatures minimale et maximale moyennees sur le mois
+
+    !initialisation debut de mois pour les fichiers mensuels annuels
+    IF(itap==itapm1 + 1) THEN
+      t2m_min_mon = 0.
+      t2m_max_mon = 0.
+    ENDIF
+
+    !initialisation debut de journee pour les fichiers mensuels annuels
+    IF(MOD(itap, NINT(un_jour / phys_tstep))==1) THEN
+      zt2m_min_mon = zt2m
+      zt2m_max_mon = zt2m
+    ENDIF
+
+    !calcul sur tous les pas de temps pour les fichiers mensuels annuels
+    DO i = 1, klon
+      zt2m_min_mon(i) = MIN(zt2m(i), zt2m_min_mon(i))
+      zt2m_max_mon(i) = MAX(zt2m(i), zt2m_max_mon(i))
+    ENDDO
+
+    !fin journee
+    IF(MOD(itap, NINT(un_jour / phys_tstep))==0) THEN
+      t2m_min_mon = t2m_min_mon + zt2m_min_mon
+      t2m_max_mon = t2m_max_mon + zt2m_max_mon
+    ENDIF
+
+    !fin mois
+    IF(itap==itapm1) THEN
+      t2m_min_mon = t2m_min_mon / mth_len
+      t2m_max_mon = t2m_max_mon / mth_len
+    ENDIF
+
+  END SUBROUTINE calcul_divers
+
+END MODULE lmdz_calcul_divers
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90	(revision 5144)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/physiq_mod.F90	(revision 5151)
@@ -3,5 +3,4 @@
 !#define IO_DEBUG
 MODULE physiq_mod
-  USE lmdz_abort_physic, ONLY: abort_physic
   IMPLICIT NONE
 
@@ -54,5 +53,5 @@
     USE phyetat0_mod, ONLY: phyetat0
     USE phystokenc_mod, ONLY: offline, phystokenc
-    USE phys_cal_mod, ONLY: year_len, mth_len, days_elapsed, jh_1jan, &
+    USE phys_cal_mod, ONLY: year_len, days_elapsed, jh_1jan, &
             year_cur, mth_cur, jD_cur, jH_cur, jD_ref, day_cur, hour, calend
     !!  USE phys_local_var_mod, ONLY: a long list of variables
@@ -109,6 +108,8 @@
     USE phytrac_mod, ONLY: phytrac_init, phytrac
     USE phys_output_write_mod
-
-    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DUST
+    USE lmdz_abort_physic, ONLY: abort_physic
+    USE lmdz_calcul_divers, ONLY: calcul_divers
+
+    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DUST, CPPKEY_COSP, CPPKEY_COSP2, CPPKEY_COSPV2
 
     !!!!!!!!!!!!!!!!!! "USE" section for CPP keys !!!!!!!!!!!!!!!!!!!!!!!!
@@ -246,6 +247,4 @@
             zustar, zu10m, zv10m, rh2m, qsat2m, &
             zq2m, zt2m, zn2mout, weak_inversion, &
-            zt2m_min_mon, zt2m_max_mon, &         ! pour calcul_divers.h
-            t2m_min_mon, t2m_max_mon, &            ! pour calcul_divers.h
 
             s_pblh_x, s_pblh_w, &
@@ -1160,10 +1159,6 @@
     !============================================================
     ! AI 10-22
-#ifdef CPP_COSP
-    include "ini_COSP.h"
-#endif
-#ifdef CPP_COSPV2
-    include "ini_COSP.h"
-#endif
+    INCLUDE "ini_COSP.h"
+
     REAL :: mr_ozone(klon, klev), phicosp(klon, klev)
 
@@ -1743,60 +1738,60 @@
 
       IF (ok_cosp) THEN
-#ifdef CPP_COSP
-        ! A.I : Initialisations pour le 1er passage a Cosp
-        CALL ini_COSP(ref_liq_cosp0,ref_ice_cosp0,pctsrf_cosp0,zu10m_cosp0,zv10m_cosp0, &
-               zxtsol_cosp0,zx_rh_cosp0,cldfra_cosp0,rnebcon_cosp0,flwc_cosp0, &
-               fiwc_cosp0,prfl_cosp0,psfl_cosp0,pmflxr_cosp0,pmflxs_cosp0, &
-               mr_ozone_cosp0,cldtau_cosp0,cldemi_cosp0,JrNt_cosp0)
-
-        CALL phys_cosp(itap,phys_tstep,freq_cosp, &
-               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
-               ecrit_mth,ecrit_day,ecrit_hf, ok_all_xml, missing_val, &
-               klon,klev,longitude_deg,latitude_deg,presnivs,overlap, &
-               JrNt_cosp0,ref_liq_cosp0,ref_ice_cosp0, &
-               pctsrf_cosp0, &
-               zu10m_cosp0,zv10m_cosp0,pphis, &
-               pphi,paprs(:,1:klev),pplay,zxtsol_cosp0,t, &
-               qx(:,:,ivap),zx_rh_cosp0,cldfra_cosp0,rnebcon_cosp0,flwc_cosp0,fiwc_cosp0, &
-               prfl_cosp0(:,1:klev),psfl_cosp0(:,1:klev), &
-               pmflxr_cosp0(:,1:klev),pmflxs_cosp0(:,1:klev), &
-               mr_ozone_cosp0,cldtau_cosp0, cldemi_cosp0)
-#endif
-
-#ifdef CPP_COSP2
-        CALL ini_COSP(ref_liq_cosp0,ref_ice_cosp0,pctsrf_cosp0,zu10m_cosp0,zv10m_cosp0, &
-               zxtsol_cosp0,zx_rh_cosp0,cldfra_cosp0,rnebcon_cosp0,flwc_cosp0, &
-               fiwc_cosp0,prfl_cosp0,psfl_cosp0,pmflxr_cosp0,pmflxs_cosp0, &
-               mr_ozone_cosp0,cldtau_cosp0,cldemi_cosp0,JrNt_cosp0)
-
-        CALL phys_cosp2(itap,phys_tstep,freq_cosp, &
-               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
-               ecrit_mth,ecrit_day,ecrit_hf, ok_all_xml, missing_val, &
-               klon,klev,longitude_deg,latitude_deg,presnivs,overlap, &
-               JrNt,ref_liq,ref_ice, &
-               pctsrf(:,is_ter)+pctsrf(:,is_lic), &
-               zu10m,zv10m,pphis, &
-               zphi,paprs(:,1:klev),pplay,zxtsol,t_seri, &
-               qx(:,:,ivap),zx_rh,cldfra,rnebcon,flwc,fiwc, &
-               prfl(:,1:klev),psfl(:,1:klev), &
-               pmflxr(:,1:klev),pmflxs(:,1:klev), &
-               mr_ozone,cldtau, cldemi)
-#endif
-
-#ifdef CPP_COSPV2
-          CALL lmdz_cosp_interface(itap,phys_tstep,freq_cosp, &
-               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
-               ecrit_mth,ecrit_day,ecrit_hf, ok_all_xml, missing_val, &
-               klon,klev,longitude_deg,latitude_deg,presnivs,overlap, &
-               JrNt,ref_liq,ref_ice, &
-               pctsrf(:,is_ter)+pctsrf(:,is_lic), &
-               zu10m,zv10m,pphis, &
-               phicosp,paprs(:,1:klev),pplay,zxtsol,t_seri, &
-               qx(:,:,ivap),zx_rh,cldfra,rnebcon,flwc,fiwc, &
-               prfl(:,1:klev),psfl(:,1:klev), &
-               pmflxr(:,1:klev),pmflxs(:,1:klev), &
-               mr_ozone,cldtau, cldemi)
-#endif
-      ENDIF
+        IF (CPPKEY_COSP) THEN
+          ! A.I : Initialisations pour le 1er passage a Cosp
+          CALL ini_COSP(ref_liq_cosp0, ref_ice_cosp0, pctsrf_cosp0, zu10m_cosp0, zv10m_cosp0, &
+                  zxtsol_cosp0, zx_rh_cosp0, cldfra_cosp0, rnebcon_cosp0, flwc_cosp0, &
+                  fiwc_cosp0, prfl_cosp0, psfl_cosp0, pmflxr_cosp0, pmflxs_cosp0, &
+                  mr_ozone_cosp0, cldtau_cosp0, cldemi_cosp0, JrNt_cosp0)
+
+          CALL phys_cosp(itap, phys_tstep, freq_cosp, &
+                  ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
+                  ecrit_mth, ecrit_day, ecrit_hf, ok_all_xml, missing_val, &
+                  klon, klev, longitude_deg, latitude_deg, presnivs, overlap, &
+                  JrNt_cosp0, ref_liq_cosp0, ref_ice_cosp0, &
+                  pctsrf_cosp0, &
+                  zu10m_cosp0, zv10m_cosp0, pphis, &
+                  pphi, paprs(:, 1:klev), pplay, zxtsol_cosp0, t, &
+                  qx(:, :, ivap), zx_rh_cosp0, cldfra_cosp0, rnebcon_cosp0, flwc_cosp0, fiwc_cosp0, &
+                  prfl_cosp0(:, 1:klev), psfl_cosp0(:, 1:klev), &
+                  pmflxr_cosp0(:, 1:klev), pmflxs_cosp0(:, 1:klev), &
+                  mr_ozone_cosp0, cldtau_cosp0, cldemi_cosp0)
+        END IF
+
+        IF (CPPKEY_COSP2) THEN
+          CALL ini_COSP(ref_liq_cosp0, ref_ice_cosp0, pctsrf_cosp0, zu10m_cosp0, zv10m_cosp0, &
+                  zxtsol_cosp0, zx_rh_cosp0, cldfra_cosp0, rnebcon_cosp0, flwc_cosp0, &
+                  fiwc_cosp0, prfl_cosp0, psfl_cosp0, pmflxr_cosp0, pmflxs_cosp0, &
+                  mr_ozone_cosp0, cldtau_cosp0, cldemi_cosp0, JrNt_cosp0)
+
+          CALL phys_cosp2(itap, phys_tstep, freq_cosp, &
+                  ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
+                  ecrit_mth, ecrit_day, ecrit_hf, ok_all_xml, missing_val, &
+                  klon, klev, longitude_deg, latitude_deg, presnivs, overlap, &
+                  JrNt, ref_liq, ref_ice, &
+                  pctsrf(:, is_ter) + pctsrf(:, is_lic), &
+                  zu10m, zv10m, pphis, &
+                  zphi, paprs(:, 1:klev), pplay, zxtsol, t_seri, &
+                  qx(:, :, ivap), zx_rh, cldfra, rnebcon, flwc, fiwc, &
+                  prfl(:, 1:klev), psfl(:, 1:klev), &
+                  pmflxr(:, 1:klev), pmflxs(:, 1:klev), &
+                  mr_ozone, cldtau, cldemi)
+        END IF
+
+        IF (CPPKEY_COSPV2) THEN
+          CALL lmdz_cosp_interface(itap, phys_tstep, freq_cosp, &
+                  ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
+                  ecrit_mth, ecrit_day, ecrit_hf, ok_all_xml, missing_val, &
+                  klon, klev, longitude_deg, latitude_deg, presnivs, overlap, &
+                  JrNt, ref_liq, ref_ice, &
+                  pctsrf(:, is_ter) + pctsrf(:, is_lic), &
+                  zu10m, zv10m, pphis, &
+                  phicosp, paprs(:, 1:klev), pplay, zxtsol, t_seri, &
+                  qx(:, :, ivap), zx_rh, cldfra, rnebcon, flwc, fiwc, &
+                  prfl(:, 1:klev), psfl(:, 1:klev), &
+                  pmflxr(:, 1:klev), pmflxs(:, 1:klev), &
+                  mr_ozone, cldtau, cldemi)
+        END IF
+      END IF
 
 
@@ -5065,26 +5060,25 @@
 
     IF (ok_cosp) THEN
-      ! adeclarer
-#ifdef CPP_COSP
-       IF (itap.EQ.1.OR.MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN
-
-          IF (prt_level .GE.10) THEN
-             PRINT*,'freq_cosp',freq_cosp
+      IF (CPPKEY_COSP) THEN
+        IF (itap==1.OR.MOD(itap, NINT(freq_cosp / phys_tstep))==0) THEN
+
+          IF (prt_level >=10) THEN
+            PRINT*, 'freq_cosp', freq_cosp
           ENDIF
-          mr_ozone=wo(:, :, 1) * dobson_u * 1e3 / zmasse
+          mr_ozone = wo(:, :, 1) * dobson_u * 1e3 / zmasse
           !       PRINT*,'Dans physiq.F avant appel cosp ref_liq,ref_ice=',
           !     s        ref_liq,ref_ice
-          CALL phys_cosp(itap,phys_tstep,freq_cosp, &
-               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
-               ecrit_mth,ecrit_day,ecrit_hf, ok_all_xml, missing_val, &
-               klon,klev,longitude_deg,latitude_deg,presnivs,overlap, &
-               JrNt,ref_liq,ref_ice, &
-               pctsrf(:,is_ter)+pctsrf(:,is_lic), &
-               zu10m,zv10m,pphis, &
-               zphi,paprs(:,1:klev),pplay,zxtsol,t_seri, &
-               qx(:,:,ivap),zx_rh,cldfra,rnebcon,flwc,fiwc, &
-               prfl(:,1:klev),psfl(:,1:klev), &
-               pmflxr(:,1:klev),pmflxs(:,1:klev), &
-               mr_ozone,cldtau, cldemi)
+          CALL phys_cosp(itap, phys_tstep, freq_cosp, &
+                  ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
+                  ecrit_mth, ecrit_day, ecrit_hf, ok_all_xml, missing_val, &
+                  klon, klev, longitude_deg, latitude_deg, presnivs, overlap, &
+                  JrNt, ref_liq, ref_ice, &
+                  pctsrf(:, is_ter) + pctsrf(:, is_lic), &
+                  zu10m, zv10m, pphis, &
+                  zphi, paprs(:, 1:klev), pplay, zxtsol, t_seri, &
+                  qx(:, :, ivap), zx_rh, cldfra, rnebcon, flwc, fiwc, &
+                  prfl(:, 1:klev), psfl(:, 1:klev), &
+                  pmflxr(:, 1:klev), pmflxs(:, 1:klev), &
+                  mr_ozone, cldtau, cldemi)
 
           !     L         calipso2D,calipso3D,cfadlidar,parasolrefl,atb,betamol,
@@ -5094,62 +5088,62 @@
           !     I          tauisccp,albisccp,meantbisccp,meantbclrisccp)
 
-       ENDIF
-#endif
-
-#ifdef CPP_COSP2
-       IF (itap.EQ.1.OR.MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN
-
-          IF (prt_level .GE.10) THEN
-             PRINT*,'freq_cosp',freq_cosp
+        END IF
+      END IF
+
+      IF (CPPKEY_COSP2) THEN
+        IF (itap==1.OR.MOD(itap, NINT(freq_cosp / phys_tstep))==0) THEN
+
+          IF (prt_level >=10) THEN
+            PRINT*, 'freq_cosp', freq_cosp
           ENDIF
-          mr_ozone=wo(:, :, 1) * dobson_u * 1e3 / zmasse
-                 PRINT*,'Dans physiq.F avant appel '
+          mr_ozone = wo(:, :, 1) * dobson_u * 1e3 / zmasse
+          PRINT*, 'Dans physiq.F avant appel '
           !     s        ref_liq,ref_ice
-          CALL phys_cosp2(itap,phys_tstep,freq_cosp, &
-               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
-               ecrit_mth,ecrit_day,ecrit_hf, ok_all_xml, missing_val, &
-               klon,klev,longitude_deg,latitude_deg,presnivs,overlap, &
-               JrNt,ref_liq,ref_ice, &
-               pctsrf(:,is_ter)+pctsrf(:,is_lic), &
-               zu10m,zv10m,pphis, &
-               zphi,paprs(:,1:klev),pplay,zxtsol,t_seri, &
-               qx(:,:,ivap),zx_rh,cldfra,rnebcon,flwc,fiwc, &
-               prfl(:,1:klev),psfl(:,1:klev), &
-               pmflxr(:,1:klev),pmflxs(:,1:klev), &
-               mr_ozone,cldtau, cldemi)
-       ENDIF
-#endif
-
-#ifdef CPP_COSPV2
-       IF (itap.EQ.1.OR.MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN
-!        IF (MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN
-
-          IF (prt_level .GE.10) THEN
-             PRINT*,'freq_cosp',freq_cosp
+          CALL phys_cosp2(itap, phys_tstep, freq_cosp, &
+                  ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
+                  ecrit_mth, ecrit_day, ecrit_hf, ok_all_xml, missing_val, &
+                  klon, klev, longitude_deg, latitude_deg, presnivs, overlap, &
+                  JrNt, ref_liq, ref_ice, &
+                  pctsrf(:, is_ter) + pctsrf(:, is_lic), &
+                  zu10m, zv10m, pphis, &
+                  zphi, paprs(:, 1:klev), pplay, zxtsol, t_seri, &
+                  qx(:, :, ivap), zx_rh, cldfra, rnebcon, flwc, fiwc, &
+                  prfl(:, 1:klev), psfl(:, 1:klev), &
+                  pmflxr(:, 1:klev), pmflxs(:, 1:klev), &
+                  mr_ozone, cldtau, cldemi)
+        END IF
+      END IF
+
+      IF (CPPKEY_COSPV2) THEN
+        IF (itap==1.OR.MOD(itap, NINT(freq_cosp / phys_tstep))==0) THEN
+          !        IF (MOD(itap,NINT(freq_cosp/phys_tstep)).EQ.0) THEN
+
+          IF (prt_level >=10) THEN
+            PRINT*, 'freq_cosp', freq_cosp
           ENDIF
-           DO k = 1, klev
-             DO i = 1, klon
-               phicosp(i,k) = pphi(i,k) + pphis(i)
-             ENDDO
-           ENDDO
-          mr_ozone=wo(:, :, 1) * dobson_u * 1e3 / zmasse
-                 PRINT*,'Dans physiq.F avant appel '
+          DO k = 1, klev
+            DO i = 1, klon
+              phicosp(i, k) = pphi(i, k) + pphis(i)
+            ENDDO
+          ENDDO
+          mr_ozone = wo(:, :, 1) * dobson_u * 1e3 / zmasse
+          PRINT*, 'Dans physiq.F avant appel '
           !     s        ref_liq,ref_ice
-          CALL lmdz_cosp_interface(itap,phys_tstep,freq_cosp, &
-               ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
-               ecrit_mth,ecrit_day,ecrit_hf, ok_all_xml, missing_val, &
-               klon,klev,longitude_deg,latitude_deg,presnivs,overlap, &
-               JrNt,ref_liq,ref_ice, &
-               pctsrf(:,is_ter)+pctsrf(:,is_lic), &
-               zu10m,zv10m,pphis, &
-               zphi,paprs(:,1:klev),pplay,zxtsol,t_seri, &
-               qx(:,:,ivap),zx_rh,cldfra,rnebcon,flwc,fiwc, &
-               prfl(:,1:klev),psfl(:,1:klev), &
-               pmflxr(:,1:klev),pmflxs(:,1:klev), &
-               mr_ozone,cldtau, cldemi)
-       ENDIF
-#endif
-
-    ENDIF  !ok_cosp
+          CALL lmdz_cosp_interface(itap, phys_tstep, freq_cosp, &
+                  ok_mensuelCOSP, ok_journeCOSP, ok_hfCOSP, &
+                  ecrit_mth, ecrit_day, ecrit_hf, ok_all_xml, missing_val, &
+                  klon, klev, longitude_deg, latitude_deg, presnivs, overlap, &
+                  JrNt, ref_liq, ref_ice, &
+                  pctsrf(:, is_ter) + pctsrf(:, is_lic), &
+                  zu10m, zv10m, pphis, &
+                  zphi, paprs(:, 1:klev), pplay, zxtsol, t_seri, &
+                  qx(:, :, ivap), zx_rh, cldfra, rnebcon, flwc, fiwc, &
+                  prfl(:, 1:klev), psfl(:, 1:klev), &
+                  pmflxr(:, 1:klev), pmflxs(:, 1:klev), &
+                  mr_ozone, cldtau, cldemi)
+        ENDIF
+      END IF
+
+    END IF  !ok_cosp
 
 
@@ -5389,6 +5383,5 @@
 
     !IM initialisation + calculs divers diag AMIP2
-
-    include "calcul_divers.h"
+    CALL calcul_divers(itap, itapm1, un_jour)
 
     !IM Interpolation sur les niveaux de pression du NMC
