Index: LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 5133)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90	(revision 5154)
@@ -3,7 +3,7 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    MODULE cosp_output_write_mod
-  
+
    USE cosp_output_mod
-  
+
    IMPLICIT NONE
 
@@ -28,5 +28,5 @@
     USE wxios, only: wxios_closedef
     USE lmdz_xios, only: xios_update_calendar, xios_field_is_active, using_xios
-  IMPLICIT NONE  
+  IMPLICIT NONE
 !!! Variables d'entree
   integer               :: itap, Nlevlmdz, Ncolumns, Npoints
@@ -67,5 +67,5 @@
        itau_wcosp = itau_phy + itap + start_time * day_step_phy
         if (prt_level >= 10) then
-             WRITE(lunout,*)'itau_wcosp, itap, start_time, day_step_phy =', & 
+             WRITE(lunout,*)'itau_wcosp, itap, start_time, day_step_phy =', &
                              itau_wcosp, itap, start_time, day_step_phy
         endif
@@ -78,5 +78,5 @@
 
     ok_sync = .TRUE.
-    
+
 !DO iinit=1, iinitend
 ! AI sept 2014 cette boucle supprimee
@@ -93,5 +93,5 @@
 !         WRITE(lunout,*)'Apell xios_update_calendar cosp_varsdefined iinitend ', &
 !                         cosp_varsdefined,iinitend
-!   endif 
+!   endif
 !    CALL xios_update_calendar(itau_wcosp)
 !ENDIF
@@ -102,11 +102,11 @@
 !!!! Sorties Calipso
  if (cfg%Llidar_sim) then
-!!! AI 02 2018 
+!!! AI 02 2018
 ! Traitement missing_val
    where(stlidar%lidarcld == R_UNDEF) stlidar%lidarcld = missing_val
-   where(stlidar%proftemp == R_UNDEF) stlidar%proftemp = missing_val   !TIBO  
+   where(stlidar%proftemp == R_UNDEF) stlidar%proftemp = missing_val   !TIBO
    where(stlidar%profSR == R_UNDEF) stlidar%profSR = missing_val       !TIBO2
-   where(sglidar%beta_mol == R_UNDEF) sglidar%beta_mol = missing_val  
-   where(sglidar%beta_tot == R_UNDEF) sglidar%beta_tot = missing_val 
+   where(sglidar%beta_mol == R_UNDEF) sglidar%beta_mol = missing_val
+   where(sglidar%beta_tot == R_UNDEF) sglidar%beta_tot = missing_val
    where(stlidar%cldlayer == R_UNDEF) stlidar%cldlayer = missing_val
    where(stlidar%cldtype == R_UNDEF) stlidar%cldtype = missing_val     !OPAQ
@@ -119,9 +119,9 @@
    where(stlidar%lidarcldtype == R_UNDEF) stlidar%lidarcldtype = missing_val   !OPAQ
    where(stlidar%lidarcldtmp == R_UNDEF) stlidar%lidarcldtmp = missing_val
- 
+
 !   print*,'Appel histwrite2d_cosp'
    if (cfg%Lcllcalipso) CALL histwrite2d_cosp(o_cllcalipso,stlidar%cldlayer(:,1))
    if (cfg%Lclhcalipso) CALL histwrite2d_cosp(o_clhcalipso,stlidar%cldlayer(:,3))
-   if (cfg%Lclmcalipso) CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2)) 
+   if (cfg%Lclmcalipso) CALL histwrite2d_cosp(o_clmcalipso,stlidar%cldlayer(:,2))
    if (cfg%Lcltcalipso) CALL histwrite2d_cosp(o_cltcalipso,stlidar%cldlayer(:,4))
    if (cfg%Lclcalipso) CALL histwrite3d_cosp(o_clcalipso,stlidar%lidarcld,nvert)
@@ -182,5 +182,5 @@
    if (cfg%LparasolRefl) CALL histwrite3d_cosp(o_parasol_refl,stlidar%parasolrefl,nvertp)
 
-  if (cfg%LparasolRefl) then 
+  if (cfg%LparasolRefl) then
     do k=1,PARASOL_NREFL
      do ip=1, Npoints
@@ -202,12 +202,12 @@
      if (cfg%Latb532) CALL histwrite4d_cosp(o_atb532,sglidar%beta_tot)
    ELSE
-     if (cfg%Latb532) then  
-       do icl=1,Ncolumns 
+     if (cfg%Latb532) then
+       do icl=1,Ncolumns
           CALL histwrite3d_cosp(o_atb532,sglidar%beta_tot(:,icl,:),nvertmcosp,icl)
        enddo
-     endif 
+     endif
    ENDIF
 
