Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histdayCOSP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histdayCOSP.h	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histdayCOSP.h	(revision 1928)
@@ -21,5 +21,5 @@
         CALL histvert(nid_day_cosp,"height","height","m",Nlevout,vgrid%z,nvert)
        else
-        CALL histvert(nid_day_cosp,"presnivs","Vertical levels","mb",Nlevout,presnivs,nvert)
+        CALL histvert(nid_day_cosp,"presnivs","Vertical levels","mb",Nlevout,presnivs,nvert,"down")
        endif
 
@@ -28,5 +28,5 @@
         CALL histvert(nid_day_cosp,"sza","solar_zenith_angle","degrees",PARASOL_NREFL,PARASOL_SZA,nvertp)
 
-        CALL histvert(nid_day_cosp,"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp)
+        CALL histvert(nid_day_cosp,"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp,"down")
 
         CALL histvert(nid_day_cosp,"column","column","count",Ncolumns,column_ax(1:Ncolumns),nvertcol)
@@ -77,4 +77,12 @@
                         iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
                         "ave(X)", zout,zstoday)   
+            CALL histdef(nid_day_cosp, "parasol_crefl", &
+                        "PARASOL-like mono-directional reflectance","1", &
+                        iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
+                        "ave(X)", zout,zstoday)
+            CALL histdef(nid_day_cosp, "Ncrefl", &
+                        "0 ou 1 si reflectance <= ou > 0","1", &
+                        iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
+                        "ave(X)", zout,zstoday)
            endif
            if (cfg%Latb532) then
@@ -134,4 +142,8 @@
 ! Sorties ISCCP
         if (cfg%Lisccp_sim) then
+          CALL histdef(nid_day_cosp, "sunlit", &
+                     "1 si jour 0 si nuit", "1", &
+                     iim, jj_nb,nhori,1,1,1,-99,32, &
+                     "ave(X)", zout,zstomth)
          if (cfg%Lclisccp2) then
             do ii=1,7
Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histhfCOSP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histhfCOSP.h	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histhfCOSP.h	(revision 1928)
@@ -21,5 +21,5 @@
         CALL histvert(nid_hf_cosp,"height","height","m",Nlevout,vgrid%z,nvert)
        else
-        CALL histvert(nid_hf_cosp,"presnivs","Vertical levels","mb",Nlevout,presnivs,nvert)
+        CALL histvert(nid_hf_cosp,"presnivs","Vertical levels","mb",Nlevout,presnivs,nvert,"down")
        endif
 
@@ -28,5 +28,5 @@
         CALL histvert(nid_hf_cosp,"sza","solar_zenith_angle","degrees",PARASOL_NREFL,PARASOL_SZA,nvertp)
 
-        CALL histvert(nid_hf_cosp,"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp)
+        CALL histvert(nid_hf_cosp,"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp,"down")
 
         CALL histvert(nid_hf_cosp,"column","column","count",Ncolumns,column_ax(1:Ncolumns),nvertcol)
@@ -77,4 +77,12 @@
                         iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
                         "ave(X)", zout,zstohf)   
+            CALL histdef(nid_hf_cosp, "parasol_crefl", &
+                        "PARASOL-like mono-directional reflectance","1", &
+                        iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
+                        "ave(X)", zout,zstohf)
+            CALL histdef(nid_hf_cosp, "Ncrefl", &
+                        "1 ou 0 si cldt > o <= 0 ","1", &
+                        iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
+                        "ave(X)", zout,zstohf)
            endif
            if (cfg%Latb532) then
@@ -134,4 +142,9 @@
 ! Sorties ISCCP
         if (cfg%Lisccp_sim) then
+
+          CALL histdef(nid_hf_cosp, "sunlit", &
+                     "0 si nuit 1 si jour", "1", &
+                     iim, jj_nb,nhori,1,1,1,-99,32, &
+                     "ave(X)", zout,zstomth)
          if (cfg%Lclisccp2) then
             do ii=1,7
Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histmthCOSP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histmthCOSP.h	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/ini_histmthCOSP.h	(revision 1928)
@@ -27,5 +27,5 @@
         CALL histvert(nid_mth_cosp,"sza","solar_zenith_angle","degrees",PARASOL_NREFL,PARASOL_SZA,nvertp)
 
-        CALL histvert(nid_mth_cosp,"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp)
+        CALL histvert(nid_mth_cosp,"pressure2","pressure","mb",7,ISCCP_PC,nvertisccp,"down")
 
         CALL histvert(nid_mth_cosp,"column","column","count",Ncolumns,column_ax(1:Ncolumns),nvertcol)
@@ -84,4 +84,12 @@
                         iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
                         "ave(X)", zout,zstomth)   
+            CALL histdef(nid_mth_cosp, "parasol_crefl", &
+                        "PARASOL-like mono-directional reflectance","1", &
+                        iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
+                        "ave(X)", zout,zstomth)
+            CALL histdef(nid_mth_cosp, "Ncrefl", &
+                        "0 ou 1 si reflectance <= ou > 0","1", &
+                        iim,jj_nb,nhori, PARASOL_NREFL,1, PARASOL_NREFL, nvertp,32, &
+                        "ave(X)", zout,zstomth)
            endif
            if (cfg%Latb532) then
@@ -141,4 +149,9 @@
 ! Sorties ISCCP
         if (cfg%Lisccp_sim) then
+
+             CALL histdef(nid_mth_cosp, "sunlit", &
+                     "1 si jour 0 si nuit", "1", &
+                     iim, jj_nb,nhori,1,1,1,-99,32, &
+                     "ave(X)", zout,zstomth)
          if (cfg%Lclisccp2) then
             do ii=1,7
Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/phys_cosp.F90
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/phys_cosp.F90	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/phys_cosp.F90	(revision 1928)
@@ -1,11 +1,11 @@
 ! Simulateur COSP : Cfmip Observation Simulator Package
+
 ! ISCCP, Radar (QuickBeam), Lidar et Parasol (ACTSIM), MISR, RTTOVS
 !Idelkadi Abderrahmane Aout-Septembre 2009
-
 
   subroutine phys_cosp( itap,dtime,freq_cosp, &
                         ok_mensuelCOSP,ok_journeCOSP,ok_hfCOSP, &
                         ecrit_mth,ecrit_day,ecrit_hf, &
-                        Nptslmdz,Nlevlmdz,lon,lat, presnivs,overlaplmdz, &
+                        Nptslmdz,Nlevlmdz,lon,lat, presnivs,overlaplmdz,sunlit, &
                         ref_liq,ref_ice,fracTerLic,u_wind,v_wind,phis,phi,ph,p,skt,t, &
                         sh,rh,tca,cca,mr_lsliq,mr_lsice,fl_lsrainI,fl_lssnowI, &
@@ -144,9 +144,11 @@
                                      zlev,zlev_half,mr_ozone,radliq,radice,dtau_s,dem_s,ref_liq,ref_ice
   real,dimension(Nptslmdz,Nlevlmdz) ::  fl_lsrainI,fl_lssnowI,fl_ccrainI,fl_ccsnowI
-  real,dimension(Nptslmdz)        :: lon,lat,skt,fracTerLic,u_wind,v_wind,phis
+  real,dimension(Nptslmdz)        :: lon,lat,skt,fracTerLic,u_wind,v_wind,phis,sunlit    
   real,dimension(Nlevlmdz)        :: presnivs
   integer                         :: itap,k,ip
   real                            :: dtime,freq_cosp
   logical, parameter              :: lCOSP=.FALSE.
+
+  real, dimension(Nptslmdz,PARASOL_NREFL) :: parasolcrefl, Ncref
 
 !
@@ -237,5 +239,5 @@
         gbx%q = rh*100.
         gbx%sh = sh
-        gbx%cca = cca !convective_cloud_amount (1)
+        gbx%cca = 0.
         gbx%tca = tca ! total_cloud_amount (1)
         gbx%psfc = ph(:,1) !pression de surface
@@ -253,6 +255,12 @@
         gbx%u_wind  = u_wind !eastward_wind (m s-1)
         gbx%v_wind  = v_wind !northward_wind
-! Attention
-        gbx%sunlit  = 1
+
+      do ip = 1, Npoints
+        if (sunlit(ip).le.0.) then
+           gbx%sunlit(ip)=0
+        else
+           gbx%sunlit(ip)=1
+        endif
+      enddo
 
 ! A voir l equivalent LMDZ
@@ -280,5 +288,4 @@
      gbx%Reff(:,:,I_CVCLIQ) = ref_liq*1e-6
      gbx%Reff(:,:,I_CVCICE) = ref_ice*1e-6
-
         ! ISCCP simulator
         gbx%dtau_s   = dtau_s
@@ -423,4 +430,17 @@
      if(isccp%boxptop(ip,ii).eq.-1.E+30)then
        isccp%boxptop(ip,ii)=0.
+     endif
+    enddo
+   enddo
+
+   do k=1,PARASOL_NREFL
+    do ii=1, Npoints
+     if (stlidar%cldlayer(ii,4).gt.0.01) then
+        parasolcrefl(ii,k)=(stlidar%parasolrefl(ii,k)-0.03*(1.-stlidar%cldlayer(ii,4)))/ &
+                   stlidar%cldlayer(ii,4)
+        Ncref(ii,k) = 1.
+     else
+        parasolcrefl(ii,k)=0.
+        Ncref(ii,k) = 0.
      endif
     enddo
Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histdayCOSP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histdayCOSP.h	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histdayCOSP.h	(revision 1928)
@@ -38,4 +38,8 @@
            CALL histwrite_phy(nid_day_cosp,lCOSP,"parasol_refl", &
      itau_wcosp,stlidar%parasolrefl)
+           CALL histwrite_phy(nid_day_cosp,lCOSP,"parasol_crefl", &
+     itau_wcosp,parasolcrefl)
+           CALL histwrite_phy(nid_day_cosp,lCOSP,"Ncrefl", &
+     itau_wcosp,Ncref)
          endif
          if (cfg%Latb532) then
@@ -91,4 +95,6 @@
 ! Sorties ISCCP
         if (cfg%Lisccp_sim) then
+          CALL histwrite_phy(nid_day_cosp,lCOSP,"sunlit", &
+     itau_wcosp,sunlit)
           if (cfg%Lclisccp2) then
             do ii=1,7
Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histhfCOSP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histhfCOSP.h	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histhfCOSP.h	(revision 1928)
@@ -38,4 +38,8 @@
            CALL histwrite_phy(nid_hf_cosp,lCOSP,"parasol_refl", &
      itau_wcosp,stlidar%parasolrefl)
+           CALL histwrite_phy(nid_hf_cosp,lCOSP,"parasol_crefl", &
+     itau_wcosp,parasolcrefl)
+           CALL histwrite_phy(nid_hf_cosp,lCOSP,"Ncrefl", &
+     itau_wcosp,Ncref)
          endif
          if (cfg%Latb532) then
@@ -91,4 +95,7 @@
 ! Sorties ISCCP
         if (cfg%Lisccp_sim) then
+
+          CALL histwrite_phy(nid_hf_cosp,lCOSP,"sunlit", &
+                        itau_wcosp,gbx%sunlit)
           if (cfg%Lclisccp2) then
             do ii=1,7
Index: /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histmthCOSP.h
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histmthCOSP.h	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/cosp/write_histmthCOSP.h	(revision 1928)
@@ -38,4 +38,8 @@
            CALL histwrite_phy(nid_mth_cosp,lCOSP,"parasol_refl", &
      itau_wcosp,stlidar%parasolrefl)
+           CALL histwrite_phy(nid_mth_cosp,lCOSP,"parasol_crefl", &
+     itau_wcosp,parasolcrefl)
+           CALL histwrite_phy(nid_mth_cosp,lCOSP,"Ncrefl", &
+     itau_wcosp,Ncref)
          endif
          if (cfg%Latb532) then
@@ -91,4 +95,5 @@
 ! Sorties ISCCP
         if (cfg%Lisccp_sim) then
+       CALL histwrite_phy(nid_mth_cosp,lCOSP,"sunlit",itau_wcosp,gbx%sunlit)
           if (cfg%Lclisccp2) then
             do ii=1,7
Index: /LMDZ4/branches/LMDZ4_AR5/libf/phylmd/physiq.F
===================================================================
--- /LMDZ4/branches/LMDZ4_AR5/libf/phylmd/physiq.F	(revision 1927)
+++ /LMDZ4/branches/LMDZ4_AR5/libf/phylmd/physiq.F	(revision 1928)
@@ -3447,5 +3447,5 @@
      $                   ecrit_mth,ecrit_day,ecrit_hf,
      $                   klon,klev,rlon,rlat,presnivs,overlap,
-     $                   ref_liq,ref_ice,
+     $                   fract,ref_liq,ref_ice,
      $                   pctsrf(:,is_ter)+pctsrf(:,is_lic),
      $                   zu10m,zv10m,pphis,
