Skip to content

Commit

Permalink
code review changes
Browse files Browse the repository at this point in the history
	modified:   bld/namelist_files/namelist_definition.xml
	modified:   src/physics/cam/carma_flags_mod.F90
	modified:   src/physics/carma/cam/carma_intr.F90
  • Loading branch information
fvitt committed Jan 3, 2025
1 parent ea7b248 commit 189151b
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 17 deletions.
5 changes: 4 additions & 1 deletion bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4480,7 +4480,10 @@ Default: none
group="carma_nl" valid_values="ZhaoTurco,Vehkamaki" >
Nucleation methods:
ZhaoTurco
Zhao and Turco, JAS, V.26, No.5, 1995.
Zhao, J. and Turco, R.,
Nucleation simulations in the wake of a jet aircraft in stratospheric flight,
J. Aerosol Sci., 26, 779-795, 1995,
https://doi.org/10.1016/0021-8502(95)00010-A
Vehkamaki
Vehkamaki, H., M. Kulmala, I. Napari, K.E.J. Lehtinen,
C. Timmreck, M. Noppel and A. Laaksonen, 2002,
Expand Down
51 changes: 49 additions & 2 deletions src/physics/cam/carma_flags_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ subroutine carma_readnl(nlfile)

use cam_abortutils, only: endrun
use namelist_utils, only: find_group_name
use spmd_utils, only: mpicom, masterprocid, mpi_real8, mpi_integer, mpi_logical, mpi_character
use spmd_utils, only: mpicom, masterprocid, mpi_real8, mpi_integer, mpi_logical, mpi_character, mpi_success
use carma_model_flags_mod, only: carma_model_readnl

! args
Expand All @@ -96,6 +96,7 @@ subroutine carma_readnl(nlfile)
! local vars

integer :: unitn, ierr, i
character(len=*), parameter :: prefix = 'carma_readnl: '

