module m_cloud ! use m_kinds use m_interp_NR, only : find_name implicit none ! private public :: clean_cloud public :: set_cloud public :: cloud ! integer, save :: ncloud integer, save :: k_iter integer, save :: prof_indexes(10) real(rkind3), allocatable, save :: cloud_table(:,:) ! ! This module has software for determining either (1) if an IR observation ! is cloud affected or (2) if a MW observation is unduely affected ! by the surface or by precipitation. ! ! For IR, the effect is determined by first determining a probability that ! the observation is cloud affected. That probability is defined by a ! piece-wise linear function of the cloud fraction. Separate probabilities ! are determined for high, medium, and low clouds, based on the corresponding ! cloud fractions (f). ! ! The probability function P(f) is defined by three parameters (a, b, c) ! a: if f <= a, then P(f)=0 (the scene is clear of this level cloud) ! c: if f >= c, then P(f)=1 (the scene is cloud contaminated) ! b defines 2 ranges: ! if a < f < b , P(f)= 0.5 * (f-a)/(b-a) ! if b < f < c , P(f)= 0.5 + 0.5*(f-b)/(c-b) ! ! A random number 0= cloud_table(3,i) ) then prob_cloud=one_k1 elseif (prof_2d(j) <= cloud_table(1,i) ) then prob_cloud=zero_k1 else d=prof_2d(j)-cloud_table(2,i) if (d >= zero_k1 ) then prob_cloud=0.5*(one_k3+d/(cloud_table(3,i)-cloud_table(2,i))) else prob_cloud=0.5*(one_k3+d/(cloud_table(2,i)-cloud_table(1,i))) endif endif call random_number(x) if (x < prob_cloud) then sigma=cloud_table(4,i) endif if (sigma /= one_k1) exit enddo ! pcldtop=sigma*prof_2d(prof_indexes(1)) ! ! Find the grid point index for the pressure level just above pcldtop by ! successively dividing the range it is in by factors of 2. lcldtop=1 k_below=nlevs if (pcldtop >= plevs(nlevs)) then lcldtop=nlevs else do i=1,k_iter j=(lcldtop+k_below)/2 if (pcldtop >= plevs(j)) then lcldtop=j else k_below=j endif enddo endif ! test if cloud top between surface and lowest level ! end subroutine cloud ! end module m_cloud