Ignore:
Timestamp:
Jul 22, 2024, 9:46:57 AM (12 months ago)
Author:
abarral
Message:

Revert cosp*/ from the trunk, as it's external code
Add missing bits from FCM2 source

Location:
LMDZ6/branches/Amaury_dev/libf/phylmd/cosp
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/MISR_simulator.F

    r5082 r5095  
    133133           
    134134        ! define location of "layer top"
    135         if(ilev==1 .or. ilev==nlev) then
     135        if(ilev.eq.1 .or. ilev.eq.nlev) then
    136136            ztest=zfull(j,ilev)
    137137        else
     
    144144        do loop=2,n_MISR_CTH
    145145       
    146             if ( ztest >
     146            if ( ztest .gt.
    147147     &                1000*MISR_CTH_boundaries(loop+1) ) then
    148148       
     
    173173             dtau=0
    174174             
    175              if (frac_out(j,ibox,ilev)==1) then
     175             if (frac_out(j,ibox,ilev).eq.1) then
    176176                        dtau = dtau_s(j,ilev)
    177177                 endif
    178178                 
    179                  if (frac_out(j,ibox,ilev)==2) then
     179                 if (frac_out(j,ibox,ilev).eq.2) then
    180180                        dtau = dtau_c(j,ilev)
    181181                 end if
     
    186186        ! NOW for MISR ..
    187187        ! if there a cloud ... start the counter ... store this height
    188         if(thres_crossed_MISR == 0 .and. dtau > 0.) then
     188        if(thres_crossed_MISR .eq. 0 .and. dtau .gt. 0.) then
    189189       
    190190            ! first encountered a "cloud"
     
    193193        endif   
    194194               
    195         if( thres_crossed_MISR < 99 .and.
    196      &              thres_crossed_MISR > 0 ) then
     195        if( thres_crossed_MISR .lt. 99 .and.
     196     &              thres_crossed_MISR .gt. 0 ) then
    197197     
    198                 if( dtau == 0.) then
     198                if( dtau .eq. 0.) then
    199199       
    200200                    ! we have come to the end of the current cloud
     
    212212            ! then MISR will like see a top below the top of the current
    213213            ! layer
    214             if( dtau>0 .and. (cloud_dtau-dtau) < 1) then
    215            
    216                 if(dtau < 1 .or. ilev==1 .or. ilev==nlev) then
     214            if( dtau.gt.0 .and. (cloud_dtau-dtau) .lt. 1) then
     215           
     216                if(dtau .lt. 1 .or. ilev.eq.1 .or. ilev.eq.nlev) then
    217217
    218218                    ! MISR will likely penetrate to some point
     
    233233       
    234234            ! check for a distinctive water layer
    235             if(dtau > 1 .and. at(j,ilev)>273 ) then
     235            if(dtau .gt. 1 .and. at(j,ilev).gt.273 ) then
    236236     
    237237                    ! must be a water cloud ...
     
    242242            ! if the total column optical depth is "large" than
    243243            ! MISR can't seen anything else ... set current point as CTH level
    244             if(tau(j,ibox) > 5) then
     244            if(tau(j,ibox) .gt. 5) then
    245245
    246246                thres_crossed_MISR=99           
     
    254254        ! check to see if there was a cloud for which we didn't
    255255        ! set a MISR cloud top boundary
    256         if( thres_crossed_MISR == 1) then
     256        if( thres_crossed_MISR .eq. 1) then
    257257   
    258258        ! if the cloud has a total optical depth of greater
     
    260260        ! with a height near the true cloud top
    261261        ! otherwise there should be no CTH
    262         if( tau(j,ibox) > 0.5) then
     262        if( tau(j,ibox) .gt. 0.5) then
    263263
    264264            ! keep MISR detected CTH
    265265           
    266         elseif(tau(j,ibox) > 0.2) then
     266        elseif(tau(j,ibox) .gt. 0.2) then
    267267
    268268            ! MISR may detect but wont likley have a good height
     
    294294    !   This setup assumes the columns represent a about a 1 to 4 km scale
    295295    !   it will need to be modified significantly, otherwise
    296         if(ncol==1) then
     296        if(ncol.eq.1) then
    297297   
    298298       ! adjust based on neightboring points ... i.e. only 2D grid was input
    299299           do j=2,npoints-1
    300300           
    301             if(box_MISR_ztop(j-1,1)>0 .and.
    302      &             box_MISR_ztop(j+1,1)>0       ) then
     301            if(box_MISR_ztop(j-1,1).gt.0 .and.
     302     &             box_MISR_ztop(j+1,1).gt.0       ) then
    303303
    304304                if( abs( box_MISR_ztop(j-1,1) - 
    305      &                   box_MISR_ztop(j+1,1) ) < 500
     305     &                   box_MISR_ztop(j+1,1) ) .lt. 500
    306306     &              .and.
    307      &                   box_MISR_ztop(j,1) <
     307     &                   box_MISR_ztop(j,1) .lt.
    308308     &                   box_MISR_ztop(j+1,1)     ) then
    309309           
     
    319319         do ibox=2,ncol-1
    320320           
    321             if(box_MISR_ztop(1,ibox-1)>0 .and.
    322      &             box_MISR_ztop(1,ibox+1)>0        ) then
     321            if(box_MISR_ztop(1,ibox-1).gt.0 .and.
     322     &             box_MISR_ztop(1,ibox+1).gt.0        ) then
    323323
    324324                if( abs( box_MISR_ztop(1,ibox-1) - 
    325      &                   box_MISR_ztop(1,ibox+1) ) < 500
     325     &                   box_MISR_ztop(1,ibox+1) ) .lt. 500
    326326     &              .and.
    327      &                   box_MISR_ztop(1,ibox) <
     327     &                   box_MISR_ztop(1,ibox) .lt.
    328328     &                   box_MISR_ztop(1,ibox+1)     ) then
    329329           
     
    357357         do ibox=1,ncol
    358358
    359             if (tau(j,ibox) > (tauchk)) then
     359            if (tau(j,ibox) .gt. (tauchk)) then
    360360               box_cloudy(j,ibox)=.true.
    361361            endif
     
    366366   
    367367          !determine optical depth category
    368               if (tau(j,ibox) < isccp_taumin) then
     368              if (tau(j,ibox) .lt. isccp_taumin) then
    369369                  itau=1
    370               else if (tau(j,ibox) >= isccp_taumin
    371      &          .and. tau(j,ibox) < 1.3) then
     370              else if (tau(j,ibox) .ge. isccp_taumin                                   
     371     &          .and. tau(j,ibox) .lt. 1.3) then
    372372                  itau=2
    373               else if (tau(j,ibox) >= 1.3
    374      &          .and. tau(j,ibox) < 3.6) then
     373              else if (tau(j,ibox) .ge. 1.3
     374     &          .and. tau(j,ibox) .lt. 3.6) then
    375375                  itau=3
    376               else if (tau(j,ibox) >= 3.6
    377      &          .and. tau(j,ibox) < 9.4) then
     376              else if (tau(j,ibox) .ge. 3.6
     377     &          .and. tau(j,ibox) .lt. 9.4) then
    378378                  itau=4
    379               else if (tau(j,ibox) >= 9.4
    380      &          .and. tau(j,ibox) < 23.) then
     379              else if (tau(j,ibox) .ge. 9.4
     380     &          .and. tau(j,ibox) .lt. 23.) then
    381381                  itau=5
    382               else if (tau(j,ibox) >= 23.
    383      &          .and. tau(j,ibox) < 60.) then
     382              else if (tau(j,ibox) .ge. 23.
     383     &          .and. tau(j,ibox) .lt. 60.) then
    384384                  itau=6
    385               else if (tau(j,ibox) >= 60.) then
     385              else if (tau(j,ibox) .ge. 60.) then
    386386                  itau=7
    387387              endif
     
    390390
    391391       ! update MISR histograms and summary metrics - roj 5/2005
    392        if (sunlit(j)==1) then
     392       if (sunlit(j).eq.1) then
    393393                     
    394394              !if cloudy added by roj 5/2005
    395           if( box_MISR_ztop(j,ibox)==0) then
     395          if( box_MISR_ztop(j,ibox).eq.0) then
    396396         
    397397            ! no cloud detected
    398398            iMISR_ztop=0
    399399
    400           elseif( box_MISR_ztop(j,ibox)==-1) then
     400          elseif( box_MISR_ztop(j,ibox).eq.-1) then
    401401
    402402            ! cloud can be detected but too thin to get CTH
     
    416416            do loop=2,n_MISR_CTH
    417417       
    418                 if ( box_MISR_ztop(j,ibox) >
     418                if ( box_MISR_ztop(j,ibox) .gt.
    419419     &                1000*MISR_CTH_boundaries(loop+1) ) then
    420420       
     
    466466       enddo ! ibox - loop over subcolumns         
    467467     
    468        if( MISR_cldarea(j) > 0.) then
     468       if( MISR_cldarea(j) .gt. 0.) then
    469469        MISR_mean_ztop(j)= MISR_mean_ztop(j) / MISR_cldarea(j)   ! roj 5/2006
    470470       endif
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/array_lib.F90

    r5082 r5095  
    4545 
    4646! ----- INPUTS -----
    47   real(kind=8), dimension(:), intent(in) :: list
    48   real(kind=8), intent(in) :: val
     47  real*8, dimension(:), intent(in) :: list
     48  real*8, intent(in) :: val 
    4949  integer, intent(in), optional :: sort
    5050 
    5151! ----- OUTPUTS -----
    52   integer(kind=4) :: infind
    53   real(kind=8), intent(out), optional :: dist
     52  integer*4 :: infind
     53  real*8, intent(out), optional :: dist
    5454
    5555! ----- INTERNAL -----
    56   real(kind=8), dimension(size(list)) :: lists
    57   integer(kind=4) :: nlist, result, tmp(1), sort_list
    58   integer(kind=4), dimension(size(list)) :: mask, idx
     56  real*8, dimension(size(list)) :: lists
     57  integer*4 :: nlist, result, tmp(1), sort_list
     58  integer*4, dimension(size(list)) :: mask, idx
    5959
    6060  if (present(sort)) then
     
    121121
    122122! ----- INPUTS -----
    123   real(kind=8), dimension(:), intent(in) :: yarr, xarr, xxarr
    124   real(kind=8), intent(in) :: tol
     123  real*8, dimension(:), intent(in) :: yarr, xarr, xxarr
     124  real*8, intent(in) :: tol
    125125
    126126! ----- OUTPUTS -----
    127   real(kind=8), dimension(size(xxarr)), intent(out) :: yyarr
     127  real*8, dimension(size(xxarr)), intent(out) :: yyarr
    128128
    129129! ----- INTERNAL -----
    130   real(kind=8), dimension(size(xarr)) :: ysort, xsort
    131   integer(kind=4), dimension(size(xarr)) :: ist
    132   integer(kind=4) :: nx, nxx, i, iloc
    133   real(kind=8) :: d, m
     130  real*8, dimension(size(xarr)) :: ysort, xsort
     131  integer*4, dimension(size(xarr)) :: ist
     132  integer*4 :: nx, nxx, i, iloc
     133  real*8 :: d, m
    134134
    135135  nx = size(xarr)
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/atmos_lib.F90

    r5082 r5095  
    4343
    4444! ----- OUTPUTS -----
    45   real(kind=8), intent(out), dimension(ndat) :: &
     45  real*8, intent(out), dimension(ndat) :: &
    4646  hgt, &                        ! height (m)
    4747  prs, &                        ! pressure (hPa)
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/calc_Re.F90

    r5082 r5095  
    4040! ----- INPUTS ----- 
    4141 
    42   real(kind=8), intent(in) :: Q,Np,rho_a
     42  real*8, intent(in) :: Q,Np,rho_a
    4343 
    4444  integer, intent(in):: dtype
    45   real(kind=8), intent(in) :: dmin,dmax,rho_c,p1,p2,p3
    46    
    47   real(kind=8), intent(inout) :: apm,bpm
     45  real*8, intent(in) :: dmin,dmax,rho_c,p1,p2,p3
     46   
     47  real*8, intent(inout) :: apm,bpm 
    4848   
    4949! ----- OUTPUTS -----
    5050
    51   real(kind=8), intent(out) :: Re
     51  real*8, intent(out) :: Re
    5252 
    5353! ----- INTERNAL -----
    5454 
    5555  integer :: local_dtype
    56   real(kind=8)  :: local_p3,local_Np
    57 
    58   real(kind=8) :: pi, &
     56  real*8  :: local_p3,local_Np
     57
     58  real*8 :: pi, &
    5959  N0,D0,vu,dm,ld, &         ! gamma, exponential variables
    6060  rg,log_sigma_g
    6161 
    62   real(kind=8) :: tmp1,tmp2
     62  real*8 :: tmp1,tmp2
    6363
    6464  pi = acos(-1.0)
     
    7272  ! Exponential is same as modified gamma with vu =1
    7373  ! if Np is specified then we will just treat as modified gamma
    74   if(dtype==2 .and. Np>0) then
     74  if(dtype.eq.2 .and. Np>0) then
    7575    local_dtype=1;
    7676    local_p3=1;
     
    119119   
    120120
    121     if( Np==0 .and. p2+1 > 1E-8) then     ! use default value for MEAN diameter as first default
     121    if( Np.eq.0 .and. p2+1 > 1E-8) then     ! use default value for MEAN diameter as first default
    122122     
    123123        dm = p2             ! by definition, should have units of microns
     
    126126    else   ! use value of Np
    127127       
    128         if(Np==0) then
     128        if(Np.eq.0) then
    129129       
    130130            if( abs(p1+1) > 1E-8 ) then  !   use default number concentration
     
    233233     
    234234    ! get rg ...
    235     if( Np==0 .and. (abs(p2+1) > 1E-8) ) then ! use default value of rg
     235    if( Np.eq.0 .and. (abs(p2+1) > 1E-8) ) then ! use default value of rg
    236236   
    237237            rg = p2
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/cosp_output_write_mod.F90

    r5093 r5095  
    185185    do k=1,PARASOL_NREFL
    186186     do ip=1, Npoints
    187       if (stlidar%cldlayer(ip,4)>0.01.and.stlidar%parasolrefl(ip,k)/=missing_val) then
     187      if (stlidar%cldlayer(ip,4).gt.0.01.and.stlidar%parasolrefl(ip,k).ne.missing_val) then
    188188        parasolcrefl(ip,k)=(stlidar%parasolrefl(ip,k)-0.03*(1.-stlidar%cldlayer(ip,4)))/ &
    189189                             stlidar%cldlayer(ip,4)
     
    456456    CHARACTER(LEN=20) :: typeecrit
    457457
    458     ! ug On récupère le type écrit de la structure:
    459     !       Assez moche, à refaire si meilleure méthode...
     458    ! ug On récupère le type écrit de la structure:
     459    !       Assez moche, Ã|  refaire si meilleure méthode...
    460460    IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN
    461461       typeecrit = 'once'
     
    523523
    524524! Axe vertical
    525       IF (nvertsave==nvertp(iff)) THEN
     525      IF (nvertsave.eq.nvertp(iff)) THEN
    526526          klevs=PARASOL_NREFL
    527527          nam_axvert="sza"
    528       ELSE IF (nvertsave==nvertisccp(iff)) THEN
     528      ELSE IF (nvertsave.eq.nvertisccp(iff)) THEN
    529529          klevs=7
    530530          nam_axvert="pressure2"
    531       ELSE IF (nvertsave==nvertcol(iff)) THEN
     531      ELSE IF (nvertsave.eq.nvertcol(iff)) THEN
    532532          klevs=Ncolout
    533533          nam_axvert="column"
    534       ELSE IF (nvertsave==nverttemp(iff)) THEN
     534      ELSE IF (nvertsave.eq.nverttemp(iff)) THEN
    535535          klevs=LIDAR_NTEMP
    536536          nam_axvert="temp"
    537       ELSE IF (nvertsave==nvertmisr(iff)) THEN
     537      ELSE IF (nvertsave.eq.nvertmisr(iff)) THEN
    538538          klevs=MISR_N_CTH
    539539          nam_axvert="cth16"
    540       ELSE IF (nvertsave==nvertReffIce(iff)) THEN
     540      ELSE IF (nvertsave.eq.nvertReffIce(iff)) THEN
    541541          klevs= numMODISReffIceBins
    542542          nam_axvert="ReffIce"
    543       ELSE IF (nvertsave==nvertReffLiq(iff)) THEN
     543      ELSE IF (nvertsave.eq.nvertReffLiq(iff)) THEN
    544544          klevs= numMODISReffLiqBins
    545545          nam_axvert="ReffLiq"
     
    558558      END IF
    559559
    560     ! ug On récupère le type écrit de la structure:
    561     !       Assez moche, à refaire si meilleure méthode...
     560    ! ug On récupère le type écrit de la structure:
     561    !       Assez moche, Ã|  refaire si meilleure méthode...
    562562    IF (INDEX(var%cosp_typeecrit(iff), "once") > 0) THEN
    563563       typeecrit = 'once'
     
    628628    IF (prt_level >= 9) WRITE(lunout,*)'Begin histrwrite2d ',var%name
    629629
    630   ! On regarde si on est dans la phase de définition ou d'écriture:
     630  ! On regarde si on est dans la phase de définition ou d'écriture:
    631631  IF(.NOT.cosp_varsdefined) THEN
    632632!$OMP MASTER
    633       !Si phase de définition.... on définit
     633      !Si phase de définition.... on définit
    634634      CALL conf_cospoutputs(var%name,var%cles)
    635635      DO iff=1, 3
     
    640640!$OMP END MASTER
    641641  ELSE
    642     !Et sinon on.... écrit
     642    !Et sinon on.... écrit
    643643    IF (SIZE(field)/=klon) &
    644644  CALL abort_physic('iophy::histwrite2d_cosp','Field first DIMENSION not equal to klon',1)
     
    725725               nom=var%name
    726726      END IF
    727   ! On regarde si on est dans la phase de définition ou d'écriture:
     727  ! On regarde si on est dans la phase de définition ou d'écriture:
    728728  IF(.NOT.cosp_varsdefined) THEN
    729       !Si phase de définition.... on définit
     729      !Si phase de définition.... on définit
    730730!$OMP MASTER
    731731      CALL conf_cospoutputs(var%name,var%cles)
     
    737737!$OMP END MASTER
    738738  ELSE
    739     !Et sinon on.... écrit
     739    !Et sinon on.... écrit
    740740    IF (SIZE(field,1)/=klon) &
    741741   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)                                 
     
    809809
    810810  IF(cosp_varsdefined) THEN
    811     !Et sinon on.... écrit
     811    !Et sinon on.... écrit
    812812    IF (SIZE(field,1)/=klon) &
    813813   CALL abort_physic('iophy::histwrite3d','Field first DIMENSION not equal to klon',1)           
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/dsd.F90

    r5082 r5095  
    6060  integer, intent(in) :: nsizes
    6161  integer, intent(in) :: dtype
    62   real(kind=8), intent(in)  :: Q,Re_,Np,D(nsizes)
    63   real(kind=8), intent(in)  :: rho_a,tk,dmin,dmax,rho_c,p1,p2,p3
    64    
    65   real(kind=8), intent(inout) :: apm,bpm
     62  real*8, intent(in)  :: Q,Re_,Np,D(nsizes)
     63  real*8, intent(in)  :: rho_a,tk,dmin,dmax,rho_c,p1,p2,p3
     64   
     65  real*8, intent(inout) :: apm,bpm 
    6666 
    6767! ----- OUTPUTS -----
    6868
    69   real(kind=8), intent(out) :: N(nsizes)
     69  real*8, intent(out) :: N(nsizes)
    7070 
    7171! ----- INTERNAL -----
    7272 
    73    real(kind=8) :: fc(nsizes)
    74 
    75   real(kind=8) :: &
     73   real*8 :: fc(nsizes)
     74
     75  real*8 :: &
    7676  N0,D0,vu,local_np,dm,ld, &            ! gamma, exponential variables
    7777  dmin_mm,dmax_mm,ahp,bhp, &        ! power law variables
     
    7979  rho_e                 ! particle density (kg m^-3)
    8080 
    81   real(kind=8) :: tmp1, tmp2
    82   real(kind=8) :: pi,rc,tc
    83   real(kind=8) :: Re
     81  real*8 :: tmp1, tmp2
     82  real*8 :: pi,rc,tc
     83  real*8 :: Re
    8484
    8585  integer k,lidx,uidx
     
    352352      log_sigma_g = p3
    353353      tmp2 = (bpm*log_sigma_g)**2.
    354       if(Re<=0) then
     354      if(Re.le.0) then
    355355        rg = p2
    356356      else
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/format_input.F90

    r5082 r5095  
    4040
    4141! ----- INPUTS -----
    42   real(kind=8), dimension(:,:), intent(in) :: &
     42  real*8, dimension(:,:), intent(in) :: &
    4343    hgt_matrix,env_hgt_matrix,env_t_matrix,env_p_matrix,env_rh_matrix
    4444
    4545! ----- OUTPUTS -----
    46   real(kind=8), dimension(:,:), intent(out) :: &
     46  real*8, dimension(:,:), intent(out) :: &
    4747    t_matrix,p_matrix,rh_matrix
    4848
     
    9797
    9898! ----- OUTPUTS -----
    99   real(kind=8), dimension(:,:), intent(inout) :: &
     99  real*8, dimension(:,:), intent(inout) :: &
    100100    hgt_matrix,p_matrix,t_matrix,rh_matrix
    101   real(kind=8), dimension(:,:,:), intent(inout) :: &
     101  real*8, dimension(:,:,:), intent(inout) :: &
    102102    hm_matrix
    103103  logical, intent(out) :: hgt_reversed
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/gases.F90

    r5082 r5095  
    2727  nbands_o2 = 48 ,&
    2828  nbands_h2o = 30
    29   real(kind=8), intent(in) :: PRES_mb, T, RH, f
    30   real(kind=8) :: gases, th, e, p, sumo, gm0, a0, ap, term1, term2, term3, &
     29  real*8, intent(in) :: PRES_mb, T, RH, f
     30  real*8 :: gases, th, e, p, sumo, gm0, a0, ap, term1, term2, term3, &
    3131            bf, be, term4, npp
    32   real(kind=8), dimension(nbands_o2) :: v0, a1, a2, a3, a4, a5, a6
    33   real(kind=8), dimension(nbands_h2o) :: v1, b1, b2, b3
    34   real(kind=8) :: e_th,one_th,pth3,eth35,aux1,aux2,aux3,aux4
    35   real(kind=8) :: gm,delt,x,y,gm2
    36   real(kind=8) :: fpp_o2,fpp_h2o,s_o2,s_h2o
     32  real*8, dimension(nbands_o2) :: v0, a1, a2, a3, a4, a5, a6
     33  real*8, dimension(nbands_h2o) :: v1, b1, b2, b3
     34  real*8 :: e_th,one_th,pth3,eth35,aux1,aux2,aux3,aux4
     35  real*8 :: gm,delt,x,y,gm2
     36  real*8 :: fpp_o2,fpp_h2o,s_o2,s_h2o
    3737  integer :: i
    3838 
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/icarus.F

    r5086 r5095  
    293293      ncolprint=0
    294294
    295       if ( debug/=0 ) then
     295      if ( debug.ne.0 ) then
    296296          j=1
    297297          write(6,'(a10)') 'j='
     
    347347!     ---------------------------------------------------!
    348348
    349       if (ncolprint/=0) then
     349      if (ncolprint.ne.0) then
    350350      do j=1,npoints,1000
    351351        write(6,'(a10)') 'j='
     
    354354      endif
    355355
    356       if (top_height == 1 .or. top_height == 3) then
     356      if (top_height .eq. 1 .or. top_height .eq. 3) then
    357357
    358358      do j=1,npoints
     
    364364      enddo
    365365
    366       do ilev=1,nlev
     366      do 12 ilev=1,nlev
    367367        do j=1,npoints
    368          if (pfull(j,ilev) < 40000. .and.
    369      &          pfull(j,ilev) >  5000. .and.
    370      &          at(j,ilev) < attropmin(j)) then
     368         if (pfull(j,ilev) .lt. 40000. .and.
     369     &          pfull(j,ilev) .gt.  5000. .and.
     370     &          at(j,ilev) .lt. attropmin(j)) then
    371371                ptrop(j) = pfull(j,ilev)
    372372                attropmin(j) = at(j,ilev)
     
    375375           end if
    376376        enddo
    377       END DO
    378 
    379       do ilev=1,nlev
     37712    continue
     378
     379      do 13 ilev=1,nlev
    380380        do j=1,npoints
    381            if (at(j,ilev) > atmax(j) .and.
    382      &              ilev  >= itrop(j)) atmax(j)=at(j,ilev)
    383         enddo
    384       END DO
     381           if (at(j,ilev) .gt. atmax(j) .and.
     382     &              ilev  .ge. itrop(j)) atmax(j)=at(j,ilev)
     383        enddo
     38413    continue
    385385
    386386      end if
    387387
    388388
    389       if (top_height == 1 .or. top_height == 3) then
     389      if (top_height .eq. 1 .or. top_height .eq. 3) then
    390390          do j=1,npoints
    391391              meantb(j) = 0.
    392392              meantbclr(j) = 0.
    393           END DO
     393          end do
    394394      else
    395395          do j=1,npoints
    396396              meantb(j) = output_missing_value
    397397              meantbclr(j) = output_missing_value
    398           END DO
     398          end do
    399399      end if
    400400     
     
    408408          rangevec(j)=0
    409409
    410           if (cc(j,ilev) < 0. .or. cc(j,ilev) > 1.) then
     410          if (cc(j,ilev) .lt. 0. .or. cc(j,ilev) .gt. 1.) then
    411411!           error = cloud fraction less than zero
    412412!           error = cloud fraction greater than 1
     
    414414          endif
    415415
    416           if (conv(j,ilev) < 0. .or. conv(j,ilev) > 1.) then
     416          if (conv(j,ilev) .lt. 0. .or. conv(j,ilev) .gt. 1.) then
    417417!           ' error = convective cloud fraction less than zero'
    418418!           ' error = convective cloud fraction greater than 1'
     
    420420          endif
    421421
    422           if (dtau_s(j,ilev) < 0.) then
     422          if (dtau_s(j,ilev) .lt. 0.) then
    423423!           ' error = stratiform cloud opt. depth less than zero'
    424424            rangevec(j)=rangevec(j)+4
    425425          endif
    426426
    427           if (dtau_c(j,ilev) < 0.) then
     427          if (dtau_c(j,ilev) .lt. 0.) then
    428428!           ' error = convective cloud opt. depth less than zero'
    429429            rangevec(j)=rangevec(j)+8
    430430          endif
    431431
    432           if (dem_s(j,ilev) < 0. .or. dem_s(j,ilev) > 1.) then
     432          if (dem_s(j,ilev) .lt. 0. .or. dem_s(j,ilev) .gt. 1.) then
    433433!             ' error = stratiform cloud emissivity less than zero'
    434434!             ' error = stratiform cloud emissivity greater than 1'
     
    436436          endif
    437437
    438           if (dem_c(j,ilev) < 0. .or. dem_c(j,ilev) > 1.) then
     438          if (dem_c(j,ilev) .lt. 0. .or. dem_c(j,ilev) .gt. 1.) then
    439439!             ' error = convective cloud emissivity less than zero'
    440440!             ' error = convective cloud emissivity greater than 1'
     
    448448        enddo
    449449
    450         if (rangeerror/=0) then
     450        if (rangeerror.ne.0) then
    451451              write (6,*) 'Input variable out of range'
    452452              write (6,*) 'rangevec:'
     
    466466 
    467467      !initialize tau and albedocld to zero
    468       do ibox=1,ncol
     468      do 15 ibox=1,ncol
    469469        do j=1,npoints
    470470            tau(j,ibox)=0.
     
    474474          box_cloudy(j,ibox)=.false.
    475475        enddo
    476       END DO
     47615    continue
    477477
    478478      !compute total cloud optical depth for each column     
     
    481481            do ibox=1,ncol
    482482              do j=1,npoints
    483                  if (frac_out(j,ibox,ilev)==1) then
     483                 if (frac_out(j,ibox,ilev).eq.1) then
    484484                        tau(j,ibox)=tau(j,ibox)
    485485     &                     + dtau_s(j,ilev)
    486486                 endif
    487                  if (frac_out(j,ibox,ilev)==2) then
     487                 if (frac_out(j,ibox,ilev).eq.2) then
    488488                        tau(j,ibox)=tau(j,ibox)
    489489     &                     + dtau_c(j,ilev)
     
    492492            enddo ! ibox
    493493      enddo ! ilev
    494           if (ncolprint/=0) then
     494          if (ncolprint.ne.0) then
    495495
    496496              do j=1,npoints ,1000
     
    521521!             sky versions of these quantities.
    522522
    523       if (top_height == 1 .or. top_height == 3) then
     523      if (top_height .eq. 1 .or. top_height .eq. 3) then
    524524
    525525
     
    539539        pstd = 1.013250E+06
    540540        t0 = 296.
    541         if (ncolprint /= 0)
     541        if (ncolprint .ne. 0)
    542542     &         write(6,*)  'ilev   pw (kg/m2)   tauwv(j)      dem_wv'
    543         do ilev=1,nlev
     543        do 125 ilev=1,nlev
    544544          do j=1,npoints
    545545               !press and dpress are dyne/cm2 = Pascals *10
     
    559559               dem_wv(j,ilev) = 1. - exp( -1. * tauwv(j))
    560560          enddo
    561                if (ncolprint /= 0) then
     561               if (ncolprint .ne. 0) then
    562562               do j=1,npoints ,1000
    563563               write(6,'(a10)') 'j='
     
    568568               enddo
    569569             endif
    570       END DO
     570125     continue
    571571
    572572        !initialize variables
     
    598598
    599599          enddo   
    600             if (ncolprint/=0) then
     600            if (ncolprint.ne.0) then
    601601             do j=1,npoints ,1000
    602602              write(6,'(a10)') 'j='
     
    627627        enddo
    628628
    629         if (ncolprint/=0) then
     629        if (ncolprint.ne.0) then
    630630        do j=1,npoints ,1000
    631631          write(6,'(a10)') 'j='
     
    649649
    650650
    651         if (ncolprint/=0) then
     651        if (ncolprint.ne.0) then
    652652
    653653        do j=1,npoints ,1000
     
    683683
    684684              ! emissivity for point in this layer
    685                 if (frac_out(j,ibox,ilev)==1) then
     685                if (frac_out(j,ibox,ilev).eq.1) then
    686686                dem(j,ibox)= 1. -
    687687     &             ( (1. - dem_wv(j,ilev)) * (1. -  dem_s(j,ilev)) )
    688                 else if (frac_out(j,ibox,ilev)==2) then
     688                else if (frac_out(j,ibox,ilev).eq.2) then
    689689                dem(j,ibox)= 1. -
    690690     &             ( (1. - dem_wv(j,ilev)) * (1. -  dem_c(j,ilev)) )
     
    710710            enddo ! ibox
    711711
    712             if (ncolprint/=0) then
     712            if (ncolprint.ne.0) then
    713713              do j=1,npoints,1000
    714714              write (6,'(a)') 'ilev:'
     
    740740            bb(j)=1/( exp(1307.27/skt(j)) - 1. )
    741741            !bb(j)=5.67e-8*skt(j)**4
    742           END DO
     742          end do
    743743
    744744        do ibox=1,ncol
     
    751751     &         * trans_layers_above(j,ibox)
    752752           
    753           END DO
    754         END DO
     753          end do
     754        end do
    755755
    756756        !calculate mean infrared brightness temperature
     
    758758          do j=1,npoints
    759759            meantb(j) = meantb(j)+1307.27/(log(1.+(1./fluxtop(j,ibox))))
    760           END DO
    761         END DO
     760          end do
     761        end do
    762762          do j=1, npoints
    763763            meantb(j) = meantb(j) / real(ncol)
    764           END DO
    765 
    766         if (ncolprint/=0) then
     764          end do       
     765
     766        if (ncolprint.ne.0) then
    767767
    768768          do j=1,npoints ,1000
     
    784784          write (6,'(8f7.2)') (meantb(j),ibox=1,ncolprint)
    785785     
    786           END DO
     786          end do
    787787      endif
    788788   
     
    819819          enddo
    820820
    821           if (top_height == 1) then
     821          if (top_height .eq. 1) then
    822822            do j=1,npoints 
    823               if (transmax(j) > 0.001 .and.
    824      &          transmax(j) <= 0.9999999) then
     823              if (transmax(j) .gt. 0.001 .and.
     824     &          transmax(j) .le. 0.9999999) then
    825825                fluxtopinit(j) = fluxtop(j,ibox)
    826826              tauir(j) = tau(j,ibox) *rec2p13
     
    829829            do icycle=1,2
    830830              do j=1,npoints 
    831                 if (tau(j,ibox) > (tauchk            )) then
    832                 if (transmax(j) > 0.001 .and.
    833      &            transmax(j) <= 0.9999999) then
     831                if (tau(j,ibox) .gt. (tauchk            )) then
     832                if (transmax(j) .gt. 0.001 .and.
     833     &            transmax(j) .le. 0.9999999) then
    834834                  emcld(j,ibox) = 1. - exp(-1. * tauir(j)  )
    835835                  fluxtop(j,ibox) = fluxtopinit(j) -   
     
    839839                  tb(j,ibox)= 1307.27
    840840     &              / (log(1. + (1./fluxtop(j,ibox))))
    841                   if (tb(j,ibox) > 260.) then
     841                  if (tb(j,ibox) .gt. 260.) then
    842842                  tauir(j) = tau(j,ibox) / 2.56
    843843                  end if                   
     
    850850       
    851851          do j=1,npoints
    852             if (tau(j,ibox) > (tauchk            )) then
     852            if (tau(j,ibox) .gt. (tauchk            )) then
    853853                !cloudy box
    854854                !NOTE: tb is the cloud-top temperature not infrared brightness temperature
    855855                !at this point in the code
    856856                tb(j,ibox)= 1307.27/ (log(1. + (1./fluxtop(j,ibox))))
    857                 if (top_height==1.and.tauir(j)<taumin(j)) then
     857                if (top_height.eq.1.and.tauir(j).lt.taumin(j)) then
    858858                         tb(j,ibox) = attrop(j) - 5.
    859859                   tau(j,ibox) = 2.13*taumin(j)
     
    866866        enddo ! ibox
    867867
    868         if (ncolprint/=0) then
     868        if (ncolprint.ne.0) then
    869869
    870870          do j=1,npoints,1000
     
    925925
    926926      !compute cloud top pressure
    927       do ibox=1,ncol
     927      do 30 ibox=1,ncol
    928928        !segregate according to optical thickness
    929         if (top_height == 1 .or. top_height == 3) then
     929        if (top_height .eq. 1 .or. top_height .eq. 3) then 
    930930          !find level whose temperature
    931931          !most closely matches brightness temperature
     
    933933            nmatch(j)=0
    934934          enddo
    935           do k1=1,nlev-1
    936             if (top_height_direction == 2) then
     935          do 29 k1=1,nlev-1
     936            if (top_height_direction .eq. 2) then
    937937              ilev = nlev - k1
    938938            else
     
    941941            !cdir nodep
    942942            do j=1,npoints
    943              if (ilev >= itrop(j)) then
    944               if ((at(j,ilev)   >= tb(j,ibox) .and.
    945      &          at(j,ilev+1) <= tb(j,ibox)) .or.
    946      &          (at(j,ilev) <= tb(j,ibox) .and.
    947      &          at(j,ilev+1) >= tb(j,ibox))) then
     943             if (ilev .ge. itrop(j)) then
     944              if ((at(j,ilev)   .ge. tb(j,ibox) .and.
     945     &          at(j,ilev+1) .le. tb(j,ibox)) .or.
     946     &          (at(j,ilev) .le. tb(j,ibox) .and.
     947     &          at(j,ilev+1) .ge. tb(j,ibox))) then
    948948                nmatch(j)=nmatch(j)+1
    949949                match(j,nmatch(j))=ilev
     
    951951             end if                         
    952952            enddo
    953       END DO
     95329        continue
    954954
    955955          do j=1,npoints
    956             if (nmatch(j) >= 1) then
     956            if (nmatch(j) .ge. 1) then
    957957              k1 = match(j,nmatch(j))
    958958              k2 = k1 + 1
     
    962962              logp=logp1+(logp2-logp1)*abs(tb(j,ibox)-at(j,k1))/atd
    963963              ptop(j,ibox) = exp(logp)
    964               if(abs(pfull(j,k1)-ptop(j,ibox)) <
     964              if(abs(pfull(j,k1)-ptop(j,ibox)) .lt.
    965965     &            abs(pfull(j,k2)-ptop(j,ibox))) then
    966966                 levmatch(j,ibox)=k1
     
    969969              end if   
    970970            else
    971               if (tb(j,ibox) <= attrop(j)) then
     971              if (tb(j,ibox) .le. attrop(j)) then
    972972                ptop(j,ibox)=ptrop(j)
    973973                levmatch(j,ibox)=itrop(j)
    974974              end if
    975               if (tb(j,ibox) >= atmax(j)) then
     975              if (tb(j,ibox) .ge. atmax(j)) then
    976976                ptop(j,ibox)=pfull(j,nlev)
    977977                levmatch(j,ibox)=nlev
     
    987987          do ilev=1,nlev
    988988            do j=1,npoints     
    989               if ((ptop(j,ibox) == 0. )
    990      &           .and.(frac_out(j,ibox,ilev) /= 0)) then
     989              if ((ptop(j,ibox) .eq. 0. )
     990     &           .and.(frac_out(j,ibox,ilev) .ne. 0)) then
    991991                ptop(j,ibox)=phalf(j,ilev)
    992992              levmatch(j,ibox)=ilev
    993993              end if
    994             END DO
    995           END DO
     994            end do
     995          end do
    996996        end if                           
    997997         
    998998        do j=1,npoints
    999           if (tau(j,ibox) <= (tauchk            )) then
     999          if (tau(j,ibox) .le. (tauchk            )) then
    10001000            ptop(j,ibox)=0.
    10011001            levmatch(j,ibox)=0     
     
    10031003        enddo
    10041004
    1005       END DO
     100530    continue
    10061006             
    10071007!
     
    10321032
    10331033      !reset frequencies
    1034       do ilev=1,7
     1034      do 38 ilev=1,7
    10351035      do 38 ilev2=1,7
    10361036        do j=1,npoints !
    1037              if (sunlit(j)==1 .or. top_height == 3) then
     1037             if (sunlit(j).eq.1 .or. top_height .eq. 3) then
    10381038                fq_isccp(j,ilev,ilev2)= 0.
    10391039             else
     
    10421042        enddo
    1043104338    continue
    1044       END DO
    10451044
    10461045      !reset variables need for averaging cloud properties
    10471046      do j=1,npoints
    1048         if (sunlit(j)==1 .or. top_height == 3) then
     1047        if (sunlit(j).eq.1 .or. top_height .eq. 3) then
    10491048             totalcldarea(j) = 0.
    10501049             meanalbedocld(j) = 0.
     
    10611060      boxarea = 1./real(ncol)
    10621061     
    1063       do ibox=1,ncol
     1062      do 39 ibox=1,ncol
    10641063        do j=1,npoints
    10651064
    1066           if (tau(j,ibox) > (tauchk            )
    1067      &      .and. ptop(j,ibox) > 0.) then
     1065          if (tau(j,ibox) .gt. (tauchk            )
     1066     &      .and. ptop(j,ibox) .gt. 0.) then
    10681067              box_cloudy(j,ibox)=.true.
    10691068          endif
     
    10711070          if (box_cloudy(j,ibox)) then
    10721071
    1073               if (sunlit(j)==1 .or. top_height == 3) then
     1072              if (sunlit(j).eq.1 .or. top_height .eq. 3) then
    10741073
    10751074                boxtau(j,ibox) = tau(j,ibox)
    10761075
    1077                 if (tau(j,ibox) >= isccp_taumin) then
     1076                if (tau(j,ibox) .ge. isccp_taumin) then
    10781077                   totalcldarea(j) = totalcldarea(j) + boxarea
    10791078               
     
    10921091          endif
    10931092
    1094           if (sunlit(j)==1 .or. top_height == 3) then
     1093          if (sunlit(j).eq.1 .or. top_height .eq. 3) then
    10951094
    10961095           if (box_cloudy(j,ibox)) then
     
    11021101              boxptop(j,ibox) = ptop(j,ibox)
    11031102   
    1104               if (tau(j,ibox) >= isccp_taumin) then
     1103              if (tau(j,ibox) .ge. isccp_taumin) then
    11051104                meanptop(j) = meanptop(j) + ptop(j,ibox)*boxarea
    11061105              end if           
     
    11111110
    11121111              !determine optical depth category
    1113               if (tau(j,ibox) < isccp_taumin) then
     1112              if (tau(j,ibox) .lt. isccp_taumin) then
    11141113                  itau(j)=1
    1115               else if (tau(j,ibox) >= isccp_taumin
     1114              else if (tau(j,ibox) .ge. isccp_taumin
    11161115     &                                   
    1117      &          .and. tau(j,ibox) < 1.3) then
     1116     &          .and. tau(j,ibox) .lt. 1.3) then
    11181117                itau(j)=2
    1119               else if (tau(j,ibox) >= 1.3
    1120      &          .and. tau(j,ibox) < 3.6) then
     1118              else if (tau(j,ibox) .ge. 1.3
     1119     &          .and. tau(j,ibox) .lt. 3.6) then
    11211120                itau(j)=3
    1122               else if (tau(j,ibox) >= 3.6
    1123      &          .and. tau(j,ibox) < 9.4) then
     1121              else if (tau(j,ibox) .ge. 3.6
     1122     &          .and. tau(j,ibox) .lt. 9.4) then
    11241123                  itau(j)=4
    1125               else if (tau(j,ibox) >= 9.4
    1126      &          .and. tau(j,ibox) < 23.) then
     1124              else if (tau(j,ibox) .ge. 9.4
     1125     &          .and. tau(j,ibox) .lt. 23.) then
    11271126                  itau(j)=5
    1128               else if (tau(j,ibox) >= 23.
    1129      &          .and. tau(j,ibox) < 60.) then
     1127              else if (tau(j,ibox) .ge. 23.
     1128     &          .and. tau(j,ibox) .lt. 60.) then
    11301129                  itau(j)=6
    1131               else if (tau(j,ibox) >= 60.) then
     1130              else if (tau(j,ibox) .ge. 60.) then
    11321131                  itau(j)=7
    11331132              end if
    11341133
    11351134              !determine cloud top pressure category
    1136               if (    ptop(j,ibox) > 0.
    1137      &          .and.ptop(j,ibox) < 180.) then
     1135              if (    ptop(j,ibox) .gt. 0. 
     1136     &          .and.ptop(j,ibox) .lt. 180.) then
    11381137                  ipres(j)=1
    1139               else if(ptop(j,ibox) >= 180.
    1140      &          .and.ptop(j,ibox) < 310.) then
     1138              else if(ptop(j,ibox) .ge. 180.
     1139     &          .and.ptop(j,ibox) .lt. 310.) then
    11411140                  ipres(j)=2
    1142               else if(ptop(j,ibox) >= 310.
    1143      &          .and.ptop(j,ibox) < 440.) then
     1141              else if(ptop(j,ibox) .ge. 310.
     1142     &          .and.ptop(j,ibox) .lt. 440.) then
    11441143                  ipres(j)=3
    1145               else if(ptop(j,ibox) >= 440.
    1146      &          .and.ptop(j,ibox) < 560.) then
     1144              else if(ptop(j,ibox) .ge. 440.
     1145     &          .and.ptop(j,ibox) .lt. 560.) then
    11471146                  ipres(j)=4
    1148               else if(ptop(j,ibox) >= 560.
    1149      &          .and.ptop(j,ibox) < 680.) then
     1147              else if(ptop(j,ibox) .ge. 560.
     1148     &          .and.ptop(j,ibox) .lt. 680.) then
    11501149                  ipres(j)=5
    1151               else if(ptop(j,ibox) >= 680.
    1152      &          .and.ptop(j,ibox) < 800.) then
     1150              else if(ptop(j,ibox) .ge. 680.
     1151     &          .and.ptop(j,ibox) .lt. 800.) then
    11531152                  ipres(j)=6
    1154               else if(ptop(j,ibox) >= 800.) then
     1153              else if(ptop(j,ibox) .ge. 800.) then
    11551154                  ipres(j)=7
    11561155              end if
    11571156
    11581157              !update frequencies
    1159               if(ipres(j) > 0.and.itau(j) > 0) then
     1158              if(ipres(j) .gt. 0.and.itau(j) .gt. 0) then
    11601159              fq_isccp(j,itau(j),ipres(j))=
    11611160     &          fq_isccp(j,itau(j),ipres(j))+ boxarea
     
    11671166                       
    11681167        enddo ! j
    1169       END DO
     116839    continue
    11701169     
    11711170      !compute mean cloud properties
    11721171      do j=1,npoints
    1173         if (totalcldarea(j) > 0.) then
     1172        if (totalcldarea(j) .gt. 0.) then
    11741173          ! code above guarantees that totalcldarea > 0
    11751174          ! only if sunlit .eq. 1 .or. top_height = 3
     
    11941193!     OPTIONAL PRINTOUT OF DATA TO CHECK PROGRAM
    11951194!
    1196       if (debugcol/=0) then
     1195      if (debugcol.ne.0) then
    11971196!     
    11981197         do j=1,npoints,debugcol
     
    12081207              do ibox=1,ncol
    12091208                   acc(ilev,ibox)=frac_out(j,ibox,ilev)*2
    1210                    if (levmatch(j,ibox) == ilev)
     1209                   if (levmatch(j,ibox) .eq. ilev)
    12111210     &                 acc(ilev,ibox)=acc(ilev,ibox)+1
    12121211              enddo
     
    12281227     &           (cchar_realtops(acc(ilev,ibox)+1),ilev=1,nlev)
    12291228     &           ,(cchar(acc(ilev,ibox)+1),ilev=1,nlev)
    1230              END DO
     1229             end do
    12311230             close(9)
    12321231
    1233              if (ncolprint/=0) then
     1232             if (ncolprint.ne.0) then
    12341233               write(6,'(a1)') ' '
    12351234                    write(6,'(a2,1X,5(a7,1X),a50)')
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/lidar_simulator.F90

    r5093 r5095  
    247247!------------------------------------------------------------
    248248
    249       if ( npart /= 4 ) then
     249      if ( npart .ne. 4 ) then
    250250        print *,'Error in lidar_simulator, npart should be 4, not',npart
    251251        stop
     
    267267         polpart(INDX_LSLIQ,5) =  0.0626
    268268!*     LS Ice coefficients:
    269       if (ice_type==0) then
     269      if (ice_type.eq.0) then     
    270270         polpart(INDX_LSICE,1) = -1.0176e-8
    271271         polpart(INDX_LSICE,2) =  1.7615e-6
     
    275275      endif
    276276!*     LS Ice NS coefficients:
    277       if (ice_type==1) then
     277      if (ice_type.eq.1) then
    278278         polpart(INDX_LSICE,1) = 1.3615e-8
    279279         polpart(INDX_LSICE,2) = -2.04206e-6
     
    289289         polpart(INDX_CVLIQ,5) =  0.0626
    290290!*     CONV Ice coefficients:
    291       if (ice_type==0) then
     291      if (ice_type.eq.0) then
    292292         polpart(INDX_CVICE,1) = -1.0176e-8
    293293         polpart(INDX_CVICE,2) =  1.7615e-6
     
    296296         polpart(INDX_CVICE,5) =  0.0460
    297297      endif
    298       if (ice_type==1) then
     298      if (ice_type.eq.1) then
    299299         polpart(INDX_CVICE,1) = 1.3615e-8
    300300         polpart(INDX_CVICE,2) = -2.04206e-6
     
    342342! polynomes kp_lidar derived from Mie theory:
    343343      do i = 1, npart
    344        where ( rad_part(:,:,i)>0.0)
     344       where ( rad_part(:,:,i).gt.0.0)
    345345         kp_part(:,:,i) = &
    346346            polpart(i,1)*(rad_part(:,:,i)*1e6)**4 &
     
    362362! alpha of particles in each subcolumn:
    363363      do i = 1, npart
    364         where ( rad_part(:,:,i)>0.0)
     364        where ( rad_part(:,:,i).gt.0.0)
    365365          alpha_part(:,:,i) = 3.0/4.0 * Qscat &
    366366                 * rhoair(:,:) * qpart(:,:,i) &
     
    378378!     opt. thick of each layer
    379379      tau_mol(:,1:nlev) = alpha_mol(:,1:nlev) &
    380    *(zheight(:,2:nlev+1)-zheight(:,1:nlev))
     380         & *(zheight(:,2:nlev+1)-zheight(:,1:nlev))
    381381!     opt. thick from TOA
    382382      DO k = nlev-1, 1, -1
     
    390390!       opt. thick of each layer
    391391        tau_part(:,:,i) = tau_part(:,:,i) &
    392    * (zheight(:,2:nlev+1)-zheight(:,1:nlev) )
     392           & * (zheight(:,2:nlev+1)-zheight(:,1:nlev) )
    393393!       opt. thick from TOA
    394394        DO k = nlev-1, 1, -1
     
    400400!      Upper layer
    401401       pmol(:,nlev) = beta_mol(:,nlev) / (2.*tau_mol(:,nlev)) &
    402    * (1.-exp(-2.0*tau_mol(:,nlev)))
     402            & * (1.-exp(-2.0*tau_mol(:,nlev)))
    403403!      Other layers
    404404       DO k= nlev-1, 1, -1
    405405        tau_mol_lay(:) = tau_mol(:,k)-tau_mol(:,k+1) ! opt. thick. of layer k
    406         WHERE (tau_mol_lay(:)>0.)
     406        WHERE (tau_mol_lay(:).GT.0.)
    407407          pmol(:,k) = beta_mol(:,k) * EXP(-2.0*tau_mol(:,k+1)) / (2.*tau_mol_lay(:)) &
    408    * (1.-exp(-2.0*tau_mol_lay(:)))
     408            & * (1.-exp(-2.0*tau_mol_lay(:)))
    409409        ELSEWHERE
    410410!         This must never happend, but just in case, to avoid div. by 0
     
    429429!     Upper layer
    430430      pnorm(:,nlev) = betatot(:,nlev) / (2.*tautot(:,nlev)) &
    431    * (1.-exp(-2.0*tautot(:,nlev)))
     431            & * (1.-exp(-2.0*tautot(:,nlev)))
    432432
    433433!     Other layers
    434434      DO k= nlev-1, 1, -1
    435435          tautot_lay(:) = tautot(:,k)-tautot(:,k+1) ! optical thickness of layer k
    436         WHERE (tautot_lay(:)>0.)
     436        WHERE (tautot_lay(:).GT.0.)
    437437          pnorm(:,k) = betatot(:,k) * EXP(-2.0*tautot(:,k+1)) / (2.*tautot_lay(:)) &
    438    * (1.-EXP(-2.0*tautot_lay(:)))
     438               & * (1.-EXP(-2.0*tautot_lay(:)))
    439439        ELSEWHERE
    440440!         This must never happend, but just in case, to avoid div. by 0
     
    468468!     Upper layer
    469469      pnorm_ice(:,nlev) = betatot_ice(:,nlev) / (2.*tautot_ice(:,nlev)) &
    470    * (1.-exp(-2.0*tautot_ice(:,nlev)))
     470            & * (1.-exp(-2.0*tautot_ice(:,nlev)))
    471471
    472472      DO k= nlev-1, 1, -1
    473473          tautot_lay_ice(:) = tautot_ice(:,k)-tautot_ice(:,k+1)
    474         WHERE (tautot_lay_ice(:)>0.)
     474        WHERE (tautot_lay_ice(:).GT.0.)
    475475         pnorm_ice(:,k)=betatot_ice(:,k)*EXP(-2.0*tautot_ice(:,k+1))/(2.*tautot_lay_ice(:)) &
    476    * (1.-EXP(-2.0*tautot_lay_ice(:)))
     476               & * (1.-EXP(-2.0*tautot_lay_ice(:)))
    477477        ELSEWHERE
    478478         pnorm_ice(:,k)=betatot_ice(:,k)*EXP(-2.0*tautot_ice(:,k+1))
     
    483483!     Upper layer
    484484      pnorm_liq(:,nlev) = betatot_liq(:,nlev) / (2.*tautot_liq(:,nlev)) &
    485    * (1.-exp(-2.0*tautot_liq(:,nlev)))
     485            & * (1.-exp(-2.0*tautot_liq(:,nlev)))
    486486
    487487      DO k= nlev-1, 1, -1
    488488          tautot_lay_liq(:) = tautot_liq(:,k)-tautot_liq(:,k+1)
    489         WHERE (tautot_lay_liq(:)>0.)
     489        WHERE (tautot_lay_liq(:).GT.0.)
    490490          pnorm_liq(:,k)=betatot_liq(:,k)*EXP(-2.0*tautot_liq(:,k+1))/(2.*tautot_lay_liq(:)) &
    491    * (1.-EXP(-2.0*tautot_lay_liq(:)))
     491               & * (1.-EXP(-2.0*tautot_lay_liq(:)))
    492492        ELSEWHERE
    493493          pnorm_liq(:,k)=betatot_liq(:,k)*EXP(-2.0*tautot_liq(:,k+1))
     
    510510!     Upper layer
    511511      beta_perp_ice(:,nlev) = pnorm_perp_ice(:,nlev) * (2.*tautot_ice(:,nlev)) &
    512    / (1.-exp(-2.0*tautot_ice(:,nlev)))
     512            & / (1.-exp(-2.0*tautot_ice(:,nlev)))
    513513
    514514      DO k= nlev-1, 1, -1
    515515        tautot_lay_ice(:) = tautot_ice(:,k)-tautot_ice(:,k+1)
    516         WHERE (tautot_lay_ice(:)>0.)
     516        WHERE (tautot_lay_ice(:).GT.0.)
    517517         beta_perp_ice(:,k) = pnorm_perp_ice(:,k)/ EXP(-2.0*tautot_ice(:,k+1)) * (2.*tautot_lay_ice(:)) &
    518    / (1.-exp(-2.0*tautot_lay_ice(:)))
     518            & / (1.-exp(-2.0*tautot_lay_ice(:)))
    519519
    520520        ELSEWHERE
     
    526526!     Upper layer
    527527      beta_perp_liq(:,nlev) = pnorm_perp_liq(:,nlev) * (2.*tautot_liq(:,nlev)) &
    528    / (1.-exp(-2.0*tautot_liq(:,nlev)))
     528            & / (1.-exp(-2.0*tautot_liq(:,nlev)))
    529529
    530530      DO k= nlev-1, 1, -1
    531531          tautot_lay_liq(:) = tautot_liq(:,k)-tautot_liq(:,k+1)
    532         WHERE (tautot_lay_liq(:)>0.)
     532        WHERE (tautot_lay_liq(:).GT.0.)
    533533         beta_perp_liq(:,k) = pnorm_perp_liq(:,k)/ max(seuil,EXP(-2.0*tautot_liq(:,k+1))) &
    534    * (2.*tautot_lay_liq(:)) / (1.-exp(-2.0*tautot_lay_liq(:)))
     534            & * (2.*tautot_lay_liq(:)) / (1.-exp(-2.0*tautot_lay_liq(:)))
    535535
    536536        ELSEWHERE
     
    547547! Computation of the total perpendicular lidar signal (ATBperp for liq+ice)
    548548!     Upper layer
    549     WHERE(tautot(:,nlev)>0)
     549    WHERE(tautot(:,nlev).GT.0)
    550550          pnorm_perp_tot(:,nlev) = &
    551551              (beta_perp_ice(:,nlev)+beta_perp_liq(:,nlev)-(beta_mol(:,nlev)/(1+1/0.0284))) / (2.*tautot(:,nlev)) &
    552    * (1.-exp(-2.0*tautot(:,nlev)))
     552              & * (1.-exp(-2.0*tautot(:,nlev)))
    553553    ELSEWHERE
    554554    pnorm_perp_tot(:,nlev) = 0.
     
    563563          ! We remove one contribution using
    564564          ! Betaperp=beta_mol(:,k)/(1+1/0.0284)) [bodhaine et al. 1999] in the following equations:
    565             WHERE (pnorm(:,k)==0)
     565            WHERE (pnorm(:,k).eq.0)
    566566                  pnorm_perp_tot(:,k)=0.
    567567                  ELSEWHERE
    568                     WHERE (tautot_lay(:)>0.)
     568                    WHERE (tautot_lay(:).GT.0.)
    569569                      pnorm_perp_tot(:,k) = &
    570570                          (beta_perp_ice(:,k)+beta_perp_liq(:,k)-(beta_mol(:,k)/(1+1/0.0284))) * &
    571571                          EXP(-2.0*tautot(:,k+1)) / (2.*tautot_lay(:)) &
    572    * (1.-EXP(-2.0*tautot_lay(:)))
     572                          & * (1.-EXP(-2.0*tautot_lay(:)))
    573573                    ELSEWHERE
    574574          !         This must never happen, but just in case, to avoid div. by 0
     
    690690! Lum_norm=f(tetaS,tau_cloud) derived from adding-doubling calculations
    691691!        valid ONLY ABOVE OCEAN (albedo_sfce=5%)
    692 !        valid only in one viewing direction (theta_v=30°, phi_s-phi_v=320°)
     692!        valid only in one viewing direction (theta_v=30�, phi_s-phi_v=320�)
    693693!        based on adding-doubling radiative transfer computation
    694694!        for tau values (0 to 100) and for tetas values (0 to 80)
    695695!        for 2 scattering phase functions: liquid spherical, ice non spherical
    696696
    697     IF ( nrefl> ntetas ) THEN
     697    IF ( nrefl.GT. ntetas ) THEN
    698698        PRINT *,'Error in lidar_simulator, nrefl should be less then ',ntetas,' not',nrefl
    699699        STOP
     
    711711!
    712712! relative fraction of the opt. thick due to liquid or ice clouds
    713     WHERE (tautot_S(:) > 0.)
     713    WHERE (tautot_S(:) .GT. 0.)
    714714        frac_taucol_liq(:) = tautot_S_liq(:) / tautot_S(:)
    715715        frac_taucol_ice(:) = tautot_S_ice(:) / tautot_S(:)
     
    733733    DO it=1,ntetas
    734734      DO ny=1,nbtau-1
    735         WHERE (tautot_S(:)>=tau(ny).AND.tautot_S(:)<=tau(ny+1))
     735        WHERE (tautot_S(:).GE.tau(ny).AND.tautot_S(:).LE.tau(ny+1))
    736736            rlumA_mod(:,it) = aA(it,ny)*tautot_S(:) + bA(it,ny)
    737737            rlumB_mod(:,it) = aB(it,ny)*tautot_S(:) + bB(it,ny)
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/m_mrgrnk.F90

    r5081 r5095  
    3333         IRNGT (1) = 1
    3434         Return
     35      Case Default
     36         Continue
    3537      End Select
    3638!
     
    231233         IRNGT (1) = 1
    232234         Return
     235      Case Default
     236         Continue
    233237      End Select
    234238!
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/math_lib.F90

    r5086 r5095  
    3434
    3535! ----- INPUTS -----
    36   real(kind=8), intent(in) :: x
     36  real*8, intent(in) :: x
    3737 
    3838! ----- OUTPUTS -----
    39   real(kind=8) :: gamma
     39  real*8 :: gamma
    4040
    4141! ----- INTERNAL ----- 
    42   real(kind=8) :: pi,ga,z,r,gr
    43   real(kind=8) :: g(26)
     42  real*8 :: pi,ga,z,r,gr
     43  real*8 :: g(26)
    4444  integer :: k,m1,m
    4545       
     
    124124
    125125! ----- INPUTS ----- 
    126   real(kind=8), intent(in), dimension(:) :: f,s
     126  real*8, intent(in), dimension(:) :: f,s 
    127127  integer, intent(in) :: i1, i2
    128128
    129129! ---- OUTPUTS -----
    130   real(kind=8) :: path_integral
     130  real*8 :: path_integral 
    131131 
    132132! ----- INTERNAL -----   
    133   real(kind=8) :: sumo, deltah, val
    134   integer(kind=4) :: nelm, j
    135   integer(kind=4), dimension(i2-i1+1) :: idx
    136   real(kind=8), dimension(i2-i1+1) :: f_rev, s_rev
     133  real*8 :: sumo, deltah, val
     134  integer*4 :: nelm, j
     135  integer*4, dimension(i2-i1+1) :: idx
     136  real*8, dimension(i2-i1+1) :: f_rev, s_rev
    137137
    138138  nelm = i2-i1+1
     
    273273       exit
    274274    end if
    275   END DO
     275  end do
    276276 
    277277  if (lerror) then
     
    316316    end if
    317317    ilo = ilo + 1
    318   END DO
     318  end do
    319319
    320320  ilo = max ( 2, ilo )
     
    326326    end if
    327327    ihi = ihi - 1
    328   END DO
     328  end do
    329329 
    330330  ihi = min ( ihi, ntab - 1 )
     
    374374    syl = x2
    375375 
    376   END DO
     376  end do
    377377 
    378378  result = sum1 &
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_cosp.F90

    r5082 r5095  
    179179   minp = minval(gbx%psfc)
    180180   maxp = maxval(gbx%psfc)
    181    if (Npoints > 1) seed=int((gbx%psfc-minp)/(maxp-minp)*100000) + 1
     181   if (Npoints .gt. 1) seed=int((gbx%psfc-minp)/(maxp-minp)*100000) + 1
    182182   ! Below it's how it was done in the original implementation of the ISCCP simulator.
    183183   ! The one above is better for offline data, when you may have packed data
     
    414414                if (sgx%frac_out (j,i,Nlevels+1-k) == I_LSC) frac_ls(j,k)=frac_ls(j,k)+1.
    415415                if (sgx%frac_out (j,i,Nlevels+1-k) == I_CVC) frac_cv(j,k)=frac_cv(j,k)+1.
    416                 if (sgx%prec_frac(j,i,Nlevels+1-k) == 1) prec_ls(j,k)=prec_ls(j,k)+1.
    417                 if (sgx%prec_frac(j,i,Nlevels+1-k) == 2) prec_cv(j,k)=prec_cv(j,k)+1.
    418                 if (sgx%prec_frac(j,i,Nlevels+1-k) == 3) then
     416                if (sgx%prec_frac(j,i,Nlevels+1-k) .eq. 1) prec_ls(j,k)=prec_ls(j,k)+1.
     417                if (sgx%prec_frac(j,i,Nlevels+1-k) .eq. 2) prec_cv(j,k)=prec_cv(j,k)+1.
     418                if (sgx%prec_frac(j,i,Nlevels+1-k) .eq. 3) then
    419419                    prec_cv(j,k)=prec_cv(j,k)+1.
    420420                    prec_ls(j,k)=prec_ls(j,k)+1.
     
    501501            do j=1,Npoints
    502502                !--------- Clouds -------
    503                 if (frac_ls(j,k) /= 0.) then
     503                if (frac_ls(j,k) .ne. 0.) then
    504504                    sghydro%mr_hydro(j,:,k,I_LSCLIQ) = sghydro%mr_hydro(j,:,k,I_LSCLIQ)/frac_ls(j,k)
    505505                    sghydro%mr_hydro(j,:,k,I_LSCICE) = sghydro%mr_hydro(j,:,k,I_LSCICE)/frac_ls(j,k)
    506506                endif
    507                 if (frac_cv(j,k) /= 0.) then
     507                if (frac_cv(j,k) .ne. 0.) then
    508508                    sghydro%mr_hydro(j,:,k,I_CVCLIQ) = sghydro%mr_hydro(j,:,k,I_CVCLIQ)/frac_cv(j,k)
    509509                    sghydro%mr_hydro(j,:,k,I_CVCICE) = sghydro%mr_hydro(j,:,k,I_CVCICE)/frac_cv(j,k)
     
    511511                !--------- Precip -------
    512512                if (gbx%use_precipitation_fluxes) then
    513                     if (prec_ls(j,k) /= 0.) then
     513                    if (prec_ls(j,k) .ne. 0.) then
    514514                        gbx%rain_ls(j,k) = gbx%rain_ls(j,k)/prec_ls(j,k)
    515515                        gbx%snow_ls(j,k) = gbx%snow_ls(j,k)/prec_ls(j,k)
    516516                        gbx%grpl_ls(j,k) = gbx%grpl_ls(j,k)/prec_ls(j,k)
    517517                    endif
    518                     if (prec_cv(j,k) /= 0.) then
     518                    if (prec_cv(j,k) .ne. 0.) then
    519519                        gbx%rain_cv(j,k) = gbx%rain_cv(j,k)/prec_cv(j,k)
    520520                        gbx%snow_cv(j,k) = gbx%snow_cv(j,k)/prec_cv(j,k)
    521521                    endif
    522522                else
    523                     if (prec_ls(j,k) /= 0.) then
     523                    if (prec_ls(j,k) .ne. 0.) then
    524524                        sghydro%mr_hydro(j,:,k,I_LSRAIN) = sghydro%mr_hydro(j,:,k,I_LSRAIN)/prec_ls(j,k)
    525525                        sghydro%mr_hydro(j,:,k,I_LSSNOW) = sghydro%mr_hydro(j,:,k,I_LSSNOW)/prec_ls(j,k)
    526526                        sghydro%mr_hydro(j,:,k,I_LSGRPL) = sghydro%mr_hydro(j,:,k,I_LSGRPL)/prec_ls(j,k)
    527527                    endif
    528                     if (prec_cv(j,k) /= 0.) then
     528                    if (prec_cv(j,k) .ne. 0.) then
    529529                        sghydro%mr_hydro(j,:,k,I_CVRAIN) = sghydro%mr_hydro(j,:,k,I_CVRAIN)/prec_cv(j,k)
    530530                        sghydro%mr_hydro(j,:,k,I_CVSNOW) = sghydro%mr_hydro(j,:,k,I_CVSNOW)/prec_cv(j,k)
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_cosp_modis_simulator.F90

    r5086 r5095  
    176176              opticalThickness(i, j, k) = 0.   
    177177            end if
    178           END DO
    179         END DO
    180       END DO
     178          end do
     179        end do
     180      end do
    181181
    182182      !
     
    197197          do i = 1, nSunlit
    198198            if(subCols%frac_out(sunlit(i), j, k) == I_CVC) opticalThickness(i, j, k) = gridBox%dtau_c(sunlit(i), k)
    199           END DO
    200         END DO
    201       END DO
     199          end do
     200        end do
     201      end do
    202202
    203203      !
     
    220220                                retrievedPhase(i, :), retrievedCloudTopPressure(i, :),      &
    221221                                retrievedTau(i, :), retrievedSize(i, :))
    222      END DO
     222     end do
    223223     
    224224      ! DJS2015: Call L3 modis simulator used by cospv2.0
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_cosp_radar.F90

    r5082 r5095  
    5353
    5454        real undef
    55         real(kind=8), dimension(nprof,ngate), intent(in) :: hgt_matrix, p_matrix, &
     55        real*8, dimension(nprof,ngate), intent(in) :: hgt_matrix, p_matrix, &
    5656            t_matrix,rh_matrix
    57         real(kind=8), dimension(hp%nhclass,nprof,ngate), intent(in) :: hm_matrix
    58         real(kind=8), dimension(hp%nhclass,nprof,ngate), intent(inout) :: re_matrix
    59         real(kind=8), dimension(hp%nhclass,nprof,ngate), intent(inout) :: Np_matrix
     57        real*8, dimension(hp%nhclass,nprof,ngate), intent(in) :: hm_matrix
     58        real*8, dimension(hp%nhclass,nprof,ngate), intent(inout) :: re_matrix
     59        real*8, dimension(hp%nhclass,nprof,ngate), intent(inout) :: Np_matrix
    6060
    6161        ! ----- OUTPUTS -----
    62         real(kind=8), dimension(nprof,ngate), intent(out) :: Ze_non,Ze_ray, &
     62        real*8, dimension(nprof,ngate), intent(out) :: Ze_non,Ze_ray, &
    6363            g_to_vol,dBZe,a_to_vol
    6464        ! ----- OPTIONAL -----
    65         real(kind=8), optional, dimension(nprof,ngate) :: &
     65        real*8, optional, dimension(nprof,ngate) :: &
    6666            g_to_vol_in,g_to_vol_out
    6767     end subroutine radar_simulator
     
    8686  nsizes            ! num of discrete drop sizes
    8787
    88   real(kind=8), dimension(:,:), allocatable :: &
     88  real*8, dimension(:,:), allocatable :: &
    8989  g_to_vol ! integrated atten due to gases, r>v (dB)
    9090
    91   real(kind=8), dimension(:,:), allocatable :: &
     91  real*8, dimension(:,:), allocatable :: &
    9292  Ze_non, &         ! radar reflectivity withOUT attenuation (dBZ)
    9393  Ze_ray, &         ! Rayleigh reflectivity (dBZ)
     
    100100  rh_matrix                     !relative humidity (%)
    101101
    102   real(kind=8), dimension(:,:,:), allocatable :: &
     102  real*8, dimension(:,:,:), allocatable :: &
    103103  hm_matrix, &          ! hydrometeor mixing ratio (g kg^-1)
    104104  re_matrix, &          ! effective radius (microns).   Optional. 0 ==> use Np_matrix or defaults
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_cosp_types.F90

    r5082 r5095  
    11101110
    11111111
    1112     if(y%Nhydro/=N_HYDRO) then
     1112    if(y%Nhydro.ne.N_HYDRO) then
    11131113
    11141114        write(*,*) 'Number of hydrometeor input to subroutine', &
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_llnl_stats.F90

    r5082 r5095  
    119119       do j=Nlevels,1,-1 !top->surf
    120120        sc_ratio = beta_tot(pr,i,j)/beta_mol(pr,j)
    121         if ((sc_ratio <= s_att) .and. (flag_sat == 0)) flag_sat = j
    122         if (Ze_tot(pr,i,j) < -30.) then  !radar can't detect cloud
    123          if ( (sc_ratio > s_cld) .or. (flag_sat == j) ) then  !lidar sense cloud
     121        if ((sc_ratio .le. s_att) .and. (flag_sat .eq. 0)) flag_sat = j
     122        if (Ze_tot(pr,i,j) .lt. -30.) then  !radar can't detect cloud
     123         if ( (sc_ratio .gt. s_cld) .or. (flag_sat .eq. j) ) then  !lidar sense cloud
    124124            lidar_only_freq_cloud(pr,j)=lidar_only_freq_cloud(pr,j)+1. !top->surf
    125125            flag_cld=1
     
    129129        endif
    130130       enddo !levels
    131        if (flag_cld == 1) tcc(pr)=tcc(pr)+1.
     131       if (flag_cld .eq. 1) tcc(pr)=tcc(pr)+1.
    132132     enddo !columns
    133133   enddo !points
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_lmd_ipsl_stats.F90

    r5082 r5095  
    148148      do ic = 1, ncol
    149149        pnorm_c = pnorm(:,ic,:)
    150         where ((pnorm_c<xmax) .and. (pmol<xmax) .and. (pmol> 0.0 ))
     150        where ((pnorm_c.lt.xmax) .and. (pmol.lt.xmax) .and. (pmol.gt. 0.0 ))
    151151            x3d_c = pnorm_c/pmol
    152152        elsewhere
     
    247247! c 0- Initializations
    248248! c -------------------------------------------------------
    249       if ( Nbins < 6) return
     249      if ( Nbins .lt. 6) return
    250250
    251251      srbval(1) =  S_att
     
    275275               do i = 1, Npoints
    276276                  if (x(i,k,j) /= undef) then
    277                      if ((x(i,k,j)>srbval_ext(ib-1)).and.(x(i,k,j)<=srbval_ext(ib))) &
     277                     if ((x(i,k,j).gt.srbval_ext(ib-1)).and.(x(i,k,j).le.srbval_ext(ib))) &
    278278                          cfad(i,ib,j) = cfad(i,ib,j) + 1.0
    279279                  else
     
    285285      enddo
    286286
    287       where (cfad /= undef)  cfad = cfad / float(Ncolumns)
     287      where (cfad .ne. undef)  cfad = cfad / float(Ncolumns)
    288288
    289289! c -------------------------------------------------------
     
    373373! ---------------------------------------------------------------
    374374
    375       if ( Ncat /= 4 ) then
     375      if ( Ncat .ne. 4 ) then
    376376         print *,'Error in lmd_ipsl_stats.cosp_cldfrac, Ncat must be 4, not',Ncat
    377377         stop
     
    423423
    424424! cloud detection at subgrid-scale:
    425          where ( (x(:,:,k)>S_cld) .and. (x(:,:,k)/= undef) )
     425         where ( (x(:,:,k).gt.S_cld) .and. (x(:,:,k).ne. undef) )
    426426           cldy(:,:,k)=1.0
    427427         elsewhere
     
    430430
    431431! number of usefull sub-columns:
    432          where ( (x(:,:,k)>S_att) .and. (x(:,:,k)/= undef)  )
     432         where ( (x(:,:,k).gt.S_att) .and. (x(:,:,k).ne. undef)  )
    433433           srok(:,:,k)=1.0
    434434         elsewhere
     
    513513          ! Computation of the cloud fraction as a function of the temperature
    514514          ! instead of height, for ice,liquid and all clouds
    515           if(srok(ip,ic,k)>0.)then
     515          if(srok(ip,ic,k).gt.0.)then
    516516          do itemp=1,Ntemp
    517             if( (tmp(ip,k)>=tempmod(itemp)).and.(tmp(ip,k)<tempmod(itemp+1)) )then
     517            if( (tmp(ip,k).ge.tempmod(itemp)).and.(tmp(ip,k).lt.tempmod(itemp+1)) )then
    518518              lidarcldtempind(ip,itemp)=lidarcldtempind(ip,itemp)+1.
    519519            endif
     
    521521          endif
    522522
    523           if(cldy(ip,ic,k)==1.)then
     523          if(cldy(ip,ic,k).eq.1.)then
    524524          do itemp=1,Ntemp
    525             if( (tmp(ip,k)>=tempmod(itemp)).and.(tmp(ip,k)<tempmod(itemp+1)) )then
     525            if( (tmp(ip,k).ge.tempmod(itemp)).and.(tmp(ip,k).lt.tempmod(itemp+1)) )then
    526526              lidarcldtemp(ip,itemp,1)=lidarcldtemp(ip,itemp,1)+1.
    527527            endif
     
    532532          iz=1
    533533          p1 = pplay(ip,k)
    534           if ( p1>0. .and. p1<(440.*100.)) then ! high clouds
     534          if ( p1.gt.0. .and. p1.lt.(440.*100.)) then ! high clouds
    535535            iz=3
    536           else if(p1>=(440.*100.) .and. p1<(680.*100.)) then  ! mid clouds
     536          else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then  ! mid clouds
    537537            iz=2
    538538         endif
     
    554554! -- grid-box 3D cloud fraction
    555555
    556       where ( nsub(:,:)>0.0 )
     556      where ( nsub(:,:).gt.0.0 )
    557557         lidarcld(:,:) = lidarcld(:,:)/nsub(:,:)
    558558      elsewhere
     
    573573       enddo
    574574      enddo
    575       where ( nsublayer(:,:)>0.0 )
     575      where ( nsublayer(:,:).gt.0.0 )
    576576         cldlayer(:,:) = cldlayer(:,:)/nsublayer(:,:)
    577577      elsewhere
     
    593593
    594594! Avoid zero values
    595         if( (cldy(i,ncol,nlev)==1.) .and. (ATBperp(i,ncol,nlev)>0.) )then
     595        if( (cldy(i,ncol,nlev).eq.1.) .and. (ATBperp(i,ncol,nlev).gt.0.) )then
    596596! Computation of the ATBperp along the phase discrimination line
    597597           ATBperp_tmp = (ATB(i,ncol,nlev)**5)*alpha50 + (ATB(i,ncol,nlev)**4)*beta50 + &
     
    604604!____________________________________________________________________________________________________
    605605!
    606            if( (ATBperp(i,ncol,nlev)-ATBperp_tmp)>=0. )then   ! Ice clouds
     606           if( (ATBperp(i,ncol,nlev)-ATBperp_tmp).ge.0. )then   ! Ice clouds
    607607             ! ICE with temperature above 273,15°K = Liquid (false ice)
    608             if(tmp(i,nlev)>273.15)then                ! Temperature above 273,15 K
     608            if(tmp(i,nlev).gt.273.15)then                ! Temperature above 273,15 K
    609609              ! Liquid: False ice corrected by the temperature to Liquid
    610610               lidarcldphase(i,nlev,2)=lidarcldphase(i,nlev,2)+1.   ! false ice detection ==> added to Liquid
     
    613613                                                    ! to classify the phase cloud
    614614                   cldlayphase(i,ncol,4,2) = 1.                         ! tot cloud
    615                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     615                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    616616                   cldlayphase(i,ncol,3,2) = 1.
    617                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     617                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    618618                   cldlayphase(i,ncol,2,2) = 1.
    619619                else                                                    ! low cloud
     
    621621                endif
    622622                   cldlayphase(i,ncol,4,5) = 1.                         ! tot cloud
    623                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     623                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    624624                   cldlayphase(i,ncol,3,5) = 1.
    625                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     625                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    626626                   cldlayphase(i,ncol,2,5) = 1.
    627627                else                                                    ! low cloud
     
    634634              tmpi(i,ncol,nlev)=tmp(i,nlev)
    635635                   cldlayphase(i,ncol,4,1) = 1.                         ! tot cloud
    636                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     636                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    637637                   cldlayphase(i,ncol,3,1) = 1.
    638                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     638                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    639639                   cldlayphase(i,ncol,2,1) = 1.
    640640                else                                                    ! low cloud
     
    651651             else                                        ! Liquid clouds
    652652              ! Liquid with temperature above 231,15°K
    653             if(tmp(i,nlev)>231.15)then
     653            if(tmp(i,nlev).gt.231.15)then
    654654               lidarcldphase(i,nlev,2)=lidarcldphase(i,nlev,2)+1.
    655655               tmpl(i,ncol,nlev)=tmp(i,nlev)
    656656                   cldlayphase(i,ncol,4,2) = 1.                         ! tot cloud
    657                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     657                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    658658                   cldlayphase(i,ncol,3,2) = 1. 
    659                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     659                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    660660                   cldlayphase(i,ncol,2,2) = 1.
    661661                else                                                    ! low cloud
     
    670670                                                    ! to classify the phase cloud
    671671                   cldlayphase(i,ncol,4,4) = 1.                         ! tot cloud
    672                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     672                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    673673                   cldlayphase(i,ncol,3,4) = 1. 
    674                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     674                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    675675                   cldlayphase(i,ncol,2,4) = 1.
    676676                else                                                    ! low cloud
     
    678678                endif
    679679                   cldlayphase(i,ncol,4,1) = 1.                         ! tot cloud
    680                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     680                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    681681                   cldlayphase(i,ncol,3,1) = 1. 
    682                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     682                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    683683                   cldlayphase(i,ncol,2,1) = 1.
    684684                else                                                    ! low cloud
     
    702702         p1 = pplay(i,nlev)
    703703
    704         if( (cldy(i,ncol,nlev)==1.) .and. (ATBperp(i,ncol,nlev)>0.) )then
     704        if( (cldy(i,ncol,nlev).eq.1.) .and. (ATBperp(i,ncol,nlev).gt.0.) )then
    705705! Phase discrimination line : ATBperp = ATB^5*alpha50 + ATB^4*beta50 + ATB^3*gamma50 + ATB^2*delta50
    706706!                                  + ATB*epsilon50 + zeta50
     
    715715!
    716716            ! ICE with temperature above 273,15°K = Liquid (false ice)
    717           if( (ATBperp(i,ncol,nlev)-ATBperp_tmp)>=0. )then   ! Ice clouds
    718             if(tmp(i,nlev)>273.15)then
     717          if( (ATBperp(i,ncol,nlev)-ATBperp_tmp).ge.0. )then   ! Ice clouds
     718            if(tmp(i,nlev).gt.273.15)then
    719719               lidarcldphase(i,nlev,2)=lidarcldphase(i,nlev,2)+1.  ! false ice ==> liq
    720720               tmpl(i,ncol,nlev)=tmp(i,nlev)
     
    722722
    723723                   cldlayphase(i,ncol,4,2) = 1.                         ! tot cloud
    724                if ( p1>0. .and. p1<(440.*100.)) then              ! high cloud
     724               if ( p1.gt.0. .and. p1.lt.(440.*100.)) then              ! high cloud
    725725                   cldlayphase(i,ncol,3,2) = 1.
    726                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     726                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    727727                   cldlayphase(i,ncol,2,2) = 1.
    728728                else                                                    ! low cloud
     
    731731
    732732                   cldlayphase(i,ncol,4,5) = 1.                         ! tot cloud
    733                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     733                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    734734                   cldlayphase(i,ncol,3,5) = 1.
    735                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     735                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    736736                   cldlayphase(i,ncol,2,5) = 1.
    737737                else                                                    ! low cloud
     
    745745
    746746                   cldlayphase(i,ncol,4,1) = 1.                         ! tot cloud
    747                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     747                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    748748                   cldlayphase(i,ncol,3,1) = 1.
    749                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     749                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    750750                   cldlayphase(i,ncol,2,1) = 1.
    751751                else                                                    ! low cloud
     
    762762          else 
    763763             ! Liquid with temperature above 231,15°K
    764             if(tmp(i,nlev)>231.15)then
     764            if(tmp(i,nlev).gt.231.15)then
    765765               lidarcldphase(i,nlev,2)=lidarcldphase(i,nlev,2)+1.
    766766               tmpl(i,ncol,nlev)=tmp(i,nlev)
    767767
    768768                   cldlayphase(i,ncol,4,2) = 1.                         ! tot cloud
    769                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     769                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    770770                   cldlayphase(i,ncol,3,2) = 1. 
    771                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     771                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    772772                   cldlayphase(i,ncol,2,2) = 1.
    773773                else                                                    ! low cloud
     
    782782
    783783                   cldlayphase(i,ncol,4,4) = 1.                         ! tot cloud
    784                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     784                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    785785                   cldlayphase(i,ncol,3,4) = 1. 
    786                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     786                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    787787                   cldlayphase(i,ncol,2,4) = 1.
    788788                else                                                    ! low cloud
     
    791791
    792792                   cldlayphase(i,ncol,4,1) = 1.                         ! tot cloud
    793                 if ( p1>0. .and. p1<(440.*100.)) then             ! high cloud
     793                if ( p1.gt.0. .and. p1.lt.(440.*100.)) then             ! high cloud
    794794                   cldlayphase(i,ncol,3,1) = 1. 
    795                 else if(p1>=(440.*100.) .and. p1<(680.*100.)) then ! mid cloud
     795                else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then ! mid cloud
    796796                   cldlayphase(i,ncol,2,1) = 1.
    797797                else                                                    ! low cloud
     
    805805
    806806           ! Find the level of the highest cloud with SR>30
    807             if(x(i,ncol,nlev)>S_cld_att)then     ! SR > 30.
     807            if(x(i,ncol,nlev).gt.S_cld_att)then  ! SR > 30.
    808808                toplvlsat=nlev-1
    809809                goto 99
     
    821821!____________________________________________________________________________________________________
    822822!
    823 if(toplvlsat/=0)then
     823if(toplvlsat.ne.0)then         
    824824      do nlev=toplvlsat,1,-1
    825825         p1 = pplay(i,nlev)
    826         if(cldy(i,ncol,nlev)==1.)then
     826        if(cldy(i,ncol,nlev).eq.1.)then
    827827           lidarcldphase(i,nlev,3)=lidarcldphase(i,nlev,3)+1.
    828828           tmpu(i,ncol,nlev)=tmp(i,nlev)
    829829
    830830                   cldlayphase(i,ncol,4,3) = 1.                         ! tot cloud
    831           if ( p1>0. .and. p1<(440.*100.)) then              ! high cloud
     831          if ( p1.gt.0. .and. p1.lt.(440.*100.)) then              ! high cloud
    832832             cldlayphase(i,ncol,3,3) = 1.
    833           else if(p1>=(440.*100.) .and. p1<(680.*100.)) then  ! mid cloud
     833          else if(p1.ge.(440.*100.) .and. p1.lt.(680.*100.)) then  ! mid cloud
    834834             cldlayphase(i,ncol,2,3) = 1.
    835835          else                                                     ! low cloud
     
    857857! of the occurrences
    858858lidarcldphasetmp(:,:)=lidarcldphase(:,:,1)+lidarcldphase(:,:,2);
    859 WHERE (lidarcldphasetmp(:,:)> 0.)
     859WHERE (lidarcldphasetmp(:,:).gt. 0.)
    860860   lidarcldphase(:,:,6)=lidarcldphase(:,:,1)/lidarcldphasetmp(:,:)
    861861ELSEWHERE
     
    864864
    865865! Compute Phase 3D Cloud Fraction
    866      WHERE ( nsub(:,:)>0.0 )
     866     WHERE ( nsub(:,:).gt.0.0 )
    867867       lidarcldphase(:,:,1)=lidarcldphase(:,:,1)/nsub(:,:)
    868868       lidarcldphase(:,:,2)=lidarcldphase(:,:,2)/nsub(:,:)
     
    899899! Compute the Ice percentage in cloud = ice/(ice+liq)
    900900cldlayerphasetmp(:,:)=cldlayerphase(:,:,1)+cldlayerphase(:,:,2)
    901     WHERE (cldlayerphasetmp(:,:)> 0.)
     901    WHERE (cldlayerphasetmp(:,:).gt. 0.)
    902902       cldlayerphase(:,:,6)=cldlayerphase(:,:,1)/cldlayerphasetmp(:,:)
    903903    ELSEWHERE
     
    906906
    907907    do i=1,Nphase-1
    908       WHERE ( cldlayerphasesum(:,:)>0.0 )
     908      WHERE ( cldlayerphasesum(:,:).gt.0.0 )
    909909         cldlayerphase(:,:,i) = (cldlayerphase(:,:,i)/cldlayerphasesum(:,:)) * cldlayer(:,:)
    910910      ENDWHERE
     
    917917          checkcldlayerphase2=0.
    918918
    919           if (cldlayerphasesum(i,iz)>0.0 )then
     919          if (cldlayerphasesum(i,iz).gt.0.0 )then
    920920             do ic=1,Nphase-3
    921921                checkcldlayerphase=checkcldlayerphase+cldlayerphase(i,iz,ic) 
    922922             enddo
    923923             checkcldlayerphase2=cldlayer(i,iz)-checkcldlayerphase
    924              if( (checkcldlayerphase2>0.01).or.(checkcldlayerphase2<-0.01) ) print *, checkcldlayerphase,cldlayer(i,iz)
     924             if( (checkcldlayerphase2.gt.0.01).or.(checkcldlayerphase2.lt.-0.01) ) print *, checkcldlayerphase,cldlayer(i,iz)
    925925
    926926          endif
     
    930930
    931931    do i=1,Nphase-1
    932       WHERE ( nsublayer(:,:)==0.0 )
     932      WHERE ( nsublayer(:,:).eq.0.0 )
    933933         cldlayerphase(:,:,i) = undef
    934934      ENDWHERE
     
    942942do i=1,Npoints
    943943do itemp=1,Ntemp
    944 if(tmpi(i,ncol,nlev)>0.)then
    945       if( (tmpi(i,ncol,nlev)>=tempmod(itemp)).and.(tmpi(i,ncol,nlev)<tempmod(itemp+1)) )then
     944if(tmpi(i,ncol,nlev).gt.0.)then
     945      if( (tmpi(i,ncol,nlev).ge.tempmod(itemp)).and.(tmpi(i,ncol,nlev).lt.tempmod(itemp+1)) )then
    946946        lidarcldtemp(i,itemp,2)=lidarcldtemp(i,itemp,2)+1.
    947947      endif
    948 elseif(tmpl(i,ncol,nlev)>0.)then
    949       if( (tmpl(i,ncol,nlev)>=tempmod(itemp)).and.(tmpl(i,ncol,nlev)<tempmod(itemp+1)) )then
     948elseif(tmpl(i,ncol,nlev).gt.0.)then
     949      if( (tmpl(i,ncol,nlev).ge.tempmod(itemp)).and.(tmpl(i,ncol,nlev).lt.tempmod(itemp+1)) )then
    950950        lidarcldtemp(i,itemp,3)=lidarcldtemp(i,itemp,3)+1.
    951951      endif
    952 elseif(tmpu(i,ncol,nlev)>0.)then
    953       if( (tmpu(i,ncol,nlev)>=tempmod(itemp)).and.(tmpu(i,ncol,nlev)<tempmod(itemp+1)) )then
     952elseif(tmpu(i,ncol,nlev).gt.0.)then
     953      if( (tmpu(i,ncol,nlev).ge.tempmod(itemp)).and.(tmpu(i,ncol,nlev).lt.tempmod(itemp+1)) )then
    954954        lidarcldtemp(i,itemp,4)=lidarcldtemp(i,itemp,4)+1.
    955955      endif
     
    965965checktemp=lidarcldtemp(i,itemp,2)+lidarcldtemp(i,itemp,3)+lidarcldtemp(i,itemp,4)
    966966
    967         if(checktemp/=lidarcldtemp(i,itemp,1))then
     967        if(checktemp.NE.lidarcldtemp(i,itemp,1))then
    968968          print *, i,itemp
    969969          print *, lidarcldtemp(i,itemp,1:4)
     
    984984
    985985do i=1,4
    986   WHERE(lidarcldtempind(:,:)>0.)
     986  WHERE(lidarcldtempind(:,:).gt.0.)
    987987     lidarcldtemp(:,:,i) = lidarcldtemp(:,:,i)/lidarcldtempind(:,:)
    988988  ELSEWHERE
     
    10461046    do k=1,Nlevels
    10471047       ! Cloud detection at subgrid-scale:
    1048        where ( (x(:,:,k) > S_cld) .and. (x(:,:,k) /= undef) )
     1048       where ( (x(:,:,k) .gt. S_cld) .and. (x(:,:,k) .ne. undef) )
    10491049          cldy(:,:,k)=1.0
    10501050       elsewhere
     
    10521052       endwhere
    10531053       ! Fully attenuated layer detection at subgrid-scale:
    1054        where ( (x(:,:,k) > 0.0) .and. (x(:,:,k) < S_att_opaq) .and. (x(:,:,k) /= undef) )
     1054       where ( (x(:,:,k) .gt. 0.0) .and. (x(:,:,k) .lt. S_att_opaq) .and. (x(:,:,k) .ne. undef) )
    10551055          cldyopaq(:,:,k)=1.0
    10561056       elsewhere
     
    10591059
    10601060       ! Number of useful sub-column layers:
    1061        where ( (x(:,:,k) > S_att) .and. (x(:,:,k) /= undef) )
     1061       where ( (x(:,:,k) .gt. S_att) .and. (x(:,:,k) .ne. undef) )
    10621062          srok(:,:,k)=1.0
    10631063       elsewhere
     
    10651065       endwhere
    10661066       ! Number of useful sub-columns layers for z_opaque 3D fraction:
    1067        where ( (x(:,:,k) > 0.0) .and. (x(:,:,k) /= undef) )
     1067       where ( (x(:,:,k) .gt. 0.0) .and. (x(:,:,k) .ne. undef) )
    10681068          srokopaq(:,:,k)=1.0
    10691069       elsewhere
     
    10981098
    10991099     ! Declaring non-opaque cloudy profiles as thin cloud profiles
    1100            if ( (cldlay(ip,ic,4) == 1.0) .and. (cldlay(ip,ic,1) == 0.0) ) then
     1100           if ( (cldlay(ip,ic,4) .eq. 1.0) .and. (cldlay(ip,ic,1) .eq. 0.0) ) then
    11011101              cldlay(ip,ic,2)  =  1.0
    11021102           endif
     
    11051105
    11061106     ! Opaque cloud profiles
    1107            if ( cldlay(ip,ic,1) == 1.0 ) then
     1107           if ( cldlay(ip,ic,1) .eq. 1.0 ) then
    11081108              zopac = 0.0
    11091109              do k=2,Nlevels
    11101110     ! Declaring opaque cloud fraction and z_opaque altitude for 3D and 2D variables
    1111                  if ( (cldy(ip,ic,k) == 1.0) .and. (zopac == 0.0) ) then
     1111                 if ( (cldy(ip,ic,k) .eq. 1.0) .and. (zopac .eq. 0.0) ) then
    11121112                    lidarcldtype(ip,k-1,3) = lidarcldtype(ip,k-1,3) + 1.0
    11131113                    cldlay(ip,ic,3)        = vgrid_z(k-1) !z_opaque altitude
     
    11151115                    zopac = 1.0
    11161116                 endif
    1117                  if ( cldy(ip,ic,k) == 1.0 ) then
     1117                 if ( cldy(ip,ic,k) .eq. 1.0 ) then
    11181118                    lidarcldtype(ip,k,1)   = lidarcldtype(ip,k,1) + 1.0
    11191119                 endif
     
    11221122
    11231123     ! Thin cloud profiles
    1124            if ( cldlay(ip,ic,2) == 1.0 ) then
     1124           if ( cldlay(ip,ic,2) .eq. 1.0 ) then
    11251125              do k=1,Nlevels
    11261126     ! Declaring thin cloud fraction for 3D variable
    1127                  if ( cldy(ip,ic,k) == 1.0 ) then
     1127                 if ( cldy(ip,ic,k) .eq. 1.0 ) then
    11281128                    lidarcldtype(ip,k,2) = lidarcldtype(ip,k,2) + 1.0
    11291129                 endif
     
    11351135
    11361136    ! 3D cloud types fraction (opaque=1 and thin=2)
    1137     where ( nsub(:,:) > 0.0 )
     1137    where ( nsub(:,:) .gt. 0.0 )
    11381138       lidarcldtype(:,:,1) = lidarcldtype(:,:,1)/nsub(:,:)
    11391139       lidarcldtype(:,:,2) = lidarcldtype(:,:,2)/nsub(:,:)
     
    11431143    endwhere
    11441144    ! 3D z_opaque fraction (=3)
    1145     where ( nsubopaq(:,:) > 0.0 )
     1145    where ( nsubopaq(:,:) .gt. 0.0 )
    11461146       lidarcldtype(:,:,3) = lidarcldtype(:,:,3)/nsubopaq(:,:)
    11471147    elsewhere
     
    11521152    do ip = 1, Npoints
    11531153        do k = Nlevels-1, 1, -1
    1154            if ( lidarcldtype(ip,k,3) /= undef ) then
     1154           if ( lidarcldtype(ip,k,3) .ne. undef ) then
    11551155              lidarcldtype(ip,k,4) = lidarcldtype(ip,k+1,4) + lidarcldtype(ip,k,3)
    11561156           endif
    11571157        enddo
    11581158    enddo
    1159     where ( nsubopaq(:,:) == 0.0 )
     1159    where ( nsubopaq(:,:) .eq. 0.0 )
    11601160       lidarcldtype(:,:,4) = undef
    11611161    endwhere
     
    11691169       enddo
    11701170    enddo
    1171     where (nsublayer(:,:) > 0.0)
     1171    where (nsublayer(:,:) .gt. 0.0)
    11721172       cldtype(:,:) = cldtype(:,:)/nsublayer(:,:)
    11731173    elsewhere
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/mod_modis_sim.F90

    r5086 r5095  
    331331        retrievedTau(i) = R_UNDEF
    332332      end if
    333     END DO
     333    end do
    334334    where((retrievedSize(:) < 0.).and.(retrievedSize(:) /= R_UNDEF)) retrievedSize(:) = 1.0e-06*re_fill
    335335
     
    666666    do ij=2,nbin1+1
    667667       do ik=2,nbin2+1
    668           jointHist(ij-1,ik-1)=count(var1 >= bin1(ij-1) .and. var1 < bin1(ij) .and. &
    669                var2 >= bin2(ik-1) .and. var2 < bin2(ik))
     668          jointHist(ij-1,ik-1)=count(var1 .ge. bin1(ij-1) .and. var1 .lt. bin1(ij) .and. &
     669               var2 .ge. bin2(ik-1) .and. var2 .lt. bin2(ik))       
    670670       enddo
    671671    enddo
     
    802802        tauMask(:, :, i) = .false.
    803803      end where
    804     END DO
     804    end do
    805805
    806806    do i = 1, numPressureHistogramBins
     
    811811        pressureMask(:, :, i) = .false.
    812812      end where
    813     END DO
     813    end do
    814814   
    815815    do i = 1, numPressureHistogramBins
     
    817817        Optical_Thickness_vs_Cloud_Top_Pressure(:, j, i) = &
    818818          real(count(tauMask(:, :, j) .and. pressureMask(:, :, i), dim = 2)) / real(nSubcols)
    819       END DO
    820     END DO
     819      end do
     820    end do
    821821   
    822822  end subroutine modis_L3_simulator
     
    851851      end if
    852852      if(totalTau >= tauLimit) exit
    853     END DO
     853    end do
    854854    cloud_top_pressure = totalProduct/totalTau
    855855  end function cloud_top_pressure
     
    877877      end if
    878878      if(totalTau >= tauLimit) exit
    879     END DO
     879    end do
    880880    weight_by_extinction = totalProduct/totalTau
    881881  end function weight_by_extinction
     
    11141114    do i = 1, size(cloudIndicies)
    11151115      call two_stream(tau(cloudIndicies(i)), g(cloudIndicies(i)), w0(cloudIndicies(i)), Refl(i), Trans(i))
    1116     END DO
     1116    end do
    11171117                   
    11181118    call adding_doubling(Refl(:), Trans(:), Refl_tot, Trans_tot) 
     
    12921292          Refl_cumulative(i) = Refl_cumulative(i-1) + Refl(i)*(Tran_cumulative(i-1)**2)/(1 - Refl_cumulative(i-1) * Refl(i))
    12931293          Tran_cumulative(i) = (Tran_cumulative(i-1)*Tran(i)) / (1 - Refl_cumulative(i-1) * Refl(i))
    1294       END DO
     1294      end do
    12951295     
    12961296      Refl_tot = Refl_cumulative(size(Refl))
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/optics_lib.F90

    r5086 r5095  
    3838 
    3939! ----- INPUTS -----
    40   real(kind=8), intent(in) :: freq,tk
     40  real*8, intent(in) :: freq,tk
    4141 
    4242! ----- OUTPUTS -----
    43   real(kind=8), intent(out) :: n_r, n_i
     43  real*8, intent(out) :: n_r, n_i
    4444
    4545! ----- INTERNAL -----   
    46   real(kind=8) ld,es,ei,a,ls,sg,tm1,cos1,sin1
    47   real(kind=8) e_r,e_i
    48   real(kind=8) pi
    49   real(kind=8) tc
    50   complex(kind=8) e_comp, sq
     46  real*8 ld,es,ei,a,ls,sg,tm1,cos1,sin1
     47  real*8 e_r,e_i
     48  real*8 pi
     49  real*8 tc
     50  complex*16 e_comp, sq
    5151
    5252  tc = tk - 273.15
     
    102102
    103103! ----- INPUTS -----
    104   real(kind=8), intent(in) :: freq, t
     104  real*8, intent(in) :: freq, t
    105105 
    106106! ----- OUTPUTS ----- 
    107   real(kind=8), intent(out) :: n_r,n_i
     107  real*8, intent(out) :: n_r,n_i
    108108
    109109! Parameters:
    110   integer(kind=2) :: i,lt1,lt2,nwl,nwlt
     110  integer*2 :: i,lt1,lt2,nwl,nwlt
    111111  parameter(nwl=468,nwlt=62)
    112112
    113   real(kind=8) :: alam,cutice,pi,t1,t2,wlmax,wlmin, &
     113  real*8 :: alam,cutice,pi,t1,t2,wlmax,wlmin, &
    114114            x,x1,x2,y,y1,y2,ylo,yhi,tk
    115115
    116   real(kind=8) :: &
     116  real*8 :: &
    117117       tabim(nwl),tabimt(nwlt,4),tabre(nwl),tabret(nwlt,4),temref(4), &
    118118       wl(nwl),wlt(nwlt)
     
    519519
    520520!   // region from 0.045 microns to 167.0 microns - no temperature depend
     521    do i=2,nwl
     522      if(alam < wl(i)) continue
     523    enddo
    521524    x1=log(wl(i-1))
    522525    x2=log(wl(i))
     
    536539    if(tk > temref(1)) tk=temref(1)
    537540    if(tk < temref(4)) tk=temref(4)
    538     do i=2,4
    539       if(tk>=temref(i)) go to 12
    540     END DO
     541    do 11 i=2,4
     542      if(tk.ge.temref(i)) go to 12
     543    11 continue
    541544    12 lt1=i
    542545    lt2=i-1
    543     do i=2,nwlt
    544       if(alam<=wlt(i)) go to 14
    545     END DO
     546    do 13 i=2,nwlt
     547      if(alam.le.wlt(i)) go to 14
     548    13 continue
    546549    14 x1=log(wlt(i-1))
    547550    x2=log(wlt(i))
     
    583586      Subroutine MieInt(Dx, SCm, Inp, Dqv, Dqxt, Dqsc, Dbsc, Dg, Xs1, Xs2, DPh, Error)
    584587
    585       Integer (kind=2)  Imaxx
     588      Integer * 2  Imaxx
    586589      Parameter (Imaxx = 12000)
    587       Real (kind=4)     RIMax          ! largest real part of refractive index
     590      Real * 4     RIMax          ! largest real part of refractive index
    588591      Parameter (RIMax = 2.5)
    589       Real (kind=4)     IRIMax         ! largest imaginary part of refractive index
     592      Real * 4     IRIMax         ! largest imaginary part of refractive index
    590593      Parameter (IRIMax = -2)
    591       Integer (kind=2)  Itermax
     594      Integer * 2  Itermax
    592595      Parameter (Itermax = 12000 * 2.5)
    593596                                ! must be large enough to cope with the
    594597                                ! largest possible nmx = x * abs(scm) + 15
    595598                                ! or nmx =  Dx + 4.05*Dx**(1./3.) + 2.0
    596       Integer (kind=2)  Imaxnp
     599      Integer * 2  Imaxnp
    597600      Parameter (Imaxnp = 10000)  ! Change this as required
    598601!     INPUT
    599       Real (kind=8)     Dx
    600       Complex (kind=8)  SCm
    601       Integer (kind=4)  Inp
    602       Real (kind=8)     Dqv(Inp)
     602      Real * 8     Dx
     603      Complex * 16  SCm
     604      Integer * 4  Inp
     605      Real * 8     Dqv(Inp)
    603606!     OUTPUT
    604       Complex (kind=8)  Xs1(InP)
    605       Complex (kind=8)  Xs2(InP)
    606       Real (kind=8)     Dqxt
    607       Real (kind=8)     Dqsc
    608       Real (kind=8)     Dg
    609       Real (kind=8)     Dbsc
    610       Real (kind=8)     DPh(InP)
    611       Integer (kind=4)  Error
     607      Complex * 16  Xs1(InP)
     608      Complex * 16  Xs2(InP)
     609      Real * 8     Dqxt
     610      Real * 8     Dqsc
     611      Real * 8     Dg
     612      Real * 8     Dbsc
     613      Real * 8     DPh(InP)
     614      Integer * 4  Error
    612615!     LOCAL
    613       Integer (kind=2)  I
    614       Integer (kind=2)  NStop
    615       Integer (kind=2)  NmX
    616       Integer (kind=4)  N    ! N*N > 32767 ie N > 181
    617       Integer (kind=4)  Inp2
    618       Real (kind=8)     Chi,Chi0,Chi1
    619       Real (kind=8)     APsi,APsi0,APsi1
    620       Real (kind=8)     Pi0(Imaxnp)
    621       Real (kind=8)     Pi1(Imaxnp)
    622       Real (kind=8)     Taun(Imaxnp)
    623       Real (kind=8)     Psi,Psi0,Psi1
    624       Complex (kind=4)  Ir
    625       Complex (kind=8) Cm
    626       Complex (kind=8) A,ANM1,APB
    627       Complex (kind=8) B,BNM1,AMB
    628       Complex (kind=8) D(Itermax)
    629       Complex (kind=8) Sp(Imaxnp)
    630       Complex (kind=8) Sm(Imaxnp)
    631       Complex (kind=8) Xi,Xi0,Xi1
    632       Complex (kind=8) Y
     616      Integer * 2  I
     617      Integer * 2  NStop
     618      Integer * 2  NmX
     619      Integer * 4  N    ! N*N > 32767 ie N > 181
     620      Integer * 4  Inp2
     621      Real * 8     Chi,Chi0,Chi1
     622      Real * 8     APsi,APsi0,APsi1
     623      Real * 8     Pi0(Imaxnp)
     624      Real * 8     Pi1(Imaxnp)
     625      Real * 8     Taun(Imaxnp)
     626      Real * 8     Psi,Psi0,Psi1
     627      Complex * 8  Ir
     628      Complex * 16 Cm
     629      Complex * 16 A,ANM1,APB
     630      Complex * 16 B,BNM1,AMB
     631      Complex * 16 D(Itermax)
     632      Complex * 16 Sp(Imaxnp)
     633      Complex * 16 Sm(Imaxnp)
     634      Complex * 16 Xi,Xi0,Xi1
     635      Complex * 16 Y
    633636!     ACCELERATOR VARIABLES
    634       Integer (kind=2)  Tnp1
    635       Integer (kind=2)  Tnm1
    636       Real (kind=8)     Dn
    637       Real (kind=8)     Rnx
    638       Real (kind=8)     S(Imaxnp)
    639       Real (kind=8)     T(Imaxnp)
    640       Real (kind=8)     Turbo
    641       Real (kind=8)     A2
    642       Complex (kind=8) A1
     637      Integer * 2  Tnp1
     638      Integer * 2  Tnm1
     639      Real * 8     Dn
     640      Real * 8     Rnx
     641      Real * 8     S(Imaxnp)
     642      Real * 8     T(Imaxnp)
     643      Real * 8     Turbo
     644      Real * 8     A2
     645      Complex * 16 A1
    643646     
    644       If ((Dx>Imaxx) .Or. (InP>ImaxNP)) Then
     647      If ((Dx.Gt.Imaxx) .Or. (InP.Gt.ImaxNP)) Then
    645648        Error = 1
    646649        Return
     
    649652      Ir = 1 / Cm
    650653      Y =  Dx * Cm
    651       If (Dx<0.02) Then
     654      If (Dx.Lt.0.02) Then
    652655         NStop = 2
    653656      Else
    654          If (Dx<=8.0) Then
     657         If (Dx.Le.8.0) Then
    655658            NStop = Dx + 4.00*Dx**(1./3.) + 2.0
    656659         Else
    657             If (Dx< 4200.0) Then
     660            If (Dx.Lt. 4200.0) Then
    658661               NStop = Dx + 4.05*Dx**(1./3.) + 2.0
    659662            Else
     
    663666      End If
    664667      NmX = Max(Real(NStop),Real(Abs(Y))) + 15.
    665       If (Nmx > Itermax) then
     668      If (Nmx .gt. Itermax) then
    666669          Error = 1
    667670          Return
     
    706709         Dqxt = Tnp1 *      Dble(A + B)          + Dqxt
    707710         Dqsc = Tnp1 * (A*Conjg(A) + B*Conjg(B)) + Dqsc
    708          If (N>1) then
     711         If (N.Gt.1) then
    709712         Dg = Dg + (dN*dN - 1) * Dble(ANM1*Conjg(A) + BNM1 * Conjg(B)) / dN + TNM1 * Dble(ANM1*Conjg(BNM1)) / (dN*dN - dN)
    710713         End If
     
    714717         AMB = A2 * (A - B)
    715718         Do I = 1,Inp2
    716             If (I>Inp) Then
     719            If (I.GT.Inp) Then
    717720               S(I) = -Pi1(I)
    718721            Else
     
    733736         Xi1 = Dcmplx(APsi1,Chi1)
    734737      End Do
    735       If (Dg >0) Dg = 2 * Dg / Dqsc
     738      If (Dg .GT.0) Dg = 2 * Dg / Dqsc
    736739      Dqsc =  2 * Dqsc / Dx**2
    737740      Dqxt =  2 * Dqxt / Dx**2
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/pf_to_mr.F

    r5082 r5095  
    107107                mx_rain_cv(j,ibox,ilev)=0.
    108108                mx_snow_cv(j,ibox,ilev)=0.
    109                 if ((prec_frac(j,ibox,ilev) == 1.) .or.
    110      &              (prec_frac(j,ibox,ilev) == 3.)) then
     109                if ((prec_frac(j,ibox,ilev) .eq. 1.) .or.
     110     &              (prec_frac(j,ibox,ilev) .eq. 3.)) then
    111111                    mx_rain_ls(j,ibox,ilev)=
    112112     &                     (term4r_ls**(1./(1.+br/4.)))/rho
     
    116116     &                     (term4g_ls**(1./(1.+bg/4.)))/rho
    117117                endif
    118                 if ((prec_frac(j,ibox,ilev) == 2.) .or.
    119      &              (prec_frac(j,ibox,ilev) == 3.)) then
     118                if ((prec_frac(j,ibox,ilev) .eq. 2.) .or.
     119     &              (prec_frac(j,ibox,ilev) .eq. 3.)) then
    120120                    mx_rain_cv(j,ibox,ilev)=
    121121     &                     (term4r_cv**(1./(1.+br/4.)))/rho
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/phys_cosp.F90

    r5082 r5095  
    193193          cfg%Lrttov_sim,cfg%Lstats
    194194
    195     if (overlaplmdz/=overlap) then
     195    if (overlaplmdz.ne.overlap) then
    196196       print*,'Attention overlaplmdz different de overlap lu dans namelist '
    197197    endif
     
    201201
    202202!!! Ici on modifie les cles logiques pour les outputs selon les champs actives dans les .xml
    203   if ((itap>1).and.(first_write))then
     203  if ((itap.gt.1).and.(first_write))then
    204204   
    205205    IF (using_xios) call read_xiosfieldactive(cfg)
     
    268268
    269269        do ip = 1, Npoints
    270           if (fracTerLic(ip)>=0.5) then
     270          if (fracTerLic(ip).ge.0.5) then
    271271             gbx%land(ip) = 1.
    272272          else
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/prec_scops.F

    r5082 r5095  
    5555
    5656      cv_col = 0.05*ncol
    57       if (cv_col == 0) cv_col=1
     57      if (cv_col .eq. 0) cv_col=1
    5858 
    5959      do ilev=1,nlev
     
    7272        flag_cv=0
    7373        do ilev=1,nlev
    74           if (frac_out(j,ibox,ilev) == 1) then
     74          if (frac_out(j,ibox,ilev) .eq. 1) then
    7575            flag_ls=1
    7676          endif
    77           if (frac_out(j,ibox,ilev) == 2) then
     77          if (frac_out(j,ibox,ilev) .eq. 2) then
    7878            flag_cv=1
    7979          endif
    8080        enddo !loop over nlev
    81         if (flag_ls == 1) then
     81        if (flag_ls .eq. 1) then
    8282           frac_out_ls(j,ibox)=1
    8383        endif
    84         if (flag_cv == 1) then
     84        if (flag_cv .eq. 1) then
    8585           frac_out_cv(j,ibox)=1
    8686        endif
     
    9393        flag_cv=0
    9494   
    95         if (ls_p_rate(j,1) > 0.) then
     95        if (ls_p_rate(j,1) .gt. 0.) then
    9696            do ibox=1,ncol ! possibility ONE
    97                 if (frac_out(j,ibox,1) == 1) then
     97                if (frac_out(j,ibox,1) .eq. 1) then
    9898                    prec_frac(j,ibox,1) = 1
    9999                    flag_ls=1
    100100                endif
    101101            enddo ! loop over ncol
    102             if (flag_ls == 0) then ! possibility THREE
     102            if (flag_ls .eq. 0) then ! possibility THREE
    103103                do ibox=1,ncol
    104                     if (frac_out(j,ibox,2) == 1) then
     104                    if (frac_out(j,ibox,2) .eq. 1) then
    105105                        prec_frac(j,ibox,1) = 1
    106106                        flag_ls=1
     
    108108                enddo ! loop over ncol
    109109            endif
    110         if (flag_ls == 0) then ! possibility Four
    111         do ibox=1,ncol
    112         if (frac_out_ls(j,ibox) == 1) then
     110        if (flag_ls .eq. 0) then ! possibility Four
     111        do ibox=1,ncol
     112        if (frac_out_ls(j,ibox) .eq. 1) then
    113113            prec_frac(j,ibox,1) = 1
    114114            flag_ls=1
     
    116116        enddo ! loop over ncol
    117117        endif
    118         if (flag_ls == 0) then ! possibility Five
     118        if (flag_ls .eq. 0) then ! possibility Five
    119119        do ibox=1,ncol
    120120    !     prec_frac(j,1:ncol,1) = 1
     
    125125       ! There is large scale precipitation
    126126     
    127         if (cv_p_rate(j,1) > 0.) then
     127        if (cv_p_rate(j,1) .gt. 0.) then
    128128         do ibox=1,ncol ! possibility ONE
    129           if (frac_out(j,ibox,1) == 2) then
    130            if (prec_frac(j,ibox,1) == 0) then
     129          if (frac_out(j,ibox,1) .eq. 2) then
     130           if (prec_frac(j,ibox,1) .eq. 0) then
    131131        prec_frac(j,ibox,1) = 2
    132132       else
     
    136136      endif
    137137        enddo ! loop over ncol
    138         if (flag_cv == 0) then ! possibility THREE
    139         do ibox=1,ncol
    140         if (frac_out(j,ibox,2) == 2) then
    141                 if (prec_frac(j,ibox,1) == 0) then
     138        if (flag_cv .eq. 0) then ! possibility THREE
     139        do ibox=1,ncol
     140        if (frac_out(j,ibox,2) .eq. 2) then
     141                if (prec_frac(j,ibox,1) .eq. 0) then
    142142            prec_frac(j,ibox,1) = 2
    143143            else
     
    148148        enddo ! loop over ncol
    149149        endif
    150         if (flag_cv == 0) then ! possibility Four
    151         do ibox=1,ncol
    152         if (frac_out_cv(j,ibox) == 1) then
    153                 if (prec_frac(j,ibox,1) == 0) then
     150        if (flag_cv .eq. 0) then ! possibility Four
     151        do ibox=1,ncol
     152        if (frac_out_cv(j,ibox) .eq. 1) then
     153                if (prec_frac(j,ibox,1) .eq. 0) then
    154154            prec_frac(j,ibox,1) = 2
    155155            else
     
    160160        enddo ! loop over ncol
    161161        endif
    162         if (flag_cv == 0) then  ! possibility Five
     162        if (flag_cv .eq. 0) then  ! possibility Five
    163163        do ibox=1,cv_col
    164                 if (prec_frac(j,ibox,1) == 0) then
     164                if (prec_frac(j,ibox,1) .eq. 0) then
    165165            prec_frac(j,ibox,1) = 2
    166166            else
     
    183183        flag_cv=0
    184184   
    185         if (ls_p_rate(j,ilev) > 0.) then
     185        if (ls_p_rate(j,ilev) .gt. 0.) then
    186186         do ibox=1,ncol ! possibility ONE&TWO
    187           if ((frac_out(j,ibox,ilev) == 1) .or.
    188      &       ((prec_frac(j,ibox,ilev-1) == 1)
    189      &       .or. (prec_frac(j,ibox,ilev-1) == 3))) then
     187          if ((frac_out(j,ibox,ilev) .eq. 1) .or.
     188     &       ((prec_frac(j,ibox,ilev-1) .eq. 1)
     189     &       .or. (prec_frac(j,ibox,ilev-1) .eq. 3))) then
    190190           prec_frac(j,ibox,ilev) = 1
    191191           flag_ls=1
    192192          endif
    193193        enddo ! loop over ncol
    194         if ((flag_ls == 0) .and. (ilev < nlev)) then ! possibility THREE
    195         do ibox=1,ncol
    196         if (frac_out(j,ibox,ilev+1) == 1) then
     194        if ((flag_ls .eq. 0) .and. (ilev .lt. nlev)) then ! possibility THREE
     195        do ibox=1,ncol
     196        if (frac_out(j,ibox,ilev+1) .eq. 1) then
    197197            prec_frac(j,ibox,ilev) = 1
    198198            flag_ls=1
     
    200200        enddo ! loop over ncol
    201201        endif
    202         if (flag_ls == 0) then ! possibility Four
    203         do ibox=1,ncol
    204         if (frac_out_ls(j,ibox) == 1) then
     202        if (flag_ls .eq. 0) then ! possibility Four
     203        do ibox=1,ncol
     204        if (frac_out_ls(j,ibox) .eq. 1) then
    205205            prec_frac(j,ibox,ilev) = 1
    206206            flag_ls=1
     
    208208        enddo ! loop over ncol
    209209        endif
    210         if (flag_ls == 0) then ! possibility Five
     210        if (flag_ls .eq. 0) then ! possibility Five
    211211        do ibox=1,ncol
    212212!     prec_frac(j,1:ncol,ilev) = 1
     
    216216      endif ! There is large scale precipitation
    217217   
    218         if (cv_p_rate(j,ilev) > 0.) then
     218        if (cv_p_rate(j,ilev) .gt. 0.) then
    219219         do ibox=1,ncol ! possibility ONE&TWO
    220           if ((frac_out(j,ibox,ilev) == 2) .or.
    221      &       ((prec_frac(j,ibox,ilev-1) == 2)
    222      &       .or. (prec_frac(j,ibox,ilev-1) == 3))) then
    223             if (prec_frac(j,ibox,ilev) == 0) then
     220          if ((frac_out(j,ibox,ilev) .eq. 2) .or.
     221     &       ((prec_frac(j,ibox,ilev-1) .eq. 2)
     222     &       .or. (prec_frac(j,ibox,ilev-1) .eq. 3))) then
     223            if (prec_frac(j,ibox,ilev) .eq. 0) then
    224224         prec_frac(j,ibox,ilev) = 2
    225225        else
     
    229229        endif
    230230       enddo ! loop over ncol
    231         if ((flag_cv == 0) .and. (ilev < nlev)) then ! possibility THREE
    232         do ibox=1,ncol
    233         if (frac_out(j,ibox,ilev+1) == 2) then
    234                 if (prec_frac(j,ibox,ilev) == 0) then
     231        if ((flag_cv .eq. 0) .and. (ilev .lt. nlev)) then ! possibility THREE
     232        do ibox=1,ncol
     233        if (frac_out(j,ibox,ilev+1) .eq. 2) then
     234                if (prec_frac(j,ibox,ilev) .eq. 0) then
    235235            prec_frac(j,ibox,ilev) = 2
    236236            else
     
    241241        enddo ! loop over ncol
    242242        endif
    243         if (flag_cv == 0) then ! possibility Four
    244         do ibox=1,ncol
    245         if (frac_out_cv(j,ibox) == 1) then
    246                 if (prec_frac(j,ibox,ilev) == 0) then
     243        if (flag_cv .eq. 0) then ! possibility Four
     244        do ibox=1,ncol
     245        if (frac_out_cv(j,ibox) .eq. 1) then
     246                if (prec_frac(j,ibox,ilev) .eq. 0) then
    247247            prec_frac(j,ibox,ilev) = 2
    248248            else
     
    253253        enddo ! loop over ncol
    254254        endif
    255         if (flag_cv == 0) then  ! possibility Five
     255        if (flag_cv .eq. 0) then  ! possibility Five
    256256        do ibox=1,cv_col
    257                 if (prec_frac(j,ibox,ilev) == 0) then
     257                if (prec_frac(j,ibox,ilev) .eq. 0) then
    258258            prec_frac(j,ibox,ilev) = 2
    259259            else
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/predict_mom07.F90

    r5082 r5095  
    77            implicit none
    88       
    9             real(kind=8) :: a1,a2,a3,b1,b2,b3,c1,c2,c3
    10             real(kind=8) :: m2,tc,n,m,a_,b_,c_,A,B,C,n2
     9            real*8 :: a1,a2,a3,b1,b2,b3,c1,c2,c3
     10            real*8 :: m2,tc,n,m,a_,b_,c_,A,B,C,n2
    1111       
    1212            a1=      13.6078
     
    3030           
    3131        ! predict m from m2 and tc
    32                 if(m2/=-9999) then
     32                if(m2.ne.-9999) then
    3333                m=A*exp(B*tc)*m2**C
    3434                endif
    3535        ! get m2 if mass-dimension relationship not proportional to D**2
    36                 if(m2==-9999) then
     36                if(m2.eq.-9999) then
    3737                m2=(m/(A*exp(B*tc)))**(1.0/C)   
    3838                endif
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/radar_simulator.F90

    r5082 r5095  
    9191
    9292  real undef
    93   real(kind=8), dimension(nprof,ngate), intent(in) :: &
     93  real*8, dimension(nprof,ngate), intent(in) :: &
    9494    hgt_matrix, p_matrix,t_matrix,rh_matrix
    9595
    96   real(kind=8), dimension(hp%nhclass,nprof,ngate), intent(in) :: hm_matrix
    97   real(kind=8), dimension(hp%nhclass,nprof,ngate), intent(inout) :: re_matrix
    98   real(kind=8), dimension(hp%nhclass,nprof,ngate), intent(inout)    :: Np_matrix
     96  real*8, dimension(hp%nhclass,nprof,ngate), intent(in) :: hm_matrix
     97  real*8, dimension(hp%nhclass,nprof,ngate), intent(inout) :: re_matrix
     98  real*8, dimension(hp%nhclass,nprof,ngate), intent(inout)    :: Np_matrix
    9999
    100100! ----- OUTPUTS -----
    101   real(kind=8), dimension(nprof,ngate), intent(out) :: Ze_non,Ze_ray, &
     101  real*8, dimension(nprof,ngate), intent(out) :: Ze_non,Ze_ray, &
    102102       g_to_vol,dBZe,a_to_vol
    103103
    104104! ----- OPTIONAL -----
    105   real(kind=8), optional, dimension(nprof,ngate) :: &
     105  real*8, optional, dimension(nprof,ngate) :: &
    106106  g_to_vol_in,g_to_vol_out ! integrated atten due to gases, r>v (dB). This allows to output and then input
    107107                           ! the same gaseous absorption in different calls. Optional to allow compatibility
     
    112112
    113113  real, parameter :: one_third = 1.0/3.0
    114   real(kind=8) :: t_kelvin
     114  real*8 :: t_kelvin
    115115  integer :: &
    116116  phase, & ! 0=liquid, 1=ice
     
    118118
    119119  logical :: hydro      ! true=hydrometeor in vol, false=none
    120   real(kind=8) :: &
     120  real*8 :: &
    121121  rho_a, &   ! air density (kg m^-3)
    122122  gases      ! function: 2-way gas atten (dB/km)
    123123
    124   real(kind=8), dimension(:), allocatable :: &
     124  real*8, dimension(:), allocatable :: &
    125125  Di, Deq, &   ! discrete drop sizes (um)
    126126  Ni, &        ! discrete concentrations (cm^-3 um^-1)
    127127  rhoi         ! discrete densities (kg m^-3)
    128128
    129   real(kind=8), dimension(nprof, ngate) :: &
     129  real*8, dimension(nprof, ngate) :: &
    130130  z_vol, &      ! effective reflectivity factor (mm^6/m^3)
    131131  z_ray, &                      ! reflectivity factor, Rayleigh only (mm^6/m^3)
     
    135135
    136136  integer,parameter :: KR8 = selected_real_kind(15,300)
    137   real(kind=8), parameter :: xx = -1.0_KR8
    138   real(kind=8),  dimension(:), allocatable :: xxa
    139   real(kind=8) :: kr, ze, zr, pi, scale_factor, tc, Re, ld, tmp1, ze2, kr2, apm, bpm
    140   real(kind=8) :: half_a_atten_current,half_a_atten_above
    141   real(kind=8) :: half_g_atten_current,half_g_atten_above
    142   integer(kind=4) :: tp, i, j, k, pr, itt, iff
    143 
    144   real(kind=8)    step,base, Np
    145   integer(kind=4) iRe_type,n,max_bin
     137  real*8, parameter :: xx = -1.0_KR8
     138  real*8,  dimension(:), allocatable :: xxa
     139  real*8 :: kr, ze, zr, pi, scale_factor, tc, Re, ld, tmp1, ze2, kr2, apm, bpm
     140  real*8 :: half_a_atten_current,half_a_atten_above
     141  real*8 :: half_g_atten_current,half_g_atten_above
     142  integer*4 :: tp, i, j, k, pr, itt, iff
     143
     144  real*8    step,base, Np
     145  integer*4 iRe_type,n,max_bin
    146146
    147147  integer   start_gate,end_gate,d_gate
     
    207207            itt = infind(hp%mt_tti,t_kelvin)
    208208          endif
    209           if (re_matrix(tp,pr,k)==0) then
     209          if (re_matrix(tp,pr,k).eq.0) then
    210210            call calc_Re(hm_matrix(tp,pr,k),Np_matrix(tp,pr,k),rho_a, &
    211211              hp%dtype(tp),hp%dmin(tp),hp%dmax(tp),hp%apm(tp),hp%bpm(tp), &
     
    221221
    222222          iRe_type=1
    223           if(Re>0) then
     223          if(Re.gt.0) then
    224224            ! determine index in to scale LUT
    225225            !
     
    232232            base=hp%base_list(n+1)
    233233            iRe_type=Re/step
    234             if (iRe_type<1) iRe_type=1
     234            if (iRe_type.lt.1) iRe_type=1
    235235
    236236            Re=step*(iRe_type+0.5)      ! set value of Re to closest value allowed in LUT.
     
    238238
    239239            ! make sure iRe_type is within bounds
    240             if (iRe_type>=nRe_types) then
     240            if (iRe_type.ge.nRe_types) then
    241241!               write(*,*) 'Warning: size of Re exceed value permitted ', &
    242242!                    'in Look-Up Table (LUT).  Will calculate. '
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/radar_simulator_init.F90

    r5082 r5095  
    7474! ----- INTERNAL ----- 
    7575  integer :: i,j
    76   real(kind=8)  :: delt, deltp
     76  real*8  :: delt, deltp
    7777       
    7878    !
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/radar_simulator_types.F90

    r5082 r5095  
    1212  integer, parameter ::       &
    1313  nd = 85               ! number of discrete particles used in construction DSDs
    14   real(kind=8), parameter ::        &
     14  real*8, parameter ::        &
    1515  dmin = 0.1                 ,& ! min size of discrete particle
    1616  dmax = 10000.                 ! max size of discrete particle
     
    3636 
    3737    ! variables used to store hydrometeor "default" properties
    38     real(kind=8),  dimension(maxhclass) :: p1,p2,p3,dmin,dmax,apm,bpm,rho
     38    real*8,  dimension(maxhclass) :: p1,p2,p3,dmin,dmax,apm,bpm,rho
    3939    integer, dimension(maxhclass) :: dtype,col,cp,phase
    4040 
    4141    ! Radar properties
    42     real(kind=8)  :: freq,k2
     42    real*8  :: freq,k2
    4343    integer :: nhclass      ! number of hydrometeor classes in use
    4444    integer :: use_gas_abs, do_ray
     
    5656    logical, dimension(maxhclass,nRe_types) :: N_scale_flag
    5757    logical, dimension(maxhclass,mt_ntt,nRe_types) :: Z_scale_flag,Z_scale_added_flag
    58     real(kind=8),  dimension(maxhclass,mt_ntt,nRe_types) :: Ze_scaled,Zr_scaled,kr_scaled
    59     real(kind=8),  dimension(maxhclass,nd,nRe_types) :: fc, rho_eff
     58    real*8,  dimension(maxhclass,mt_ntt,nRe_types) :: Ze_scaled,Zr_scaled,kr_scaled
     59    real*8,  dimension(maxhclass,nd,nRe_types) :: fc, rho_eff
    6060
    6161    ! used to determine Re index
    62     real(kind=8)  :: step_list(Re_MAX_BIN),base_list(Re_MAX_BIN)
     62    real*8  :: step_list(Re_MAX_BIN),base_list(Re_MAX_BIN)
    6363 
    6464    ! used to determine temperature index
    65     real(kind=8) :: &
     65    real*8 :: &
    6666        mt_ttl(cnt_liq), &  ! liquid temperatures (K)
    6767        mt_tti(cnt_ice)     ! ice temperatures (K)
    6868
    69     real(kind=8) :: D(nd) ! set of discrete diameters used to represent DSDs
     69    real*8 :: D(nd) ! set of discrete diameters used to represent DSDs
    7070
    7171  end type class_param
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/scops.F

    r5086 r5095  
    133133      enddo
    134134
    135       if (ncolprint/=0) then
     135      if (ncolprint.ne.0) then
    136136        write (6,'(a)') 'frac_out_pp_rev:'
    137137          do j=1,npoints,1000
     
    145145        write (6,'(I3)') ncol
    146146      endif
    147       if (ncolprint/=0) then
     147      if (ncolprint.ne.0) then
    148148        write (6,'(a)') 'last_frac_pp:'
    149149          do j=1,npoints,1000
     
    161161     
    162162      !loop over vertical levels
    163       DO ilev = 1,nlev
     163      DO 200 ilev = 1,nlev
    164164                                 
    165165!     Initialise threshold
    166166
    167         IF (ilev==1) then
     167        IF (ilev.eq.1) then
    168168          ! If max overlap
    169           IF (overlap==1) then
     169          IF (overlap.eq.1) then
    170170            ! select pixels spread evenly
    171171            ! across the gridbox
     
    187187              enddo
    188188            ENDIF
    189             IF (ncolprint/=0) then
     189            IF (ncolprint.ne.0) then
    190190              write (6,'(a)') 'threshold_nsf2:'
    191191                do j=1,npoints,1000
     
    197197        ENDIF
    198198
    199         IF (ncolprint/=0) then
     199        IF (ncolprint.ne.0) then
    200200            write (6,'(a)') 'ilev:'
    201201            write (6,'(I2)') ilev
     
    206206          ! All versions
    207207          do j=1,npoints
    208             if (boxpos(j,ibox)<=conv(j,ilev)) then
     208            if (boxpos(j,ibox).le.conv(j,ilev)) then
    209209              maxocc(j,ibox) = 1
    210210            else
     
    214214
    215215          ! Max overlap
    216           if (overlap==1) then
     216          if (overlap.eq.1) then
    217217            do j=1,npoints
    218218              threshold_min(j,ibox)=conv(j,ilev)
     
    222222
    223223          ! Random overlap
    224           if (overlap==2) then
     224          if (overlap.eq.2) then
    225225            do j=1,npoints
    226226              threshold_min(j,ibox)=conv(j,ilev)
     
    230230
    231231          ! Max/Random overlap
    232           if (overlap==3) then
     232          if (overlap.eq.3) then
    233233            do j=1,npoints
    234234              threshold_min(j,ibox)=max(conv(j,ilev),
    235235     &          min(tca(j,ilev-1),tca(j,ilev)))
    236236              if (threshold(j,ibox)
    237      &          <min(tca(j,ilev-1),tca(j,ilev))
    238      &          .and.(threshold(j,ibox)>conv(j,ilev))) then
     237     &          .lt.min(tca(j,ilev-1),tca(j,ilev))
     238     &          .and.(threshold(j,ibox).gt.conv(j,ilev))) then
    239239                   maxosc(j,ibox)= 1
    240240              else
     
    276276           DO ibox=1,ncol
    277277             do j=1,npoints
    278                if (tca(j,ilev)>threshold(j,ibox)) then
     278               if (tca(j,ilev).gt.threshold(j,ibox)) then
    279279               frac_out(j,ibox,ilev)=1
    280280               else
     
    289289           DO ibox=1,ncol
    290290             do j=1,npoints
    291                 if (threshold(j,ibox)<=conv(j,ilev)) then
     291                if (threshold(j,ibox).le.conv(j,ilev)) then
    292292                    ! = 2 IF threshold le conv(j)
    293293                    frac_out(j,ibox,ilev) = 2
     
    302302!         from last level next time round
    303303
    304           if (ncolprint/=0) then
     304          if (ncolprint.ne.0) then
    305305
    306306            do j=1,npoints ,1000
     
    331331          endif
    332332
    333       END DO    !loop over nlev
     333200   CONTINUE    !loop over nlev
    334334
    335335
  • LMDZ6/branches/Amaury_dev/libf/phylmd/cosp/zeff.F90

    r5086 r5095  
    3535  integer, intent(in) :: ice, xr
    3636  integer, intent(in) :: nsizes
    37   real(kind=8), intent(in) :: freq,D(nsizes),N(nsizes),tt,qe(nsizes), &
     37  real*8, intent(in) :: freq,D(nsizes),N(nsizes),tt,qe(nsizes), &
    3838    qs(nsizes), rho_e(nsizes)
    39   real(kind=8), intent(inout) :: k2
     39  real*8, intent(inout) :: k2
    4040 
    4141! ----- OUTPUTS -----
    42   real(kind=8), intent(out) :: z_eff,z_ray,kr
     42  real*8, intent(out) :: z_eff,z_ray,kr
    4343   
    4444! ----- INTERNAL -----
    4545  integer :: &
    4646  correct_for_rho        ! correct for density flag
    47   real(kind=8), dimension(nsizes) :: &
     47  real*8, dimension(nsizes) :: &
    4848  D0, &                  ! D in (m)
    4949  N0, &                  ! N in m^-3 m^-1
     
    5353  rho_ice, &             ! bulk density ice (kg m^-3)
    5454  f                 ! ice fraction
    55   real(kind=8), dimension(nsizes) :: xtemp
    56   real(kind=8) :: &
     55  real*8, dimension(nsizes) :: xtemp
     56  real*8 :: &
    5757  wl, &                  ! wavelength (m)
    5858  cr                            ! kr(dB/km) = cr * kr(1/km)
    59   complex(kind=8) :: &
     59  complex*16 :: &
    6060  m                 ! complex index of refraction of bulk form
    61   complex(kind=8), dimension(nsizes) :: &
     61  complex*16, dimension(nsizes) :: &
    6262  m0                ! complex index of refraction
    6363 
    64   integer(kind=4) :: i,one
    65   real(kind=8) :: pi
    66   real(kind=8) :: eta_sum, eta_mie, const, z0_eff, z0_ray, k_sum, &
     64  integer*4 :: i,one
     65  real*8 :: pi
     66  real*8 :: eta_sum, eta_mie, const, z0_eff, z0_ray, k_sum, &
    6767            n_r, n_i, dqv(1), dqsc, dg, dph(1)
    68   integer(kind=4) :: err
    69   complex(kind=8) :: Xs1(1), Xs2(1)
     68  integer*4 :: err
     69  complex*16 :: Xs1(1), Xs2(1)
    7070
    7171  one=1
     
    113113      call mieint(sizep(i), m0(i), one, dqv, qext(i), dqsc, qbsca(i), &
    114114        dg, xs1, xs2, dph, err)
    115     END DO
     115    end do
    116116   
    117117  else
Note: See TracChangeset for help on using the changeset viewer.