LCOV - code coverage report
Current view: | top level - physics/cam - microp_driver.F90 (source / functions) |  |  | Hit | Total | Coverage
Test: | coverage.info |  | Lines: | 25 | 42 | 59.5 %
Date: | 2024-12-17 22:39:59 |  | Functions: | 4 | 6 | 66.7 %

              Line data    Source code
           1             : module microp_driver
           2             :
           3             : !-------------------------------------------------------------------------------------------------------
           4             : !
           5             : ! Driver for CAM microphysics parameterizations
           6             : !
           7             : !-------------------------------------------------------------------------------------------------------
           8             :
           9             : use shr_kind_mod,   only: r8 => shr_kind_r8
          10             : use ppgrid,         only: pver
          11             : use physics_types,  only: physics_state, physics_ptend, physics_tend,  &
          12             :                           physics_ptend_copy, physics_ptend_sum
          13             : use physics_buffer, only: pbuf_get_index, pbuf_get_field, physics_buffer_desc
          14             : use phys_control,   only: phys_getopts
          15             :
          16             : use micro_pumas_cam,   only: micro_pumas_cam_readnl, micro_pumas_cam_register, &
          17             :                           micro_pumas_cam_implements_cnst, micro_pumas_cam_init_cnst, &
          18             :                           micro_pumas_cam_init, micro_pumas_cam_tend
          19             : use cam_logfile,    only: iulog
          20             : use cam_abortutils, only: endrun
          21             : use perf_mod,       only: t_startf, t_stopf
          22             :
          23             : implicit none
          24             : private
          25             : save
          26             :
          27             : public :: &
          28             :    microp_driver_readnl,          &
          29             :    microp_driver_register,        &
          30             :    microp_driver_init_cnst,       &
          31             :    microp_driver_implements_cnst, &
          32             :    microp_driver_init,            &
          33             :    microp_driver_tend
          34             :
          35             : character(len=16)  :: microp_scheme   ! Microphysics scheme
          36             :
          37             : !===============================================================================
          38             : contains
          39             : !===============================================================================
          40             :
          41        1536 : subroutine microp_driver_readnl(nlfile)
          42             :
          43             :    character(len=*), intent(in) :: nlfile  ! filepath for file containing namelist input
          44             :
          45             :    ! Read in namelist for microphysics scheme
          46             :    !-----------------------------------------------------------------------
          47             :
          48        1536 :    call phys_getopts(microp_scheme_out=microp_scheme)
          49             :
          50        1536 :    select case (microp_scheme)
          51             :    case ('MG')
          52        1536 :       call micro_pumas_cam_readnl(nlfile)
          53             :    case ('NONE', 'RK', 'SPCAM_sam1mom', 'SPCAM_m2005')
          54           0 :       continue
          55             :    case default
          56        1536 :       call endrun('microp_driver_readnl:: unrecognized microp_scheme, "'//trim(microp_scheme)//'"')
          57             :    end select
          58             :
          59        1536 : end subroutine microp_driver_readnl
          60             :
          61        1536 : subroutine microp_driver_register
          62             :
          63             :    ! Register microphysics constituents and fields in the physics buffer.
          64             :    !-----------------------------------------------------------------------
          65             :
          66             :
          67        1536 :    select case (microp_scheme)
          68             :    case ('MG')
          69        1536 :       call micro_pumas_cam_register()
          70             :    case ('RK')
          71             :       ! microp_driver doesn't handle this one
          72           0 :       continue
          73             :    case default
          74        1536 :       call endrun('microp_driver_register:: unrecognized microp_scheme')
          75             :    end select
          76             :
          77        1536 : end subroutine microp_driver_register
          78             :
          79             : !===============================================================================
          80             :
          81           0 : function microp_driver_implements_cnst(name)
          82             :
          83             :    ! Return true if specified constituent is implemented by the
          84             :    ! microphysics package
          85             :
          86             :    character(len=*), intent(in) :: name        ! constituent name
          87             :    logical :: microp_driver_implements_cnst    ! return value
          88             :
          89             :    ! Local workspace
          90             :    integer :: m
          91             :    !-----------------------------------------------------------------------
          92             :
          93           0 :    microp_driver_implements_cnst = .false.
          94             :
          95           0 :    select case (microp_scheme)
          96             :    case ('MG')
          97           0 :       microp_driver_implements_cnst = micro_pumas_cam_implements_cnst(name)
          98             :    case ('NONE', 'RK', 'SPCAM_sam1mom', 'SPCAM_m2005')
          99           0 :       continue
         100             :    case default
         101           0 :       call endrun('microp_driver_implements_cnst:: unrecognized microp_scheme, '//trim(microp_scheme))
         102             :    end select
         103             :
         104           0 : end function microp_driver_implements_cnst
         105             :
         106             : !===============================================================================
         107             :
         108           0 : subroutine microp_driver_init_cnst(name, latvals, lonvals, mask, q)
         109             :
         110             :    ! Initialize the microphysics constituents, if they are
         111             :    ! not read from the initial file.
         112             :
         113             :    character(len=*), intent(in)  :: name       ! constituent name
         114             :    real(r8),         intent(in)  :: latvals(:) ! lat in degrees (ncol)
         115             :    real(r8),         intent(in)  :: lonvals(:) ! lon in degrees (ncol)
         116             :    logical,          intent(in)  :: mask(:)    ! Only initialize where .true.
         117             :    real(r8),         intent(out) :: q(:,:)     ! kg tracer/kg dry air (gcol, plev
         118             :    !-----------------------------------------------------------------------
         119             :
         120           0 :    select case (microp_scheme)
         121             :    case ('MG')
         122           0 :       call micro_pumas_cam_init_cnst(name, latvals, lonvals, mask, q)
         123             :    case ('RK')
         124             :       ! microp_driver doesn't handle this one
         125             :       continue
         126             :    case ('SPCAM_m2005')
         127             :       ! microp_driver doesn't handle this one
         128             :       continue
         129             :    case ('SPCAM_sam1mom')
         130             :       ! microp_driver doesn't handle this one
         131           0 :       continue
         132             :    case default
         133           0 :       call endrun('microp_driver_init_cnst:: unrecognized microp_scheme'//trim(microp_scheme))
         134             :    end select
         135             :
         136           0 : end subroutine microp_driver_init_cnst
         137             :
         138             : !===============================================================================
         139             :
         140        1536 : subroutine microp_driver_init(pbuf2d)
         141             :
         142             :    type(physics_buffer_desc), pointer :: pbuf2d(:,:)
         143             :
         144             :    ! Initialize the microphysics parameterizations
         145             :    !-----------------------------------------------------------------------
         146             :
         147        1536 :    select case (microp_scheme)
         148             :    case ('MG')
         149        1536 :       call micro_pumas_cam_init(pbuf2d)
         150             :    case ('RK')
         151             :       ! microp_driver doesn't handle this one
         152           0 :       continue
         153             :    case default
         154        1536 :       call endrun('microp_driver_init:: unrecognized microp_scheme'//trim(microp_scheme))
         155             :    end select
         156             :
         157             :
         158        1536 : end subroutine microp_driver_init
         159             :
         160             : !===============================================================================
         161             :
         162   187636176 : subroutine microp_driver_tend(state, ptend, dtime, pbuf)
         163             :
         164             :    ! Call the microphysics parameterization run methods.
         165             :
         166             :    ! Input arguments
         167             :
         168             :    type(physics_state), intent(in)    :: state       ! State variables
         169             :    type(physics_ptend), intent(out)   :: ptend       ! Package tendencies
         170             :    type(physics_buffer_desc), pointer :: pbuf(:)
         171             :
         172             :    real(r8), intent(in)  :: dtime                    ! Timestep
         173             :
         174             :    ! Local variables
         175             :
         176             :    integer :: lchnk
         177             :    integer :: ncol
         178             :
         179             :    !======================================================================
         180             :
         181     4467528 :    lchnk = state%lchnk
         182     4467528 :    ncol  = state%ncol
         183             :
         184             :    ! Call MG Microphysics
         185             :
         186     4467528 :    select case (microp_scheme)
         187             :    case ('MG')
         188     4467528 :       call t_startf('microp_mg_tend')
         189     4467528 :       call micro_pumas_cam_tend(state, ptend, dtime, pbuf)
         190     4467528 :       call t_stopf('microp_mg_tend')
         191             :    case ('RK')
         192             :       ! microp_driver doesn't handle this one
         193           0 :       continue
         194             :    case default
         195     4467528 :       call endrun('microp_driver_tend:: unrecognized microp_scheme'//trim(microp_scheme))
         196             :    end select
         197             :
         198     4467528 : end subroutine microp_driver_tend
         199             :
         200             : end module microp_driver

Generated by: LCOV version 1.14