-   if (cfg%LlidarBetaMol532) CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp) 
+   if (cfg%LlidarBetaMol532) CALL histwrite3d_cosp(o_beta_mol532,sglidar%beta_mol,nvertmcosp)
 
  endif !Lidar
@@ -259,5 +259,5 @@
   where(isccp%fq_isccp == R_UNDEF) isccp%fq_isccp = missing_val
   where(isccp%boxtau == R_UNDEF) isccp%boxtau = missing_val
-  where(isccp%boxptop == R_UNDEF) isccp%boxptop = missing_val 
+  where(isccp%boxptop == R_UNDEF) isccp%boxptop = missing_val
 
    CALL histwrite2d_cosp(o_sunlit,gbx%sunlit)
@@ -267,5 +267,5 @@
      if (cfg%Lclisccp) then
        do icl=1,7
-         CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl) 
+         CALL histwrite3d_cosp(o_clisccp2,isccp%fq_isccp(:,icl,:),nvertisccp,icl)
        enddo
      endif
@@ -273,10 +273,10 @@
 
    if (cfg%Lboxtauisccp) CALL histwrite3d_cosp(o_boxtauisccp,isccp%boxtau,nvertcol)
-   if (cfg%Lboxptopisccp) CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol) 
-   if (cfg%Lcltisccp) CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea) 
-   if (cfg%Lpctisccp) CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop) 
-   if (cfg%Ltauisccp) CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld) 
-   if (cfg%Lalbisccp) CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld) 
-   if (cfg%Lmeantbisccp) CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb) 
+   if (cfg%Lboxptopisccp) CALL histwrite3d_cosp(o_boxptopisccp,isccp%boxptop,nvertcol)
+   if (cfg%Lcltisccp) CALL histwrite2d_cosp(o_tclisccp,isccp%totalcldarea)
+   if (cfg%Lpctisccp) CALL histwrite2d_cosp(o_ctpisccp,isccp%meanptop)
+   if (cfg%Ltauisccp) CALL histwrite2d_cosp(o_tauisccp,isccp%meantaucld)
+   if (cfg%Lalbisccp) CALL histwrite2d_cosp(o_albisccp,isccp%meanalbedocld)
+   if (cfg%Lmeantbisccp) CALL histwrite2d_cosp(o_meantbisccp,isccp%meantb)
    if (cfg%Lmeantbclrisccp) CALL histwrite2d_cosp(o_meantbclrisccp,isccp%meantbclr)
  endif ! Isccp
@@ -294,5 +294,5 @@
    ELSE
      if (cfg%LclMISR) then
-      do icl=1,7 
+      do icl=1,7
         CALL histwrite3d_cosp(o_clMISR,misr%fq_MISR(:,icl,:),nvertmisr,icl)
       enddo
@@ -329,5 +329,5 @@
         modis%Cloud_Top_Pressure_Total_Mean = missing_val
   where(modis%Liquid_Water_Path_Mean == R_UNDEF) &
-        modis%Liquid_Water_Path_Mean = missing_val 
+        modis%Liquid_Water_Path_Mean = missing_val
   where(modis%Ice_Water_Path_Mean == R_UNDEF) &
         modis%Ice_Water_Path_Mean = missing_val
@@ -335,5 +335,5 @@
   where(modis%Optical_Thickness_Total_LogMean == R_UNDEF) &
           modis%Optical_Thickness_Total_LogMean = missing_val
-           
+
   where(modis%Optical_Thickness_Water_LogMean == R_UNDEF) &
           modis%Optical_Thickness_Water_LogMean = missing_val
@@ -341,5 +341,5 @@
   where(modis%Optical_Thickness_Ice_LogMean == R_UNDEF) &
           modis%Optical_Thickness_Ice_LogMean = missing_val
-    
+
   if (cfg%Lcllmodis) CALL histwrite2d_cosp(o_cllmodis,modis%Cloud_Fraction_Low_Mean)
   if (cfg%Lclhmodis) CALL histwrite2d_cosp(o_clhmodis,modis%Cloud_Fraction_High_Mean)
@@ -351,5 +351,5 @@
   if (cfg%Ltauwmodis) CALL histwrite2d_cosp(o_tauwmodis,modis%Optical_Thickness_Water_Mean)
   if (cfg%Ltauimodis) CALL histwrite2d_cosp(o_tauimodis,modis%Optical_Thickness_Ice_Mean)
-  if (cfg%Ltautlogmodis) CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean)  
+  if (cfg%Ltautlogmodis) CALL histwrite2d_cosp(o_tautlogmodis,modis%Optical_Thickness_Total_LogMean)
   if (cfg%Ltauwlogmodis) CALL histwrite2d_cosp(o_tauwlogmodis,modis%Optical_Thickness_Water_LogMean)
   if (cfg%Ltauilogmodis) CALL histwrite2d_cosp(o_tauilogmodis,modis%Optical_Thickness_Ice_LogMean)
