LCOV - code coverage report
Current view: top level - physics/cam7 - stochastic_emulated_cam.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 62 0.0 %
Date: 2024-12-17 22:39:59 Functions: 0 2 0.0 %

          Line data    Source code
       1             : module stochastic_emulated_cam
       2             : ! From Morrison (Lebo, originally TAU bin code)
       3             : ! Gettelman and Chen 2018
       4             : !the subroutines take in air density, air temperature, and the bin mass boundaries, and 
       5             : !output the mass and number mixing ratio tendencies in each bin directly.
       6             : !this is then wrapped for CAM. 
       7             : 
       8             : use shr_kind_mod,      only: cl=>shr_kind_cl
       9             : use cam_history,       only: addfld
      10             : use cam_logfile,       only: iulog
      11             : use cam_abortutils,    only: endrun
      12             : 
      13             : implicit none
      14             : private
      15             : save
      16             : 
      17             : ! Subroutines
      18             : public :: stochastic_emulated_readnl
      19             : public :: stochastic_emulated_init_cam
      20             : 
      21             : !Module variables
      22             : integer, parameter, public  :: ncd = 35
      23             : integer, parameter, public  :: ncdp = ncd + 1
      24             : 
      25             : character(len=cl) :: stochastic_emulated_filename_quantile = " "
      26             : character(len=cl) :: stochastic_emulated_filename_input_scale = " "
      27             : character(len=cl) :: stochastic_emulated_filename_output_scale = " "
      28             : 
      29             : !===============================================================================
      30             : contains
      31             : !===============================================================================
      32             : 
      33           0 : subroutine stochastic_emulated_readnl(nlfile)
      34             : 
      35             :   use namelist_utils,  only: find_group_name
      36             :   use units,           only: getunit, freeunit
      37             :   use spmd_utils,      only: mpicom, mstrid=>masterprocid, mpi_character, masterproc
      38             :   use string_utils,    only: int2str
      39             : 
      40             :   character(len=*), intent(in) :: nlfile  ! filepath for file containing namelist input
      41             :   integer :: unitn, ierr
      42             :   character(len=*), parameter :: sub = 'stochastic_emulated_readnl'
      43             : 
      44             :   namelist /stochastic_emulated_nl/ stochastic_emulated_filename_quantile, stochastic_emulated_filename_input_scale, &
      45             :                                stochastic_emulated_filename_output_scale
      46             : 
      47           0 :   if (masterproc) then
      48           0 :      unitn = getunit()
      49           0 :      open( unitn, file=trim(nlfile), status='old' )
      50           0 :      call find_group_name(unitn, 'stochastic_emulated_nl', status=ierr)
      51           0 :      if (ierr == 0) then
      52           0 :         read(unitn, stochastic_emulated_nl, iostat=ierr)
      53           0 :         if (ierr /= 0) then
      54           0 :            call endrun(sub // ':: ERROR reading namelist, iostat = ' // int2str(ierr))
      55             :         end if
      56             :      end if
      57           0 :      close(unitn)
      58           0 :      call freeunit(unitn)
      59             :   end if
      60             : 
      61             :   ! Broadcast namelist variables
      62           0 :   call mpi_bcast(stochastic_emulated_filename_quantile, cl, mpi_character, mstrid, mpicom, ierr)
      63           0 :   if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_quantile")
      64             : 
      65           0 :   call mpi_bcast(stochastic_emulated_filename_input_scale, cl, mpi_character, mstrid, mpicom, ierr)
      66           0 :   if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_input_scale")
      67             : 
      68           0 :   call mpi_bcast(stochastic_emulated_filename_output_scale, cl, mpi_character, mstrid, mpicom, ierr)
      69           0 :   if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_output_scale")
      70             : 
      71           0 :   write(iulog,*) 'PUMAS stochastic_emulated_readnl, stochastic_emulated_filename_quantile=',&
      72           0 :                stochastic_emulated_filename_quantile
      73             : 
      74           0 : end subroutine stochastic_emulated_readnl
      75             : 
      76           0 : subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_out, &
      77           0 :                                        stochastic_emulated_filename_input_scale_out, &
      78           0 :                                        stochastic_emulated_filename_output_scale_out)
      79             : 
      80             :     use cam_history_support, only:          add_hist_coord
      81             : 
      82             :     character(len=cl),intent(out) :: stochastic_emulated_filename_quantile_out
      83             :     character(len=cl),intent(out) :: stochastic_emulated_filename_input_scale_out
      84             :     character(len=cl),intent(out) :: stochastic_emulated_filename_output_scale_out
      85             : 
      86           0 :     call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics')
      87             : 
      88           0 :     call addfld('amk_c',(/'trop_cld_lev','bins_ncd    '/),'A','kg','cloud liquid mass from bins')
      89           0 :     call addfld('ank_c',(/'trop_cld_lev','bins_ncd    '/),'A','1/kg','cloud liquid number concentration from bins')
      90           0 :     call addfld('amk_r',(/'trop_cld_lev','bins_ncd    '/),'A','kg','rain mass from bins')
      91           0 :     call addfld('ank_r',(/'trop_cld_lev','bins_ncd    '/),'A','1/kg','rain number concentration from bins')
      92           0 :     call addfld('amk',(/'trop_cld_lev','bins_ncd    '/),'A','kg','all liquid mass from bins')
      93           0 :     call addfld('ank',(/'trop_cld_lev','bins_ncd    '/),'A','1/kg','all liquid number concentration from bins')
      94           0 :     call addfld('amk_out',(/'trop_cld_lev','bins_ncd    '/),'A','kg','all liquid mass from bins')
      95           0 :     call addfld('ank_out',(/'trop_cld_lev','bins_ncd    '/),'A','1/kg','all liquid number concentration from bins')
      96             : 
      97           0 :     call addfld('scale_nc',(/'trop_cld_lev'/),'A','1','scaling factor for nc') 
      98           0 :     call addfld('scale_nr',(/'trop_cld_lev'/),'A','1','scaling factor for nr') 
      99           0 :     call addfld('scale_qc',(/'trop_cld_lev'/),'A','1','scaling factor for qc') 
     100           0 :     call addfld('scale_qr',(/'trop_cld_lev'/),'A','1','scaling factor for qr')
     101             :  
     102           0 :     call addfld('QC_TAU_in',(/'trop_cld_lev'/),'A','kg/kg','qc in TAU')
     103           0 :     call addfld('NC_TAU_in',(/'trop_cld_lev'/),'A','1/kg','nc in TAU')
     104           0 :     call addfld('QR_TAU_in',(/'trop_cld_lev'/),'A','kg/kg','qr in TAU')
     105           0 :     call addfld('NR_TAU_in',(/'trop_cld_lev'/),'A','1/kg','nr in TAU')
     106           0 :     call addfld('QC_TAU_out',(/'trop_cld_lev'/),'A','kg/kg','qc out TAU')
     107           0 :     call addfld('NC_TAU_out',(/'trop_cld_lev'/),'A','1/kg','nc out TAU')
     108           0 :     call addfld('QR_TAU_out',(/'trop_cld_lev'/),'A','kg/kg','qr out TAU')
     109           0 :     call addfld('NR_TAU_out',(/'trop_cld_lev'/),'A','1/kg','nr out TAU')  
     110             :  
     111           0 :     call addfld('qctend_TAU',(/'trop_cld_lev'/),'A','kg/kg/s','qc tendency due to TAU bin code') 
     112           0 :     call addfld('nctend_TAU',(/'trop_cld_lev'/),'A','1/kg/s','nc tendency due to TAU bin code')
     113           0 :     call addfld('qrtend_TAU',(/'trop_cld_lev'/),'A','kg/kg/s','qr tendency due to TAU bin code') 
     114           0 :     call addfld('nrtend_TAU',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code')
     115           0 :     call addfld('qctend_TAU_diag',(/'trop_cld_lev'/),'A','kg/kg/s','qc tendency due to TAU bin code')
     116           0 :     call addfld('nctend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nc tendency due to TAU bin code')
     117           0 :     call addfld('qrtend_TAU_diag',(/'trop_cld_lev'/),'A','kg/kg/s','qr tendency due to TAU bin code')
     118           0 :     call addfld('nrtend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code')
     119             : 
     120           0 :     call addfld('gmnnn_lmnnn_TAU',(/'trop_cld_lev'/),'A','1','sum of mass gain and loss from bin code')
     121           0 :     call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency that ML fixer is activated')
     122           0 :     call addfld('qc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qc due to ML fixer')
     123           0 :     call addfld('nc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nc due to ML fixer')
     124           0 :     call addfld('qr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qr due to ML fixer')
     125           0 :     call addfld('nr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nr due to ML fixer')
     126             : 
     127           0 :     stochastic_emulated_filename_quantile_out     = stochastic_emulated_filename_quantile
     128           0 :     stochastic_emulated_filename_input_scale_out  = stochastic_emulated_filename_input_scale
     129           0 :     stochastic_emulated_filename_output_scale_out = stochastic_emulated_filename_output_scale
     130             : 
     131           0 : end subroutine stochastic_emulated_init_cam
     132             : end module stochastic_emulated_cam
     133             : 
     134             : 

Generated by: LCOV version 1.14