! read namelist for CARMA
namelist /carma_nl/ &
Expand Down Expand Up @@ -152,58 +153,104 @@ subroutine carma_readnl(nlfile)
if (ierr == 0) then
read(unitn, carma_nl, iostat=ierr)
if (ierr /= 0) then
call endrun('carma_readnl: ERROR reading namelist')
call endrun(prefix//'ERROR reading namelist')
end if
end if
close(unitn)
end if

call mpi_bcast (carma_flag, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_flag')
call mpi_bcast (carma_do_aerosol, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_aerosol')
call mpi_bcast (carma_do_coremasscheck,1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_coremasscheck')
call mpi_bcast (carma_do_cldliq, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_cldliq')
call mpi_bcast (carma_do_cldice, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_cldice')
call mpi_bcast (carma_do_clearsky, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_clearsky')
call mpi_bcast (carma_do_cloudborne, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_cloudborne')
call mpi_bcast (carma_do_coag, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_coag')
call mpi_bcast (carma_do_detrain, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_detrain')
call mpi_bcast (carma_do_drydep, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_drydep')
call mpi_bcast (carma_do_emission, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_emission')
call mpi_bcast (carma_do_fixedinit, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_fixedinit')
call mpi_bcast (carma_hetchem_feedback,1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_hetchem_feedback')
call mpi_bcast (carma_rad_feedback, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_rad_feedback')
call mpi_bcast (carma_do_explised, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_explised')
call mpi_bcast (carma_do_budget_diags, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_budget_diags')
call mpi_bcast (carma_do_package_diags,1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_package_diags')
call mpi_bcast (carma_do_incloud, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_incloud')
call mpi_bcast (carma_do_grow, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_grow')
call mpi_bcast (carma_do_optics, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_optics')
call mpi_bcast (carma_do_partialinit, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_partialinit')
call mpi_bcast (carma_do_pheat, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_pheat')
call mpi_bcast (carma_do_pheatatm, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_pheatatm')
call mpi_bcast (carma_do_substep, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_substep')
call mpi_bcast (carma_do_thermo, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_thermo')
call mpi_bcast (carma_do_wetdep, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_wetdep')
call mpi_bcast (carma_do_vdiff, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_vdiff')
call mpi_bcast (carma_do_vtran, 1 ,mpi_logical, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_do_vtran')
call mpi_bcast (carma_diags_file, 1 ,mpi_integer, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_diags_file')
call mpi_bcast (carma_maxsubsteps, 1 ,mpi_integer, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_maxsubsteps')
call mpi_bcast (carma_minsubsteps, 1 ,mpi_integer, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_minsubsteps')
call mpi_bcast (carma_maxretries, 1 ,mpi_integer, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_maxretries')
call mpi_bcast (carma_conmax, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_conmax')
call mpi_bcast (carma_dgc_threshold, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_dgc_threshold')
call mpi_bcast (carma_ds_threshold, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_ds_threshold')
call mpi_bcast (carma_dt_threshold, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_dt_threshold')
call mpi_bcast (carma_tstick, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_tstick')
call mpi_bcast (carma_gsticki, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_gsticki')
call mpi_bcast (carma_gstickl, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_gstickl')
call mpi_bcast (carma_cstick, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_cstick')
call mpi_bcast (carma_rhcrit, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_rhcrit')
call mpi_bcast (carma_vf_const, 1 ,mpi_real8, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_vf_const')
call mpi_bcast (carma_model, len(carma_model), mpi_character, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_model')
call mpi_bcast (carma_sulfnuc_method, len(carma_sulfnuc_method), mpi_character, masterprocid, mpicom, ierr)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_sulfnuc_method')
call mpibcast (carma_diags_packages, len(carma_diags_packages(1))*carma_maxdiags, mpi_character, 0, mpicom)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_diags_packages')
call mpibcast (carma_debug_packages, len(carma_debug_packages(1))*carma_maxdiags, mpi_character, 0, mpicom)
if (ierr/=mpi_success) call endrun(prefix//'mpi_bcast error : carma_debug_packages')

carma_ndiagpkgs = 0
do i = 1, carma_maxdiags
Expand Down
41 changes: 27 additions & 14 deletions src/physics/carma/cam/carma_intr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@
!! @version July 2009
module carma_intr

use carma_precision_mod
use carma_enums_mod
use carma_constants_mod, only : GRAV, REARTH, WTMOL_AIR, WTMOL_H2O, R_AIR, CP, RKAPPA
use carma_types_mod
use carma_flags_mod
use carma_model_mod
use carmaelement_mod
use carmagas_mod
use carmagroup_mod
use carmasolute_mod
use carmastate_mod
use carma_mod
use carma_precision_mod, only: f
use carma_enums_mod, only: I_OPTICS_FIXED, I_OPTICS_MIXED_CORESHELL, I_OPTICS_MIXED_VOLUME, &
I_OPTICS_MIXED_MAXWELL, I_OPTICS_SULFATE, I_CNSTTYPE_PROGNOSTIC, I_HYBRID
use carma_constants_mod, only : GRAV, REARTH, WTMOL_AIR, WTMOL_H2O, R_AIR, CP, RKAPPA, NWAVE, &
CARMA_NAME_LEN, CARMA_SHORT_NAME_LEN, PI, CAM_FILL, RGAS, RM2CGS, RAD2DEG, CLDFRC_INCLOUD
use carma_types_mod, only : carma_type, carmastate_type
use carma_flags_mod, only : carma_flag, carma_do_fixedinit, carma_model, carma_do_wetdep, carma_do_emission, &
carma_do_pheat, carma_do_substep, carma_do_thermo, carma_do_cldice, carma_diags_file, &
carma_do_grow, carma_ndebugpkgs, carma_conmax, carma_cstick, carma_tstick, carma_vf_const, carma_sulfnuc_method, &
carma_rhcrit, carma_rad_feedback, carma_minsubsteps, carma_maxsubsteps, carma_gstickl, carma_gsticki, &
carma_maxretries, carma_dt_threshold, carma_ds_threshold, carma_do_vtran, carma_do_vdiff, carma_do_pheatatm, &
carma_do_partialinit, carma_do_optics, carma_do_incloud, carma_do_explised, carma_do_drydep, carma_do_detrain, &
carma_do_coremasscheck, carma_do_coag, carma_do_clearsky, carma_do_cldliq, carma_do_aerosol, carma_dgc_threshold

use carma_model_mod, only : NGAS, NBIN, NELEM, NGROUP, NMIE_WTP, NREFIDX, MIE_RH, NMIE_RH, NSOLUTE
use carma_model_mod, only : mie_rh, mie_wtp, is_convtran1, CARMAMODEL_DiagnoseBulk, CARMAMODEL_DiagnoseBins, &
CARMAMODEL_Detrain, CARMAMODEL_OutputDiagnostics, CARMAMODEL_CreateOpticsFile, CARMAMODEL_WetDeposition, &
CARMAMODEL_EmitParticle, CARMAMODEL_InitializeParticle, CARMAMODEL_DefineModel, CARMAMODEL_InitializeModel
use carmaelement_mod, only : CARMAELEMENT_Get
use carmagas_mod, only : CARMAGAS_Get
use carmagroup_mod, only : CARMAGROUP_Get
use carmastate_mod, only : CARMASTATE_CreateFromReference, CARMASTATE_SetGas, CARMASTATE_Step, CARMASTATE_GetBin, &
CARMASTATE_GetGas, CARMASTATE_GetState, CARMASTATE_Get, CARMASTATE_Create, CARMASTATE_SetBin, CARMASTATE_Destroy
use carma_mod, only : CARMA_Get, CARMA_Create, CARMA_Initialize, CARMA_Destroy

use shr_kind_mod, only: r8 => shr_kind_r8
use spmd_utils, only: masterproc, mpicom
Expand All @@ -35,6 +47,7 @@ module carma_intr
use physics_buffer, only: physics_buffer_desc, pbuf_add_field, pbuf_old_tim_idx, &
pbuf_get_index, pbuf_get_field, dtype_r8, pbuf_set_field
use pio, only: var_desc_t
use radconstants, only: nlwbands, nswbands

implicit none

Expand Down Expand Up @@ -180,7 +193,7 @@ module carma_intr
!! @author Chuck Bardeen
!! @version May-2009
subroutine carma_register
use radconstants, only : nlwbands, get_sw_spectral_boundaries, get_lw_spectral_boundaries
use radconstants, only : get_sw_spectral_boundaries, get_lw_spectral_boundaries
use cam_logfile, only : iulog
use cam_control_mod, only : initial_run
use physconst, only: gravit, p_rearth=>rearth, mwdry, mwh2o
Expand Down Expand Up @@ -2608,7 +2621,7 @@ subroutine CARMA_CreateOpticsFile_Sulfate(carma, igroup, rc)
integer :: rhdim, lwdim, swdim, wtpdim
integer :: rhvar, lwvar, swvar, wtp_var
integer :: rwetvar
integer :: abs_lw_wtp_var, qabs_lw_wtp_var
integer :: abs_lw_wtp_var, qabs_lw_wtp_var
integer :: ext_sw_wtp_var, ssa_sw_wtp_var, asm_sw_wtp_var, qext_sw_wtp_var
integer :: omdim, andim, namedim
integer :: omvar, anvar, namevar
Expand Down

0 comments on commit 189151b

Please sign in to comment.