@@ -369,7 +369,7 @@
        do icl=1,7
          CALL histwrite3d_cosp(o_clmodis, &
-         modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)           
+         modis%Optical_Thickness_vs_Cloud_Top_Pressure(:,icl,:),nvertisccp,icl)
        enddo
-      endif 
+      endif
    ENDIF
 
@@ -391,9 +391,9 @@
      endif
      if (cfg%Lcrlmodis) then
-       do icl=1,7 
+       do icl=1,7
          CALL histwrite3d_cosp(o_crlmodis, &
             modis%Optical_Thickness_vs_ReffLiq(:,icl,:),nvertReffLiq,icl)
        enddo
-     endif 
+     endif
    ENDIF
  endif !modis
@@ -445,8 +445,7 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
     USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                          :: iff
@@ -480,5 +479,5 @@
         IF ( var%cles(iff) ) THEN
           if (prt_level >= 10) then
-            WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name 
+            WRITE(lunout,*)'Appel wxios_add_field_to_file var%name =',var%name
           endif
           CALL wxios_add_field_to_file(var%name, 2, cosp_nidfiles(iff), cosp_outfilenames(iff), &
@@ -506,8 +505,7 @@
     USE lmdz_print_control, ONLY: lunout,prt_level
     USE wxios
+    USE lmdz_clesphys
 
     IMPLICIT NONE
-
-    INCLUDE "clesphys.h"
 
     INTEGER                        :: iff, klevs
@@ -582,5 +580,5 @@
         IF ( var%cles(iff) ) THEN
           if (prt_level >= 10) then
-              WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert 
+              WRITE(lunout,*)'Appel wxios_add_field_to_file 3d nom variable nam_axvert = ',nom, nam_axvert
           endif
           CALL wxios_add_field_to_file(nom, 3, cosp_nidfiles(iff), cosp_outfilenames(iff), &
@@ -610,7 +608,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN) :: var
@@ -643,5 +641,5 @@
     !Et sinon on.... écrit
     IF (SIZE(field)/=klon) &
-  CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1) 
+  CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1)
 
     CALL Gather_omp(field,buffer_omp)
@@ -655,5 +653,5 @@
                 ALLOCATE(index2d(nbp_lon*jj_nb))
 #ifndef CPP_IOIPSL_NO_OUTPUT
-        CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d) 
+        CALL histwrite(cosp_nidfiles(iff),var%name,itau_iocosp,Field2d,nbp_lon*jj_nb,index2d)
 #endif
             deallocate(index2d)
@@ -670,5 +668,5 @@
             ENDIF
           ENDIF
-      ENDDO 
+      ENDDO
 
     IF (using_xios) THEN
@@ -681,5 +679,5 @@
     ENDIF
 
-!$OMP END MASTER   
+!$OMP END MASTER
   ENDIF ! vars_defined
   IF (prt_level >= 9) WRITE(lunout,*)'End histrwrite2d_cosp ',var%name
@@ -697,7 +695,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
@@ -741,5 +739,5 @@
     !Et sinon on.... écrit
     IF (SIZE(field,1)/=klon) &
-   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)                                  
+   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
     nlev=SIZE(field,2)
 
@@ -755,5 +753,5 @@
            ALLOCATE(index3d(nbp_lon*jj_nb*nlev))
 #ifndef CPP_IOIPSL_NO_OUTPUT
-    CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d) 
+    CALL histwrite(cosp_nidfiles(iff),nom,itau_iocosp,Field3d,nbp_lon*jj_nb*nlev,index3d)
 #endif
 
@@ -778,5 +776,5 @@
   ENDIF
 
-!$OMP END MASTER   
+!$OMP END MASTER
   ENDIF ! vars_defined
   IF (prt_level >= 9) write(lunout,*)'End histrwrite3d_cosp ',nom
@@ -794,7 +792,7 @@
   USE lmdz_xios, only: xios_send_field, using_xios
   USE lmdz_abort_physic, ONLY: abort_physic
+  USE lmdz_clesphys
 
   IMPLICIT NONE
-  INCLUDE 'clesphys.h'
 
     TYPE(ctrl_outcosp), INTENT(IN)    :: var
@@ -814,5 +812,5 @@
     !Et sinon on.... écrit
     IF (SIZE(field,1)/=klon) &
-   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)            
+   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)
 
     nlev=SIZE(field,2)
@@ -829,5 +827,5 @@
    ENDIF
 
-!$OMP END MASTER   
+!$OMP END MASTER
   ENDIF ! vars_defined
   IF (prt_level >= 9) write(lunout,*)'End histrwrite4d_cosp ',nom
