34       SUBROUTINE diag_lidar(npoints,ncol,llm,max_bin,nrefl &
 
   35                   ,pnorm,pmol,refl,land,
pplay,undef,ok_lidar_cfad &
 
   37                   ,ncat,lidarcld,cldlayer,parasolrefl)
 
   78       real pnorm(npoints,ncol,llm)  
 
   79       real pmol(npoints,llm)        
 
   81       real pplay(npoints,llm)       
 
   83       real refl(npoints,ncol,nrefl) 
 
   86       real lidarcld(npoints,llm)     
 
   87       real cldlayer(npoints,ncat)    
 
   88       real cfad2(npoints,max_bin,llm) 
 
   90       real parasolrefl(npoints,nrefl)
 
  103       real x3d(npoints,ncol,llm)
 
  104       real x3d_c(npoints,llm),pnorm_c(npoints,llm)
 
  126         pnorm_c = pnorm(:,ic,:)
 
  127         where ((pnorm_c.lt.xmax) .and. (pmol.lt.xmax) .and. (pmol.gt. 0.0 ))
 
  141               x3d,pplay, s_att,s_cld,undef,lidarcld, &
 
  147       if (ok_lidar_cfad) 
then 
  153                  s_att,s_clr,xmax,cfad2,srbval)
 
  162       parasolrefl(:,:) = 0.0
 
  166          parasolrefl(:,k) = parasolrefl(:,k) + refl(:,ic,k)
 
  171         parasolrefl(:,k) = parasolrefl(:,k) / float(ncol)
 
  174         parasolrefl(:,k) = parasolrefl(:,k) * max(1.0-land(:),0.0) &
 
  175                            + (1.0 - max(1.0-land(:),0.0))*undef
 
  186       SUBROUTINE cosp_cfad_sr(Npoints,Ncolumns,Nlevels,Nbins,undef, &
 
  187                       x,s_att,s_clr,xmax,cfad,srbval)
 
  207       integer Npoints,Ncolumns,Nlevels,Nbins
 
  208       real xmax,S_att,S_clr,undef
 
  210       real x(npoints,ncolumns,nlevels)
 
  212       real cfad(npoints,nbins,nlevels)
 
  216       real srbval_ext(0:nbins)
 
  221       if ( nbins .lt. 6) 
return 
  229       do i = 7, min(10,nbins)
 
  230        srbval(i) = srbval(i-1) + 5.0
 
  232       DO i = 11, min(13,nbins)
 
  233        srbval(i) = srbval(i-1) + 10.0
 
  235       srbval(min(14,nbins)) = 80.0
 
  239       srbval_ext(1:nbins) = srbval
 
  249                   if (x(i,k,j) /= undef) 
then 
  250                      if ((x(i,k,j).gt.srbval_ext(ib-1)).and.(x(i,k,j).le.srbval_ext(ib))) &
 
  251                           cfad(i,ib,j) = cfad(i,ib,j) + 1.0
 
  260       where (cfad .ne. undef)  cfad = cfad / float(ncolumns)
 
  270       SUBROUTINE cosp_cldfrac(Npoints,Ncolumns,Nlevels,Ncat, &
 
  271                   x,
pplay,s_att,s_cld,undef,lidarcld, &
 
  275       integer Npoints,Ncolumns,Nlevels,Ncat
 
  276       real x(npoints,ncolumns,nlevels)
 
  277       real pplay(npoints,nlevels)
 
  281       real lidarcld(npoints,nlevels) 
 
  282       real cldlayer(npoints,ncat)    
 
  284       integer ip, k, iz, ic
 
  286       real cldy(npoints,ncolumns,nlevels)
 
  287       real srok(npoints,ncolumns,nlevels)
 
  288       real cldlay(npoints,ncolumns,ncat)
 
  289       real nsublay(npoints,ncolumns,ncat), nsublayer(npoints,ncat)
 
  290       real nsub(npoints,nlevels)
 
  292       real cldlay1(npoints,ncolumns)
 
  293       real cldlay2(npoints,ncolumns)
 
  294       real cldlay3(npoints,ncolumns)
 
  295       real nsublay1(npoints,ncolumns)
 
  296       real nsublay2(npoints,ncolumns)
 
  297       real nsublay3(npoints,ncolumns)
 
  304       if ( ncat .ne. 4 ) 
then 
  305          print *,
'Error in lmd_ipsl_stats.cosp_cldfrac, Ncat must be 4, not',ncat
 
  321          where ( (x(:,:,k).gt.s_cld) .and. (x(:,:,k).ne. undef) )
 
  328          where ( (x(:,:,k).gt.s_att) .and. (x(:,:,k).ne. undef)  )
 
  352       do k = nlevels, 1, -1
 
  357          if ( p1.gt.0. .and. p1.lt.(440.*100.)) 
then  
  358             cldlay3(ip,ic) = max(cldlay3(ip,ic), cldy(ip,ic,k))
 
  359             nsublay3(ip,ic) = max(nsublay3(ip,ic), srok(ip,ic,k))
 
  360          else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) 
