LCOV - code coverage report
Current view: top level - physics/cam - carma_flags_mod.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 106 111 95.5 %
Date: 2025-03-14 01:21:06 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !! This module handles reading the namelist and provides access to some other flags
       2             : !! that control CARMA's behavior.
       3             : !!
       4             : !! It needs to be in its own file to resolve some circular dependencies.
       5             : !!
       6             : !! @author  Chuck Bardeen
       7             : !! @version Aug-2010
       8             : module carma_flags_mod
       9             : 
      10             :   use shr_kind_mod,   only: r8 => shr_kind_r8
      11             :   use spmd_utils,     only: masterproc
      12             : 
      13             :   ! Flags for integration with CAM Microphysics
      14             : 
      15             :   implicit none
      16             :   public
      17             : 
      18             :   integer, parameter           :: carma_maxdiags = 100
      19             :   integer, protected           :: carma_ndiagpkgs  ! Number of diags_packages listed
      20             :   integer, protected           :: carma_ndebugpkgs  ! Number of diags_packages listed
      21             : 
      22             :   ! Namelist flags
      23             :   !
      24             :   ! NOTE: Setting the carma_flag to false prevents CARMA from doing any microphysics
      25             :   ! calculations, but it will still initialize itself. This allows the same build and
      26             :   ! namelist to be used, but the CARMA processing diabled. Use the configure option
      27             :   ! -carma none to totally disable CARMA and prevent even the register from happening.
      28             :   logical, protected           :: carma_flag        = .false.   ! If .true. then turn on CARMA microphysics in CAM
      29             :   logical, protected           :: carma_do_aerosol  = .true.    ! If .true. then CARMA is processed after surface coupling
      30             :   logical, protected           :: carma_do_coremasscheck = .false. ! If .true. then do coremasscheck and abort model after certain subroutines
      31             :   logical, protected           :: carma_do_cldice   = .false.   ! If .true. then do cloud ice
      32             :   logical, protected           :: carma_do_cldliq   = .false.   ! If .true. then do cloud liquid
      33             :   logical, protected           :: carma_do_clearsky = .false.   ! If .true. then do clear sky particle calculations
      34             :   logical, protected           :: carma_do_cloudborne = .false. ! If .true. then do then the carma groups can be cloudborne
      35             :   logical, protected           :: carma_do_coag     = .false.   ! If .true. then do coagulation
      36             :   logical, protected           :: carma_do_detrain  = .false.   ! If .true. then do detrain
      37             :   logical, protected           :: carma_do_drydep   = .false.   ! If .true. then do dry deposition
      38             :   logical, protected           :: carma_do_emission = .false.   ! If .true. then do emission
      39             :   logical, protected           :: carma_do_fixedinit= .false.   ! If .true. then do fixed initialization to a reference state
      40             :   logical, protected           :: carma_hetchem_feedback=.false.! If .true. then CARMA sulfate surface area density used in heterogeneous chemistry
      41             :   logical, protected           :: carma_rad_feedback= .false.   ! If .true. then CARMA sulfate mass mixing ratio & effective radius used in radiation
      42             :   logical, protected           :: carma_do_explised = .false.   ! If .true. then do sedimentation with substepping
      43             :   logical, protected           :: carma_do_incloud  = .false.   ! If .true. then do incloud particle calculations
      44             :   logical, protected           :: carma_do_budget_diags  = .false.   ! If .true. then do budget diagnostics
      45             :   logical, protected           :: carma_do_package_diags = .false.   ! If .true. then do package diagnostics
      46             :   logical, protected           :: carma_do_grow     = .false.   ! If .true. then do growth
      47             :   logical, protected           :: carma_do_optics   = .false.   ! If .true. then do optical properties file
      48             :   logical, protected           :: carma_do_partialinit= .false. ! If .true. then do initialization of coagulation to a reference state (requires fixedinit)
      49             :   logical, protected           :: carma_do_pheat    = .false.   ! If .true. then do particle heating
      50             :   logical, protected           :: carma_do_pheatatm = .false.   ! If .true. then do particle heating of atmosphere
      51             :   logical, protected           :: carma_do_substep  = .false.   ! If .true. then do substeping
      52             :   logical, protected           :: carma_do_thermo   = .false.   ! If .true. then do solve thermodynamics equation
      53             :   logical, protected           :: carma_do_wetdep   = .false.   ! If .true. then do wet deposition
      54             :   logical, protected           :: carma_do_vdiff    = .false.   ! If .true. then do vertical brownian diffusion
      55             :   logical, protected           :: carma_do_vtran    = .false.   ! If .true. then do vertical transport
      56             :   integer, protected           :: carma_diags_file  = 0         ! Default file for diagnostic output
      57             :   integer, protected           :: carma_maxsubsteps = 1         ! Maximum number of time substeps allowed
      58             :   integer, protected           :: carma_minsubsteps = 1         ! Minimum number of time substeps allowed
      59             :   integer, protected           :: carma_maxretries  = 8         ! Maximum number of time substeps allowed
      60             :   real(r8), protected          :: carma_conmax      = 0.1_r8    ! Minumum relative concentration to consider in substep
      61             :   real(r8), protected          :: carma_dgc_threshold  = 0.0_r8 ! When non-zero, the largest percentage change in gas concentration allowed per substep.
      62             :   real(r8), protected          :: carma_ds_threshold  = 0.0_r8  ! When non-zero, the largest percentage change in gas saturation allowed per substep.
      63             :   real(r8), protected          :: carma_dt_threshold  = 0.0_r8  ! When non-zero, the largest change in temperature (K) allowed per substep.
      64             :   real(r8), protected          :: carma_tstick      = 1.0_r8    ! Thermal accommodation coefficient
      65             :   real(r8), protected          :: carma_gsticki     = 0.93_r8   ! Growth accommodation coefficient for ice
      66             :   real(r8), protected          :: carma_gstickl     = 1.0_r8    ! Growth accommodation coefficient for liquid
      67             :   real(r8), protected          :: carma_cstick      = 1.0_r8    ! Coagulation accommodation coefficient
      68             :   real(r8), protected          :: carma_rhcrit      = 1.0_r8    ! Critical relative humidity for liquid clouds
      69             :   real(r8), protected          :: carma_vf_const    = 0.0_r8    ! If specified and non-zero, constant fall velocity for all particles [cm/s]
      70             :   character(len=32), protected :: carma_model       = "none"    ! String (no spaces) that identifies the model
      71             :   character(len=10), protected :: carma_sulfnuc_method = "none" ! Sulfate Nucleation method
      72             :   character(len=32), protected :: carma_diags_packages(carma_maxdiags) = " " ! Names of physics packages for which diagnostic output is desired
      73             :   character(len=12), protected :: carma_debug_packages(carma_maxdiags) = " " ! Names of physics packages for which debug output is desired
      74             : 
      75             : 
      76             : contains
      77             : 
      78             : 
      79             :   !! Read the CARMA runtime options from the namelist
      80             :   !!
      81             :   !! @author  Chuck Bardeen
      82             :   !! @version Aug-2010
      83        1536 :   subroutine carma_readnl(nlfile)
      84             : 
      85             :     ! Read carma namelist group.
      86             : 
      87             :     use cam_abortutils,  only: endrun
      88             :     use namelist_utils,  only: find_group_name
      89             :     use spmd_utils,      only: mpicom, masterprocid, mpi_real8, mpi_integer, mpi_logical, mpi_character, mpi_success
      90             :     use carma_model_flags_mod, only: carma_model_readnl
      91             : 
      92             :     ! args
      93             : 
      94             :     character(len=*), intent(in) :: nlfile  ! filepath for file containing namelist input
      95             : 
      96             :     ! local vars
      97             : 
      98             :     integer :: unitn, ierr, i
      99             :     character(len=*), parameter :: prefix = 'carma_readnl: '
     100             : 
     101             :     ! read namelist for CARMA
     102             :     namelist /carma_nl/ &
     103             :       carma_flag, &
     104             :       carma_do_aerosol, &
     105             :       carma_do_coremasscheck, &
     106             :       carma_do_cldliq, &
     107             :       carma_do_cldice, &
     108             :       carma_do_clearsky, &
     109             :       carma_do_cloudborne, &
     110             :       carma_do_coag, &
     111             :       carma_do_detrain, &
     112             :       carma_do_drydep, &
     113             :       carma_do_emission, &
     114             :       carma_do_fixedinit, &
     115             :       carma_hetchem_feedback, &
     116             :       carma_rad_feedback, &
     117             :       carma_do_explised, &
     118             :       carma_do_incloud, &
     119             :       carma_do_grow, &
     120             :       carma_do_optics, &
     121             :       carma_do_partialinit, &
     122             :       carma_do_pheat, &
     123             :       carma_do_pheatatm, &
     124             :       carma_do_substep, &
     125             :       carma_do_thermo, &
     126             :       carma_do_wetdep, &
     127             :       carma_do_vdiff, &
     128             :       carma_do_vtran, &
     129             :       carma_maxsubsteps, &
     130             :       carma_minsubsteps, &
     131             :       carma_maxretries, &
     132             :       carma_model, &
     133             :       carma_conmax, &
     134             :       carma_dgc_threshold, &
     135             :       carma_ds_threshold, &
     136             :       carma_dt_threshold, &
     137             :       carma_tstick, &
     138             :       carma_gsticki, &
     139             :       carma_gstickl, &
     140             :       carma_cstick, &
     141             :       carma_rhcrit, &
     142             :       carma_vf_const, &
     143             :       carma_sulfnuc_method, &
     144             :       carma_do_budget_diags, &
     145             :       carma_do_package_diags, &
     146             :       carma_diags_packages, &
     147             :       carma_debug_packages, &
     148             :       carma_diags_file
     149             : 
     150        1536 :     if (masterproc) then
     151           2 :        open( newunit=unitn, file=trim(nlfile), status='old' )
     152           2 :        call find_group_name(unitn, 'carma_nl', status=ierr)
     153           2 :        if (ierr == 0) then
     154           0 :           read(unitn, carma_nl, iostat=ierr)
     155           0 :           if (ierr /= 0) then
     156           0 :              call endrun(prefix//'ERROR reading namelist')
     157             :           end if
     158             :        end if
     159           2 :        close(unitn)
     160             :     end if
     161             : 
     162        1536 :     call mpi_bcast (carma_flag,            1 ,mpi_logical, masterprocid, mpicom, ierr)
     163        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_flag')
     164        1536 :     call mpi_bcast (carma_do_aerosol,      1 ,mpi_logical, masterprocid, mpicom, ierr)
     165        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_aerosol')
     166        1536 :     call mpi_bcast (carma_do_coremasscheck,1 ,mpi_logical, masterprocid, mpicom, ierr)
     167        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_coremasscheck')
     168        1536 :     call mpi_bcast (carma_do_cldliq,       1 ,mpi_logical, masterprocid, mpicom, ierr)
     169        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_cldliq')
     170        1536 :     call mpi_bcast (carma_do_cldice,       1 ,mpi_logical, masterprocid, mpicom, ierr)
     171        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_cldice')
     172        1536 :     call mpi_bcast (carma_do_clearsky,     1 ,mpi_logical, masterprocid, mpicom, ierr)
     173        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_clearsky')
     174        1536 :     call mpi_bcast (carma_do_cloudborne,   1 ,mpi_logical, masterprocid, mpicom, ierr)
     175        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_cloudborne')
     176        1536 :     call mpi_bcast (carma_do_coag,         1 ,mpi_logical, masterprocid, mpicom, ierr)
     177        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_coag')
     178        1536 :     call mpi_bcast (carma_do_detrain,      1 ,mpi_logical, masterprocid, mpicom, ierr)
     179        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_detrain')
     180        1536 :     call mpi_bcast (carma_do_drydep,       1 ,mpi_logical, masterprocid, mpicom, ierr)
     181        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_drydep')
     182        1536 :     call mpi_bcast (carma_do_emission,     1 ,mpi_logical, masterprocid, mpicom, ierr)
     183        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_emission')
     184        1536 :     call mpi_bcast (carma_do_fixedinit,    1 ,mpi_logical, masterprocid, mpicom, ierr)
     185        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_fixedinit')
     186        1536 :     call mpi_bcast (carma_hetchem_feedback,1 ,mpi_logical, masterprocid, mpicom, ierr)
     187        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_hetchem_feedback')
     188        1536 :     call mpi_bcast (carma_rad_feedback,    1 ,mpi_logical, masterprocid, mpicom, ierr)
     189        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_rad_feedback')
     190        1536 :     call mpi_bcast (carma_do_explised,     1 ,mpi_logical, masterprocid, mpicom, ierr)
     191        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_explised')
     192        1536 :     call mpi_bcast (carma_do_budget_diags, 1 ,mpi_logical, masterprocid, mpicom, ierr)
     193        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_budget_diags')
     194        1536 :     call mpi_bcast (carma_do_package_diags,1 ,mpi_logical, masterprocid, mpicom, ierr)
     195        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_package_diags')
     196        1536 :     call mpi_bcast (carma_do_incloud,      1 ,mpi_logical, masterprocid, mpicom, ierr)
     197        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_incloud')
     198        1536 :     call mpi_bcast (carma_do_grow,         1 ,mpi_logical, masterprocid, mpicom, ierr)
     199        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_grow')
     200        1536 :     call mpi_bcast (carma_do_optics,       1 ,mpi_logical, masterprocid, mpicom, ierr)
     201        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_optics')
     202        1536 :     call mpi_bcast (carma_do_partialinit,  1 ,mpi_logical, masterprocid, mpicom, ierr)
     203        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_partialinit')
     204        1536 :     call mpi_bcast (carma_do_pheat,        1 ,mpi_logical, masterprocid, mpicom, ierr)
     205        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_pheat')
     206        1536 :     call mpi_bcast (carma_do_pheatatm,     1 ,mpi_logical, masterprocid, mpicom, ierr)
     207        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_pheatatm')
     208        1536 :     call mpi_bcast (carma_do_substep,      1 ,mpi_logical, masterprocid, mpicom, ierr)
     209        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_substep')
     210        1536 :     call mpi_bcast (carma_do_thermo,       1 ,mpi_logical, masterprocid, mpicom, ierr)
     211        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_thermo')
     212        1536 :     call mpi_bcast (carma_do_wetdep,       1 ,mpi_logical, masterprocid, mpicom, ierr)
     213        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_wetdep')
     214        1536 :     call mpi_bcast (carma_do_vdiff,        1 ,mpi_logical, masterprocid, mpicom, ierr)
     215        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_vdiff')
     216        1536 :     call mpi_bcast (carma_do_vtran,        1 ,mpi_logical, masterprocid, mpicom, ierr)
     217        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_vtran')
     218        1536 :     call mpi_bcast (carma_diags_file,      1 ,mpi_integer, masterprocid, mpicom, ierr)
     219        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_diags_file')
     220        1536 :     call mpi_bcast (carma_maxsubsteps,     1 ,mpi_integer, masterprocid, mpicom, ierr)
     221        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_maxsubsteps')
     222        1536 :     call mpi_bcast (carma_minsubsteps,     1 ,mpi_integer, masterprocid, mpicom, ierr)
     223        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_minsubsteps')
     224        1536 :     call mpi_bcast (carma_maxretries,      1 ,mpi_integer, masterprocid, mpicom, ierr)
     225        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_maxretries')
     226        1536 :     call mpi_bcast (carma_conmax,          1 ,mpi_real8, masterprocid, mpicom, ierr)
     227        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_conmax')
     228        1536 :     call mpi_bcast (carma_dgc_threshold,   1 ,mpi_real8, masterprocid, mpicom, ierr)
     229        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_dgc_threshold')
     230        1536 :     call mpi_bcast (carma_ds_threshold,    1 ,mpi_real8, masterprocid, mpicom, ierr)
     231        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_ds_threshold')
     232        1536 :     call mpi_bcast (carma_dt_threshold,    1 ,mpi_real8, masterprocid, mpicom, ierr)
     233        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_dt_threshold')
     234        1536 :     call mpi_bcast (carma_tstick,          1 ,mpi_real8, masterprocid, mpicom, ierr)
     235        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_tstick')
     236        1536 :     call mpi_bcast (carma_gsticki,         1 ,mpi_real8, masterprocid, mpicom, ierr)
     237        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_gsticki')
     238        1536 :     call mpi_bcast (carma_gstickl,         1 ,mpi_real8, masterprocid, mpicom, ierr)
     239        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_gstickl')
     240        1536 :     call mpi_bcast (carma_cstick,          1 ,mpi_real8, masterprocid, mpicom, ierr)
     241        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_cstick')
     242        1536 :     call mpi_bcast (carma_rhcrit,          1 ,mpi_real8, masterprocid, mpicom, ierr)
     243        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_rhcrit')
     244        1536 :     call mpi_bcast (carma_vf_const,        1 ,mpi_real8, masterprocid, mpicom, ierr)
     245        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_vf_const')
     246        1536 :     call mpi_bcast (carma_model, len(carma_model), mpi_character, masterprocid, mpicom, ierr)
     247        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_model')
     248        1536 :     call mpi_bcast (carma_sulfnuc_method, len(carma_sulfnuc_method), mpi_character, masterprocid, mpicom, ierr)
     249        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_sulfnuc_method')
     250        1536 :     call mpibcast  (carma_diags_packages, len(carma_diags_packages(1))*carma_maxdiags, mpi_character, 0, mpicom)
     251        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_diags_packages')
     252        1536 :     call mpibcast  (carma_debug_packages, len(carma_debug_packages(1))*carma_maxdiags, mpi_character, 0, mpicom)
     253        1536 :     if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_debug_packages')
     254             : 
     255        1536 :     carma_ndiagpkgs = 0
     256      155136 :     do i = 1, carma_maxdiags
     257      155136 :        if (len_trim(carma_diags_packages(i)) > 0) then
     258           0 :           carma_ndiagpkgs = carma_ndiagpkgs + 1
     259             :        endif
     260             :     enddo
     261             : 
     262        1536 :     carma_ndebugpkgs = 0
     263      155136 :     do i = 1, carma_maxdiags
     264      155136 :        if (len_trim(carma_debug_packages(i)) > 0) then
     265           0 :           carma_ndebugpkgs = carma_ndebugpkgs + 1
     266             :        endif
     267             :     enddo
     268             : 
     269             :     ! Also cause the CARMA model flags to be read in.
     270        1536 :     call carma_model_readnl(nlfile)
     271             : 
     272        1536 :   end subroutine carma_readnl
     273             : 
     274             : end module carma_flags_mod

Generated by: LCOV version 1.14