LCOV - code coverage report
Current view: | top level - chemistry/aerosol - cldaero_mod.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 41 | 42 | 97.6 %
Date: | 2024-12-17 22:39:59 |  | Functions: | 3 | 4 | 75.0 %

              Line data    Source code
           1             : !----------------------------------------------------------------------------------
           2             : ! low level utility module for cloud aerosols
           3             : !
           4             : ! Created by Francis Vitt
           5             : !----------------------------------------------------------------------------------
           6             : module cldaero_mod
           7             :
           8             :   use shr_kind_mod, only : r8 => shr_kind_r8
           9             :   use ppgrid,       only : pcols, pver
          10             :
          11             :   implicit none
          12             :   private
          13             :
          14             :   public :: cldaero_uptakerate
          15             :   public :: cldaero_conc_t
          16             :   public :: cldaero_allocate
          17             :   public :: cldaero_deallocate
          18             :
          19             :   type cldaero_conc_t
          20             :      real(r8), pointer :: so4c(:,:)
          21             :      real(r8), pointer :: nh4c(:,:)
          22             :      real(r8), pointer :: no3c(:,:)
          23             :      real(r8), pointer :: xlwc(:,:)
          24             :      real(r8) :: so4_fact
          25             :   end type cldaero_conc_t
          26             :
          27             : contains
          28             :
          29             : !----------------------------------------------------------------------------------
          30             : !----------------------------------------------------------------------------------
          31     1489176 :   function cldaero_allocate( ) result( cldconc )
          32             :     type(cldaero_conc_t), pointer:: cldconc
          33             :
          34     1489176 :     allocate( cldconc )
          35     1489176 :     allocate( cldconc%so4c(pcols,pver) )
          36     1489176 :     allocate( cldconc%nh4c(pcols,pver) )
          37     1489176 :     allocate( cldconc%no3c(pcols,pver) )
          38     1489176 :     allocate( cldconc%xlwc(pcols,pver) )
          39             :
          40  2355876432 :     cldconc%so4c(:,:) = 0._r8
          41  2355876432 :     cldconc%nh4c(:,:) = 0._r8
          42  2355876432 :     cldconc%no3c(:,:) = 0._r8
          43  2355876432 :     cldconc%xlwc(:,:) = 0._r8
          44     1489176 :     cldconc%so4_fact  = 2._r8
          45             :
          46     1489176 :   end function cldaero_allocate
          47             :
          48             : !----------------------------------------------------------------------------------
          49             : !----------------------------------------------------------------------------------
          50     1489176 :   subroutine cldaero_deallocate( cldconc )
          51             :     type(cldaero_conc_t), pointer :: cldconc
          52             :
          53     1489176 :     if ( associated(cldconc%so4c) ) then
          54     1489176 :        deallocate(cldconc%so4c)
          55     1489176 :        nullify(cldconc%so4c)
          56             :     endif
          57             :
          58     1489176 :     if ( associated(cldconc%nh4c) ) then
          59     1489176 :        deallocate(cldconc%nh4c)
          60     1489176 :        nullify(cldconc%nh4c)
          61             :     endif
          62             :
          63     1489176 :     if ( associated(cldconc%no3c) ) then
          64     1489176 :        deallocate(cldconc%no3c)
          65     1489176 :        nullify(cldconc%no3c)
          66             :     endif
          67             :
          68     1489176 :     if ( associated(cldconc%xlwc) ) then
          69     1489176 :        deallocate(cldconc%xlwc)
          70     1489176 :        nullify(cldconc%xlwc)
          71             :     endif
          72             :
          73     1489176 :     deallocate( cldconc )
          74             :     nullify( cldconc )
          75             :
          76     1489176 :   end subroutine cldaero_deallocate
          77             :
          78             : !----------------------------------------------------------------------------------
          79             : ! utility function for cloud-borne aerosols
          80             : !----------------------------------------------------------------------------------
          81             :
          82    83838975 :   function cldaero_uptakerate( xl, cldnum, cfact, cldfrc, tfld,  press ) result( uptkrate )
          83             :     use mo_constants, only : pi
          84             :
          85             :     real(r8), intent(in) :: xl, cldnum, cfact, cldfrc, tfld,  press
          86             :
          87             :     real(r8) :: uptkrate
          88             :
          89             :     real(r8) :: &
          90             :          rad_cd, radxnum_cd, num_cd, &
          91             :          gasdiffus, gasspeed, knudsen, &
          92             :          fuchs_sutugin, volx34pi_cd
          93             :
          94             : !-----------------------------------------------------------------------
          95             : ! compute uptake of h2so4 and msa to cloud water
          96             : !
          97             : ! first-order uptake rate is
          98             : ! 4*pi*(drop radius)*(drop number conc)
          99             : ! *(gas diffusivity)*(fuchs sutugin correction)
         100             :
         101             : ! num_cd = (drop number conc in 1/cm^3)
         102    83838975 :         num_cd = 1.0e-3_r8*cldnum*cfact/cldfrc
         103    83838975 :         num_cd = max( num_cd, 0.0_r8 )
         104             :
         105             : ! rad_cd = (drop radius in cm), computed from liquid water and drop number,
         106             : ! then bounded by 0.5 and 50.0 micrometers
         107             : ! radxnum_cd = (drop radius)*(drop number conc)
         108             : ! volx34pi_cd = (3/4*pi) * (liquid water volume in cm^3/cm^3)
         109             :
         110    83838975 :         volx34pi_cd = xl*0.75_r8/pi
         111             :
         112             : ! following holds because volx34pi_cd = num_cd*(rad_cd**3)
         113    83838975 :         radxnum_cd = (volx34pi_cd*num_cd*num_cd)**0.3333333_r8
         114             :
         115             : ! apply bounds to rad_cd to avoid the occasional unphysical value
         116    83838975 :         if (radxnum_cd .le. volx34pi_cd*4.0e4_r8) then
         117             :             radxnum_cd = volx34pi_cd*4.0e4_r8
         118             :             rad_cd = 50.0e-4_r8
         119    83836732 :         else if (radxnum_cd .ge. volx34pi_cd*4.0e8_r8) then
         120             :             radxnum_cd = volx34pi_cd*4.0e8_r8
         121             :             rad_cd = 0.5e-4_r8
         122             :         else
         123    83836732 :             rad_cd = radxnum_cd/num_cd
         124             :         end if
         125             :
         126             : ! gasdiffus = h2so4 gas diffusivity from mosaic code (cm^2/s)
         127             : ! (pmid must be Pa)
         128    83838975 :         gasdiffus = 0.557_r8 * (tfld**1.75_r8) / press
         129             :
         130             : ! gasspeed = h2so4 gas mean molecular speed from mosaic code (cm/s)
         131    83838975 :         gasspeed = 1.455e4_r8 * sqrt(tfld/98.0_r8)
         132             :
         133             : ! knudsen number
         134    83838975 :         knudsen = 3.0_r8*gasdiffus/(gasspeed*rad_cd)
         135             :
         136             : ! following assumes accomodation coefficient = 0.65
         137             : ! (Adams & Seinfeld, 2002, JGR, and references therein)
         138             : ! fuchs_sutugin = (0.75*accom*(1. + knudsen)) /
         139             : ! (knudsen*(1.0 + knudsen + 0.283*accom) + 0.75*accom)
         140             :         fuchs_sutugin = (0.4875_r8*(1._r8 + knudsen)) / &
         141    83838975 :                         (knudsen*(1.184_r8 + knudsen) + 0.4875_r8)
         142             :
         143             : ! instantaneous uptake rate
         144    83838975 :         uptkrate = 12.56637_r8*radxnum_cd*gasdiffus*fuchs_sutugin
         145             :
         146    83838975 :   end function cldaero_uptakerate
         147             :
         148           0 : end module cldaero_mod

Generated by: LCOV version 1.14