then   
  361             cldlay2(ip,ic) = max(cldlay2(ip,ic), cldy(ip,ic,k))
 
  362             nsublay2(ip,ic) = max(nsublay2(ip,ic), srok(ip,ic,k))
 
  364             cldlay1(ip,ic) = max(cldlay1(ip,ic), cldy(ip,ic,k))
 
  365             nsublay1(ip,ic) = max(nsublay1(ip,ic), srok(ip,ic,k))
 
  368          cldlay(ip,ic,4) = max(cldlay(ip,ic,4), cldy(ip,ic,k))
 
  369          lidarcld(ip,k)=lidarcld(ip,k) + cldy(ip,ic,k)
 
  370          nsublay(ip,ic,4) = max(nsublay(ip,ic,4),srok(ip,ic,k))
 
  371          nsub(ip,k)=nsub(ip,k) + srok(ip,ic,k)
 
  375       cldlay(:,:,1) = cldlay1
 
  376       cldlay(:,:,2) = cldlay2
 
  377       cldlay(:,:,3) = cldlay3
 
  378       nsublay(:,:,1) = nsublay1
 
  379       nsublay(:,:,2) = nsublay2
 
  380       nsublay(:,:,3) = nsublay3
 
  384       where ( nsub(:,:).gt.0.0 )
 
  385          lidarcld(:,:) = lidarcld(:,:)/nsub(:,:)
 
  387          lidarcld(:,:) = undef
 
  398           cldlayer(:,iz)=cldlayer(:,iz) + cldlay(:,ic,iz)
 
  399           nsublayer(:,iz)=nsublayer(:,iz) + nsublay(:,ic,iz)
 
  403       where ( nsublayer(:,:).gt.0.0 )
 
  404          cldlayer(:,:) = cldlayer(:,:)/nsublayer(:,:)
 
  406          cldlayer(:,:) = undef
 
subroutine cosp_cldfrac(Npoints, Ncolumns, Nlevels, Ncat, x, pplay, S_att, S_cld, undef, lidarcld, cldlayer)
 
subroutine cosp_cfad_sr(Npoints, Ncolumns, Nlevels, Nbins, undef, x, S_att, S_clr, xmax, cfad, srbval)
 
!$Id itapm1 ENDIF!IM on interpole les champs sur les niveaux STD de pression!IM a chaque pas de temps de la physique c!positionnement de l argument logique a false c!pour ne pas recalculer deux fois la meme chose!c!a cet effet un appel a plevel_new a ete deplace c!a la fin de la serie d appels c!la boucle DO nlevSTD a ete internalisee c!dans d ou la creation de cette routine c c!CALL pplay
 
!$Header!integer nvarmx parameter(nfmx=10, imx=200, jmx=150, lmx=200, nvarmx=1000) real xd(imx
 
!$Header!c c INCLUDE fxyprim h c c c Fonctions in line c c REAL fyprim REAL rj c c il faut la calculer avant d appeler ces fonctions c c c Fonctions a changer selon x(x) et y(y) choisis.c-----------------------------------------------------------------c c.....ici
 
subroutine diag_lidar(npoints, ncol, llm, max_bin, nrefl, pnorm, pmol, refl, land, pplay, undef, ok_lidar_cfad, cfad2, srbval, ncat, lidarcld, cldlayer, parasolrefl)