From 44a3586353d481e473d64a22ead1a9eb5d9aa872 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 16 Dec 2022 14:04:29 -0700 Subject: [PATCH 01/54] Initial machine learning code for PUMAS --- Externals_CAM.cfg | 2 +- src/physics/cam/microp_driver.F90 | 9 ++++ src/physics/cam/modal_aer_opt.F90 | 46 +++++++++++++++++ src/physics/cam_dev/micro_pumas_cam.F90 | 68 ++++++++++++++++++++++++- 4 files changed, 123 insertions(+), 2 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 85802da348..1ab2ab50d4 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -tag = pumas_cam-release_v1.28 +hash = 6cc148f64 required = True [pumas-frozen] diff --git a/src/physics/cam/microp_driver.F90 b/src/physics/cam/microp_driver.F90 index baf11c4a9e..a7c3a81de1 100644 --- a/src/physics/cam/microp_driver.F90 +++ b/src/physics/cam/microp_driver.F90 @@ -19,6 +19,10 @@ module microp_driver use cam_logfile, only: iulog use cam_abortutils, only: endrun use perf_mod, only: t_startf, t_stopf +! ++ TAU +use stochastic_collect_tau_cam, only: stochastic_kernel_init +use tau_neural_net_batch, only: initialize_tau_emulators +! -- TAU implicit none private @@ -147,6 +151,11 @@ subroutine microp_driver_init(pbuf2d) select case (microp_scheme) case ('MG') call micro_pumas_cam_init(pbuf2d) +!CACNOTE - Should this only be called when machine learning is on? +! ++ TAU + call stochastic_kernel_init + call initialize_tau_emulators +! -- TAU case ('RK') ! microp_driver doesn't handle this one continue diff --git a/src/physics/cam/modal_aer_opt.F90 b/src/physics/cam/modal_aer_opt.F90 index 5c95c17840..42910d53e4 100644 --- a/src/physics/cam/modal_aer_opt.F90 +++ b/src/physics/cam/modal_aer_opt.F90 @@ -204,6 +204,17 @@ subroutine modal_aer_opt_init() call addfld ('EXTxASYM', (/ 'lev' /), 'A',' ','extinction 550 nm * asymmetry factor, day only', & flag_xyfill=.true.) +!++ag Add angstrom exponent + call addfld ('AEXPUV', horiz_only, 'A',' ','Angstrom Exponent from 350nn-550nm, day only', & + flag_xyfill=.true.) + call addfld ('AEXPNIR', horiz_only, 'A',' ','Angstrom Exponent from 1020nn-550nm, day only', & + flag_xyfill=.true.) + call addfld ('AEXPUVdn', horiz_only, 'A',' ','Angstrom Exponent from 350nn-550nm, day night', & + flag_xyfill=.true.) + call addfld ('AEXPNIRdn', horiz_only, 'A',' ','Angstrom Exponent from 1020nn-550nm, day night', & + flag_xyfill=.true.) +!--ag + call addfld ('EXTINCTdn', (/ 'lev' /), 'A','/m','Aerosol extinction 550 nm, day night', & flag_xyfill=.true.) call addfld ('EXTINCTUVdn', (/ 'lev' /), 'A','/m','Aerosol extinction 350 nm, day night', & @@ -589,6 +600,11 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & real(r8) :: aodnir(pcols) ! extinction optical depth in nir real(r8) :: aodnirst(pcols) ! stratospheric extinction optical depth in nir +!CACNOTE - Are these changes part of the machine learning? +!++ag + real(r8) :: aenir(pcols) ! angstrom exponent + real(r8) :: aeuv(pcols) ! angstrom exponent +!--ag character(len=32) :: outname @@ -650,6 +666,11 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & aodnirst(:ncol) = 0.0_r8 call tropopause_findChemTrop(state, troplevchem) +!++ag + aeuv(:ncol) = 0.0_r8 + aenir(:ncol) = 0.0_r8 +!--ag + ! loop over all aerosol modes call rad_cnst_get_info(list_idx, nmodes=nmodes) @@ -1064,6 +1085,17 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & deallocate(naer_m) end if +!++ag +! Calculate angstrom exponent for band differences with NIR and UV v. vis.... +! Alpha = - ln (tau1/tau2)/ ln (lam1/lam2) +! Since wavenumber = 1/lam.... +! AEUV = -ln(AODVIS/AODUV) / ln(350/550) +! AENIR= -ln(AODVIS/AODNIR) / ln(350/1020) + + aeuv(:) = -log(aodvis(:)/aoduv(:)) / log(350._r8/550._r8) + aenir(:) = -log(aodvis(:)/aodnir(:)) / log(350._r8/550._r8) +!--ag + ! Output visible band diagnostics for quantities summed over the modes ! These fields are put out for diagnostic lists as well as the climate list. @@ -1126,6 +1158,10 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & call outfld('AODBCdn', bcaod, pcols, lchnk) call outfld('AODSSdn', seasaltaod, pcols, lchnk) +!++ag + call outfld('AEXPUVdn', aeuv, pcols, lchnk) + call outfld('AEXPNIRdn', aenir, pcols, lchnk) +!--ag do i = 1, nnite ssavis(idxnite(i)) = fillvalue @@ -1133,6 +1169,11 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & aoduv(idxnite(i)) = fillvalue aodnir(idxnite(i)) = fillvalue +!++ag + aeuv(idxnite(i)) = fillvalue + aenir(idxnite(i)) = fillvalue +!--ag + aoduvst(idxnite(i)) = fillvalue aodnirst(idxnite(i)) = fillvalue extinctuv(idxnite(i),:) = fillvalue @@ -1162,6 +1203,11 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & call outfld('EXTINCTNIR', extinctnir, pcols, lchnk) call outfld('AODUV', aoduv, pcols, lchnk) call outfld('AODNIR', aodnir, pcols, lchnk) +!++ag + call outfld('AEXPUV', aeuv, pcols, lchnk) + call outfld('AEXPNIR', aenir, pcols, lchnk) +!--ag + call outfld('AODUVst', aoduvst, pcols, lchnk) call outfld('AODNIRst', aodnirst, pcols, lchnk) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index ebe8b43976..1f22d45489 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -544,7 +544,10 @@ end subroutine micro_pumas_cam_readnl !================================================================================================ subroutine micro_pumas_cam_register - +!++ TAU +!use stochastic_collect_tau_cam, only: ncd, diammean, diamedge +!use cam_history_support, only: add_hist_coord +!-- TAU use cam_history_support, only: add_vert_coord, hist_dimension_values use cam_abortutils, only: handle_allocate_error @@ -561,6 +564,12 @@ subroutine micro_pumas_cam_register allocate(trop_levs(pver-top_lev+1), stat=ierr) call handle_allocate_error(ierr, 'micro_pumas_cam_register', 'trop_levs') +!++ TAU +! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') +! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics', 'cm', & +! diammean, bounds_name = 'bins_ncd_bnds', bounds = diamedge ) +!-- TAU + call phys_getopts(use_subcol_microp_out = use_subcol_microp, & prog_modal_aero_out = prog_modal_aero) @@ -1423,6 +1432,9 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) use wv_saturation, only: qsat use infnan, only: nan, assignment(=) use cam_abortutils, only: handle_allocate_error +!++ TAU + use stochastic_collect_tau_cam, only: ncd +!-- TAU type(physics_state), intent(in) :: state type(physics_ptend), intent(out) :: ptend @@ -2322,6 +2334,18 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Update local state call physics_update(state_loc, ptend_loc, dtime/num_steps) +!CACNOTE - Don't know if this still needs summing or not - if so need the init to zero that will be above +!++ TAU +!CACCOMMENT proc_rates%amk_c = proc_rates%amk_c + packed_amk_c/num_steps +!CACCOMMENT proc_rates%ank_c = proc_rates%ank_c + packed_ank_c/num_steps +!CACCOMMENT proc_rates%amk_r = proc_rates%amk_r + packed_amk_r/num_steps +!CACCOMMENT proc_rates%ank_r = proc_rates%ank_r + packed_ank_r/num_steps +!CACCOMMENT proc_rates%amk = proc_rates%amk + packed_amk/num_steps +!CACCOMMENT proc_rates%ank = proc_rates%ank + packed_ank/num_steps +!CACCOMMENT proc_rates%amk_out = proc_rates%amk_out + packed_amk_out/num_steps +!CACCOMMENT proc_rates%ank_out = proc_rates%ank_out + packed_ank_out/num_steps +!-- TAU + end do ! Divide ptend by substeps. @@ -3190,6 +3214,42 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld( 'MPDI2P', ftem_grid, pcols, lchnk) ! Output fields which have not been averaged already, averaging if use_subcol_microp is true +!++ TAU + call outfld('scale_qc', proc_rates%scale_qc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_nc', proc_rates%scale_nc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_qr', proc_rates%scale_qr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_nr', proc_rates%scale_nr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_c', proc_rates%amk_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_c', proc_rates%ank_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_r', proc_rates%amk_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_r', proc_rates%ank_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk', proc_rates%amk, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank', proc_rates%ank, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_out', proc_rates%amk_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_out', proc_rates%ank_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QC_TAU_out', proc_rates%qc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NC_TAU_out', proc_rates%nc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QR_TAU_out', proc_rates%qr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NR_TAU_out', proc_rates%nr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_MG2', proc_rates%qctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_MG2', proc_rates%nctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_MG2', proc_rates%qrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_MG2', proc_rates%nrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_TAU', proc_rates%qctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_TAU', proc_rates%nctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_TAU', proc_rates%qrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_TAU', proc_rates%nrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_TAU_diag', proc_rates%qctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_TAU_diag', proc_rates%nctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_TAU_diag', proc_rates%qrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_TAU_diag', proc_rates%nrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('gmnnn_lmnnn_TAU', proc_rates%gmnnn_lmnnn_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ML_fixer', proc_rates%ML_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qc_fixer', proc_rates%qc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nc_fixer', proc_rates%nc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qr_fixer', proc_rates%qr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nr_fixer', proc_rates%nr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) +!-- TAU call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('REFL', refl, psetcols, lchnk, avg_subcol_field=use_subcol_microp) @@ -3285,6 +3345,12 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) end if ! Output fields which are already on the grid +!++ TAU + call outfld('QC_TAU_in', state%q(1,1,ixcldliq), pcols, lchnk) + call outfld('NC_TAU_in', state%q(1,1,ixnumliq), pcols, lchnk) + call outfld('QR_TAU_in', state%q(1,1,ixrain), pcols, lchnk) + call outfld('NR_TAU_in', state%q(1,1,ixnumrain),pcols, lchnk) +!-- TAU call outfld('QRAIN', qrout_grid, pcols, lchnk) call outfld('QSNOW', qsout_grid, pcols, lchnk) call outfld('NRAIN', nrout_grid, pcols, lchnk) From 15ec0f0e1fea8aaa3d34cd79bfbf41e8ba5a34d5 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Mon, 19 Dec 2022 17:22:55 -0700 Subject: [PATCH 02/54] Update PUMAS external for amk and ank allocations --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 1ab2ab50d4..48f8647d7e 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 6cc148f64 +hash = fc09e1f required = True [pumas-frozen] From c434e558ad57a084bb68e5a6fddbeee9934db527 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 23 Dec 2022 14:26:22 -0700 Subject: [PATCH 03/54] Initial mods for namelist micro_mg_warm_rain --- Externals_CAM.cfg | 2 +- bld/build-namelist | 1 + bld/namelist_files/namelist_definition.xml | 7 +- src/physics/cam/microp_driver.F90 | 1 + src/physics/cam_dev/micro_pumas_cam.F90 | 107 +++++++++++---------- 5 files changed, 66 insertions(+), 52 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 48f8647d7e..c95cc79dda 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = fc09e1f +hash = aaccd5b1 required = True [pumas-frozen] diff --git a/bld/build-namelist b/bld/build-namelist index 32b822394c..18862f931d 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -2962,6 +2962,7 @@ if ($cfg->get('microphys') =~ /^mg/) { add_default($nl, 'nucleate_ice_incloud'); add_default($nl, 'nucleate_ice_strat'); add_default($nl, 'micro_mg_do_hail'); + add_default($nl, 'micro_mg_warm_rain', 'val'=>'kk2000'); add_default($nl, 'micro_mg_do_graupel'); add_default($nl, 'graupel_in_rad'); add_default($nl, 'micro_do_massless_droplet_destroyer'); diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 5781ed8ed6..39120518f5 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2599,13 +2599,18 @@ Default: 1 Maximum allowed ice number concentration Default: 1.0e8 -x + Do Seifert and Behang (2001) autoconversion and accretion physics when set to true. Default: .false. + +Warm rain process +Default: set in namelist_defaults + Do destruction of massless droplets diff --git a/src/physics/cam/microp_driver.F90 b/src/physics/cam/microp_driver.F90 index a7c3a81de1..81ab1028a0 100644 --- a/src/physics/cam/microp_driver.F90 +++ b/src/physics/cam/microp_driver.F90 @@ -152,6 +152,7 @@ subroutine microp_driver_init(pbuf2d) case ('MG') call micro_pumas_cam_init(pbuf2d) !CACNOTE - Should this only be called when machine learning is on? +!CACNOTE - probably move into pumas module ! ++ TAU call stochastic_kernel_init call initialize_tau_emulators diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 1f22d45489..9256154726 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -235,8 +235,9 @@ module micro_pumas_cam frzcnt_idx = -1, & frzdep_idx = -1 -logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop -logical :: micro_do_sb_physics = .false. ! do SB 2001 autoconversion and accretion +logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop +logical :: micro_do_sb_physics ! no longer needed, but kept because part of CAM namelist still (older CAM) +character(len=16) :: micro_mg_warm_rain= 'emulated' ! 'tau', 'emulated', 'sb2001' and ' kk2000' integer :: bergso_idx = -1 @@ -263,10 +264,12 @@ subroutine micro_pumas_cam_readnl(nlfile) integer :: unitn, ierr character(len=*), parameter :: sub = 'micro_pumas_cam_readnl' +!CACNOTE - PUT BACK IN WHEN NAMELIST WORKING + namelist /micro_mg_nl/ micro_mg_version, micro_mg_sub_version, & micro_mg_do_cldice, micro_mg_do_cldliq, micro_mg_num_steps, & microp_uniform, micro_mg_dcs, micro_mg_precip_frac_method, & - micro_mg_berg_eff_factor, micro_do_sb_physics, micro_mg_adjust_cpt, & + micro_mg_berg_eff_factor, micro_do_sb_physics, micro_mg_warm_rain, micro_mg_adjust_cpt, & micro_mg_do_hail, micro_mg_do_graupel, micro_mg_ngcons, micro_mg_ngnst, & micro_mg_vtrmi_factor, micro_mg_effi_factor, micro_mg_iaccr_factor, & micro_mg_max_nicons, micro_mg_accre_enhan_fact, & @@ -395,8 +398,8 @@ subroutine micro_pumas_cam_readnl(nlfile) call mpi_bcast(micro_mg_precip_frac_method, 16, mpi_character, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_precip_frac_method") - call mpi_bcast(micro_do_sb_physics, 1, mpi_logical, mstrid, mpicom, ierr) - if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_do_sb_physics") + call mpi_bcast(micro_mg_warm_rain, 16, mpi_character, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_warm_rain") call mpi_bcast(micro_mg_adjust_cpt, 1, mpi_logical, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_adjust_cpt") @@ -502,7 +505,7 @@ subroutine micro_pumas_cam_readnl(nlfile) write(iulog,*) ' micro_mg_iaccr_factor = ', micro_mg_iaccr_factor write(iulog,*) ' micro_mg_max_nicons = ', micro_mg_max_nicons write(iulog,*) ' micro_mg_precip_frac_method = ', micro_mg_precip_frac_method - write(iulog,*) ' micro_do_sb_physics = ', micro_do_sb_physics + write(iulog,*) ' micro_mg_warm_rain = ', micro_mg_warm_rain write(iulog,*) ' micro_mg_adjust_cpt = ', micro_mg_adjust_cpt write(iulog,*) ' micro_mg_nccons = ', micro_mg_nccons write(iulog,*) ' micro_mg_nicons = ', micro_mg_nicons @@ -545,8 +548,8 @@ end subroutine micro_pumas_cam_readnl subroutine micro_pumas_cam_register !++ TAU -!use stochastic_collect_tau_cam, only: ncd, diammean, diamedge -!use cam_history_support, only: add_hist_coord +!!!!!! use stochastic_collect_tau_cam, only: ncd, diammean, diamedge +!!!!!! use cam_history_support, only: add_hist_coord !-- TAU use cam_history_support, only: add_vert_coord, hist_dimension_values use cam_abortutils, only: handle_allocate_error @@ -565,9 +568,9 @@ subroutine micro_pumas_cam_register call handle_allocate_error(ierr, 'micro_pumas_cam_register', 'trop_levs') !++ TAU -! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') -! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics', 'cm', & -! diammean, bounds_name = 'bins_ncd_bnds', bounds = diamedge ) +!!!!!! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') +!!!!!! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics', 'cm', & +!!!!!! diammean, bounds_name = 'bins_ncd_bnds', bounds = diamedge ) !-- TAU call phys_getopts(use_subcol_microp_out = use_subcol_microp, & @@ -910,7 +913,7 @@ subroutine micro_pumas_cam_init(pbuf2d) micro_mg_autocon_fact , micro_mg_autocon_nd_exp, micro_mg_autocon_lwp_exp, micro_mg_homog_size, & micro_mg_vtrmi_factor, micro_mg_effi_factor, micro_mg_iaccr_factor, & micro_mg_max_nicons, & - allow_sed_supersat, micro_do_sb_physics, & + allow_sed_supersat, micro_mg_warm_rain, & micro_mg_evap_sed_off, micro_mg_icenuc_rh_off, micro_mg_icenuc_use_meyers, & micro_mg_evap_scl_ifs, micro_mg_evap_rhthrsh_ifs, & micro_mg_rainfreeze_ifs, micro_mg_ifs_sed, micro_mg_precip_fall_corr,& @@ -3215,40 +3218,42 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Output fields which have not been averaged already, averaging if use_subcol_microp is true !++ TAU - call outfld('scale_qc', proc_rates%scale_qc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('scale_nc', proc_rates%scale_nc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('scale_qr', proc_rates%scale_qr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('scale_nr', proc_rates%scale_nr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk_c', proc_rates%amk_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank_c', proc_rates%ank_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk_r', proc_rates%amk_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank_r', proc_rates%ank_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk', proc_rates%amk, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank', proc_rates%ank, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk_out', proc_rates%amk_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank_out', proc_rates%ank_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QC_TAU_out', proc_rates%qc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NC_TAU_out', proc_rates%nc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QR_TAU_out', proc_rates%qr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NR_TAU_out', proc_rates%nr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qctend_MG2', proc_rates%qctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_MG2', proc_rates%nctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_MG2', proc_rates%qrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_MG2', proc_rates%nrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qctend_TAU', proc_rates%qctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_TAU', proc_rates%nctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_TAU', proc_rates%qrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_TAU', proc_rates%nrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qctend_TAU_diag', proc_rates%qctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_TAU_diag', proc_rates%nctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_TAU_diag', proc_rates%qrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_TAU_diag', proc_rates%nrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('gmnnn_lmnnn_TAU', proc_rates%gmnnn_lmnnn_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ML_fixer', proc_rates%ML_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qc_fixer', proc_rates%qc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nc_fixer', proc_rates%nc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qr_fixer', proc_rates%qr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nr_fixer', proc_rates%nr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + call outfld('scale_qc', proc_rates%scale_qc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_nc', proc_rates%scale_nc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_qr', proc_rates%scale_qr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_nr', proc_rates%scale_nr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_c', proc_rates%amk_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_c', proc_rates%ank_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_r', proc_rates%amk_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_r', proc_rates%ank_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk', proc_rates%amk, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank', proc_rates%ank, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_out', proc_rates%amk_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_out', proc_rates%ank_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QC_TAU_out', proc_rates%qc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NC_TAU_out', proc_rates%nc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QR_TAU_out', proc_rates%qr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NR_TAU_out', proc_rates%nr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_MG2', proc_rates%qctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_MG2', proc_rates%nctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_MG2', proc_rates%qrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_MG2', proc_rates%nrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_TAU', proc_rates%qctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_TAU', proc_rates%nctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_TAU', proc_rates%qrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_TAU', proc_rates%nrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_TAU_diag', proc_rates%qctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_TAU_diag', proc_rates%nctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_TAU_diag', proc_rates%qrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_TAU_diag', proc_rates%nrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('gmnnn_lmnnn_TAU', proc_rates%gmnnn_lmnnn_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ML_fixer', proc_rates%ML_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qc_fixer', proc_rates%qc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nc_fixer', proc_rates%nc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qr_fixer', proc_rates%qr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nr_fixer', proc_rates%nr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + end if !-- TAU call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) @@ -3346,10 +3351,12 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Output fields which are already on the grid !++ TAU - call outfld('QC_TAU_in', state%q(1,1,ixcldliq), pcols, lchnk) - call outfld('NC_TAU_in', state%q(1,1,ixnumliq), pcols, lchnk) - call outfld('QR_TAU_in', state%q(1,1,ixrain), pcols, lchnk) - call outfld('NR_TAU_in', state%q(1,1,ixnumrain),pcols, lchnk) + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + call outfld('QC_TAU_in', state%q(1,1,ixcldliq), pcols, lchnk) + call outfld('NC_TAU_in', state%q(1,1,ixnumliq), pcols, lchnk) + call outfld('QR_TAU_in', state%q(1,1,ixrain), pcols, lchnk) + call outfld('NR_TAU_in', state%q(1,1,ixnumrain),pcols, lchnk) + end if !-- TAU call outfld('QRAIN', qrout_grid, pcols, lchnk) call outfld('QSNOW', qsout_grid, pcols, lchnk) From 2b5be1d93b7f84d6a41ee2476a49cdfa5eb16ba8 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 5 Jan 2023 14:22:55 -0700 Subject: [PATCH 04/54] Update PUMAS tag --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index c95cc79dda..863da2b9df 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = aaccd5b1 +hash = 727b0c06 required = True [pumas-frozen] From dd4b431d5f981b5d9e5f8d878d4b6785fbdc7934 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 5 Jan 2023 16:29:06 -0700 Subject: [PATCH 05/54] Update PUMAS hash --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 863da2b9df..f040772853 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 727b0c06 +hash = 3266a4c2 required = True [pumas-frozen] From 353d7cd1bcdada488118c712e30bc410ea1ee702 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 12 Jan 2023 14:04:55 -0700 Subject: [PATCH 06/54] Various code cleanup --- Externals_CAM.cfg | 2 +- bld/build-namelist | 8 ++++--- bld/namelist_files/namelist_defaults_cam.xml | 1 + src/physics/cam/microp_driver.F90 | 10 --------- src/physics/cam_dev/micro_pumas_cam.F90 | 22 ++++++++------------ 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index f040772853..1ef66e5bb4 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 3266a4c2 +hash = 571b4f4 required = True [pumas-frozen] diff --git a/bld/build-namelist b/bld/build-namelist index 18862f931d..a0ef4b5928 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -2962,7 +2962,6 @@ if ($cfg->get('microphys') =~ /^mg/) { add_default($nl, 'nucleate_ice_incloud'); add_default($nl, 'nucleate_ice_strat'); add_default($nl, 'micro_mg_do_hail'); - add_default($nl, 'micro_mg_warm_rain', 'val'=>'kk2000'); add_default($nl, 'micro_mg_do_graupel'); add_default($nl, 'graupel_in_rad'); add_default($nl, 'micro_do_massless_droplet_destroyer'); @@ -2976,14 +2975,17 @@ if ($cfg->get('microphys') =~ /^mg/) { add_default($nl, 'micro_mg_iaccr_factor'); add_default($nl, 'micro_mg_max_nicons'); - # For CESM2, the decision was made to set micro_do_sb_physics to false - add_default($nl, 'micro_do_sb_physics', 'val'=>'.false.'); # namelist options for pumas tag release_v1.22 or later # (currently only in the cam_dev physics package) if ($phys =~ /cam_dev/) { + add_default($nl, 'micro_mg_warm_rain'); add_default($nl, 'micro_mg_accre_sees_auto'); add_default($nl, 'micro_mg_implicit_fall'); + }else { + # For CESM2, the decision was made to set micro_do_sb_physics to false + # This variable is replaced with micro_mg_warm_rain in cam_dev runs + add_default($nl, 'micro_do_sb_physics', 'val'=>'.false.'); } } diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index b29e1e5be4..e6a569b50d 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2064,6 +2064,7 @@ .true. .true. + kk2000 .true. 1 diff --git a/src/physics/cam/microp_driver.F90 b/src/physics/cam/microp_driver.F90 index 81ab1028a0..baf11c4a9e 100644 --- a/src/physics/cam/microp_driver.F90 +++ b/src/physics/cam/microp_driver.F90 @@ -19,10 +19,6 @@ module microp_driver use cam_logfile, only: iulog use cam_abortutils, only: endrun use perf_mod, only: t_startf, t_stopf -! ++ TAU -use stochastic_collect_tau_cam, only: stochastic_kernel_init -use tau_neural_net_batch, only: initialize_tau_emulators -! -- TAU implicit none private @@ -151,12 +147,6 @@ subroutine microp_driver_init(pbuf2d) select case (microp_scheme) case ('MG') call micro_pumas_cam_init(pbuf2d) -!CACNOTE - Should this only be called when machine learning is on? -!CACNOTE - probably move into pumas module -! ++ TAU - call stochastic_kernel_init - call initialize_tau_emulators -! -- TAU case ('RK') ! microp_driver doesn't handle this one continue diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 9256154726..b4d687ee69 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -236,7 +236,6 @@ module micro_pumas_cam frzdep_idx = -1 logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop -logical :: micro_do_sb_physics ! no longer needed, but kept because part of CAM namelist still (older CAM) character(len=16) :: micro_mg_warm_rain= 'emulated' ! 'tau', 'emulated', 'sb2001' and ' kk2000' integer :: bergso_idx = -1 @@ -264,12 +263,10 @@ subroutine micro_pumas_cam_readnl(nlfile) integer :: unitn, ierr character(len=*), parameter :: sub = 'micro_pumas_cam_readnl' -!CACNOTE - PUT BACK IN WHEN NAMELIST WORKING - namelist /micro_mg_nl/ micro_mg_version, micro_mg_sub_version, & micro_mg_do_cldice, micro_mg_do_cldliq, micro_mg_num_steps, & microp_uniform, micro_mg_dcs, micro_mg_precip_frac_method, & - micro_mg_berg_eff_factor, micro_do_sb_physics, micro_mg_warm_rain, micro_mg_adjust_cpt, & + micro_mg_berg_eff_factor, micro_mg_warm_rain, micro_mg_adjust_cpt, & micro_mg_do_hail, micro_mg_do_graupel, micro_mg_ngcons, micro_mg_ngnst, & micro_mg_vtrmi_factor, micro_mg_effi_factor, micro_mg_iaccr_factor, & micro_mg_max_nicons, micro_mg_accre_enhan_fact, & @@ -2337,16 +2334,15 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Update local state call physics_update(state_loc, ptend_loc, dtime/num_steps) -!CACNOTE - Don't know if this still needs summing or not - if so need the init to zero that will be above !++ TAU -!CACCOMMENT proc_rates%amk_c = proc_rates%amk_c + packed_amk_c/num_steps -!CACCOMMENT proc_rates%ank_c = proc_rates%ank_c + packed_ank_c/num_steps -!CACCOMMENT proc_rates%amk_r = proc_rates%amk_r + packed_amk_r/num_steps -!CACCOMMENT proc_rates%ank_r = proc_rates%ank_r + packed_ank_r/num_steps -!CACCOMMENT proc_rates%amk = proc_rates%amk + packed_amk/num_steps -!CACCOMMENT proc_rates%ank = proc_rates%ank + packed_ank/num_steps -!CACCOMMENT proc_rates%amk_out = proc_rates%amk_out + packed_amk_out/num_steps -!CACCOMMENT proc_rates%ank_out = proc_rates%ank_out + packed_ank_out/num_steps + proc_rates%amk_c = proc_rates%amk_c/num_steps + proc_rates%ank_c = proc_rates%ank_c/num_steps + proc_rates%amk_r = proc_rates%amk_r/num_steps + proc_rates%ank_r = proc_rates%ank_r/num_steps + proc_rates%amk = proc_rates%amk/num_steps + proc_rates%ank = proc_rates%ank/num_steps + proc_rates%amk_out = proc_rates%amk_out/num_steps + proc_rates%ank_out = proc_rates%ank_out/num_steps !-- TAU end do From 1eacd3921b429fb70d84f44cc2def0367e3026b8 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 12 Jan 2023 16:57:40 -0700 Subject: [PATCH 07/54] Fix for modal_aer_opt failures --- src/physics/cam/modal_aer_opt.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/physics/cam/modal_aer_opt.F90 b/src/physics/cam/modal_aer_opt.F90 index 42910d53e4..f7221912eb 100644 --- a/src/physics/cam/modal_aer_opt.F90 +++ b/src/physics/cam/modal_aer_opt.F90 @@ -667,8 +667,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & call tropopause_findChemTrop(state, troplevchem) !++ag - aeuv(:ncol) = 0.0_r8 - aenir(:ncol) = 0.0_r8 + aeuv(:) = 0.0_r8 + aenir(:) = 0.0_r8 !--ag ! loop over all aerosol modes @@ -1092,8 +1092,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & ! AEUV = -ln(AODVIS/AODUV) / ln(350/550) ! AENIR= -ln(AODVIS/AODNIR) / ln(350/1020) - aeuv(:) = -log(aodvis(:)/aoduv(:)) / log(350._r8/550._r8) - aenir(:) = -log(aodvis(:)/aodnir(:)) / log(350._r8/550._r8) + aeuv(:ncol) = -log(aodvis(:ncol)/aoduv(:ncol)) / log(350._r8/550._r8) + aenir(:ncol) = -log(aodvis(:ncol)/aodnir(:ncol)) / log(350._r8/550._r8) !--ag ! Output visible band diagnostics for quantities summed over the modes From 1697de07615567e56543f6e6d36c9341438843f2 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 20 Jan 2023 10:03:12 -0700 Subject: [PATCH 08/54] Enclose additional section in check for machine learning code --- src/physics/cam_dev/micro_pumas_cam.F90 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index b4d687ee69..0be8dd6987 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -2335,14 +2335,16 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call physics_update(state_loc, ptend_loc, dtime/num_steps) !++ TAU - proc_rates%amk_c = proc_rates%amk_c/num_steps - proc_rates%ank_c = proc_rates%ank_c/num_steps - proc_rates%amk_r = proc_rates%amk_r/num_steps - proc_rates%ank_r = proc_rates%ank_r/num_steps - proc_rates%amk = proc_rates%amk/num_steps - proc_rates%ank = proc_rates%ank/num_steps - proc_rates%amk_out = proc_rates%amk_out/num_steps - proc_rates%ank_out = proc_rates%ank_out/num_steps + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + proc_rates%amk_c(:ncol,:,:) = proc_rates%amk_c(:ncol,:,:)/num_steps + proc_rates%ank_c(:ncol,:,:) = proc_rates%ank_c(:ncol,:,:)/num_steps + proc_rates%amk_r(:ncol,:,:) = proc_rates%amk_r(:ncol,:,:)/num_steps + proc_rates%ank_r(:ncol,:,:) = proc_rates%ank_r(:ncol,:,:)/num_steps + proc_rates%amk(:ncol,:,:) = proc_rates%amk(:ncol,:,:)/num_steps + proc_rates%ank(:ncol,:,:) = proc_rates%ank(:ncol,:,:)/num_steps + proc_rates%amk_out(:ncol,:,:) = proc_rates%amk_out(:ncol,:,:)/num_steps + proc_rates%ank_out(:ncol,:,:) = proc_rates%ank_out(:ncol,:,:)/num_steps + end if !-- TAU end do From be0b0c17d9cd9c35a76bbe2123a059a28d1cd551 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 20 Jan 2023 12:06:33 -0700 Subject: [PATCH 09/54] Update PUMAS external --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 1ef66e5bb4..fdf9942d73 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 571b4f4 +hash = 5e04788 required = True [pumas-frozen] From 934c91a6136b02903a12ca02b142e642f853c016 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 26 Jan 2023 10:03:15 -0700 Subject: [PATCH 10/54] Add stochastic_collect_tau_cam.F90 --- Externals_CAM.cfg | 2 +- .../cam/stochastic_collect_tau_cam.F90 | 774 ++++++++++++++++++ 2 files changed, 775 insertions(+), 1 deletion(-) create mode 100644 src/physics/cam/stochastic_collect_tau_cam.F90 diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index fdf9942d73..c13d69d38a 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 5e04788 +hash = a60ec55c required = True [pumas-frozen] diff --git a/src/physics/cam/stochastic_collect_tau_cam.F90 b/src/physics/cam/stochastic_collect_tau_cam.F90 new file mode 100644 index 0000000000..2645ef69a7 --- /dev/null +++ b/src/physics/cam/stochastic_collect_tau_cam.F90 @@ -0,0 +1,774 @@ +module stochastic_collect_tau_cam +! From Morrison (Lebo, originally TAU bin code) +! Gettelman and Chen 2018 +!the subroutines take in air density, air temperature, and the bin mass boundaries, and +!output the mass and number mixing ratio tendencies in each bin directly. +!this is then wrapped for CAM. + +! note, this is now coded locally. Want the CAM interface to be over i,k I think. + +#ifndef HAVE_GAMMA_INTRINSICS +use shr_spfn_mod, only: gamma => shr_spfn_gamma +#endif + +!use statements here +!use + +use shr_kind_mod, only: r8=>shr_kind_r8 +use cam_history, only: addfld +use micro_pumas_utils, only: pi, rhow, qsmall +use cam_logfile, only: iulog + +implicit none +private +save + +! Subroutines +public :: stochastic_kernel_init, stochastic_collect_tau_tend + + + +!In the module top, declare the following so that these can be used throughout the module: + +integer, parameter, public :: ncd = 35 +integer, parameter, public :: ncdp = ncd + 1 +integer, parameter, public :: ncdl = ncd +integer, parameter, public :: ncdpl = ncdl+1 + +!integer, private :: ncd,ncdp +!integer, private :: ncdl,ncdpl +!PARAMETER(ncd=35,ncdl=ncd) ! set number of ice and liquid bins +!PARAMETER(ncdp=ncd+1,ncdpl=ncdl+1) + +! for Zach's collision-coalescence code + + +real(r8), private :: knn(ncd,ncd) + +real(r8), public :: mmean(ncd), diammean(ncd) ! kg & m at bin mid-points +real(r8), public :: medge(ncdp), diamedge(ncdp) ! kg & m at bin edges +integer, private :: cutoff_id ! cutoff between cloud water and rain drop, D = 40 microns + +!=============================================================================== +contains +!=============================================================================== + + +subroutine calc_bins + +real(r8) :: DIAM(ncdp) +real(r8) :: X(ncdp) +real(r8) :: radsl(ncdp) +real(r8) :: radl(ncd) +integer :: L, lcl +real(r8) :: kkfac +!Then before doing any calculations you'll need to calculate the bin mass grid +! (note this code could be cleaned up, I'm just taking it as it's used in our bin scheme). +! This only needs to be done once, since we'll use the same bin mass grid for all calculations. + +! use mass doubling bins from Graham Feingold (note cgs units) + +! PI=3.14159_r8 +! rho_w=1000._r8 ! kg/m3 + DIAM(1)=1.5625*2.E-04_r8 ! cm + X(1)=PI/6._r8*DIAM(1)**3*rhow/1000._r8 ! rhow kg/m3 --> g/cm3 + radsl(1) = X(1) ! grams +! radsl(1) = X(1)/1000._r8 + + DO l=2,ncdp + X(l)=2._r8*X(l-1) + DIAM(l)=(6._r8/pi*X(l)*1000._r8/rhow)**(1._r8/3._r8) ! cm +! radsl(l)=X(l)/1000._r8 ! convert from g to kg + radsl(l)=X(l) + ENDDO + +! now get bin mid-points + + do l=1,ncd + radl(l)=(radsl(l)+radsl(l+1))/2._r8 ! grams +! diammean(l) = (DIAM(l)+DIAM(l+1))/2._r8 ! cm + diammean(l) = (6._r8/pi*radl(l)*1000._r8/rhow)**(1._r8/3._r8) ! cm + end do + +! set bin grid for method of moments + + ! for method of moments + + do lcl = 1,ncd+1 +! medge(lcl) = radsl(lcl)*1000._r8 ! convert to grams + medge(lcl) = radsl(lcl) ! grams + diamedge(lcl) = DIAM(lcl) ! cm + enddo + + do lcl = 1,ncd +! mmean(lcl) = radl(lcl)*1000._r8 + mmean(lcl) = radl(lcl) + diammean(lcl) = diammean(lcl) + enddo + + do lcl = ncdp,1,-1 + if( diamedge(lcl).ge.40.e-4_r8 ) cutoff_id = lcl + end do + + write(*,*) 'cutoff_id = ', cutoff_id + +end subroutine calc_bins + +subroutine stochastic_kernel_init + + use cam_history_support, only: add_hist_coord + + integer :: idd, jdd + real(r8) :: kkfac + + call calc_bins + + call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') + + call addfld('amk_c',(/'lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'lev','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'lev','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + + call addfld('scale_nc',(/'lev'/),'A','1','scaling factor for nc') + call addfld('scale_nr',(/'lev'/),'A','1','scaling factor for nr') + call addfld('scale_qc',(/'lev'/),'A','1','scaling factor for qc') + call addfld('scale_qr',(/'lev'/),'A','1','scaling factor for qr') + + call addfld('QC_TAU_in',(/'lev'/),'A','kg/kg','qc in TAU') + call addfld('NC_TAU_in',(/'lev'/),'A','1/kg','nc in TAU') + call addfld('QR_TAU_in',(/'lev'/),'A','kg/kg','qr in TAU') + call addfld('NR_TAU_in',(/'lev'/),'A','1/kg','nr in TAU') + call addfld('QC_TAU_out',(/'lev'/),'A','kg/kg','qc out TAU') + call addfld('NC_TAU_out',(/'lev'/),'A','1/kg','nc out TAU') + call addfld('QR_TAU_out',(/'lev'/),'A','kg/kg','qr out TAU') + call addfld('NR_TAU_out',(/'lev'/),'A','1/kg','nr out TAU') + + call addfld('qctend_MG2',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') + call addfld('nctend_MG2',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') + call addfld('qrtend_MG2',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') + call addfld('nrtend_MG2',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') + call addfld('qctend_TAU',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') + call addfld('nctend_TAU',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') + call addfld('qrtend_TAU',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') + call addfld('nrtend_TAU',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') + call addfld('qctend_TAU_diag',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') + call addfld('nctend_TAU_diag',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') + call addfld('qrtend_TAU_diag',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') + call addfld('nrtend_TAU_diag',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') + + call addfld('gmnnn_lmnnn_TAU',(/'lev'/),'A','1','sum of mass gain and loss from bin code') + call addfld('ML_fixer',(/'lev'/),'A','1','frequency of ML fixer is activated') + call addfld('qc_fixer',(/'lev'/),'A','kg/kg','delta qc due to ML fixer') + call addfld('nc_fixer',(/'lev'/),'A','kg/kg','delta nc due to ML fixer') + call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') + call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') + +! Read in the collection kernel code from a lookup table. Again, this only needs to be done once. +! use kernel from Zach (who got it from Jerry) + + KNN(:,:)=0._r8 ! initialize values + kkfac=1.5_r8 ! from Zach +!CACNOTE - Need to fix the opening and reading of this file + open(unit=40,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') + + 941 FORMAT(2X,E12.5) + + do idd=1,ncd + do jdd=1,idd + READ(40,941) KNN(IDD,JDD) +! KNN(IDD,JDD)=(XK_GR(IDD)*kkfac+XK_GR(JDD)*kkfac)*KNN(IDD,JDD) + KNN(IDD,JDD)=(mmean(IDD)*kkfac+mmean(JDD)*kkfac)*KNN(IDD,JDD) + + if (knn(idd,jdd).lt.0._r8) knn(idd,jdd)=0._r8 + + end do + end do + +end subroutine stochastic_kernel_init + +!main driver routine +!needs to pull in i,k fields (so might need dimensions here too) + +subroutine stochastic_collect_tau_tend(deltatin, t,rho, qc, qr, qcin,ncin,qrin,nrin, lcldm, precip_frac, & + mu_c, lambda_c, n0r, lambda_r, & + qcin_new,ncin_new,qrin_new,nrin_new, & + qctend,nctend,qrtend,nrtend,qctend_TAU,nctend_TAU,qrtend_TAU,nrtend_TAU, & + scale_qc,scale_nc,scale_qr,scale_nr, & + amk_c, ank_c, amk_r, ank_r, amk, ank, amk_out, ank_out, gmnnn_lmnnn_TAU, mgncol) + + +!use micro_pumas_utils, only: & +! mg_liq_props, & +! mg_rain_props + +!use micro_pumasmg_utils, only: & +! size_dist_param_liq, & +! size_dist_param_basic + +!inputs: mgncol,nlev,t,rho,qcin,ncin,qrin,nrin +!outputs: qctend,nctend,qrtend,nrtend +!not sure if we want to output bins (extra dimension). Good for testing? + +integer, intent(in) :: mgncol + +real(r8), intent(in) :: deltatin +real(r8), intent(in) :: t(mgncol) +real(r8), intent(in) :: rho(mgncol) +real(r8), intent(in) :: qc(mgncol) +real(r8), intent(in) :: qr(mgncol) +real(r8), intent(in) :: qcin(mgncol) +real(r8), intent(in) :: ncin(mgncol) +real(r8), intent(in) :: qrin(mgncol) +real(r8), intent(in) :: nrin(mgncol) +real(r8), intent(in) :: lcldm(mgncol) +real(r8), intent(in) :: precip_frac(mgncol) +real(r8), intent(inout) :: qctend(mgncol) +real(r8), intent(inout) :: nctend(mgncol) +real(r8), intent(inout) :: qrtend(mgncol) +real(r8), intent(inout) :: nrtend(mgncol) +real(r8), intent(out) :: qctend_TAU(mgncol) +real(r8), intent(out) :: nctend_TAU(mgncol) +real(r8), intent(out) :: qrtend_TAU(mgncol) +real(r8), intent(out) :: nrtend_TAU(mgncol) + +real(r8), intent(out) :: scale_qc(mgncol) +real(r8), intent(out) :: scale_nc(mgncol) +real(r8), intent(out) :: scale_qr(mgncol) +real(r8), intent(out) :: scale_nr(mgncol) + +real(r8), intent(out) :: amk_c(mgncol,ncd) +real(r8), intent(out) :: ank_c(mgncol,ncd) +real(r8), intent(out) :: amk_r(mgncol,ncd) +real(r8), intent(out) :: ank_r(mgncol,ncd) +real(r8), intent(out) :: amk(mgncol,ncd) +real(r8), intent(out) :: ank(mgncol,ncd) +real(r8), intent(out) :: amk_out(mgncol,ncd) +real(r8), intent(out) :: ank_out(mgncol,ncd) + +real(r8), intent(out) :: mu_c(mgncol) +real(r8), intent(out) :: lambda_c(mgncol) +real(r8), intent(out) :: lambda_r(mgncol) +real(r8), intent(out) :: n0r(mgncol) + +real(r8) :: amk0(mgncol,ncd) +real(r8) :: ank0(mgncol,ncd) +real(r8) :: gnnnn(ncd) +real(r8) :: gmnnn(ncd) +real(r8) :: lnnnn(ncd) +real(r8) :: lmnnn(ncd) +real(r8) :: gnnnn0(ncd) +real(r8) :: gmnnn0(ncd) +real(r8) :: lnnnn0(ncd) +real(r8) :: lmnnn0(ncd) + +real(r8), intent(out) :: qcin_new(mgncol) +real(r8), intent(out) :: ncin_new(mgncol) +real(r8), intent(out) :: qrin_new(mgncol) +real(r8), intent(out) :: nrin_new(mgncol) +real(r8), intent(out) :: gmnnn_lmnnn_TAU(mgncol) + +real(r8) :: qcin_old(mgncol) +real(r8) :: ncin_old(mgncol) +real(r8) :: qrin_old(mgncol) +real(r8) :: nrin_old(mgncol) + +integer :: i, n, lcl, cutoff_amk, cutoff(mgncol) + +real(r8) :: all_gmnnn, all_lmnnn + +integer, parameter :: sub_step = 60 + +cutoff = cutoff_id-1 + + +!write(iulog,*) 'TAU time step = ', deltatin + +!do k = 1,nlev +!call size_dist_param_liq(mg_liq_props, qcin, ncin, rho, mu_c, lambda_c, mgncol) +!call size_dist_param_basic(mg_rain_props, qrin, nrin, lambda_r, mgncol, n0=n0r) +!end do + +! First make bins from cam size distribution (bins are diagnostic) + +!call cam_bin_distribute(qcin,ncin,qrin,nrin,medge,amk,ank) +do i=1,mgncol +!do k=1,nlev + call cam_bin_distribute(qc(i), qr(i), qcin(i),ncin(i),qrin(i),nrin(i), & + mu_c(i),lambda_c(i),lambda_r(i),n0r(i), lcldm(i), precip_frac(i), & + scale_qc(i), scale_nc(i), scale_qr(i), scale_nr(i), & + amk_c(i,1:ncd),ank_c(i,1:ncd), amk_r(i,1:ncd), ank_r(i,1:ncd), amk(i,1:ncd), ank(i,1:ncd), cutoff_amk) +!end do + if( cutoff_amk.gt.0 ) then + cutoff(i) = cutoff_amk + end if +! cutoff(i) = cutoff_id-1 +end do + +!Then call the subroutines that actually do the calculations. The inputs/ouputs are described in comments below. + +!This part of the code needs to be called each time for each process rate calculation +! (i.e., for each sampled cloud/rain gamma distribution): + +! note: variables passed to compute_column_params are all inputs, +! outputs from this subroutine are stored as global variables + +! inputs: t --> input air temperature (K) +! rho --> input air density (kg/m^3) +! medge --> bin mass boundary (g) +! amk --> array of bin mass mixing ratio, i.e., the input drop mass distribution (kg/kg) +! ank --> array of bin number mixing ratio, i.e., the input drop number distribution (kg^-1) + +! inputs: medge --> bin mass boundary (g), same as above + +! outputs: gnnnn --> bin number mass mixing tendency gain, array in bins (#/cm^3/s) +! lnnnn --> bin number mass mixing tendency loss, array in bins (#/cm^3/s) +! gmnnn --> bin mass mixing ratio tendency gain, array in bins (g/cm^3/s) +! lmnnn --> bin mass mixing ratio tendency loss, array in bins (g/cm^3/s) + + +! Call Kernel + +!do i=1,mgncol +!do k=1,nlev +! call do_nn_n(gnnnn(i,:),gmnnn(i,:),lnnnn(i,:),lmnnn(i,:),medge) +!end do +!end do + +qcin_new = 0._r8 +ncin_new = 0._r8 +qrin_new = 0._r8 +nrin_new = 0._r8 + +qcin_old = 0._r8 +ncin_old = 0._r8 +qrin_old = 0._r8 +nrin_old = 0._r8 + +qctend_TAU = 0._r8 +nctend_TAU = 0._r8 +qrtend_TAU = 0._r8 +nrtend_TAU = 0._r8 + +amk0 = amk +ank0 = ank + +! update qc, nc, qr, nr +do i=1,mgncol + +gnnnn = 0._r8 +gmnnn = 0._r8 +lnnnn = 0._r8 +lmnnn = 0._r8 + +! substep bin code +do n=1,sub_step + call compute_coll_params(rho(i),medge,amk0(i,1:ncd),ank0(i,1:ncd),gnnnn0,gmnnn0,lnnnn0,lmnnn0) + + all_gmnnn=0._r8 + all_lmnnn=0._r8 +! scaling gmnnn, lmnnn + do lcl=1,ncd + all_gmnnn = all_gmnnn+gmnnn0(lcl) + all_lmnnn = all_lmnnn+lmnnn0(lcl) + end do + + if( (all_gmnnn.eq.0._r8).or.(all_lmnnn.eq.0._r8) ) then + gmnnn0(:) = 0._r8 + lmnnn0(:) = 0._r8 + else + lmnnn0 = lmnnn0*(all_gmnnn/all_lmnnn) + end if + + do lcl=1,ncd + amk0(i,lcl) = amk0(i,lcl)+(gmnnn0(lcl)-lmnnn0(lcl))*1.e3_r8/rho(i)*deltatin/dble(sub_step) + ank0(i,lcl) = ank0(i,lcl)+(gnnnn0(lcl)-lnnnn0(lcl))*1.e6_r8/rho(i)*deltatin/dble(sub_step) + + gmnnn(lcl) = gmnnn(lcl)+gmnnn0(lcl)/sub_step + gnnnn(lcl) = gnnnn(lcl)+gnnnn0(lcl)/sub_step + lmnnn(lcl) = lmnnn(lcl)+lmnnn0(lcl)/sub_step + lnnnn(lcl) = lnnnn(lcl)+lnnnn0(lcl)/sub_step + end do + +end do + + ! cloud water + do lcl = 1,cutoff(i) + qcin_old(i) = qcin_old(i)+amk(i,lcl) + ncin_old(i) = ncin_old(i)+ank(i,lcl) + qcin_new(i) = qcin_new(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i)*deltatin + ncin_new(i) = ncin_new(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i)*deltatin + +! qctend_TAU(i) = qctend_TAU(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i) +! nctend_TAU(i) = nctend_TAU(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i) + qctend_TAU(i) = qctend_TAU(i)+(amk0(i,lcl)-amk(i,lcl))/deltatin + nctend_TAU(i) = nctend_TAU(i)+(ank0(i,lcl)-ank(i,lcl))/deltatin + + gmnnn_lmnnn_TAU(i) = gmnnn_lmnnn_TAU(i)+gmnnn(lcl)-lmnnn(lcl) + end do + ! rain + do lcl = cutoff(i)+1, ncd + qrin_old(i) = qrin_old(i)+amk(i,lcl) + nrin_old(i) = nrin_old(i)+ank(i,lcl) + qrin_new(i) = qrin_new(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i)*deltatin + nrin_new(i) = nrin_new(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i)*deltatin + +! qrtend_TAU(i) = qrtend_TAU(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i) +! nrtend_TAU(i) = nrtend_TAU(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i) + qrtend_TAU(i) = qrtend_TAU(i)+(amk0(i,lcl)-amk(i,lcl))/deltatin + nrtend_TAU(i) = nrtend_TAU(i)+(ank0(i,lcl)-ank(i,lcl))/deltatin + gmnnn_lmnnn_TAU(i) = gmnnn_lmnnn_TAU(i)+gmnnn(lcl)-lmnnn(lcl) + end do + + do lcl = 1,ncd + amk_out(i,lcl) = amk(i,lcl) + (gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i)*deltatin + ank_out(i,lcl) = ank(i,lcl) + (gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i)*deltatin + end do + + qcin_new(i) = qcin_new(i)+qcin_old(i) + ncin_new(i) = ncin_new(i)+ncin_old(i) + qrin_new(i) = qrin_new(i)+qrin_old(i) + nrin_new(i) = nrin_new(i)+nrin_old(i) +end do + + +end subroutine stochastic_collect_tau_tend + + +subroutine cam_bin_distribute(qc_all, qr_all, qc,nc,qr,nr,mu_c,lambda_c,lambda_r,n0r, & + lcldm, precip_frac, scale_qc, scale_nc, scale_qr, scale_nr, & + amk_c,ank_c, amk_r, ank_r, amk, ank, cutoff_amk) + +real(r8) :: qc_all, qr_all, qc, nc, qr, nr, mu_c, lambda_c, lambda_r, n0r, lcldm, precip_frac +real(r8), dimension(ncd) :: amk_c, ank_c, amk_r, ank_r, amk, ank +integer :: i +real(r8) :: phi +real(r8) :: scale_nc, scale_qc, scale_nr, scale_qr + +integer :: id_max_qc, id_max_qr, cutoff_amk +real(r8) :: max_qc, max_qr, min_amk + +ank_c = 0._r8 +amk_c = 0._r8 +ank_r = 0._r8 +amk_r = 0._r8 +ank = 0._r8 +amk = 0._r8 + +scale_nc = 0._r8 +scale_qc = 0._r8 +scale_nr = 0._r8 +scale_qr = 0._r8 + +id_max_qc = 0 +id_max_qr = 0 +cutoff_amk = 0 +max_qc = 0._r8 +max_qr = 0._r8 + +! cloud water, nc in #/m3 --> #/cm3 +if( (qc_all.gt.qsmall).and.(qc.gt.qsmall) ) then +do i = 1,ncd + phi = nc*lambda_c**(mu_c+1._r8)/gamma(mu_c+1._r8)*(diammean(i)*1.e-2_r8)**mu_c*exp(-lambda_c*diammean(i)*1.e-2_r8) ! D cm --> m + ank_c(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8 ! D cm --> m + amk_c(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8*mmean(i)*1.e-3_r8 ! mass in bin g --> kg + + scale_nc = scale_nc+ank_c(i) + scale_qc = scale_qc+amk_c(i) +end do + +scale_nc = scale_nc/nc +scale_qc = scale_qc/qc + +ank_c = ank_c/scale_nc*lcldm +amk_c = amk_c/scale_qc*lcldm +!ank_c = ank_c*lcldm +!amk_c = amk_c*lcldm + +do i=1,ncd + if( amk_c(i).gt.max_qc ) then + id_max_qc = i + max_qc = amk_c(i) + end if +end do + +!else + +!do i=1,ncd +! ank_c(i) = 0._r8 +! amk_c(i) = 0._r8 +!end do + +end if + +! rain drop +if( (qr_all.gt.qsmall).and.(qr.gt.qsmall) ) then +do i = 1,ncd + phi = n0r*exp(-lambda_r*diammean(i)*1.e-2_r8) ! D cm --> m + ank_r(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8 ! D cm --> m + amk_r(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8*mmean(i)*1.e-3_r8 + + scale_nr = scale_nr + ank_r(i) + scale_qr = scale_qr + amk_r(i) +end do + +scale_nr = scale_nr/nr +scale_qr = scale_qr/qr + +ank_r = ank_r/scale_nr*precip_frac +amk_r = amk_r/scale_qr*precip_frac +!ank_r = ank_r*precip_frac +!amk_r = amk_r*precip_frac + +!else + +!do i=1,ncd +! ank_r(i) = 0._r8 +! amk_r(i) = 0._r8 +!end do + +do i=1,ncd + if( amk_r(i).gt.max_qr ) then + id_max_qr = i + max_qr = amk_r(i) + end if +end do + +end if + +amk = amk_c + amk_r +ank = ank_c + ank_r + + +if( (id_max_qc.gt.0).and.(id_max_qr.gt.0) ) then + if( (max_qc/max_qr.lt.10._r8).or.(max_qc/max_qr.gt.0.1_r8) )then + min_amk = amk(id_max_qc) + + do i=id_max_qc,id_max_qr + if( amk(i).le.min_amk ) then + cutoff_amk = i + min_amk = amk(i) + end if + end do + end if +end if + + +!if( qc_all.gt.qsmall.OR.qr_all.gt.qsmall ) then +! do i=1,ncd +! ank(i) = ank_c(i) + ank_r(i) +! amk(i) = amk_c(i) + amk_r(i) +! end do +!else +! do i=1,ncd +! amk(i) = 0._r8 +! ank(i) = 0._r8 +! end do +!end if +!input: qc,nc,qr,nr, medge (bin edges). May also need # bins? +!output: amk, ank (mixing ratio and number in each bin) + +!this part will take a bit of thinking about. +!use size distribution parameters (mu, lambda) to generate the values at discrete size points +!need to also ensure mass conservation + + +end subroutine cam_bin_distribute + + +! here are the subroutines called above that actually do the collision-coalescence calculations: + +! The Kernel is from Jerry from many moons ago (included) + +! I read in the file data and multiply by the summed mass of the individual bins +! (with a factor of 1.5 so that the values represent the middle of the bin + +! 941 FORMAT(2X,E12.5) +! READ(40,941) KNN(IDD,JDD) +! KNN(IDD,JDD)=(XK_GR(IDD)*kkfac+XK_GR(JDD)*kkfac)*KNN(IDD,JDD) + +!where idd and jdd are the indexes for the bins and xk_gr is the mass of drops in a bin in grams +! + +!************************************************************************************ +! Setup variables needed for collection +! Either pass in or define globally the following variables +! tbase(height) - temperature in K as a function of height +! rhon(height) - air density as a function of height in kg/m^3 +! xk_gr(bins) - mass of single drop in each bin in grams +! lsmall - small number +! QC - mass mixing ratio in kg/kg +! QN - number mixing ratio in #/kg +! All parameters are defined to be global in my version so that they are readily available throughout the code: +! SMN0,SNN0,SMCN,APN,AMN2,AMN3,PSIN,FN,FPSIN,XPSIN,HPSIN,FN2,XXPSIN (all arrays of drop bins) +!************************************************************************************ + +!AG: Global arrays need to be passed around I think? Right now at the module level. Is that okay? + +SUBROUTINE COMPUTE_COLL_PARAMS(rhon,xk_gr,qc,qn,gnnnn,gmnnn,lnnnn,lmnnn) + IMPLICIT NONE + +! variable declarations (added by hm, 020118) +! note: vertical array looping is stripped out, this subroutine operates +! only on LOCAL values + + real(r8), dimension(ncd) :: qc,qn + real(r8), dimension(ncdp) :: xk_gr + real(r8) :: tbase,rhon +! real(r8) :: TAIRC,UMMS,UMMS2 + integer :: lk + integer :: l + real(r8), parameter :: lsmall = 1.e-12_r8 + real(r8), dimension(ncd) :: smn0,snn0,smcn,amn2,amn3,psin,fn,fpsin, & + xpsin,hpsin,fn2,xxpsin + real(r8) :: apn + + real(r8), dimension(ncd) :: gnnnn,gmnnn,lnnnn,lmnnn + integer :: lm1,ll + + lk=ncd + + + +!.................................................................................... +! TAIRC=TBASE(K)-273.15 +! TAIRC=TBASE-273.15_r8 +! UMMS=UMM(TAIRC) +!! UMMS2=UMMS*4.66/(RHON(K)/1.E3) +!! UMMS=UMMS/(RHON(K)/1.E3) +! UMMS2=UMMS*4.66_r8/(RHON/1.E3_r8) +! UMMS=UMMS/(RHON/1.E3_r8) + + DO L=1,LK +! SMN0(L)=QC(L,K)*RHON(K)/1.E3 +! SNN0(L)=QN(L,K)*RHON(K)/1.E6 + SMN0(L)=QC(L)*RHON/1.E3_r8 + SNN0(L)=QN(L)*RHON/1.E6_r8 + + IF(SMN0(L).LT.lsmall.OR.SNN0(L).LT.lsmall)THEN + SMN0(L)=0.0_r8 + SNN0(L)=0.0_r8 + ENDIF + ENDDO + + DO L=1,LK + IF(SMN0(L) .gt. 0._r8.AND.SNN0(L) .gt. 0._r8)THEN + SMCN(L)=SMN0(L)/SNN0(L) + IF((SMCN(L) .GT. 2._r8*XK_GR(L)))THEN +! SMCN(L) = (2*XK_GR(L)) + SMCN(L) = (2._r8*XK_GR(L)) + ENDIF + IF((SMCN(L) .LT. XK_GR(L)))THEN + SMCN(L) = XK_GR(L) + ENDIF + ELSE + SMCN(L)=0._r8 + ENDIF + IF (SMCN(L).LT.XK_GR(L).OR.SMCN(L).GT.(2._r8*XK_GR(L)).OR.SMCN(L).EQ.0.0_r8)THEN + APN=1.0_r8 + ELSE +! APN=0.5*(1.+3.*(XK_GR(L)/SMCN(L))-2*((XK_GR(L)/SMCN(L))**2.)) + APN=0.5_r8*(1._r8+3._r8*(XK_GR(L)/SMCN(L))-2._r8*((XK_GR(L)/SMCN(L))**2._r8)) + ENDIF + + IF(SNN0(L) .GT. LSMALL)THEN + AMN2(L)=APN*SMN0(L)*SMN0(L)/SNN0(L) + AMN3(L)=APN*APN*APN*SMN0(L)*SMN0(L)*SMN0(L)/(SNN0(L)*SNN0(L)) + ELSE + AMN2(L)=0._r8 + AMN3(L)=0._r8 + ENDIF + + IF(SMCN(L).LT.XK_GR(L))THEN + PSIN(L)=0.0_r8 + FN(L)=2._r8*SNN0(L)/XK_GR(L) + ELSE + IF(SMCN(L).GT.(2._r8*XK_GR(L)))THEN + FN(L)=0.0_r8 + PSIN(L)=2._r8*SNN0(L)/XK_GR(L) + ELSE + PSIN(L)=2._r8/XK_GR(L)*(SMN0(L)/XK_GR(L)-SNN0(L)) + FN(L)=2._r8/XK_GR(L)*(2._r8*SNN0(L)-SMN0(L)/XK_GR(L)) + ENDIF + ENDIF + + IF(SNN0(L).LT.LSMALL.OR.SMN0(L).LT.LSMALL)THEN + PSIN(L)=0.0_r8 + FN(L)=0.0_r8 + ENDIF + + FPSIN(L)=0.5_r8/XK_GR(L)*(PSIN(L)-FN(L)) + XPSIN(L)=2._r8*XK_GR(L)*PSIN(L) + HPSIN(L)=PSIN(L)-0.5_r8*FN(L) + FN2(L)=FN(L)/2._r8 + + IF(L.GT.1)THEN + XXPSIN(L)=XK_GR(L)*PSIN(L-1) + ENDIF + ENDDO + +!************************************************************************************ +! Compute collision coalescence +! Either pass in or define globally the following variables +! Gain terms begin with G, loss terms begin with L +! Second letter defines mass (M) or number (N) +! Third and fourth letters define the types of particles colling, i.e., NN means drops colliding with drops +! Last letter defines the category the new particles go into, in this case just N for liquid drops +! The resulting rates are in units of #/cm^3/s and g/cm^3/s +! Relies on predefined kernel array KNN(bins,bins) - see top of this file +!************************************************************************************ + + GMNNN = 0._r8 + GNNNN = 0._r8 + LMNNN = 0._r8 + LNNNN = 0._r8 +! remove verical array index, calculate gain/loss terms locally + + DO L=3,LK-1 + LM1=L-1 + DO LL=1,L-2 +! GNNNN(L,K)=GNNNN(L,K)+(PSIN(LM1)*SMN0(LL)-FPSIN(LM1)*AMN2(LL))*KNN(LM1,LL) +! GMNNN(L,K)=GMNNN(L,K)+(XK_GR(L)*PSIN(LM1)*SMN0(LL)+FN2(LM1)*AMN2(LL)-FPSIN(LM1)*AMN3(LL))*KNN(LM1,LL) + GNNNN(L)=GNNNN(L)+(PSIN(LM1)*SMN0(LL)-FPSIN(LM1)*AMN2(LL))*KNN(LM1,LL) + GMNNN(L)=GMNNN(L)+(XK_GR(L)*PSIN(LM1)*SMN0(LL)+FN2(LM1)*AMN2(LL)-FPSIN(LM1)*AMN3(LL))*KNN(LM1,LL) + ENDDO + ENDDO + + DO L=2,LK-1 + LM1=L-1 + GNNNN(L)=GNNNN(L)+0.5_r8*SNN0(LM1)*SNN0(LM1)*KNN(LM1,LM1) + GMNNN(L)=GMNNN(L)+0.5_r8*(SNN0(LM1)*SMN0(LM1)+SMN0(LM1)*SNN0(LM1))*KNN(LM1,LM1) + DO LL=1,L-1 +! LNNNN(L,K)=LNNNN(L,K)+(PSIN(L)*SMN0(LL)-FPSIN(L)*AMN2(LL))*KNN(L,LL) +! GMNNN(L,K)=GMNNN(L,K)+(SMN0(LL)*SNN0(L)-PSIN(L)*AMN2(LL)+FPSIN(L)*AMN3(LL))*KNN(L,LL) +! LMNNN(L,K)=LMNNN(L,K)+(XPSIN(L)*SMN0(LL)-HPSIN(L)*AMN2(LL))*KNN(L,LL) + LNNNN(L)=LNNNN(L)+(PSIN(L)*SMN0(LL)-FPSIN(L)*AMN2(LL))*KNN(L,LL) + GMNNN(L)=GMNNN(L)+(SMN0(LL)*SNN0(L)-PSIN(L)*AMN2(LL)+FPSIN(L)*AMN3(LL))*KNN(L,LL) + LMNNN(L)=LMNNN(L)+(XPSIN(L)*SMN0(LL)-HPSIN(L)*AMN2(LL))*KNN(L,LL) + ENDDO + ENDDO + + DO L=1,LK-1 + DO LL=L,LK-1 +! LNNNN(L,K)=LNNNN(L,K)+(SNN0(LL)*SNN0(L))*KNN(LL,L) +! LMNNN(L,K)=LMNNN(L,K)+(SNN0(LL)*SMN0(L))*KNN(LL,L) + LNNNN(L)=LNNNN(L)+(SNN0(LL)*SNN0(L))*KNN(LL,L) + LMNNN(L)=LMNNN(L)+(SNN0(LL)*SMN0(L))*KNN(LL,L) + ENDDO + ENDDO + + + + +END SUBROUTINE COMPUTE_COLL_PARAMS + + + + +end module stochastic_collect_tau_cam + + From eaf9fdce25ab02608997a55df9b20e350eaf3845 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Mon, 30 Jan 2023 10:37:59 -0700 Subject: [PATCH 11/54] Separate stochastic module into CAM and PUMAS specific and introduce CAM's version --- Externals_CAM.cfg | 2 +- .../cam/stochastic_collect_tau_cam.F90 | 693 +----------------- src/physics/cam_dev/micro_pumas_cam.F90 | 8 +- 3 files changed, 24 insertions(+), 679 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index c13d69d38a..b01c3f5d46 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = a60ec55c +hash = 1f2ea0a required = True [pumas-frozen] diff --git a/src/physics/cam/stochastic_collect_tau_cam.F90 b/src/physics/cam/stochastic_collect_tau_cam.F90 index 2645ef69a7..eac8980213 100644 --- a/src/physics/cam/stochastic_collect_tau_cam.F90 +++ b/src/physics/cam/stochastic_collect_tau_cam.F90 @@ -24,7 +24,7 @@ module stochastic_collect_tau_cam save ! Subroutines -public :: stochastic_kernel_init, stochastic_collect_tau_tend +public :: stochastic_kernel_init_cam @@ -53,86 +53,29 @@ module stochastic_collect_tau_cam contains !=============================================================================== - -subroutine calc_bins +!CACNOTE - Is this a good name for this routine still (just doing addfld calls) +subroutine stochastic_kernel_init_cam -real(r8) :: DIAM(ncdp) -real(r8) :: X(ncdp) -real(r8) :: radsl(ncdp) -real(r8) :: radl(ncd) -integer :: L, lcl -real(r8) :: kkfac -!Then before doing any calculations you'll need to calculate the bin mass grid -! (note this code could be cleaned up, I'm just taking it as it's used in our bin scheme). -! This only needs to be done once, since we'll use the same bin mass grid for all calculations. + use cam_history_support, only: add_hist_coord + use pumas_stochastic_collect_tau, only: pumas_stochastic_kernel_init -! use mass doubling bins from Graham Feingold (note cgs units) + integer :: iunit ! unit number of opened file for collection kernel code from a lookup table. -! PI=3.14159_r8 -! rho_w=1000._r8 ! kg/m3 - DIAM(1)=1.5625*2.E-04_r8 ! cm - X(1)=PI/6._r8*DIAM(1)**3*rhow/1000._r8 ! rhow kg/m3 --> g/cm3 - radsl(1) = X(1) ! grams -! radsl(1) = X(1)/1000._r8 - - DO l=2,ncdp - X(l)=2._r8*X(l-1) - DIAM(l)=(6._r8/pi*X(l)*1000._r8/rhow)**(1._r8/3._r8) ! cm -! radsl(l)=X(l)/1000._r8 ! convert from g to kg - radsl(l)=X(l) - ENDDO - -! now get bin mid-points - - do l=1,ncd - radl(l)=(radsl(l)+radsl(l+1))/2._r8 ! grams -! diammean(l) = (DIAM(l)+DIAM(l+1))/2._r8 ! cm - diammean(l) = (6._r8/pi*radl(l)*1000._r8/rhow)**(1._r8/3._r8) ! cm - end do - -! set bin grid for method of moments - - ! for method of moments - - do lcl = 1,ncd+1 -! medge(lcl) = radsl(lcl)*1000._r8 ! convert to grams - medge(lcl) = radsl(lcl) ! grams - diamedge(lcl) = DIAM(lcl) ! cm - enddo - - do lcl = 1,ncd -! mmean(lcl) = radl(lcl)*1000._r8 - mmean(lcl) = radl(lcl) - diammean(lcl) = diammean(lcl) - enddo - - do lcl = ncdp,1,-1 - if( diamedge(lcl).ge.40.e-4_r8 ) cutoff_id = lcl - end do - - write(*,*) 'cutoff_id = ', cutoff_id - -end subroutine calc_bins - -subroutine stochastic_kernel_init - - use cam_history_support, only: add_hist_coord - - integer :: idd, jdd - real(r8) :: kkfac +!CACNOTE - Need to fix the opening and reading of this file + open(unit=40,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') - call calc_bins + call pumas_stochastic_kernel_init(iunit) call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') - call addfld('amk_c',(/'lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_c',(/'lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk',(/'lev','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank',(/'lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - call addfld('amk_out',(/'lev','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank_out',(/'lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_c',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') call addfld('scale_nc',(/'lev'/),'A','1','scaling factor for nc') call addfld('scale_nr',(/'lev'/),'A','1','scaling factor for nr') @@ -168,607 +111,7 @@ subroutine stochastic_kernel_init call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') -! Read in the collection kernel code from a lookup table. Again, this only needs to be done once. -! use kernel from Zach (who got it from Jerry) - - KNN(:,:)=0._r8 ! initialize values - kkfac=1.5_r8 ! from Zach -!CACNOTE - Need to fix the opening and reading of this file - open(unit=40,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') - - 941 FORMAT(2X,E12.5) - - do idd=1,ncd - do jdd=1,idd - READ(40,941) KNN(IDD,JDD) -! KNN(IDD,JDD)=(XK_GR(IDD)*kkfac+XK_GR(JDD)*kkfac)*KNN(IDD,JDD) - KNN(IDD,JDD)=(mmean(IDD)*kkfac+mmean(JDD)*kkfac)*KNN(IDD,JDD) - - if (knn(idd,jdd).lt.0._r8) knn(idd,jdd)=0._r8 - - end do - end do - -end subroutine stochastic_kernel_init - -!main driver routine -!needs to pull in i,k fields (so might need dimensions here too) - -subroutine stochastic_collect_tau_tend(deltatin, t,rho, qc, qr, qcin,ncin,qrin,nrin, lcldm, precip_frac, & - mu_c, lambda_c, n0r, lambda_r, & - qcin_new,ncin_new,qrin_new,nrin_new, & - qctend,nctend,qrtend,nrtend,qctend_TAU,nctend_TAU,qrtend_TAU,nrtend_TAU, & - scale_qc,scale_nc,scale_qr,scale_nr, & - amk_c, ank_c, amk_r, ank_r, amk, ank, amk_out, ank_out, gmnnn_lmnnn_TAU, mgncol) - - -!use micro_pumas_utils, only: & -! mg_liq_props, & -! mg_rain_props - -!use micro_pumasmg_utils, only: & -! size_dist_param_liq, & -! size_dist_param_basic - -!inputs: mgncol,nlev,t,rho,qcin,ncin,qrin,nrin -!outputs: qctend,nctend,qrtend,nrtend -!not sure if we want to output bins (extra dimension). Good for testing? - -integer, intent(in) :: mgncol - -real(r8), intent(in) :: deltatin -real(r8), intent(in) :: t(mgncol) -real(r8), intent(in) :: rho(mgncol) -real(r8), intent(in) :: qc(mgncol) -real(r8), intent(in) :: qr(mgncol) -real(r8), intent(in) :: qcin(mgncol) -real(r8), intent(in) :: ncin(mgncol) -real(r8), intent(in) :: qrin(mgncol) -real(r8), intent(in) :: nrin(mgncol) -real(r8), intent(in) :: lcldm(mgncol) -real(r8), intent(in) :: precip_frac(mgncol) -real(r8), intent(inout) :: qctend(mgncol) -real(r8), intent(inout) :: nctend(mgncol) -real(r8), intent(inout) :: qrtend(mgncol) -real(r8), intent(inout) :: nrtend(mgncol) -real(r8), intent(out) :: qctend_TAU(mgncol) -real(r8), intent(out) :: nctend_TAU(mgncol) -real(r8), intent(out) :: qrtend_TAU(mgncol) -real(r8), intent(out) :: nrtend_TAU(mgncol) - -real(r8), intent(out) :: scale_qc(mgncol) -real(r8), intent(out) :: scale_nc(mgncol) -real(r8), intent(out) :: scale_qr(mgncol) -real(r8), intent(out) :: scale_nr(mgncol) - -real(r8), intent(out) :: amk_c(mgncol,ncd) -real(r8), intent(out) :: ank_c(mgncol,ncd) -real(r8), intent(out) :: amk_r(mgncol,ncd) -real(r8), intent(out) :: ank_r(mgncol,ncd) -real(r8), intent(out) :: amk(mgncol,ncd) -real(r8), intent(out) :: ank(mgncol,ncd) -real(r8), intent(out) :: amk_out(mgncol,ncd) -real(r8), intent(out) :: ank_out(mgncol,ncd) - -real(r8), intent(out) :: mu_c(mgncol) -real(r8), intent(out) :: lambda_c(mgncol) -real(r8), intent(out) :: lambda_r(mgncol) -real(r8), intent(out) :: n0r(mgncol) - -real(r8) :: amk0(mgncol,ncd) -real(r8) :: ank0(mgncol,ncd) -real(r8) :: gnnnn(ncd) -real(r8) :: gmnnn(ncd) -real(r8) :: lnnnn(ncd) -real(r8) :: lmnnn(ncd) -real(r8) :: gnnnn0(ncd) -real(r8) :: gmnnn0(ncd) -real(r8) :: lnnnn0(ncd) -real(r8) :: lmnnn0(ncd) - -real(r8), intent(out) :: qcin_new(mgncol) -real(r8), intent(out) :: ncin_new(mgncol) -real(r8), intent(out) :: qrin_new(mgncol) -real(r8), intent(out) :: nrin_new(mgncol) -real(r8), intent(out) :: gmnnn_lmnnn_TAU(mgncol) - -real(r8) :: qcin_old(mgncol) -real(r8) :: ncin_old(mgncol) -real(r8) :: qrin_old(mgncol) -real(r8) :: nrin_old(mgncol) - -integer :: i, n, lcl, cutoff_amk, cutoff(mgncol) - -real(r8) :: all_gmnnn, all_lmnnn - -integer, parameter :: sub_step = 60 - -cutoff = cutoff_id-1 - - -!write(iulog,*) 'TAU time step = ', deltatin - -!do k = 1,nlev -!call size_dist_param_liq(mg_liq_props, qcin, ncin, rho, mu_c, lambda_c, mgncol) -!call size_dist_param_basic(mg_rain_props, qrin, nrin, lambda_r, mgncol, n0=n0r) -!end do - -! First make bins from cam size distribution (bins are diagnostic) - -!call cam_bin_distribute(qcin,ncin,qrin,nrin,medge,amk,ank) -do i=1,mgncol -!do k=1,nlev - call cam_bin_distribute(qc(i), qr(i), qcin(i),ncin(i),qrin(i),nrin(i), & - mu_c(i),lambda_c(i),lambda_r(i),n0r(i), lcldm(i), precip_frac(i), & - scale_qc(i), scale_nc(i), scale_qr(i), scale_nr(i), & - amk_c(i,1:ncd),ank_c(i,1:ncd), amk_r(i,1:ncd), ank_r(i,1:ncd), amk(i,1:ncd), ank(i,1:ncd), cutoff_amk) -!end do - if( cutoff_amk.gt.0 ) then - cutoff(i) = cutoff_amk - end if -! cutoff(i) = cutoff_id-1 -end do - -!Then call the subroutines that actually do the calculations. The inputs/ouputs are described in comments below. - -!This part of the code needs to be called each time for each process rate calculation -! (i.e., for each sampled cloud/rain gamma distribution): - -! note: variables passed to compute_column_params are all inputs, -! outputs from this subroutine are stored as global variables - -! inputs: t --> input air temperature (K) -! rho --> input air density (kg/m^3) -! medge --> bin mass boundary (g) -! amk --> array of bin mass mixing ratio, i.e., the input drop mass distribution (kg/kg) -! ank --> array of bin number mixing ratio, i.e., the input drop number distribution (kg^-1) - -! inputs: medge --> bin mass boundary (g), same as above - -! outputs: gnnnn --> bin number mass mixing tendency gain, array in bins (#/cm^3/s) -! lnnnn --> bin number mass mixing tendency loss, array in bins (#/cm^3/s) -! gmnnn --> bin mass mixing ratio tendency gain, array in bins (g/cm^3/s) -! lmnnn --> bin mass mixing ratio tendency loss, array in bins (g/cm^3/s) - - -! Call Kernel - -!do i=1,mgncol -!do k=1,nlev -! call do_nn_n(gnnnn(i,:),gmnnn(i,:),lnnnn(i,:),lmnnn(i,:),medge) -!end do -!end do - -qcin_new = 0._r8 -ncin_new = 0._r8 -qrin_new = 0._r8 -nrin_new = 0._r8 - -qcin_old = 0._r8 -ncin_old = 0._r8 -qrin_old = 0._r8 -nrin_old = 0._r8 - -qctend_TAU = 0._r8 -nctend_TAU = 0._r8 -qrtend_TAU = 0._r8 -nrtend_TAU = 0._r8 - -amk0 = amk -ank0 = ank - -! update qc, nc, qr, nr -do i=1,mgncol - -gnnnn = 0._r8 -gmnnn = 0._r8 -lnnnn = 0._r8 -lmnnn = 0._r8 - -! substep bin code -do n=1,sub_step - call compute_coll_params(rho(i),medge,amk0(i,1:ncd),ank0(i,1:ncd),gnnnn0,gmnnn0,lnnnn0,lmnnn0) - - all_gmnnn=0._r8 - all_lmnnn=0._r8 -! scaling gmnnn, lmnnn - do lcl=1,ncd - all_gmnnn = all_gmnnn+gmnnn0(lcl) - all_lmnnn = all_lmnnn+lmnnn0(lcl) - end do - - if( (all_gmnnn.eq.0._r8).or.(all_lmnnn.eq.0._r8) ) then - gmnnn0(:) = 0._r8 - lmnnn0(:) = 0._r8 - else - lmnnn0 = lmnnn0*(all_gmnnn/all_lmnnn) - end if - - do lcl=1,ncd - amk0(i,lcl) = amk0(i,lcl)+(gmnnn0(lcl)-lmnnn0(lcl))*1.e3_r8/rho(i)*deltatin/dble(sub_step) - ank0(i,lcl) = ank0(i,lcl)+(gnnnn0(lcl)-lnnnn0(lcl))*1.e6_r8/rho(i)*deltatin/dble(sub_step) - - gmnnn(lcl) = gmnnn(lcl)+gmnnn0(lcl)/sub_step - gnnnn(lcl) = gnnnn(lcl)+gnnnn0(lcl)/sub_step - lmnnn(lcl) = lmnnn(lcl)+lmnnn0(lcl)/sub_step - lnnnn(lcl) = lnnnn(lcl)+lnnnn0(lcl)/sub_step - end do - -end do - - ! cloud water - do lcl = 1,cutoff(i) - qcin_old(i) = qcin_old(i)+amk(i,lcl) - ncin_old(i) = ncin_old(i)+ank(i,lcl) - qcin_new(i) = qcin_new(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i)*deltatin - ncin_new(i) = ncin_new(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i)*deltatin - -! qctend_TAU(i) = qctend_TAU(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i) -! nctend_TAU(i) = nctend_TAU(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i) - qctend_TAU(i) = qctend_TAU(i)+(amk0(i,lcl)-amk(i,lcl))/deltatin - nctend_TAU(i) = nctend_TAU(i)+(ank0(i,lcl)-ank(i,lcl))/deltatin - - gmnnn_lmnnn_TAU(i) = gmnnn_lmnnn_TAU(i)+gmnnn(lcl)-lmnnn(lcl) - end do - ! rain - do lcl = cutoff(i)+1, ncd - qrin_old(i) = qrin_old(i)+amk(i,lcl) - nrin_old(i) = nrin_old(i)+ank(i,lcl) - qrin_new(i) = qrin_new(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i)*deltatin - nrin_new(i) = nrin_new(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i)*deltatin - -! qrtend_TAU(i) = qrtend_TAU(i)+(gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i) -! nrtend_TAU(i) = nrtend_TAU(i)+(gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i) - qrtend_TAU(i) = qrtend_TAU(i)+(amk0(i,lcl)-amk(i,lcl))/deltatin - nrtend_TAU(i) = nrtend_TAU(i)+(ank0(i,lcl)-ank(i,lcl))/deltatin - gmnnn_lmnnn_TAU(i) = gmnnn_lmnnn_TAU(i)+gmnnn(lcl)-lmnnn(lcl) - end do - - do lcl = 1,ncd - amk_out(i,lcl) = amk(i,lcl) + (gmnnn(lcl)-lmnnn(lcl))*1.e3_r8/rho(i)*deltatin - ank_out(i,lcl) = ank(i,lcl) + (gnnnn(lcl)-lnnnn(lcl))*1.e6_r8/rho(i)*deltatin - end do - - qcin_new(i) = qcin_new(i)+qcin_old(i) - ncin_new(i) = ncin_new(i)+ncin_old(i) - qrin_new(i) = qrin_new(i)+qrin_old(i) - nrin_new(i) = nrin_new(i)+nrin_old(i) -end do - - -end subroutine stochastic_collect_tau_tend - - -subroutine cam_bin_distribute(qc_all, qr_all, qc,nc,qr,nr,mu_c,lambda_c,lambda_r,n0r, & - lcldm, precip_frac, scale_qc, scale_nc, scale_qr, scale_nr, & - amk_c,ank_c, amk_r, ank_r, amk, ank, cutoff_amk) - -real(r8) :: qc_all, qr_all, qc, nc, qr, nr, mu_c, lambda_c, lambda_r, n0r, lcldm, precip_frac -real(r8), dimension(ncd) :: amk_c, ank_c, amk_r, ank_r, amk, ank -integer :: i -real(r8) :: phi -real(r8) :: scale_nc, scale_qc, scale_nr, scale_qr - -integer :: id_max_qc, id_max_qr, cutoff_amk -real(r8) :: max_qc, max_qr, min_amk - -ank_c = 0._r8 -amk_c = 0._r8 -ank_r = 0._r8 -amk_r = 0._r8 -ank = 0._r8 -amk = 0._r8 - -scale_nc = 0._r8 -scale_qc = 0._r8 -scale_nr = 0._r8 -scale_qr = 0._r8 - -id_max_qc = 0 -id_max_qr = 0 -cutoff_amk = 0 -max_qc = 0._r8 -max_qr = 0._r8 - -! cloud water, nc in #/m3 --> #/cm3 -if( (qc_all.gt.qsmall).and.(qc.gt.qsmall) ) then -do i = 1,ncd - phi = nc*lambda_c**(mu_c+1._r8)/gamma(mu_c+1._r8)*(diammean(i)*1.e-2_r8)**mu_c*exp(-lambda_c*diammean(i)*1.e-2_r8) ! D cm --> m - ank_c(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8 ! D cm --> m - amk_c(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8*mmean(i)*1.e-3_r8 ! mass in bin g --> kg - - scale_nc = scale_nc+ank_c(i) - scale_qc = scale_qc+amk_c(i) -end do - -scale_nc = scale_nc/nc -scale_qc = scale_qc/qc - -ank_c = ank_c/scale_nc*lcldm -amk_c = amk_c/scale_qc*lcldm -!ank_c = ank_c*lcldm -!amk_c = amk_c*lcldm - -do i=1,ncd - if( amk_c(i).gt.max_qc ) then - id_max_qc = i - max_qc = amk_c(i) - end if -end do - -!else - -!do i=1,ncd -! ank_c(i) = 0._r8 -! amk_c(i) = 0._r8 -!end do - -end if - -! rain drop -if( (qr_all.gt.qsmall).and.(qr.gt.qsmall) ) then -do i = 1,ncd - phi = n0r*exp(-lambda_r*diammean(i)*1.e-2_r8) ! D cm --> m - ank_r(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8 ! D cm --> m - amk_r(i) = phi*(diamedge(i+1)-diamedge(i))*1.e-2_r8*mmean(i)*1.e-3_r8 - - scale_nr = scale_nr + ank_r(i) - scale_qr = scale_qr + amk_r(i) -end do - -scale_nr = scale_nr/nr -scale_qr = scale_qr/qr - -ank_r = ank_r/scale_nr*precip_frac -amk_r = amk_r/scale_qr*precip_frac -!ank_r = ank_r*precip_frac -!amk_r = amk_r*precip_frac - -!else - -!do i=1,ncd -! ank_r(i) = 0._r8 -! amk_r(i) = 0._r8 -!end do - -do i=1,ncd - if( amk_r(i).gt.max_qr ) then - id_max_qr = i - max_qr = amk_r(i) - end if -end do - -end if - -amk = amk_c + amk_r -ank = ank_c + ank_r - - -if( (id_max_qc.gt.0).and.(id_max_qr.gt.0) ) then - if( (max_qc/max_qr.lt.10._r8).or.(max_qc/max_qr.gt.0.1_r8) )then - min_amk = amk(id_max_qc) - - do i=id_max_qc,id_max_qr - if( amk(i).le.min_amk ) then - cutoff_amk = i - min_amk = amk(i) - end if - end do - end if -end if - - -!if( qc_all.gt.qsmall.OR.qr_all.gt.qsmall ) then -! do i=1,ncd -! ank(i) = ank_c(i) + ank_r(i) -! amk(i) = amk_c(i) + amk_r(i) -! end do -!else -! do i=1,ncd -! amk(i) = 0._r8 -! ank(i) = 0._r8 -! end do -!end if -!input: qc,nc,qr,nr, medge (bin edges). May also need # bins? -!output: amk, ank (mixing ratio and number in each bin) - -!this part will take a bit of thinking about. -!use size distribution parameters (mu, lambda) to generate the values at discrete size points -!need to also ensure mass conservation - - -end subroutine cam_bin_distribute - - -! here are the subroutines called above that actually do the collision-coalescence calculations: - -! The Kernel is from Jerry from many moons ago (included) - -! I read in the file data and multiply by the summed mass of the individual bins -! (with a factor of 1.5 so that the values represent the middle of the bin - -! 941 FORMAT(2X,E12.5) -! READ(40,941) KNN(IDD,JDD) -! KNN(IDD,JDD)=(XK_GR(IDD)*kkfac+XK_GR(JDD)*kkfac)*KNN(IDD,JDD) - -!where idd and jdd are the indexes for the bins and xk_gr is the mass of drops in a bin in grams -! - -!************************************************************************************ -! Setup variables needed for collection -! Either pass in or define globally the following variables -! tbase(height) - temperature in K as a function of height -! rhon(height) - air density as a function of height in kg/m^3 -! xk_gr(bins) - mass of single drop in each bin in grams -! lsmall - small number -! QC - mass mixing ratio in kg/kg -! QN - number mixing ratio in #/kg -! All parameters are defined to be global in my version so that they are readily available throughout the code: -! SMN0,SNN0,SMCN,APN,AMN2,AMN3,PSIN,FN,FPSIN,XPSIN,HPSIN,FN2,XXPSIN (all arrays of drop bins) -!************************************************************************************ - -!AG: Global arrays need to be passed around I think? Right now at the module level. Is that okay? - -SUBROUTINE COMPUTE_COLL_PARAMS(rhon,xk_gr,qc,qn,gnnnn,gmnnn,lnnnn,lmnnn) - IMPLICIT NONE - -! variable declarations (added by hm, 020118) -! note: vertical array looping is stripped out, this subroutine operates -! only on LOCAL values - - real(r8), dimension(ncd) :: qc,qn - real(r8), dimension(ncdp) :: xk_gr - real(r8) :: tbase,rhon -! real(r8) :: TAIRC,UMMS,UMMS2 - integer :: lk - integer :: l - real(r8), parameter :: lsmall = 1.e-12_r8 - real(r8), dimension(ncd) :: smn0,snn0,smcn,amn2,amn3,psin,fn,fpsin, & - xpsin,hpsin,fn2,xxpsin - real(r8) :: apn - - real(r8), dimension(ncd) :: gnnnn,gmnnn,lnnnn,lmnnn - integer :: lm1,ll - - lk=ncd - - - -!.................................................................................... -! TAIRC=TBASE(K)-273.15 -! TAIRC=TBASE-273.15_r8 -! UMMS=UMM(TAIRC) -!! UMMS2=UMMS*4.66/(RHON(K)/1.E3) -!! UMMS=UMMS/(RHON(K)/1.E3) -! UMMS2=UMMS*4.66_r8/(RHON/1.E3_r8) -! UMMS=UMMS/(RHON/1.E3_r8) - - DO L=1,LK -! SMN0(L)=QC(L,K)*RHON(K)/1.E3 -! SNN0(L)=QN(L,K)*RHON(K)/1.E6 - SMN0(L)=QC(L)*RHON/1.E3_r8 - SNN0(L)=QN(L)*RHON/1.E6_r8 - - IF(SMN0(L).LT.lsmall.OR.SNN0(L).LT.lsmall)THEN - SMN0(L)=0.0_r8 - SNN0(L)=0.0_r8 - ENDIF - ENDDO - - DO L=1,LK - IF(SMN0(L) .gt. 0._r8.AND.SNN0(L) .gt. 0._r8)THEN - SMCN(L)=SMN0(L)/SNN0(L) - IF((SMCN(L) .GT. 2._r8*XK_GR(L)))THEN -! SMCN(L) = (2*XK_GR(L)) - SMCN(L) = (2._r8*XK_GR(L)) - ENDIF - IF((SMCN(L) .LT. XK_GR(L)))THEN - SMCN(L) = XK_GR(L) - ENDIF - ELSE - SMCN(L)=0._r8 - ENDIF - IF (SMCN(L).LT.XK_GR(L).OR.SMCN(L).GT.(2._r8*XK_GR(L)).OR.SMCN(L).EQ.0.0_r8)THEN - APN=1.0_r8 - ELSE -! APN=0.5*(1.+3.*(XK_GR(L)/SMCN(L))-2*((XK_GR(L)/SMCN(L))**2.)) - APN=0.5_r8*(1._r8+3._r8*(XK_GR(L)/SMCN(L))-2._r8*((XK_GR(L)/SMCN(L))**2._r8)) - ENDIF - - IF(SNN0(L) .GT. LSMALL)THEN - AMN2(L)=APN*SMN0(L)*SMN0(L)/SNN0(L) - AMN3(L)=APN*APN*APN*SMN0(L)*SMN0(L)*SMN0(L)/(SNN0(L)*SNN0(L)) - ELSE - AMN2(L)=0._r8 - AMN3(L)=0._r8 - ENDIF - - IF(SMCN(L).LT.XK_GR(L))THEN - PSIN(L)=0.0_r8 - FN(L)=2._r8*SNN0(L)/XK_GR(L) - ELSE - IF(SMCN(L).GT.(2._r8*XK_GR(L)))THEN - FN(L)=0.0_r8 - PSIN(L)=2._r8*SNN0(L)/XK_GR(L) - ELSE - PSIN(L)=2._r8/XK_GR(L)*(SMN0(L)/XK_GR(L)-SNN0(L)) - FN(L)=2._r8/XK_GR(L)*(2._r8*SNN0(L)-SMN0(L)/XK_GR(L)) - ENDIF - ENDIF - - IF(SNN0(L).LT.LSMALL.OR.SMN0(L).LT.LSMALL)THEN - PSIN(L)=0.0_r8 - FN(L)=0.0_r8 - ENDIF - - FPSIN(L)=0.5_r8/XK_GR(L)*(PSIN(L)-FN(L)) - XPSIN(L)=2._r8*XK_GR(L)*PSIN(L) - HPSIN(L)=PSIN(L)-0.5_r8*FN(L) - FN2(L)=FN(L)/2._r8 - - IF(L.GT.1)THEN - XXPSIN(L)=XK_GR(L)*PSIN(L-1) - ENDIF - ENDDO - -!************************************************************************************ -! Compute collision coalescence -! Either pass in or define globally the following variables -! Gain terms begin with G, loss terms begin with L -! Second letter defines mass (M) or number (N) -! Third and fourth letters define the types of particles colling, i.e., NN means drops colliding with drops -! Last letter defines the category the new particles go into, in this case just N for liquid drops -! The resulting rates are in units of #/cm^3/s and g/cm^3/s -! Relies on predefined kernel array KNN(bins,bins) - see top of this file -!************************************************************************************ - - GMNNN = 0._r8 - GNNNN = 0._r8 - LMNNN = 0._r8 - LNNNN = 0._r8 -! remove verical array index, calculate gain/loss terms locally - - DO L=3,LK-1 - LM1=L-1 - DO LL=1,L-2 -! GNNNN(L,K)=GNNNN(L,K)+(PSIN(LM1)*SMN0(LL)-FPSIN(LM1)*AMN2(LL))*KNN(LM1,LL) -! GMNNN(L,K)=GMNNN(L,K)+(XK_GR(L)*PSIN(LM1)*SMN0(LL)+FN2(LM1)*AMN2(LL)-FPSIN(LM1)*AMN3(LL))*KNN(LM1,LL) - GNNNN(L)=GNNNN(L)+(PSIN(LM1)*SMN0(LL)-FPSIN(LM1)*AMN2(LL))*KNN(LM1,LL) - GMNNN(L)=GMNNN(L)+(XK_GR(L)*PSIN(LM1)*SMN0(LL)+FN2(LM1)*AMN2(LL)-FPSIN(LM1)*AMN3(LL))*KNN(LM1,LL) - ENDDO - ENDDO - - DO L=2,LK-1 - LM1=L-1 - GNNNN(L)=GNNNN(L)+0.5_r8*SNN0(LM1)*SNN0(LM1)*KNN(LM1,LM1) - GMNNN(L)=GMNNN(L)+0.5_r8*(SNN0(LM1)*SMN0(LM1)+SMN0(LM1)*SNN0(LM1))*KNN(LM1,LM1) - DO LL=1,L-1 -! LNNNN(L,K)=LNNNN(L,K)+(PSIN(L)*SMN0(LL)-FPSIN(L)*AMN2(LL))*KNN(L,LL) -! GMNNN(L,K)=GMNNN(L,K)+(SMN0(LL)*SNN0(L)-PSIN(L)*AMN2(LL)+FPSIN(L)*AMN3(LL))*KNN(L,LL) -! LMNNN(L,K)=LMNNN(L,K)+(XPSIN(L)*SMN0(LL)-HPSIN(L)*AMN2(LL))*KNN(L,LL) - LNNNN(L)=LNNNN(L)+(PSIN(L)*SMN0(LL)-FPSIN(L)*AMN2(LL))*KNN(L,LL) - GMNNN(L)=GMNNN(L)+(SMN0(LL)*SNN0(L)-PSIN(L)*AMN2(LL)+FPSIN(L)*AMN3(LL))*KNN(L,LL) - LMNNN(L)=LMNNN(L)+(XPSIN(L)*SMN0(LL)-HPSIN(L)*AMN2(LL))*KNN(L,LL) - ENDDO - ENDDO - - DO L=1,LK-1 - DO LL=L,LK-1 -! LNNNN(L,K)=LNNNN(L,K)+(SNN0(LL)*SNN0(L))*KNN(LL,L) -! LMNNN(L,K)=LMNNN(L,K)+(SNN0(LL)*SMN0(L))*KNN(LL,L) - LNNNN(L)=LNNNN(L)+(SNN0(LL)*SNN0(L))*KNN(LL,L) - LMNNN(L)=LMNNN(L)+(SNN0(LL)*SMN0(L))*KNN(LL,L) - ENDDO - ENDDO - - - - -END SUBROUTINE COMPUTE_COLL_PARAMS - - - - +end subroutine stochastic_kernel_init_cam end module stochastic_collect_tau_cam diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 0be8dd6987..c18a3015d8 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -852,6 +852,7 @@ subroutine micro_pumas_cam_init(pbuf2d) use time_manager, only: is_first_step use micro_pumas_utils, only: micro_pumas_utils_init use micro_pumas_v1, only: micro_mg_init3_0 => micro_pumas_init + use stochastic_collect_tau_cam, only: stochastic_kernel_init_cam !----------------------------------------------------------------------- ! @@ -1189,6 +1190,10 @@ subroutine micro_pumas_cam_init(pbuf2d) ! qc limiter (only output in versions 1.5 and later) call addfld('QCRAT', (/ 'lev' /), 'A', 'fraction', 'Qc Limiter: Fraction of qc tendency applied') + ! If Machine learning is turned on, perform it's initializations + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + call stochastic_kernel_init_cam() + end if ! determine the add_default fields call phys_getopts(history_amwg_out = history_amwg , & history_budget_out = history_budget , & @@ -1432,9 +1437,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) use wv_saturation, only: qsat use infnan, only: nan, assignment(=) use cam_abortutils, only: handle_allocate_error -!++ TAU - use stochastic_collect_tau_cam, only: ncd -!-- TAU type(physics_state), intent(in) :: state type(physics_ptend), intent(out) :: ptend From eb3c76af61e32c0dc8c1141b50c315969d0bd56b Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Wed, 1 Feb 2023 16:30:20 -0700 Subject: [PATCH 12/54] Bring in updated ML code --- Externals_CAM.cfg | 2 +- src/physics/cam/stochastic_collect_tau_cam.F90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index b01c3f5d46..21d4a5bacc 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 1f2ea0a +hash = 5cd49ee required = True [pumas-frozen] diff --git a/src/physics/cam/stochastic_collect_tau_cam.F90 b/src/physics/cam/stochastic_collect_tau_cam.F90 index eac8980213..2850b15097 100644 --- a/src/physics/cam/stochastic_collect_tau_cam.F90 +++ b/src/physics/cam/stochastic_collect_tau_cam.F90 @@ -59,10 +59,10 @@ subroutine stochastic_kernel_init_cam use cam_history_support, only: add_hist_coord use pumas_stochastic_collect_tau, only: pumas_stochastic_kernel_init - integer :: iunit ! unit number of opened file for collection kernel code from a lookup table. + integer :: iunit=40 ! unit number of opened file for collection kernel code from a lookup table. !CACNOTE - Need to fix the opening and reading of this file - open(unit=40,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') + open(unit=iunit,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') call pumas_stochastic_kernel_init(iunit) From f27d906a60f1b44853511b4e196743319f91bef9 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 2 Feb 2023 12:07:44 -0700 Subject: [PATCH 13/54] move location of stochastic_collect_tau_cam.F90 from cam to cam_dev directory --- Externals_CAM.cfg | 2 +- src/physics/{cam => cam_dev}/stochastic_collect_tau_cam.F90 | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/physics/{cam => cam_dev}/stochastic_collect_tau_cam.F90 (100%) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 21d4a5bacc..fc01fa9977 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 5cd49ee +hash = 1026ad68 required = True [pumas-frozen] diff --git a/src/physics/cam/stochastic_collect_tau_cam.F90 b/src/physics/cam_dev/stochastic_collect_tau_cam.F90 similarity index 100% rename from src/physics/cam/stochastic_collect_tau_cam.F90 rename to src/physics/cam_dev/stochastic_collect_tau_cam.F90 From 6bbc1456daa58d988a9164158658f8d06dfb20be Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 3 Feb 2023 17:26:12 -0700 Subject: [PATCH 14/54] Update PUMAS --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index fc01fa9977..ad1e7aac34 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 1026ad68 +hash = c70ffe64 required = True [pumas-frozen] From 2ada00e3543f0830aea9ab0c74d9ce0dcb499499 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 24 Feb 2023 16:32:22 -0700 Subject: [PATCH 15/54] More cleanup --- Externals_CAM.cfg | 2 +- bld/namelist_files/namelist_definition.xml | 4 + src/physics/cam_dev/micro_pumas_cam.F90 | 9 +- .../cam_dev/stochastic_collect_tau_cam.F90 | 1 - .../cam_dev/stochastic_emulate_cam.F90 | 108 ++++++++++++++++++ 5 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 src/physics/cam_dev/stochastic_emulate_cam.F90 diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index ad1e7aac34..59e597a54d 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = c70ffe64 +hash = ccefbf11 required = True [pumas-frozen] diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 39120518f5..6b250696e4 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2609,6 +2609,10 @@ Default: .false. Warm rain process +sb2001 turns on alternative autoconversion and accretion scheme for liquid in microphysics (Seifert and Behang 2001) +kk2000 uses original autoconversion and accretion scheme for liquid in microphysics +tau turns on machine learning training for warm rain +emulated turns on use of machine learning for warm rain Default: set in namelist_defaults micro_pumas_init use stochastic_collect_tau_cam, only: stochastic_kernel_init_cam + use stochastic_emulate_cam, only: stochastic_emulate_init_cam !----------------------------------------------------------------------- ! @@ -1191,8 +1188,10 @@ subroutine micro_pumas_cam_init(pbuf2d) call addfld('QCRAT', (/ 'lev' /), 'A', 'fraction', 'Qc Limiter: Fraction of qc tendency applied') ! If Machine learning is turned on, perform it's initializations - if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + if (trim(micro_mg_warm_rain) == 'tau') then call stochastic_kernel_init_cam() + else if( trim(micro_mg_warm_rain) == 'emulate') then + call stochastic_emulate_init_cam() end if ! determine the add_default fields call phys_getopts(history_amwg_out = history_amwg , & diff --git a/src/physics/cam_dev/stochastic_collect_tau_cam.F90 b/src/physics/cam_dev/stochastic_collect_tau_cam.F90 index 2850b15097..b11ef27f53 100644 --- a/src/physics/cam_dev/stochastic_collect_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_collect_tau_cam.F90 @@ -53,7 +53,6 @@ module stochastic_collect_tau_cam contains !=============================================================================== -!CACNOTE - Is this a good name for this routine still (just doing addfld calls) subroutine stochastic_kernel_init_cam use cam_history_support, only: add_hist_coord diff --git a/src/physics/cam_dev/stochastic_emulate_cam.F90 b/src/physics/cam_dev/stochastic_emulate_cam.F90 new file mode 100644 index 0000000000..a6f36e13e2 --- /dev/null +++ b/src/physics/cam_dev/stochastic_emulate_cam.F90 @@ -0,0 +1,108 @@ +module stochastic_emulate_cam +! From Morrison (Lebo, originally TAU bin code) +! Gettelman and Chen 2018 +!the subroutines take in air density, air temperature, and the bin mass boundaries, and +!output the mass and number mixing ratio tendencies in each bin directly. +!this is then wrapped for CAM. + +! note, this is now coded locally. Want the CAM interface to be over i,k I think. + +#ifndef HAVE_GAMMA_INTRINSICS +use shr_spfn_mod, only: gamma => shr_spfn_gamma +#endif + +!use statements here +!use + +use shr_kind_mod, only: r8=>shr_kind_r8 +use cam_history, only: addfld +use micro_pumas_utils, only: pi, rhow, qsmall +use cam_logfile, only: iulog + +implicit none +private +save + +! Subroutines +public :: stochastic_emulate_init_cam + + + +!In the module top, declare the following so that these can be used throughout the module: + +integer, parameter, public :: ncd = 35 +integer, parameter, public :: ncdp = ncd + 1 +integer, parameter, public :: ncdl = ncd +integer, parameter, public :: ncdpl = ncdl+1 + +!integer, private :: ncd,ncdp +!integer, private :: ncdl,ncdpl +!PARAMETER(ncd=35,ncdl=ncd) ! set number of ice and liquid bins +!PARAMETER(ncdp=ncd+1,ncdpl=ncdl+1) + +! for Zach's collision-coalescence code + + +real(r8), private :: knn(ncd,ncd) + +real(r8), public :: mmean(ncd), diammean(ncd) ! kg & m at bin mid-points +real(r8), public :: medge(ncdp), diamedge(ncdp) ! kg & m at bin edges +integer, private :: cutoff_id ! cutoff between cloud water and rain drop, D = 40 microns + +!=============================================================================== +contains +!=============================================================================== + +subroutine stochastic_emulate_init_cam + + use cam_history_support, only: add_hist_coord + + call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') + + call addfld('amk_c',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + + call addfld('scale_nc',(/'lev'/),'A','1','scaling factor for nc') + call addfld('scale_nr',(/'lev'/),'A','1','scaling factor for nr') + call addfld('scale_qc',(/'lev'/),'A','1','scaling factor for qc') + call addfld('scale_qr',(/'lev'/),'A','1','scaling factor for qr') + + call addfld('QC_TAU_in',(/'lev'/),'A','kg/kg','qc in TAU') + call addfld('NC_TAU_in',(/'lev'/),'A','1/kg','nc in TAU') + call addfld('QR_TAU_in',(/'lev'/),'A','kg/kg','qr in TAU') + call addfld('NR_TAU_in',(/'lev'/),'A','1/kg','nr in TAU') + call addfld('QC_TAU_out',(/'lev'/),'A','kg/kg','qc out TAU') + call addfld('NC_TAU_out',(/'lev'/),'A','1/kg','nc out TAU') + call addfld('QR_TAU_out',(/'lev'/),'A','kg/kg','qr out TAU') + call addfld('NR_TAU_out',(/'lev'/),'A','1/kg','nr out TAU') + + call addfld('qctend_MG2',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') + call addfld('nctend_MG2',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') + call addfld('qrtend_MG2',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') + call addfld('nrtend_MG2',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') + call addfld('qctend_TAU',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') + call addfld('nctend_TAU',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') + call addfld('qrtend_TAU',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') + call addfld('nrtend_TAU',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') + call addfld('qctend_TAU_diag',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') + call addfld('nctend_TAU_diag',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') + call addfld('qrtend_TAU_diag',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') + call addfld('nrtend_TAU_diag',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') + + call addfld('gmnnn_lmnnn_TAU',(/'lev'/),'A','1','sum of mass gain and loss from bin code') + call addfld('ML_fixer',(/'lev'/),'A','1','frequency of ML fixer is activated') + call addfld('qc_fixer',(/'lev'/),'A','kg/kg','delta qc due to ML fixer') + call addfld('nc_fixer',(/'lev'/),'A','kg/kg','delta nc due to ML fixer') + call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') + call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') + +end subroutine stochastic_emulate_init_cam +end module stochastic_emulate_cam + + From b05fcce9cb83f9d89e8e7d6ea04f44498fdf6c6e Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Mon, 6 Mar 2023 12:17:40 -0700 Subject: [PATCH 16/54] Change emulate to emulated --- src/physics/cam_dev/micro_pumas_cam.F90 | 14 +++++++------- ...emulate_cam.F90 => stochastic_emulated_cam.F90} | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) rename src/physics/cam_dev/{stochastic_emulate_cam.F90 => stochastic_emulated_cam.F90} (96%) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index dfbcfd66e4..cc48ee8133 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -236,7 +236,7 @@ module micro_pumas_cam frzdep_idx = -1 logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop -character(len=16) :: micro_mg_warm_rain= 'emulated' ! 'tau', 'emulated', 'sb2001' and ' kk2000' +character(len=16) :: micro_mg_warm_rain= 'kk2000' ! 'tau', 'emulated', 'sb2001' and ' kk2000' integer :: bergso_idx = -1 @@ -849,7 +849,7 @@ subroutine micro_pumas_cam_init(pbuf2d) use micro_pumas_utils, only: micro_pumas_utils_init use micro_pumas_v1, only: micro_mg_init3_0 => micro_pumas_init use stochastic_collect_tau_cam, only: stochastic_kernel_init_cam - use stochastic_emulate_cam, only: stochastic_emulate_init_cam + use stochastic_emulated_cam, only: stochastic_emulated_init_cam !----------------------------------------------------------------------- ! @@ -1190,8 +1190,8 @@ subroutine micro_pumas_cam_init(pbuf2d) ! If Machine learning is turned on, perform it's initializations if (trim(micro_mg_warm_rain) == 'tau') then call stochastic_kernel_init_cam() - else if( trim(micro_mg_warm_rain) == 'emulate') then - call stochastic_emulate_init_cam() + else if( trim(micro_mg_warm_rain) == 'emulated') then + call stochastic_emulated_init_cam() end if ! determine the add_default fields call phys_getopts(history_amwg_out = history_amwg , & @@ -2336,7 +2336,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call physics_update(state_loc, ptend_loc, dtime/num_steps) !++ TAU - if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then proc_rates%amk_c(:ncol,:,:) = proc_rates%amk_c(:ncol,:,:)/num_steps proc_rates%ank_c(:ncol,:,:) = proc_rates%ank_c(:ncol,:,:)/num_steps proc_rates%amk_r(:ncol,:,:) = proc_rates%amk_r(:ncol,:,:)/num_steps @@ -3217,7 +3217,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Output fields which have not been averaged already, averaging if use_subcol_microp is true !++ TAU - if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then call outfld('scale_qc', proc_rates%scale_qc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('scale_nc', proc_rates%scale_nc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('scale_qr', proc_rates%scale_qr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) @@ -3350,7 +3350,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Output fields which are already on the grid !++ TAU - if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulate') then + if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then call outfld('QC_TAU_in', state%q(1,1,ixcldliq), pcols, lchnk) call outfld('NC_TAU_in', state%q(1,1,ixnumliq), pcols, lchnk) call outfld('QR_TAU_in', state%q(1,1,ixrain), pcols, lchnk) diff --git a/src/physics/cam_dev/stochastic_emulate_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 similarity index 96% rename from src/physics/cam_dev/stochastic_emulate_cam.F90 rename to src/physics/cam_dev/stochastic_emulated_cam.F90 index a6f36e13e2..b315609063 100644 --- a/src/physics/cam_dev/stochastic_emulate_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -1,4 +1,4 @@ -module stochastic_emulate_cam +module stochastic_emulated_cam ! From Morrison (Lebo, originally TAU bin code) ! Gettelman and Chen 2018 !the subroutines take in air density, air temperature, and the bin mass boundaries, and @@ -24,7 +24,7 @@ module stochastic_emulate_cam save ! Subroutines -public :: stochastic_emulate_init_cam +public :: stochastic_emulated_init_cam @@ -53,7 +53,7 @@ module stochastic_emulate_cam contains !=============================================================================== -subroutine stochastic_emulate_init_cam +subroutine stochastic_emulated_init_cam use cam_history_support, only: add_hist_coord @@ -102,7 +102,7 @@ subroutine stochastic_emulate_init_cam call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') -end subroutine stochastic_emulate_init_cam -end module stochastic_emulate_cam +end subroutine stochastic_emulated_init_cam +end module stochastic_emulated_cam From d520770ca8fb2542bf67eceafc62283d07fd0c9a Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Mon, 6 Mar 2023 14:40:18 -0700 Subject: [PATCH 17/54] Introduce namelist setting of files for emulated --- Externals_CAM.cfg | 2 +- bld/namelist_files/namelist_definition.xml | 18 ++++- src/physics/cam_dev/micro_pumas_cam.F90 | 38 +++++++--- .../cam_dev/stochastic_emulated_cam.F90 | 73 +++++++++++++++---- ...ect_tau_cam.F90 => stochastic_tau_cam.F90} | 30 ++------ 5 files changed, 110 insertions(+), 51 deletions(-) rename src/physics/cam_dev/{stochastic_collect_tau_cam.F90 => stochastic_tau_cam.F90} (85%) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 59e597a54d..7cc1bf386b 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = ccefbf11 +hash = fbcb46a required = True [pumas-frozen] diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 6b250696e4..8368560e66 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2611,9 +2611,25 @@ Default: .false. Warm rain process sb2001 turns on alternative autoconversion and accretion scheme for liquid in microphysics (Seifert and Behang 2001) kk2000 uses original autoconversion and accretion scheme for liquid in microphysics -tau turns on machine learning training for warm rain +tau replaces autoconversion and accretion with a faster emulator to generate machine learning training data emulated turns on use of machine learning for warm rain Default: set in namelist_defaults + + + +Neural net file for warm_rain machine learning + + + +Neural net input scaling values file for warm_rain machine learning + + + +Neural net output scaling values file for warm_rain machine learning + diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index cc48ee8133..cb713c9ead 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -7,6 +7,7 @@ module micro_pumas_cam !--------------------------------------------------------------------------------- use shr_kind_mod, only: r8=>shr_kind_r8 +use shr_kind_mod, only: cl=>shr_kind_cl use spmd_utils, only: masterproc use ppgrid, only: pcols, pver, pverp, psubcols use physconst, only: gravit, rair, tmelt, cpair, rh2o, rhoh2o, & @@ -251,6 +252,8 @@ subroutine micro_pumas_cam_readnl(nlfile) use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_integer, mpi_real8, & mpi_logical, mpi_character + use stochastic_emulated_cam, only: stochastic_emulated_readnl + character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input ! Namelist variables @@ -337,7 +340,7 @@ subroutine micro_pumas_cam_readnl(nlfile) end if end if - + end if ! Broadcast namelist variables @@ -529,6 +532,11 @@ subroutine micro_pumas_cam_readnl(nlfile) write(iulog,*) ' micro_mg_accre_sees_auto = ', micro_mg_accre_sees_auto end if + ! Read in the emulated namelist + if( trim(micro_mg_warm_rain) == 'emulated') then + call stochastic_emulated_readnl(nlfile) + end if + contains subroutine bad_version_endrun @@ -848,7 +856,7 @@ subroutine micro_pumas_cam_init(pbuf2d) use time_manager, only: is_first_step use micro_pumas_utils, only: micro_pumas_utils_init use micro_pumas_v1, only: micro_mg_init3_0 => micro_pumas_init - use stochastic_collect_tau_cam, only: stochastic_kernel_init_cam + use stochastic_tau_cam, only: stochastic_tau_init_cam use stochastic_emulated_cam, only: stochastic_emulated_init_cam !----------------------------------------------------------------------- @@ -870,6 +878,9 @@ subroutine micro_pumas_cam_init(pbuf2d) integer :: ierr character(128) :: errstring ! return status (non-blank for error return) + character(len=cl) :: stochastic_emulated_filename_quantile, stochastic_emulated_filename_input_scale, & + stochastic_emulated_filename_output_scale + !----------------------------------------------------------------------- call phys_getopts(use_subcol_microp_out=use_subcol_microp, & @@ -897,6 +908,15 @@ subroutine micro_pumas_cam_init(pbuf2d) ncnst = 10 end if + ! If Machine learning is turned on, perform it's initializations + if (trim(micro_mg_warm_rain) == 'tau') then + call stochastic_tau_init_cam() + else if( trim(micro_mg_warm_rain) == 'emulated') then + call stochastic_emulated_init_cam(stochastic_emulated_filename_quantile, & + stochastic_emulated_filename_input_scale, & + stochastic_emulated_filename_output_scale) + end if + call micro_mg_init3_0( & r8, gravit, rair, rh2o, cpair, & tmelt, latvap, latice, rhmini, & @@ -915,7 +935,9 @@ subroutine micro_pumas_cam_init(pbuf2d) micro_mg_accre_sees_auto, micro_mg_implicit_fall, & micro_mg_nccons, micro_mg_nicons, micro_mg_ncnst, & micro_mg_ninst, micro_mg_ngcons, micro_mg_ngnst, & - micro_mg_nrcons, micro_mg_nrnst, micro_mg_nscons, micro_mg_nsnst, errstring) + micro_mg_nrcons, micro_mg_nrnst, micro_mg_nscons, micro_mg_nsnst, & + stochastic_emulated_filename_quantile, stochastic_emulated_filename_input_scale, & + stochastic_emulated_filename_output_scale, errstring) call handle_errmsg(errstring, subname="micro_pumas_cam_init") @@ -1187,12 +1209,6 @@ subroutine micro_pumas_cam_init(pbuf2d) ! qc limiter (only output in versions 1.5 and later) call addfld('QCRAT', (/ 'lev' /), 'A', 'fraction', 'Qc Limiter: Fraction of qc tendency applied') - ! If Machine learning is turned on, perform it's initializations - if (trim(micro_mg_warm_rain) == 'tau') then - call stochastic_kernel_init_cam() - else if( trim(micro_mg_warm_rain) == 'emulated') then - call stochastic_emulated_init_cam() - end if ! determine the add_default fields call phys_getopts(history_amwg_out = history_amwg , & history_budget_out = history_budget , & @@ -1437,6 +1453,8 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) use infnan, only: nan, assignment(=) use cam_abortutils, only: handle_allocate_error + use stochastic_tau_cam, only: ncd + type(physics_state), intent(in) :: state type(physics_ptend), intent(out) :: ptend real(r8), intent(in) :: dtime @@ -1862,7 +1880,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! all the other arrays in this routine are dimensioned pver. This is required because ! PUMAS only gets the top_lev:pver array subsection, and the proc_rates arrays ! need to be the same levels. - call proc_rates%allocate(ncol,nlev, errstring) + call proc_rates%allocate(ncol,nlev, ncd, errstring) call handle_errmsg(errstring, subname="micro_pumas_cam_tend") diff --git a/src/physics/cam_dev/stochastic_emulated_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 index b315609063..6936a69508 100644 --- a/src/physics/cam_dev/stochastic_emulated_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -15,35 +15,28 @@ module stochastic_emulated_cam !use use shr_kind_mod, only: r8=>shr_kind_r8 +use shr_kind_mod, only: cl=>shr_kind_cl use cam_history, only: addfld use micro_pumas_utils, only: pi, rhow, qsmall use cam_logfile, only: iulog +use cam_abortutils, only: endrun implicit none private save ! Subroutines +public :: stochastic_emulated_readnl public :: stochastic_emulated_init_cam - - !In the module top, declare the following so that these can be used throughout the module: integer, parameter, public :: ncd = 35 integer, parameter, public :: ncdp = ncd + 1 -integer, parameter, public :: ncdl = ncd -integer, parameter, public :: ncdpl = ncdl+1 - -!integer, private :: ncd,ncdp -!integer, private :: ncdl,ncdpl -!PARAMETER(ncd=35,ncdl=ncd) ! set number of ice and liquid bins -!PARAMETER(ncdp=ncd+1,ncdpl=ncdl+1) - -! for Zach's collision-coalescence code - -real(r8), private :: knn(ncd,ncd) +character(len=cl) :: stochastic_emulated_filename_quantile = " " +character(len=cl) :: stochastic_emulated_filename_input_scale = " " +character(len=cl) :: stochastic_emulated_filename_output_scale = " " real(r8), public :: mmean(ncd), diammean(ncd) ! kg & m at bin mid-points real(r8), public :: medge(ncdp), diamedge(ncdp) ! kg & m at bin edges @@ -53,10 +46,58 @@ module stochastic_emulated_cam contains !=============================================================================== -subroutine stochastic_emulated_init_cam +subroutine stochastic_emulated_readnl(nlfile) + + use namelist_utils, only: find_group_name + use units, only: getunit, freeunit + use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_character, masterproc + + character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input + + integer :: unitn, ierr + character(len=*), parameter :: sub = 'stochastic_emulated_readnl' + + namelist /stochastic_emulated_nl/ stochastic_emulated_filename_quantile, stochastic_emulated_filename_input_scale, & + stochastic_emulated_filename_output_scale + + if (masterproc) then + unitn = getunit() + open( unitn, file=trim(nlfile), status='old' ) + call find_group_name(unitn, 'stochastic_emulated_nl', status=ierr) + if (ierr == 0) then + read(unitn, stochastic_emulated_nl, iostat=ierr) + if (ierr /= 0) then + call endrun(sub // ':: ERROR reading namelist') + end if + end if + close(unitn) + call freeunit(unitn) + end if + + ! Broadcast namelist variables + call mpi_bcast(stochastic_emulated_filename_quantile, cl, mpi_character, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_quantile") + + call mpi_bcast(stochastic_emulated_filename_input_scale, cl, mpi_character, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_input_scale") + + call mpi_bcast(stochastic_emulated_filename_output_scale, cl, mpi_character, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_output_scale") + + write(0,*) ' Inside stochastic_emulated_readnl, stochastic_emulated_filename_quantile=',& + stochastic_emulated_filename_quantile +end subroutine stochastic_emulated_readnl + +subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_out, & + stochastic_emulated_filename_input_scale_out, & + stochastic_emulated_filename_output_scale_out) use cam_history_support, only: add_hist_coord + character(len=cl),intent(out) :: stochastic_emulated_filename_quantile_out + character(len=cl),intent(out) :: stochastic_emulated_filename_input_scale_out + character(len=cl),intent(out) :: stochastic_emulated_filename_output_scale_out + call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') call addfld('amk_c',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') @@ -102,6 +143,10 @@ subroutine stochastic_emulated_init_cam call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') + stochastic_emulated_filename_quantile_out = stochastic_emulated_filename_quantile + stochastic_emulated_filename_input_scale_out = stochastic_emulated_filename_input_scale + stochastic_emulated_filename_output_scale_out = stochastic_emulated_filename_output_scale + end subroutine stochastic_emulated_init_cam end module stochastic_emulated_cam diff --git a/src/physics/cam_dev/stochastic_collect_tau_cam.F90 b/src/physics/cam_dev/stochastic_tau_cam.F90 similarity index 85% rename from src/physics/cam_dev/stochastic_collect_tau_cam.F90 rename to src/physics/cam_dev/stochastic_tau_cam.F90 index b11ef27f53..e45a96f0d1 100644 --- a/src/physics/cam_dev/stochastic_collect_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_tau_cam.F90 @@ -1,4 +1,4 @@ -module stochastic_collect_tau_cam +module stochastic_tau_cam ! From Morrison (Lebo, originally TAU bin code) ! Gettelman and Chen 2018 !the subroutines take in air density, air temperature, and the bin mass boundaries, and @@ -24,36 +24,16 @@ module stochastic_collect_tau_cam save ! Subroutines -public :: stochastic_kernel_init_cam - - +public :: stochastic_tau_init_cam !In the module top, declare the following so that these can be used throughout the module: integer, parameter, public :: ncd = 35 -integer, parameter, public :: ncdp = ncd + 1 -integer, parameter, public :: ncdl = ncd -integer, parameter, public :: ncdpl = ncdl+1 - -!integer, private :: ncd,ncdp -!integer, private :: ncdl,ncdpl -!PARAMETER(ncd=35,ncdl=ncd) ! set number of ice and liquid bins -!PARAMETER(ncdp=ncd+1,ncdpl=ncdl+1) - -! for Zach's collision-coalescence code - - -real(r8), private :: knn(ncd,ncd) - -real(r8), public :: mmean(ncd), diammean(ncd) ! kg & m at bin mid-points -real(r8), public :: medge(ncdp), diamedge(ncdp) ! kg & m at bin edges -integer, private :: cutoff_id ! cutoff between cloud water and rain drop, D = 40 microns !=============================================================================== contains !=============================================================================== - -subroutine stochastic_kernel_init_cam +subroutine stochastic_tau_init_cam use cam_history_support, only: add_hist_coord use pumas_stochastic_collect_tau, only: pumas_stochastic_kernel_init @@ -110,7 +90,7 @@ subroutine stochastic_kernel_init_cam call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') -end subroutine stochastic_kernel_init_cam -end module stochastic_collect_tau_cam +end subroutine stochastic_tau_init_cam +end module stochastic_tau_cam From 998213ae3cf402937fbfa7a203d67c62b0c6d010 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Tue, 7 Mar 2023 10:35:57 -0700 Subject: [PATCH 18/54] Remove emulated from if block where values not being set/used --- src/physics/cam_dev/micro_pumas_cam.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index cb713c9ead..d801ef909a 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -2354,7 +2354,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call physics_update(state_loc, ptend_loc, dtime/num_steps) !++ TAU - if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then + if (trim(micro_mg_warm_rain) == 'tau') then proc_rates%amk_c(:ncol,:,:) = proc_rates%amk_c(:ncol,:,:)/num_steps proc_rates%ank_c(:ncol,:,:) = proc_rates%ank_c(:ncol,:,:)/num_steps proc_rates%amk_r(:ncol,:,:) = proc_rates%amk_r(:ncol,:,:)/num_steps From 9757d92884afacff1faa89e69340d965ae5f9088 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Wed, 3 May 2023 10:29:07 -0600 Subject: [PATCH 19/54] Andrew's mods --- Externals_CAM.cfg | 2 +- src/physics/cam_dev/micro_pumas_cam.F90 | 101 ++++++++++-------- .../cam_dev/stochastic_emulated_cam.F90 | 78 +++++++------- src/physics/cam_dev/stochastic_tau_cam.F90 | 78 +++++++------- 4 files changed, 135 insertions(+), 124 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 7cc1bf386b..afba159a15 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = fbcb46a +hash = 91b125a required = True [pumas-frozen] diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index d801ef909a..f3f8c4e63b 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -1042,6 +1042,19 @@ subroutine micro_pumas_cam_init(pbuf2d) call addfld ('NMELTO', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to Melting of cloud ice ') call addfld ('NMELTS', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to Melting of snow') + call addfld ('qctend_KK2000', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from KK2000') + call addfld ('nctend_KK2000', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud number mass tendency due to autoconversion & accretion from KK2000') + call addfld ('qrtend_KK2000', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from KK2000') + call addfld ('nrtend_KK2000', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from KK2000') + call addfld ('qctend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from SB2001') + call addfld ('nctend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from SB2001') + call addfld ('qrtend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from SB2001') + call addfld ('nrtend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from SB2001') +! call addfld ('qctend_TAU', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from TAU or Emulator code') +! call addfld ('nctend_TAU', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from TAU or Emulator code') +! call addfld ('qrtend_TAU', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from TAU or Emulator code') +! call addfld ('nrtend_TAU', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from TAU or Emulator code') + if (micro_mg_version > 2) then call addfld ('NMELTG', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to Melting of graupel') call addfld ('NGSEDTEN', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to graupel sedimentation') @@ -2730,6 +2743,9 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) nc_grid = state_loc%q(:,:,ixnumliq) ni_grid = state_loc%q(:,:,ixnumice) +! write(iulog,*) "qctend_KK2000: ",proc_rates%qctend_KK2000(1,:) +! write(iulog,*) "prctot: ",proc_rates%prctot(1,:) + qcsedtenout_grid(:ncol,top_lev:) = proc_rates%qcsedten qisedtenout_grid(:ncol,top_lev:) = proc_rates%qisedten vtrmcout_grid(:ncol,top_lev:) = proc_rates%vtrmc @@ -3236,41 +3252,50 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Output fields which have not been averaged already, averaging if use_subcol_microp is true !++ TAU if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then - call outfld('scale_qc', proc_rates%scale_qc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('scale_nc', proc_rates%scale_nc, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('scale_qr', proc_rates%scale_qr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('scale_nr', proc_rates%scale_nr, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk_c', proc_rates%amk_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank_c', proc_rates%ank_c, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk_r', proc_rates%amk_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank_r', proc_rates%ank_r, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk', proc_rates%amk, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank', proc_rates%ank, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('amk_out', proc_rates%amk_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ank_out', proc_rates%ank_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QC_TAU_out', proc_rates%qc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NC_TAU_out', proc_rates%nc_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QR_TAU_out', proc_rates%qr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NR_TAU_out', proc_rates%nr_out, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qctend_MG2', proc_rates%qctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_MG2', proc_rates%nctend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_MG2', proc_rates%qrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_MG2', proc_rates%nrtend_MG2, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qctend_TAU', proc_rates%qctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_TAU', proc_rates%nctend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_TAU', proc_rates%qrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_TAU', proc_rates%nrtend_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qctend_TAU_diag', proc_rates%qctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_TAU_diag', proc_rates%nctend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_TAU_diag', proc_rates%qrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_TAU_diag', proc_rates%nrtend_TAU_diag, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('gmnnn_lmnnn_TAU', proc_rates%gmnnn_lmnnn_TAU, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('ML_fixer', proc_rates%ML_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qc_fixer', proc_rates%qc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nc_fixer', proc_rates%nc_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qr_fixer', proc_rates%qr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nr_fixer', proc_rates%nr_fixer, psetcols, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_qc', proc_rates%scale_qc, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_nc', proc_rates%scale_nc, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_qr', proc_rates%scale_qr, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('scale_nr', proc_rates%scale_nr, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_c', proc_rates%amk_c, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_c', proc_rates%ank_c, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_r', proc_rates%amk_r, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_r', proc_rates%ank_r, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk', proc_rates%amk, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank', proc_rates%ank, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('amk_out', proc_rates%amk_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ank_out', proc_rates%ank_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QC_TAU_in', proc_rates%qc_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NC_TAU_in', proc_rates%nc_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QR_TAU_in', proc_rates%qr_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NR_TAU_in', proc_rates%nr_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QC_TAU_out', proc_rates%qc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NC_TAU_out', proc_rates%nc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QR_TAU_out', proc_rates%qr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NR_TAU_out', proc_rates%nr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qctend_TAU', proc_rates%qctend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_TAU', proc_rates%nctend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_TAU', proc_rates%qrtend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_TAU', proc_rates%nrtend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('gmnnn_lmnnn_TAU', proc_rates%gmnnn_lmnnn_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('ML_fixer', proc_rates%ML_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qc_fixer', proc_rates%qc_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nc_fixer', proc_rates%nc_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qr_fixer', proc_rates%qr_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nr_fixer', proc_rates%nr_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) end if + + if (trim(micro_mg_warm_rain) == 'sb2001') then + call outfld('qctend_SB2001', proc_rates%qctend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_SB2001', proc_rates%nctend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_SB2001', proc_rates%qrtend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_SB2001', proc_rates%nrtend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) + end if + + call outfld('qctend_KK2000', proc_rates%qctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + !-- TAU call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) @@ -3367,14 +3392,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) end if ! Output fields which are already on the grid -!++ TAU - if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then - call outfld('QC_TAU_in', state%q(1,1,ixcldliq), pcols, lchnk) - call outfld('NC_TAU_in', state%q(1,1,ixnumliq), pcols, lchnk) - call outfld('QR_TAU_in', state%q(1,1,ixrain), pcols, lchnk) - call outfld('NR_TAU_in', state%q(1,1,ixnumrain),pcols, lchnk) - end if -!-- TAU call outfld('QRAIN', qrout_grid, pcols, lchnk) call outfld('QSNOW', qsout_grid, pcols, lchnk) call outfld('NRAIN', nrout_grid, pcols, lchnk) diff --git a/src/physics/cam_dev/stochastic_emulated_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 index 6936a69508..c7a32286d4 100644 --- a/src/physics/cam_dev/stochastic_emulated_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -100,48 +100,44 @@ subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_ou call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') - call addfld('amk_c',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_c',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - call addfld('amk_out',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank_out',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - - call addfld('scale_nc',(/'lev'/),'A','1','scaling factor for nc') - call addfld('scale_nr',(/'lev'/),'A','1','scaling factor for nr') - call addfld('scale_qc',(/'lev'/),'A','1','scaling factor for qc') - call addfld('scale_qr',(/'lev'/),'A','1','scaling factor for qr') + call addfld('amk_c',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + + call addfld('scale_nc',(/'trop_cld_lev'/),'A','1','scaling factor for nc') + call addfld('scale_nr',(/'trop_cld_lev'/),'A','1','scaling factor for nr') + call addfld('scale_qc',(/'trop_cld_lev'/),'A','1','scaling factor for qc') + call addfld('scale_qr',(/'trop_cld_lev'/),'A','1','scaling factor for qr') - call addfld('QC_TAU_in',(/'lev'/),'A','kg/kg','qc in TAU') - call addfld('NC_TAU_in',(/'lev'/),'A','1/kg','nc in TAU') - call addfld('QR_TAU_in',(/'lev'/),'A','kg/kg','qr in TAU') - call addfld('NR_TAU_in',(/'lev'/),'A','1/kg','nr in TAU') - call addfld('QC_TAU_out',(/'lev'/),'A','kg/kg','qc out TAU') - call addfld('NC_TAU_out',(/'lev'/),'A','1/kg','nc out TAU') - call addfld('QR_TAU_out',(/'lev'/),'A','kg/kg','qr out TAU') - call addfld('NR_TAU_out',(/'lev'/),'A','1/kg','nr out TAU') - - call addfld('qctend_MG2',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') - call addfld('nctend_MG2',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') - call addfld('qrtend_MG2',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') - call addfld('nrtend_MG2',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') - call addfld('qctend_TAU',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') - call addfld('nctend_TAU',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') - call addfld('qrtend_TAU',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') - call addfld('nrtend_TAU',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') - call addfld('qctend_TAU_diag',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') - call addfld('nctend_TAU_diag',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') - call addfld('qrtend_TAU_diag',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') - call addfld('nrtend_TAU_diag',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') - - call addfld('gmnnn_lmnnn_TAU',(/'lev'/),'A','1','sum of mass gain and loss from bin code') - call addfld('ML_fixer',(/'lev'/),'A','1','frequency of ML fixer is activated') - call addfld('qc_fixer',(/'lev'/),'A','kg/kg','delta qc due to ML fixer') - call addfld('nc_fixer',(/'lev'/),'A','kg/kg','delta nc due to ML fixer') - call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') - call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') + call addfld('QC_TAU_in',(/'trop_cld_lev'/),'A','kg/kg','qc in TAU') + call addfld('NC_TAU_in',(/'trop_cld_lev'/),'A','1/kg','nc in TAU') + call addfld('QR_TAU_in',(/'trop_cld_lev'/),'A','kg/kg','qr in TAU') + call addfld('NR_TAU_in',(/'trop_cld_lev'/),'A','1/kg','nr in TAU') + call addfld('QC_TAU_out',(/'trop_cld_lev'/),'A','kg/kg','qc out TAU') + call addfld('NC_TAU_out',(/'trop_cld_lev'/),'A','1/kg','nc out TAU') + call addfld('QR_TAU_out',(/'trop_cld_lev'/),'A','kg/kg','qr out TAU') + call addfld('NR_TAU_out',(/'trop_cld_lev'/),'A','1/kg','nr out TAU') + + call addfld('qctend_TAU',(/'trop_cld_lev'/),'A','kg/kg/s','qc tendency due to TAU bin code') + call addfld('nctend_TAU',(/'trop_cld_lev'/),'A','1/kg/s','nc tendency due to TAU bin code') + call addfld('qrtend_TAU',(/'trop_cld_lev'/),'A','kg/kg/s','qr tendency due to TAU bin code') + call addfld('nrtend_TAU',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code') + call addfld('qctend_TAU_diag',(/'trop_cld_lev'/),'A','kg/kg/s','qc tendency due to TAU bin code') + call addfld('nctend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nc tendency due to TAU bin code') + call addfld('qrtend_TAU_diag',(/'trop_cld_lev'/),'A','kg/kg/s','qr tendency due to TAU bin code') + call addfld('nrtend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code') + + call addfld('gmnnn_lmnnn_TAU',(/'trop_cld_lev'/),'A','1','sum of mass gain and loss from bin code') + call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency of ML fixer is activated') + call addfld('qc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qc due to ML fixer') + call addfld('nc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nc due to ML fixer') + call addfld('qr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qr due to ML fixer') + call addfld('nr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nr due to ML fixer') stochastic_emulated_filename_quantile_out = stochastic_emulated_filename_quantile stochastic_emulated_filename_input_scale_out = stochastic_emulated_filename_input_scale diff --git a/src/physics/cam_dev/stochastic_tau_cam.F90 b/src/physics/cam_dev/stochastic_tau_cam.F90 index e45a96f0d1..927f09c0e6 100644 --- a/src/physics/cam_dev/stochastic_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_tau_cam.F90 @@ -43,52 +43,50 @@ subroutine stochastic_tau_init_cam !CACNOTE - Need to fix the opening and reading of this file open(unit=iunit,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') +!Note: lev needs to be trop_cld_lev for proc_rates.... + call pumas_stochastic_kernel_init(iunit) call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') - call addfld('amk_c',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_c',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'lev ','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'lev ','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - call addfld('amk_out',(/'lev ','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank_out',(/'lev ','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - - call addfld('scale_nc',(/'lev'/),'A','1','scaling factor for nc') - call addfld('scale_nr',(/'lev'/),'A','1','scaling factor for nr') - call addfld('scale_qc',(/'lev'/),'A','1','scaling factor for qc') - call addfld('scale_qr',(/'lev'/),'A','1','scaling factor for qr') + call addfld('amk_c',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + + call addfld('scale_nc',(/'trop_cld_lev'/),'A','1','scaling factor for nc') + call addfld('scale_nr',(/'trop_cld_lev'/),'A','1','scaling factor for nr') + call addfld('scale_qc',(/'trop_cld_lev'/),'A','1','scaling factor for qc') + call addfld('scale_qr',(/'trop_cld_lev'/),'A','1','scaling factor for qr') - call addfld('QC_TAU_in',(/'lev'/),'A','kg/kg','qc in TAU') - call addfld('NC_TAU_in',(/'lev'/),'A','1/kg','nc in TAU') - call addfld('QR_TAU_in',(/'lev'/),'A','kg/kg','qr in TAU') - call addfld('NR_TAU_in',(/'lev'/),'A','1/kg','nr in TAU') - call addfld('QC_TAU_out',(/'lev'/),'A','kg/kg','qc out TAU') - call addfld('NC_TAU_out',(/'lev'/),'A','1/kg','nc out TAU') - call addfld('QR_TAU_out',(/'lev'/),'A','kg/kg','qr out TAU') - call addfld('NR_TAU_out',(/'lev'/),'A','1/kg','nr out TAU') + call addfld('QC_TAU_in',(/'trop_cld_lev'/),'A','kg/kg','qc in TAU') + call addfld('NC_TAU_in',(/'trop_cld_lev'/),'A','1/kg','nc in TAU') + call addfld('QR_TAU_in',(/'trop_cld_lev'/),'A','kg/kg','qr in TAU') + call addfld('NR_TAU_in',(/'trop_cld_lev'/),'A','1/kg','nr in TAU') + call addfld('QC_TAU_out',(/'trop_cld_lev'/),'A','kg/kg','qc out TAU') + call addfld('NC_TAU_out',(/'trop_cld_lev'/),'A','1/kg','nc out TAU') + call addfld('QR_TAU_out',(/'trop_cld_lev'/),'A','kg/kg','qr out TAU') + call addfld('NR_TAU_out',(/'trop_cld_lev'/),'A','1/kg','nr out TAU') - call addfld('qctend_MG2',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') - call addfld('nctend_MG2',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') - call addfld('qrtend_MG2',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') - call addfld('nrtend_MG2',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') - call addfld('qctend_TAU',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') - call addfld('nctend_TAU',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') - call addfld('qrtend_TAU',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') - call addfld('nrtend_TAU',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') - call addfld('qctend_TAU_diag',(/'lev'/),'A','kg/kg/s','qc tendency due to autoconversion & accretion in MG2') - call addfld('nctend_TAU_diag',(/'lev'/),'A','1/kg/s','nc tendency due to autoconversion & accretion in MG2') - call addfld('qrtend_TAU_diag',(/'lev'/),'A','kg/kg/s','qr tendency due to autoconversion & accretion in MG2') - call addfld('nrtend_TAU_diag',(/'lev'/),'A','1/kg/s','nr tendency due to autoconversion & accretion in MG2') - - call addfld('gmnnn_lmnnn_TAU',(/'lev'/),'A','1','sum of mass gain and loss from bin code') - call addfld('ML_fixer',(/'lev'/),'A','1','frequency of ML fixer is activated') - call addfld('qc_fixer',(/'lev'/),'A','kg/kg','delta qc due to ML fixer') - call addfld('nc_fixer',(/'lev'/),'A','kg/kg','delta nc due to ML fixer') - call addfld('qr_fixer',(/'lev'/),'A','kg/kg','delta qr due to ML fixer') - call addfld('nr_fixer',(/'lev'/),'A','kg/kg','delta nr due to ML fixer') + call addfld('qctend_TAU',(/'trop_cld_lev'/),'A','kg/kg/s','qc tendency due to TAU bin code') + call addfld('nctend_TAU',(/'trop_cld_lev'/),'A','1/kg/s','nc tendency due to TAU bin code') + call addfld('qrtend_TAU',(/'trop_cld_lev'/),'A','kg/kg/s','qr tendency due to TAU bin code') + call addfld('nrtend_TAU',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code') + call addfld('qctend_TAU_diag',(/'trop_cld_lev'/),'A','kg/kg/s','qc tendency due to TAU bin code') + call addfld('nctend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nc tendency due to TAU bin code') + call addfld('qrtend_TAU_diag',(/'trop_cld_lev'/),'A','kg/kg/s','qr tendency due to TAU bin code') + call addfld('nrtend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code') + + call addfld('gmnnn_lmnnn_TAU',(/'trop_cld_lev'/),'A','1','sum of mass gain and loss from bin code') + call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency of ML fixer is activated') + call addfld('qc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qc due to ML fixer') + call addfld('nc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nc due to ML fixer') + call addfld('qr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qr due to ML fixer') + call addfld('nr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nr due to ML fixer') end subroutine stochastic_tau_init_cam end module stochastic_tau_cam From 25bedf867f597509eeaefe996c4c387284b8284d Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Wed, 3 May 2023 16:14:31 -0600 Subject: [PATCH 20/54] cleanup --- src/physics/cam_dev/micro_pumas_cam.F90 | 6 +++--- src/physics/cam_dev/stochastic_emulated_cam.F90 | 16 ++++++++-------- src/physics/cam_dev/stochastic_tau_cam.F90 | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index f3f8c4e63b..097cd01253 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -937,7 +937,7 @@ subroutine micro_pumas_cam_init(pbuf2d) micro_mg_ninst, micro_mg_ngcons, micro_mg_ngnst, & micro_mg_nrcons, micro_mg_nrnst, micro_mg_nscons, micro_mg_nsnst, & stochastic_emulated_filename_quantile, stochastic_emulated_filename_input_scale, & - stochastic_emulated_filename_output_scale, errstring) + stochastic_emulated_filename_output_scale, iulog, errstring) call handle_errmsg(errstring, subname="micro_pumas_cam_init") @@ -1893,7 +1893,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! all the other arrays in this routine are dimensioned pver. This is required because ! PUMAS only gets the top_lev:pver array subsection, and the proc_rates arrays ! need to be the same levels. - call proc_rates%allocate(ncol,nlev, ncd, errstring) + call proc_rates%allocate(ncol, nlev, ncd, micro_mg_warm_rain, errstring) call handle_errmsg(errstring, subname="micro_pumas_cam_tend") @@ -3497,7 +3497,7 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) end if ! deallocate the proc_rates DDT - call proc_rates%deallocate() + call proc_rates%deallocate(micro_mg_warm_rain) ! ptend_loc is deallocated in physics_update above call physics_state_dealloc(state_loc) diff --git a/src/physics/cam_dev/stochastic_emulated_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 index c7a32286d4..a2fef8a13e 100644 --- a/src/physics/cam_dev/stochastic_emulated_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -100,14 +100,14 @@ subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_ou call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') - call addfld('amk_c',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_c',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - call addfld('amk_out',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank_out',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_c',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','all liquid number concentration from bins') call addfld('scale_nc',(/'trop_cld_lev'/),'A','1','scaling factor for nc') call addfld('scale_nr',(/'trop_cld_lev'/),'A','1','scaling factor for nr') diff --git a/src/physics/cam_dev/stochastic_tau_cam.F90 b/src/physics/cam_dev/stochastic_tau_cam.F90 index 927f09c0e6..35f74678b1 100644 --- a/src/physics/cam_dev/stochastic_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_tau_cam.F90 @@ -49,14 +49,14 @@ subroutine stochastic_tau_init_cam call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') - call addfld('amk_c',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_c',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'trop_cld_lev','bins_ncd'/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') - call addfld('amk_out',(/'trop_cld_lev','bins_ncd'/),'A','kg','all liquid mass from bins') - call addfld('ank_out',(/'trop_cld_lev','bins_ncd'/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_c',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') + call addfld('ank_c',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') + call addfld('ank_r',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') + call addfld('ank',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','all liquid number concentration from bins') + call addfld('amk_out',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') + call addfld('ank_out',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','all liquid number concentration from bins') call addfld('scale_nc',(/'trop_cld_lev'/),'A','1','scaling factor for nc') call addfld('scale_nr',(/'trop_cld_lev'/),'A','1','scaling factor for nr') From b380608b3f1d45d4aefd60ac2f7593c8bdfe5868 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Wed, 3 May 2023 16:16:20 -0600 Subject: [PATCH 21/54] Update PUMAS external --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index afba159a15..ecdd37797c 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 91b125a +hash = 93eebd0 required = True [pumas-frozen] From d48690cf5d506386c536fea6f1beb9f38d7f6c96 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Wed, 28 Jun 2023 16:06:50 -0600 Subject: [PATCH 22/54] Add namelist for kbarf file --- Externals_CAM.cfg | 2 +- bld/build-namelist | 10 +++ bld/namelist_files/namelist_definition.xml | 5 ++ src/physics/cam/modal_aer_opt.F90 | 16 +---- src/physics/cam_dev/micro_pumas_cam.F90 | 5 +- .../cam_dev/stochastic_emulated_cam.F90 | 18 ++---- src/physics/cam_dev/stochastic_tau_cam.F90 | 62 +++++++++++++------ 7 files changed, 69 insertions(+), 49 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index ecdd37797c..eb3b12d9ac 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 93eebd0 +hash = a2616275 required = True [pumas-frozen] diff --git a/bld/build-namelist b/bld/build-namelist index a0ef4b5928..4ca6dfacff 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -2982,6 +2982,16 @@ if ($cfg->get('microphys') =~ /^mg/) { add_default($nl, 'micro_mg_warm_rain'); add_default($nl, 'micro_mg_accre_sees_auto'); add_default($nl, 'micro_mg_implicit_fall'); + add_default($nl, 'pumas_stochastic_tau_kernel_filename', 'val'=>"$cfgdir/../src/physics/pumas/KBARF_tau_kernel.dat"); + + #set path for stochastic_tau_kernel_filename + my $cam_dir = $cfg->get('cam_dir'); + add_default($nl, 'pumas_stochastic_tau_kernel_filename'); + my $rel_path = $nl->get_value('pumas_stochastic_tau_kernel_filename'); + my $abs_path = quote_string(set_abs_filepath($rel_path, $cam_dir)); + #overwrite the relative pathname with the absolute pathname + $nl->set_variable_value('pumas_stochastic_tau_nl', 'pumas_stochastic_tau_kernel_filename', $abs_path); + }else { # For CESM2, the decision was made to set micro_do_sb_physics to false # This variable is replaced with micro_mg_warm_rain in cam_dev runs diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 8368560e66..b24acfc008 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2631,6 +2631,11 @@ Neural net input scaling values file for warm_rain machine learning Neural net output scaling values file for warm_rain machine learning + +Coefficients for the stochastic collection kernel used by the TAU stochastice collection code, invoked in PUMAS with micro_pumas_warm_rain = 'tau' + + Do destruction of massless droplets diff --git a/src/physics/cam/modal_aer_opt.F90 b/src/physics/cam/modal_aer_opt.F90 index f7221912eb..cdce3bbb47 100644 --- a/src/physics/cam/modal_aer_opt.F90 +++ b/src/physics/cam/modal_aer_opt.F90 @@ -204,7 +204,7 @@ subroutine modal_aer_opt_init() call addfld ('EXTxASYM', (/ 'lev' /), 'A',' ','extinction 550 nm * asymmetry factor, day only', & flag_xyfill=.true.) -!++ag Add angstrom exponent + ! Add angstrom exponent call addfld ('AEXPUV', horiz_only, 'A',' ','Angstrom Exponent from 350nn-550nm, day only', & flag_xyfill=.true.) call addfld ('AEXPNIR', horiz_only, 'A',' ','Angstrom Exponent from 1020nn-550nm, day only', & @@ -213,7 +213,6 @@ subroutine modal_aer_opt_init() flag_xyfill=.true.) call addfld ('AEXPNIRdn', horiz_only, 'A',' ','Angstrom Exponent from 1020nn-550nm, day night', & flag_xyfill=.true.) -!--ag call addfld ('EXTINCTdn', (/ 'lev' /), 'A','/m','Aerosol extinction 550 nm, day night', & flag_xyfill=.true.) @@ -600,11 +599,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & real(r8) :: aodnir(pcols) ! extinction optical depth in nir real(r8) :: aodnirst(pcols) ! stratospheric extinction optical depth in nir -!CACNOTE - Are these changes part of the machine learning? -!++ag real(r8) :: aenir(pcols) ! angstrom exponent real(r8) :: aeuv(pcols) ! angstrom exponent -!--ag character(len=32) :: outname @@ -666,10 +662,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & aodnirst(:ncol) = 0.0_r8 call tropopause_findChemTrop(state, troplevchem) -!++ag aeuv(:) = 0.0_r8 aenir(:) = 0.0_r8 -!--ag ! loop over all aerosol modes call rad_cnst_get_info(list_idx, nmodes=nmodes) @@ -1085,7 +1079,6 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & deallocate(naer_m) end if -!++ag ! Calculate angstrom exponent for band differences with NIR and UV v. vis.... ! Alpha = - ln (tau1/tau2)/ ln (lam1/lam2) ! Since wavenumber = 1/lam.... @@ -1094,7 +1087,6 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & aeuv(:ncol) = -log(aodvis(:ncol)/aoduv(:ncol)) / log(350._r8/550._r8) aenir(:ncol) = -log(aodvis(:ncol)/aodnir(:ncol)) / log(350._r8/550._r8) -!--ag ! Output visible band diagnostics for quantities summed over the modes ! These fields are put out for diagnostic lists as well as the climate list. @@ -1158,10 +1150,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & call outfld('AODBCdn', bcaod, pcols, lchnk) call outfld('AODSSdn', seasaltaod, pcols, lchnk) -!++ag call outfld('AEXPUVdn', aeuv, pcols, lchnk) call outfld('AEXPNIRdn', aenir, pcols, lchnk) -!--ag do i = 1, nnite ssavis(idxnite(i)) = fillvalue @@ -1169,10 +1159,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & aoduv(idxnite(i)) = fillvalue aodnir(idxnite(i)) = fillvalue -!++ag aeuv(idxnite(i)) = fillvalue aenir(idxnite(i)) = fillvalue -!--ag aoduvst(idxnite(i)) = fillvalue aodnirst(idxnite(i)) = fillvalue @@ -1203,10 +1191,8 @@ subroutine modal_aero_sw(list_idx, state, pbuf, nnite, idxnite, & call outfld('EXTINCTNIR', extinctnir, pcols, lchnk) call outfld('AODUV', aoduv, pcols, lchnk) call outfld('AODNIR', aodnir, pcols, lchnk) -!++ag call outfld('AEXPUV', aeuv, pcols, lchnk) call outfld('AEXPNIR', aenir, pcols, lchnk) -!--ag call outfld('AODUVst', aoduvst, pcols, lchnk) call outfld('AODNIRst', aodnirst, pcols, lchnk) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 097cd01253..d3e65e35c4 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -253,6 +253,7 @@ subroutine micro_pumas_cam_readnl(nlfile) mpi_logical, mpi_character use stochastic_emulated_cam, only: stochastic_emulated_readnl + use stochastic_tau_cam, only: stochastic_tau_readnl character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input @@ -532,9 +533,11 @@ subroutine micro_pumas_cam_readnl(nlfile) write(iulog,*) ' micro_mg_accre_sees_auto = ', micro_mg_accre_sees_auto end if - ! Read in the emulated namelist + ! Read in the emulated or tau namelist if needed if( trim(micro_mg_warm_rain) == 'emulated') then call stochastic_emulated_readnl(nlfile) + else if (trim(micro_mg_warm_rain) == 'tau') then + call stochastic_tau_readnl(nlfile) end if contains diff --git a/src/physics/cam_dev/stochastic_emulated_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 index a2fef8a13e..327ba20d07 100644 --- a/src/physics/cam_dev/stochastic_emulated_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -5,15 +5,6 @@ module stochastic_emulated_cam !output the mass and number mixing ratio tendencies in each bin directly. !this is then wrapped for CAM. -! note, this is now coded locally. Want the CAM interface to be over i,k I think. - -#ifndef HAVE_GAMMA_INTRINSICS -use shr_spfn_mod, only: gamma => shr_spfn_gamma -#endif - -!use statements here -!use - use shr_kind_mod, only: r8=>shr_kind_r8 use shr_kind_mod, only: cl=>shr_kind_cl use cam_history, only: addfld @@ -29,8 +20,7 @@ module stochastic_emulated_cam public :: stochastic_emulated_readnl public :: stochastic_emulated_init_cam -!In the module top, declare the following so that these can be used throughout the module: - +!Module variables integer, parameter, public :: ncd = 35 integer, parameter, public :: ncdp = ncd + 1 @@ -84,8 +74,10 @@ subroutine stochastic_emulated_readnl(nlfile) call mpi_bcast(stochastic_emulated_filename_output_scale, cl, mpi_character, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_output_scale") - write(0,*) ' Inside stochastic_emulated_readnl, stochastic_emulated_filename_quantile=',& - stochastic_emulated_filename_quantile +!CACNOTE + write(0,*) ' Inside stochastic_emulated_readnl, stochastic_emulated_filename_quantile=',& + stochastic_emulated_filename_quantile + end subroutine stochastic_emulated_readnl subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_out, & diff --git a/src/physics/cam_dev/stochastic_tau_cam.F90 b/src/physics/cam_dev/stochastic_tau_cam.F90 index 35f74678b1..0fc28c5196 100644 --- a/src/physics/cam_dev/stochastic_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_tau_cam.F90 @@ -5,16 +5,7 @@ module stochastic_tau_cam !output the mass and number mixing ratio tendencies in each bin directly. !this is then wrapped for CAM. -! note, this is now coded locally. Want the CAM interface to be over i,k I think. - -#ifndef HAVE_GAMMA_INTRINSICS -use shr_spfn_mod, only: gamma => shr_spfn_gamma -#endif - -!use statements here -!use - -use shr_kind_mod, only: r8=>shr_kind_r8 +use shr_kind_mod, only: r8=>shr_kind_r8, cl=>shr_kind_cl use cam_history, only: addfld use micro_pumas_utils, only: pi, rhow, qsmall use cam_logfile, only: iulog @@ -24,31 +15,64 @@ module stochastic_tau_cam save ! Subroutines -public :: stochastic_tau_init_cam +public :: stochastic_tau_init_cam, stochastic_tau_readnl -!In the module top, declare the following so that these can be used throughout the module: +!Module variables integer, parameter, public :: ncd = 35 +character(len=cl) :: pumas_stochastic_tau_kernel_filename ! Full filepath/filename for tau kernel file !=============================================================================== contains !=============================================================================== +subroutine stochastic_tau_readnl(nlfile) + + use namelist_utils, only: find_group_name + use units, only: getunit, freeunit + use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_character, masterproc + use cam_abortutils, only: endrun + + character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input + + integer :: unitn, ierr + character(len=*), parameter :: sub = 'stochastic_tau_readnl' + + namelist /pumas_stochastic_tau_nl/ pumas_stochastic_tau_kernel_filename + + if (masterproc) then + unitn = getunit() + open( unitn, file=trim(nlfile), status='old' ) + call find_group_name(unitn, 'pumas_stochastic_tau_nl', status=ierr) + if (ierr == 0) then + read(unitn, pumas_stochastic_tau_nl, iostat=ierr) + if (ierr /= 0) then + call endrun(sub // ':: ERROR reading namelist') + end if + end if + close(unitn) + call freeunit(unitn) + end if + + ! Broadcast namelist variables + call mpi_bcast(pumas_stochastic_tau_kernel_filename, cl, mpi_character, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: pumas_stochastic_tau_kernel_filename") + +!CACNOTE + write(0,*) ' Inside stochastic_tau_readnl, pumas_stochastic_tau_kernel_filename=',pumas_stochastic_tau_kernel_filename + +end subroutine stochastic_tau_readnl + subroutine stochastic_tau_init_cam use cam_history_support, only: add_hist_coord use pumas_stochastic_collect_tau, only: pumas_stochastic_kernel_init - integer :: iunit=40 ! unit number of opened file for collection kernel code from a lookup table. - -!CACNOTE - Need to fix the opening and reading of this file - open(unit=iunit,file='/glade/u/home/cchen/TAU/input/KBARF',status='old') - -!Note: lev needs to be trop_cld_lev for proc_rates.... - call pumas_stochastic_kernel_init(iunit) + call pumas_stochastic_kernel_init(pumas_stochastic_tau_kernel_filename) call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') + !Note: lev needs to be trop_cld_lev for proc_rates.... call addfld('amk_c',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') call addfld('ank_c',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') From 39ecca5c38259987426d3e2f5219d76a05195ec8 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Wed, 28 Jun 2023 16:12:55 -0600 Subject: [PATCH 23/54] Update PUMAS external --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index eb3b12d9ac..aee6957e31 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = a2616275 +hash = 8109294c required = True [pumas-frozen] From 617d2a7954302b5969ee09a7bc84388ca3c30b10 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 29 Jun 2023 14:16:09 -0600 Subject: [PATCH 24/54] Update PUMAS --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index ccfb4d2c80..42d01a6520 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 8109294c +hash = 1c47463 required = True [pumas-frozen] From 90f7eb7a061832e95152bb1ad335fbcce81536b3 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Thu, 29 Jun 2023 16:17:20 -0600 Subject: [PATCH 25/54] Update PUMAS to fix failing cam_dev test --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 42d01a6520..95ca0a6623 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 1c47463 +hash = 361848ce required = True [pumas-frozen] From 3bee7e48e25fdbfe2cc0832846fa6ef224a5ab24 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 7 Jul 2023 17:48:32 -0600 Subject: [PATCH 26/54] Update PUMAS external --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 95ca0a6623..403300ff17 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 361848ce +hash = 49ced039 required = True [pumas-frozen] From 3cfcce1fc9009fd4b587f269626c0f5f6fa19211 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Fri, 7 Jul 2023 18:36:21 -0600 Subject: [PATCH 27/54] Update PUMAS external --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 403300ff17..7580e45476 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 49ced039 +hash = 49f46186 required = True [pumas-frozen] From d36c56db9e8f4543104ef3ed3a1c09e9c6f22d82 Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Mon, 10 Jul 2023 16:11:47 -0600 Subject: [PATCH 28/54] Add 'never' as a testing selection for warm_rain --- Externals_CAM.cfg | 2 +- bld/namelist_files/namelist_definition.xml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 7580e45476..0330c698e7 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 49f46186 +hash = 49db48ae required = True [pumas-frozen] diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 2bc92722ed..49b9117d65 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2634,12 +2634,13 @@ Default: .false. + group="micro_mg_nl" valid_values="kk2000,sb2001,tau,emulated,never" > Warm rain process sb2001 turns on alternative autoconversion and accretion scheme for liquid in microphysics (Seifert and Behang 2001) kk2000 uses original autoconversion and accretion scheme for liquid in microphysics tau replaces autoconversion and accretion with a faster emulator to generate machine learning training data emulated turns on use of machine learning for warm rain +never turns on debugging/testing sections Default: set in namelist_defaults From 0c71c033bc6aa84ac70efe210c67f31634152be1 Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 14 Jul 2023 15:30:04 -0600 Subject: [PATCH 29/54] Remove never from warm_rain options --- bld/namelist_files/namelist_definition.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 49b9117d65..f9748d8571 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2634,7 +2634,7 @@ Default: .false. + group="micro_mg_nl" valid_values="kk2000,sb2001,tau,emulated" > Warm rain process sb2001 turns on alternative autoconversion and accretion scheme for liquid in microphysics (Seifert and Behang 2001) kk2000 uses original autoconversion and accretion scheme for liquid in microphysics From 3b41e34585915ee42f1a43d10e9c0f079a3001bb Mon Sep 17 00:00:00 2001 From: Katetc Date: Mon, 17 Jul 2023 17:20:51 -0600 Subject: [PATCH 30/54] Update Externals_CAM.cfg to point to PUMAS tag --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 0330c698e7..a85b4a1a5a 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -hash = 49db48ae +tag = pumas_cam-release_v1.30 required = True [pumas-frozen] From 38d34a0c1f8131f6aa4541bdb4aa636fb0804eee Mon Sep 17 00:00:00 2001 From: Cheryl Craig Date: Tue, 25 Jul 2023 16:09:43 -0600 Subject: [PATCH 31/54] Additional cleanup --- bld/namelist_files/namelist_definition.xml | 3 +-- src/physics/cam_dev/micro_pumas_cam.F90 | 23 +++++----------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index f9748d8571..3b4278775b 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2626,7 +2626,7 @@ Default: 1 Maximum allowed ice number concentration Default: 1.0e8 - + Do Seifert and Behang (2001) autoconversion and accretion physics when set to true. @@ -2640,7 +2640,6 @@ sb2001 turns on alternative autoconversion and accretion scheme for liquid in mi kk2000 uses original autoconversion and accretion scheme for liquid in microphysics tau replaces autoconversion and accretion with a faster emulator to generate machine learning training data emulated turns on use of machine learning for warm rain -never turns on debugging/testing sections Default: set in namelist_defaults diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index d3e65e35c4..8208ef003b 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -236,7 +236,7 @@ module micro_pumas_cam frzcnt_idx = -1, & frzdep_idx = -1 -logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop +logical :: allow_sed_supersat ! allow supersaturated conditions after sedimentation loop character(len=16) :: micro_mg_warm_rain= 'kk2000' ! 'tau', 'emulated', 'sb2001' and ' kk2000' integer :: bergso_idx = -1 @@ -341,7 +341,7 @@ subroutine micro_pumas_cam_readnl(nlfile) end if end if - + end if ! Broadcast namelist variables @@ -571,12 +571,6 @@ subroutine micro_pumas_cam_register allocate(trop_levs(pver-top_lev+1), stat=ierr) call handle_allocate_error(ierr, 'micro_pumas_cam_register', 'trop_levs') -!++ TAU -!!!!!! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics') -!!!!!! call add_hist_coord('bins_ncd', ncd, 'bins for TAU microphysics', 'cm', & -!!!!!! diammean, bounds_name = 'bins_ncd_bnds', bounds = diamedge ) -!-- TAU - call phys_getopts(use_subcol_microp_out = use_subcol_microp, & prog_modal_aero_out = prog_modal_aero) @@ -911,7 +905,7 @@ subroutine micro_pumas_cam_init(pbuf2d) ncnst = 10 end if - ! If Machine learning is turned on, perform it's initializations + ! If Machine learning is turned on, perform its initializations if (trim(micro_mg_warm_rain) == 'tau') then call stochastic_tau_init_cam() else if( trim(micro_mg_warm_rain) == 'emulated') then @@ -919,7 +913,7 @@ subroutine micro_pumas_cam_init(pbuf2d) stochastic_emulated_filename_input_scale, & stochastic_emulated_filename_output_scale) end if - + call micro_mg_init3_0( & r8, gravit, rair, rh2o, cpair, & tmelt, latvap, latice, rhmini, & @@ -2369,7 +2363,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) ! Update local state call physics_update(state_loc, ptend_loc, dtime/num_steps) -!++ TAU if (trim(micro_mg_warm_rain) == 'tau') then proc_rates%amk_c(:ncol,:,:) = proc_rates%amk_c(:ncol,:,:)/num_steps proc_rates%ank_c(:ncol,:,:) = proc_rates%ank_c(:ncol,:,:)/num_steps @@ -2380,7 +2373,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) proc_rates%amk_out(:ncol,:,:) = proc_rates%amk_out(:ncol,:,:)/num_steps proc_rates%ank_out(:ncol,:,:) = proc_rates%ank_out(:ncol,:,:)/num_steps end if -!-- TAU end do @@ -2746,9 +2738,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) nc_grid = state_loc%q(:,:,ixnumliq) ni_grid = state_loc%q(:,:,ixnumice) -! write(iulog,*) "qctend_KK2000: ",proc_rates%qctend_KK2000(1,:) -! write(iulog,*) "prctot: ",proc_rates%prctot(1,:) - qcsedtenout_grid(:ncol,top_lev:) = proc_rates%qcsedten qisedtenout_grid(:ncol,top_lev:) = proc_rates%qisedten vtrmcout_grid(:ncol,top_lev:) = proc_rates%vtrmc @@ -3253,7 +3242,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld( 'MPDI2P', ftem_grid, pcols, lchnk) ! Output fields which have not been averaged already, averaging if use_subcol_microp is true -!++ TAU if (trim(micro_mg_warm_rain) == 'tau' .or. trim(micro_mg_warm_rain) == 'emulated') then call outfld('scale_qc', proc_rates%scale_qc, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('scale_nc', proc_rates%scale_nc, ncol, lchnk, avg_subcol_field=use_subcol_microp) @@ -3292,14 +3280,13 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('nctend_SB2001', proc_rates%nctend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qrtend_SB2001', proc_rates%qrtend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nrtend_SB2001', proc_rates%nrtend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) - end if + end if call outfld('qctend_KK2000', proc_rates%qctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) -!-- TAU call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('REFL', refl, psetcols, lchnk, avg_subcol_field=use_subcol_microp) From a9d5d30c5e3f8e85f6ab353a9909daaa2382b759 Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 23 Aug 2023 13:58:53 -0600 Subject: [PATCH 32/54] Change needed to build with most recent updates --- src/physics/cam_dev/micro_pumas_cam.F90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 8208ef003b..cb35fd3f46 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -3255,10 +3255,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('ank', proc_rates%ank, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('amk_out', proc_rates%amk_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('ank_out', proc_rates%ank_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QC_TAU_in', proc_rates%qc_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NC_TAU_in', proc_rates%nc_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QR_TAU_in', proc_rates%qr_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NR_TAU_in', proc_rates%nr_in, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('QC_TAU_out', proc_rates%qc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('NC_TAU_out', proc_rates%nc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('QR_TAU_out', proc_rates%qr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) From 1655bebb0f06b6371b521d8f22e8fdf1962d1017 Mon Sep 17 00:00:00 2001 From: Katetc Date: Tue, 12 Sep 2023 14:23:30 -0600 Subject: [PATCH 33/54] Added aux_pumas test suite, added first attempt at making pumas a valid configure and namelist option for microphysics. Added a test to make sure pumas and mg3 give the same results and it only passes when pumas is set to mg3 in configure right now. More work to do. --- bld/build-namelist | 6 +-- bld/config_files/definition.xml | 4 +- bld/configure | 24 ++++++---- bld/namelist_files/namelist_defaults_cam.xml | 22 ++++++++- bld/namelist_files/namelist_definition.xml | 2 +- cime_config/SystemTests/mgp.py | 47 +++++++++++++++++++ cime_config/testdefs/testlist_cam.xml | 35 ++++++++++++++ .../cam/outfrq9s_mg3_default/shell_commands | 8 ---- .../outfrq9s_mg3_nondefault/shell_commands | 8 ---- .../cam/outfrq9s_mg3_nondefault/user_nl_cam | 24 ---------- .../cam/outfrq9s_mg3_pcols1536/shell_commands | 8 ---- .../outfrq9s_pumas_emulated/shell_commands | 3 ++ .../cam/outfrq9s_pumas_emulated/user_nl_cam | 5 ++ .../user_nl_clm | 0 .../cam/outfrq9s_pumas_sb2001/shell_commands | 3 ++ .../user_nl_cam | 1 + .../user_nl_clm | 0 .../cam/outfrq9s_pumas_tau/shell_commands | 3 ++ .../user_nl_cam | 1 + .../user_nl_clm | 0 src/physics/cam/cloud_diagnostics.F90 | 2 +- src/physics/cam/convect_shallow.F90 | 2 +- src/physics/cam/microp_driver.F90 | 12 ++--- src/physics/cam/phys_control.F90 | 10 ++-- src/physics/cam/physpkg.F90 | 6 +-- src/physics/cam/radiation_data.F90 | 2 +- 26 files changed, 157 insertions(+), 81 deletions(-) create mode 100644 cime_config/SystemTests/mgp.py delete mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands delete mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands delete mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam delete mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_cam rename cime_config/testdefs/testmods_dirs/cam/{outfrq9s_mg3_default => outfrq9s_pumas_emulated}/user_nl_clm (100%) create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/shell_commands rename cime_config/testdefs/testmods_dirs/cam/{outfrq9s_mg3_default => outfrq9s_pumas_sb2001}/user_nl_cam (72%) rename cime_config/testdefs/testmods_dirs/cam/{outfrq9s_mg3_nondefault => outfrq9s_pumas_sb2001}/user_nl_clm (100%) create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/shell_commands rename cime_config/testdefs/testmods_dirs/cam/{outfrq9s_mg3_pcols1536 => outfrq9s_pumas_tau}/user_nl_cam (75%) rename cime_config/testdefs/testmods_dirs/cam/{outfrq9s_mg3_pcols1536 => outfrq9s_pumas_tau}/user_nl_clm (100%) diff --git a/bld/build-namelist b/bld/build-namelist index cee73ece6c..892434142c 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3020,7 +3020,7 @@ add_default($nl, 'srf_flux_avg', 'val'=>0); add_default($nl, 'use_subcol_microp'); add_default($nl, 'microp_scheme'); -if ($cfg->get('microphys') =~ /^mg/) { +if ($cfg->get('microphys') =~ /^mg|pumas/) { add_default($nl, 'micro_mg_version'); add_default($nl, 'micro_mg_sub_version'); add_default($nl, 'micro_mg_num_steps'); @@ -3077,7 +3077,7 @@ if ($cfg->get('microphys') =~ /^mg/) { my $micro_mg_dcs = '400.D-6'; # default for cam5/mg1 - if ($microphys =~ /mg2|mg3/) { + if ($microphys =~ /mg2|mg3|pumas/) { if ($silhs eq '1') { $micro_mg_dcs = '390.D-6'; # default for SIHLS } @@ -4910,7 +4910,7 @@ sub check_snapshot_settings { "'physics_dme_adjust'")); push (@validList_bc, ("'dadadj_tend'", "'convect_deep_tend'", "'convect_shallow_tend'")); - if ($microphys =~ /^mg/) { + if ($microphys =~ /^mg|pumas/) { if ($clubb_sgs =~ /$TRUE/io) { push (@validList_bc, ("'clubb_tend_cam'")); } else { diff --git a/bld/config_files/definition.xml b/bld/config_files/definition.xml index 156a3e4a36..15ac6b2f55 100644 --- a/bld/config_files/definition.xml +++ b/bld/config_files/definition.xml @@ -60,10 +60,10 @@ Ionosphere model used in WACCMX. Physics package: cam3, cam4, cam5, cam6, cam_dev, held_suarez, adiabatic, kessler, tj2016, spcam_sam1mom, spcam_m2005. - + Microphysics package: rk (Rasch and Kristjansson), mg1 (Morrison and Gettelman two moment scheme CAM5.1), mg2 (Morrison and Gettelman second -version CAM6), mg3 (MG scheme 3rd version, graupel), SPCAM_m2005, SPCAM_sam1mom. +version CAM6), mg3 (MG scheme 3rd version, graupel), PUMAS, SPCAM_m2005, SPCAM_sam1mom. Macrophysics package: RK, Park, CLUBB_SGS, SPCAM_sam1mom, SPCAM_m2005. diff --git a/bld/configure b/bld/configure index 8d621a4866..ff6a91402c 100755 --- a/bld/configure +++ b/bld/configure @@ -88,7 +88,7 @@ OPTIONS -macrophys Specify the macrophysics option [rk | park | clubb_sgs]. -max_n_rad_cnst Maximum number of constituents that are either radiatively active, or in any single diagnostic list for the radiation. - -microphys Specify the microphysics option [mg1 | mg2 | mg3| rk]. + -microphys Specify the microphysics option [mg1 | mg2 | mg3| rk | pumas]. -model_top Specify the model_top option [ lt | mt ]. -nadv Set total number of advected species to . -nadv_tt Set number of advected test tracers . @@ -839,6 +839,10 @@ if (defined $opts{'microphys'}) { $microphys_pkg = lc($opts{'microphys'}); } +if($microphys_pkg == 'pumas') { + $microphys_pkg = 'mg3'; +} + $cfg_ref->set('microphys', $microphys_pkg); if ($print>=2) { print "Microphysics package: $microphys_pkg$eol"; } @@ -854,10 +858,10 @@ if (defined $opts{'carma'}) { } if ($carma_pkg =~ m/cirrus/i) { - unless ($microphys_pkg =~ /^mg/) { + unless ($microphys_pkg =~ /^mg|pumas/) { die <<"EOF"; ** ERROR: microphysics package set to: $microphys_pkg -** The CARMA cirrus model only works with MG microphysics. +** The CARMA cirrus model only works with MG or PUMAS microphysics. EOF } } @@ -881,10 +885,10 @@ if (defined $opts{'clubb_sgs'}) { # consistency checks... # CLUBB_SGS only works with mg microphysics -if ($clubb_sgs and not ($microphys_pkg =~ m/^mg/ )) { +if ($clubb_sgs and not ($microphys_pkg =~ m/^mg|pumas/ )) { die <<"EOF"; ** ERROR: microphysics package set to: $microphys_pkg -** CLUBB_SGS only works with MG microphysics. +** CLUBB_SGS only works with MG or PUMAS microphysics. EOF } @@ -1021,10 +1025,10 @@ if (defined $opts{'pbl'}) { # UW PBL only works with mg microphysics if ($pbl_pkg =~ m/uw/i) { - unless ($microphys_pkg =~ /^mg/) { + unless ($microphys_pkg =~ /^mg|pumas/) { die <<"EOF"; ** ERROR: microphysics package set to: $microphys_pkg -** The UW PBL scheme only works with MG microphysics. +** The UW PBL scheme only works with MG or PUMAS microphysics. EOF } } @@ -1045,9 +1049,9 @@ my $unicon = $cfg_ref->get('unicon'); # UNICON assumes park macrophysics, uw pbl, and mg microphysics if ($unicon and - ($macrophys_pkg ne 'park' or $pbl_pkg ne 'uw' or $microphys_pkg !~ m/^mg/) ) { + ($macrophys_pkg ne 'park' or $pbl_pkg ne 'uw' or $microphys_pkg !~ m/^mg|pumas/) ) { die <<"EOF"; -** ERROR: UNICON assumes macrophys='park', pbl='uw', microphys='mg*'. Current values are: +** ERROR: UNICON assumes macrophys='park', pbl='uw', microphys='mg*|pumas'. Current values are: ** macrophys: $macrophys_pkg, pbl: $pbl_pkg, microphys: $microphys_pkg. EOF } @@ -1506,7 +1510,7 @@ else { $nadv += 8; if ($print>=2) { print "Advected constituents added by $microphys_pkg microphysics: 8$eol"; } } - elsif ($microphys_pkg =~/^mg3/) { + elsif ($microphys_pkg =~/^mg3|pumas/) { $nadv += 10; if ($print>=2) { print "Advected constituents added by $microphys_pkg microphysics: 10$eol"; } } diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index a69d330723..b205ad8dd2 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2152,6 +2152,7 @@ .false. .false. .true. + .true. .false. NONE @@ -2161,6 +2162,7 @@ SPCAM_m2005 SPCAM_sam1mom MG +PUMAS 1 0 @@ -2174,6 +2176,10 @@ 0 1 + 3 + 0 + 1 + .false. .true. @@ -2239,17 +2245,21 @@ 1 1 3 + 3 2 1 2 - 1 + 1 2 + 1 1.0D0 1.2D0 1.2D0 1.2D0 +1.2D0 1.0D0 @@ -2257,6 +2267,7 @@ 1.2D0 1.2D0 1.2D0 +1.2D0 .false. .true. @@ -2399,6 +2410,7 @@ 0.6D0 1.0D0 1.0D0 +1.0D0 0.1D0 1.0D0 @@ -2520,6 +2532,7 @@ 0.910D0 0.950D0 0.950D0 + 0.950D0 0.8975D0 0.8875D0 0.9125D0 @@ -2686,10 +2699,12 @@ 0.4000D0 0.7000D0 0.7000D0 + 0.7000D0 0.4000D0 0.7000D0 0.7000D0 + 0.7000D0 0.0030D0 0.0059D0 @@ -2707,6 +2722,7 @@ 0.0035D0 0.0075D0 0.0075D0 + 0.0075D0 0.0035D0 0.0035D0 0.0020D0 @@ -2728,6 +2744,7 @@ 0.0035D0 0.0300D0 0.0300D0 + 0.0300D0 0.0035D0 0.0035D0 0.0020D0 @@ -2738,6 +2755,7 @@ 3.0E-6 1.0E-5 1.0E-5 + 1.0E-5 3.0E-6 5.0E-6 @@ -2895,6 +2913,7 @@ 'Q','CLDLIQ','CLDICE' 'Q','CLDLIQ','CLDICE','RAINQM','SNOWQM' 'Q','CLDLIQ','CLDICE','RAINQM','SNOWQM','GRAUQM' +'Q','CLDLIQ','CLDICE','RAINQM','SNOWQM','GRAUQM' @@ -2937,6 +2956,7 @@ 5 6 6 + 6 1 1 3 diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 3b4278775b..53dfae14ca 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -3432,7 +3432,7 @@ Default: 'ZM' unless using 'UNICON', 'SPCAM' or 'pbl=none' + group="phys_ctl_nl" valid_values="NONE,RK,MG,PUMAS,SPCAM_m2005,SPCAM_sam1mom" > Type of microphysics scheme employed. 'RK' for Rasch and Kristjansson (1998); 'MG' for Morrison and Gettelman (2008), Gettelman et al (2010) two moment scheme for CAM5 and CAM6 diff --git a/cime_config/SystemTests/mgp.py b/cime_config/SystemTests/mgp.py new file mode 100644 index 0000000000..6f4a30b5c0 --- /dev/null +++ b/cime_config/SystemTests/mgp.py @@ -0,0 +1,47 @@ +""" +CIME MGP test. This class inherits from SystemTestsCompareTwo + +This is a changing config options test to compare between MG3 and +PUMAS in camdev. The use of MG3 or PUMAS should be bfb. +This is just like an ERC test and it's meant for CAM only +as it only does a single build. + +(1) Do an initial run with microphys setup as MG3 (suffix MG3) +(2) Do an initial run with microphys setup as PUMAS (suffix PUMAS) +""" + +import sys +from CIME.XML.standard_module_setup import * +from CIME.SystemTests.restart_tests import SystemTestsCompareTwo + +logger = logging.getLogger(__name__) + +class MGP(SystemTestsCompareTwo): + + def __init__(self, case, + separate_builds=True, + run_one_suffix="mg3", + run_two_suffix="pumas", + run_one_description="initial", + run_two_description="restart", + multisubmit=False, + **kwargs + ): + SystemTestsCompareTwo.__init__(self, case, + separate_builds=separate_builds, + run_one_suffix=run_one_suffix, + run_two_suffix=run_two_suffix, + run_one_description=run_one_description, + run_two_description=run_two_description, + multisubmit=multisubmit, + **kwargs + ) + def _case_one_setup(self): + stop_n = self._case1.get_value("STOP_N") + expect(stop_n >= 3, "STOP_N must be at least 3, STOP_N = {}".format(stop_n)) + self._case.set_value("CAM_CONFIG_OPTS","-phys cam_dev -microphys mg3") + + def _case_two_setup(self): + self._case.set_value("CAM_CONFIG_OPTS","-phys cam_dev -microphys pumas") + + diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index 210a58dc5f..b69434a7b2 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -1308,6 +1308,15 @@ + + + + + + + + + @@ -1392,15 +1401,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands deleted file mode 100644 index 9fdcee8bfd..0000000000 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands +++ /dev/null @@ -1,8 +0,0 @@ -./xmlchange NTASKS=36 -./xmlchange NTHRDS=1 -./xmlchange ROOTPE='0' -./xmlchange ROF_NCPL=`./xmlquery --value ATM_NCPL` -./xmlchange GLC_NCPL=`./xmlquery --value ATM_NCPL` -./xmlchange CAM_CONFIG_OPTS=' -microphys mg3' --append -./xmlchange TIMER_DETAIL='6' -./xmlchange TIMER_LEVEL='999' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands deleted file mode 100644 index 9fdcee8bfd..0000000000 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands +++ /dev/null @@ -1,8 +0,0 @@ -./xmlchange NTASKS=36 -./xmlchange NTHRDS=1 -./xmlchange ROOTPE='0' -./xmlchange ROF_NCPL=`./xmlquery --value ATM_NCPL` -./xmlchange GLC_NCPL=`./xmlquery --value ATM_NCPL` -./xmlchange CAM_CONFIG_OPTS=' -microphys mg3' --append -./xmlchange TIMER_DETAIL='6' -./xmlchange TIMER_LEVEL='999' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam deleted file mode 100644 index 8bb09f9ffc..0000000000 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam +++ /dev/null @@ -1,24 +0,0 @@ -mfilt=1,1,1,1,1,1 -ndens=1,1,1,1,1,1 -nhtfrq=9,9,9,9,9,9 -inithist='ENDOFRUN' -micro_mg_do_graupel=.false. -micro_mg_do_hail=.true. -micro_do_sb_physics=.true. -micro_do_massless_droplet_destroyer=.true. -microp_uniform=.true. -micro_mg_nccons=.true. -micro_mg_nicons=.true. -micro_mg_ngcons=.true. -micro_mg_nrcons=.true. -micro_mg_nscons=.true. -micro_mg_evap_sed_off=.true. -micro_mg_icenuc_rh_off=.true. -micro_mg_icenuc_use_meyers=.true. -micro_mg_evap_scl_ifs=.true. -micro_mg_evap_rhthrsh_ifs=.true. -micro_mg_rainfreeze_ifs=.true. -micro_mg_ifs_sed=.true. -micro_mg_precip_fall_corr=.true. -micro_mg_implicit_fall=.false. -micro_mg_accre_sees_auto=.true. diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands deleted file mode 100644 index d6e6750eb4..0000000000 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands +++ /dev/null @@ -1,8 +0,0 @@ -./xmlchange NTASKS=36 -./xmlchange NTHRDS=1 -./xmlchange ROOTPE='0' -./xmlchange ROF_NCPL=`./xmlquery --value ATM_NCPL` -./xmlchange GLC_NCPL=`./xmlquery --value ATM_NCPL` -./xmlchange CAM_CONFIG_OPTS=' -microphys mg3 -pcols 1536' --append -./xmlchange TIMER_DETAIL='6' -./xmlchange TIMER_LEVEL='999' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/shell_commands new file mode 100644 index 0000000000..d10bce4cdc --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/shell_commands @@ -0,0 +1,3 @@ +./xmlchange ROF_NCPL=\$ATM_NCPL +./xmlchange GLC_NCPL=\$ATM_NCPL +./xmlchange CAM_CONFIG_OPTS=' -microphys pumas' --append diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_cam new file mode 100644 index 0000000000..172af9ba82 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_cam @@ -0,0 +1,5 @@ +mfilt=1,1,1,1,1,1 +ndens=1,1,1,1,1,1 +nhtfrq=9,9,9,9,9,9 +inithist='ENDOFRUN' +micro_mg_warm_rain='emulated' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_clm rename to cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/shell_commands new file mode 100644 index 0000000000..d10bce4cdc --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/shell_commands @@ -0,0 +1,3 @@ +./xmlchange ROF_NCPL=\$ATM_NCPL +./xmlchange GLC_NCPL=\$ATM_NCPL +./xmlchange CAM_CONFIG_OPTS=' -microphys pumas' --append diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_cam similarity index 72% rename from cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam rename to cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_cam index 8482082dce..5caf9ff70d 100644 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_cam @@ -2,3 +2,4 @@ mfilt=1,1,1,1,1,1 ndens=1,1,1,1,1,1 nhtfrq=9,9,9,9,9,9 inithist='ENDOFRUN' +micro_mg_warm_rain='sb2001' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_clm rename to cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/shell_commands new file mode 100644 index 0000000000..d10bce4cdc --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/shell_commands @@ -0,0 +1,3 @@ +./xmlchange ROF_NCPL=\$ATM_NCPL +./xmlchange GLC_NCPL=\$ATM_NCPL +./xmlchange CAM_CONFIG_OPTS=' -microphys pumas' --append diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_cam similarity index 75% rename from cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam rename to cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_cam index 8482082dce..28d485b6bd 100644 --- a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_cam @@ -2,3 +2,4 @@ mfilt=1,1,1,1,1,1 ndens=1,1,1,1,1,1 nhtfrq=9,9,9,9,9,9 inithist='ENDOFRUN' +micro_mg_warm_rain='tau' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_clm similarity index 100% rename from cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_clm rename to cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_clm diff --git a/src/physics/cam/cloud_diagnostics.F90 b/src/physics/cam/cloud_diagnostics.F90 index f7a5115914..181334d2bf 100644 --- a/src/physics/cam/cloud_diagnostics.F90 +++ b/src/physics/cam/cloud_diagnostics.F90 @@ -58,7 +58,7 @@ subroutine cloud_diagnostics_register call phys_getopts(radiation_scheme_out=rad_pkg,microp_scheme_out=microp_pgk) camrt_rad = rad_pkg .eq. 'camrt' rk_clouds = microp_pgk == 'RK' - mg_clouds = microp_pgk == 'MG' + mg_clouds = (microp_pgk == 'MG') .or. (microp_pgk == 'PUMAS') spcam_m2005_clouds = microp_pgk == 'SPCAM_m2005' spcam_sam1mom_clouds = microp_pgk == 'SPCAM_sam1mom' one_mom_clouds = (rk_clouds .or. spcam_sam1mom_clouds) diff --git a/src/physics/cam/convect_shallow.F90 b/src/physics/cam/convect_shallow.F90 index 0fa7e3b83d..95f5b6bf1e 100644 --- a/src/physics/cam/convect_shallow.F90 +++ b/src/physics/cam/convect_shallow.F90 @@ -730,7 +730,7 @@ subroutine convect_shallow_tend( ztodt , cmfmc , & ! Output new partition of cloud condensate variables, as well as precipitation ! ! ---------------------------------------------------------------------------- ! - if( microp_scheme == 'MG' ) then + if( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then call cnst_get_ind( 'NUMLIQ', ixnumliq ) call cnst_get_ind( 'NUMICE', ixnumice ) endif diff --git a/src/physics/cam/microp_driver.F90 b/src/physics/cam/microp_driver.F90 index baf11c4a9e..6b1ff55048 100644 --- a/src/physics/cam/microp_driver.F90 +++ b/src/physics/cam/microp_driver.F90 @@ -48,7 +48,7 @@ subroutine microp_driver_readnl(nlfile) call phys_getopts(microp_scheme_out=microp_scheme) select case (microp_scheme) - case ('MG') + case ('MG', 'PUMAS') call micro_pumas_cam_readnl(nlfile) case ('NONE', 'RK', 'SPCAM_sam1mom', 'SPCAM_m2005') continue @@ -65,7 +65,7 @@ subroutine microp_driver_register select case (microp_scheme) - case ('MG') + case ('MG','PUMAS') call micro_pumas_cam_register() case ('RK') ! microp_driver doesn't handle this one @@ -93,7 +93,7 @@ function microp_driver_implements_cnst(name) microp_driver_implements_cnst = .false. select case (microp_scheme) - case ('MG') + case ('MG','PUMAS') microp_driver_implements_cnst = micro_pumas_cam_implements_cnst(name) case ('NONE', 'RK', 'SPCAM_sam1mom', 'SPCAM_m2005') continue @@ -118,7 +118,7 @@ subroutine microp_driver_init_cnst(name, latvals, lonvals, mask, q) !----------------------------------------------------------------------- select case (microp_scheme) - case ('MG') + case ('MG','PUMAS') call micro_pumas_cam_init_cnst(name, latvals, lonvals, mask, q) case ('RK') ! microp_driver doesn't handle this one @@ -145,7 +145,7 @@ subroutine microp_driver_init(pbuf2d) !----------------------------------------------------------------------- select case (microp_scheme) - case ('MG') + case ('MG','PUMAS') call micro_pumas_cam_init(pbuf2d) case ('RK') ! microp_driver doesn't handle this one @@ -184,7 +184,7 @@ subroutine microp_driver_tend(state, ptend, dtime, pbuf) ! Call MG Microphysics select case (microp_scheme) - case ('MG') + case ('MG','PUMAS') call t_startf('microp_mg_tend') call micro_pumas_cam_tend(state, ptend, dtime, pbuf) call t_stopf('microp_mg_tend') diff --git a/src/physics/cam/phys_control.F90 b/src/physics/cam/phys_control.F90 index 8d0cad7ee3..45992cf2f7 100644 --- a/src/physics/cam/phys_control.F90 +++ b/src/physics/cam/phys_control.F90 @@ -222,9 +222,11 @@ subroutine phys_ctl_readnl(nlfile) endif ! Add a check to make sure CLUBB and MG are used together - if ( do_clubb_sgs .and. ( microp_scheme .ne. 'MG') .and. .not. use_spcam) then - write(iulog,*)'CLUBB is only compatible with MG microphysics. Quiting' - call endrun('CLUBB and microphysics schemes incompatible') + if ( do_clubb_sgs .and. .not. use_spcam) then + if ( (microp_scheme .ne. 'MG') .and. (microp_scheme .ne. 'PUMAS') ) then + write(iulog,*)'CLUBB is only compatible with MG or PUMAS microphysics. Quiting' + call endrun('CLUBB and microphysics schemes incompatible') + endif endif ! Check that eddy_scheme, macrop_scheme, shallow_scheme are all set to CLUBB_SGS if do_clubb_sgs is true @@ -255,7 +257,7 @@ subroutine phys_ctl_readnl(nlfile) ! Macro/micro co-substepping support. if (cld_macmic_num_steps > 1) then - if (microp_scheme /= "MG" .or. (macrop_scheme /= "park" .and. macrop_scheme /= "CLUBB_SGS")) then + if ((microp_scheme /= "MG" .and. microp_scheme /= "PUMAS") .or. (macrop_scheme /= "park" .and. macrop_scheme /= "CLUBB_SGS")) then call endrun ("Setting cld_macmic_num_steps > 1 is only & &supported with Park or CLUBB macrophysics and MG microphysics.") end if diff --git a/src/physics/cam/physpkg.F90 b/src/physics/cam/physpkg.F90 index 371cab1c13..96295bf6df 100644 --- a/src/physics/cam/physpkg.F90 +++ b/src/physics/cam/physpkg.F90 @@ -226,7 +226,7 @@ subroutine phys_register ! cloud water if( microp_scheme == 'RK' ) then call rk_stratiform_register() - elseif( microp_scheme == 'MG' ) then + elseif( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then if (.not. do_clubb_sgs) call macrop_driver_register() call microp_aero_register() call microp_driver_register() @@ -911,7 +911,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out ) if( microp_scheme == 'RK' ) then call rk_stratiform_init() - elseif( microp_scheme == 'MG' ) then + elseif( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then if (.not. do_clubb_sgs) call macrop_driver_init(pbuf2d) call microp_aero_init(phys_state,pbuf2d) call microp_driver_init(pbuf2d) @@ -2475,7 +2475,7 @@ subroutine tphysbc (ztodt, state, & call t_stopf('rk_stratiform_tend') - elseif( microp_scheme == 'MG' ) then + elseif( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then ! Start co-substepping of macrophysics and microphysics cld_macmic_ztodt = ztodt/cld_macmic_num_steps diff --git a/src/physics/cam/radiation_data.F90 b/src/physics/cam/radiation_data.F90 index 517b967f10..8e8c788855 100644 --- a/src/physics/cam/radiation_data.F90 +++ b/src/physics/cam/radiation_data.F90 @@ -209,7 +209,7 @@ subroutine rad_data_init( pbuf2d ) if (.not.enabled) return call phys_getopts(microp_scheme_out=microp_scheme, radiation_scheme_out=rad_scheme) - mg_microphys = (trim(microp_scheme) == 'MG') + mg_microphys = (trim(microp_scheme) == 'MG' .or. trim(microp_scheme) == 'PUMAS') volcgeom_ifld = pbuf_get_index('VOLC_RAD_GEOM',errcode=err) ! might need 3 more for 3-mode inputs volcgeom1_ifld = pbuf_get_index('VOLC_RAD_GEOM1',errcode=err) ! might need 3 more for 3-mode inputs From 3c9ca023bfa625c0bc698a833e44fa43d46a1a31 Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 13 Sep 2023 10:47:26 -0600 Subject: [PATCH 34/54] Andrew's changes for more output --- src/physics/cam_dev/micro_pumas_cam.F90 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index cb35fd3f46..af16f7fa6f 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -1051,6 +1051,10 @@ subroutine micro_pumas_cam_init(pbuf2d) ! call addfld ('nctend_TAU', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from TAU or Emulator code') ! call addfld ('qrtend_TAU', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from TAU or Emulator code') ! call addfld ('nrtend_TAU', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from TAU or Emulator code') + call addfld ('LAMC', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter lambda for liquid' ) + call addfld ('LAMR', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter lambda for rain' ) + call addfld ('PGAM', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter mu (pgam) for liquid' ) + call addfld ('N0R', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter n0 for rain' ) if (micro_mg_version > 2) then call addfld ('NMELTG', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to Melting of graupel') @@ -2371,7 +2375,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) proc_rates%amk(:ncol,:,:) = proc_rates%amk(:ncol,:,:)/num_steps proc_rates%ank(:ncol,:,:) = proc_rates%ank(:ncol,:,:)/num_steps proc_rates%amk_out(:ncol,:,:) = proc_rates%amk_out(:ncol,:,:)/num_steps - proc_rates%ank_out(:ncol,:,:) = proc_rates%ank_out(:ncol,:,:)/num_steps end if end do @@ -3282,6 +3285,10 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('LAMC', proc_rates%lamc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('LAMR', proc_rates%lamr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('PGAM', proc_rates%pgam_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('N0R', proc_rates%n0r_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) From 4645cfea0618c8a0a5dc1213fb7fada4939350f7 Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 13 Sep 2023 10:48:00 -0600 Subject: [PATCH 35/54] Found one more MG check --- src/physics/cam_dev/physpkg.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/physics/cam_dev/physpkg.F90 b/src/physics/cam_dev/physpkg.F90 index 7452f9e115..e74cab58fe 100644 --- a/src/physics/cam_dev/physpkg.F90 +++ b/src/physics/cam_dev/physpkg.F90 @@ -1646,7 +1646,7 @@ subroutine tphysac (ztodt, cam_in, & call t_stopf('carma_timestep_tend') - if( microp_scheme == 'MG' ) then + if( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then ! Start co-substepping of macrophysics and microphysics cld_macmic_ztodt = ztodt/cld_macmic_num_steps From ef2a91ca9317b61d855a7740170f9a2996f1d889 Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 15 Sep 2023 14:55:04 -0600 Subject: [PATCH 36/54] Small change to get new outputs working with older code --- src/physics/cam_dev/micro_pumas_cam.F90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index af16f7fa6f..cfca193541 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -3272,6 +3272,10 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('nc_fixer', proc_rates%nc_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qr_fixer', proc_rates%qr_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nr_fixer', proc_rates%nr_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('LAMC', proc_rates%lamc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('LAMR', proc_rates%lamr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('PGAM', proc_rates%pgam_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('N0R', proc_rates%n0r_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) end if if (trim(micro_mg_warm_rain) == 'sb2001') then @@ -3285,10 +3289,6 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('LAMC', proc_rates%lamc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('LAMR', proc_rates%lamr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('PGAM', proc_rates%pgam_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('N0R', proc_rates%n0r_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) From 7dac4af8aba45f87a569b31fc8cbc5d8ed3c7c8d Mon Sep 17 00:00:00 2001 From: Katetc Date: Mon, 18 Sep 2023 16:56:15 -0600 Subject: [PATCH 37/54] Adding tests for Derecho as well --- cime_config/testdefs/testlist_cam.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index b69434a7b2..5629aa8e87 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -1311,6 +1311,7 @@ + @@ -1402,6 +1403,7 @@ + @@ -1411,14 +1413,16 @@ + - + + @@ -1427,6 +1431,7 @@ + @@ -1436,6 +1441,7 @@ + From c1f6899f612d5f98a3cfc61f2543238deb441e97 Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 20 Sep 2023 16:44:04 -0600 Subject: [PATCH 38/54] Update Externals to new PUMAS tag --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index a85b4a1a5a..20a2836be4 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -tag = pumas_cam-release_v1.30 +tag = pumas_cam-release_v1.32 required = True [pumas-frozen] From 73cd17fb1c9e2d5ffcc3efb8caff4b8d700d02d0 Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 21 Sep 2023 12:58:25 -0600 Subject: [PATCH 39/54] Add definition for MGP test --- cime_config/config_tests.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cime_config/config_tests.xml b/cime_config/config_tests.xml index 111cb8371e..910a3f3e94 100644 --- a/cime_config/config_tests.xml +++ b/cime_config/config_tests.xml @@ -69,5 +69,15 @@ TMC CAM mass conservation test $STOP_N + + CAM test: Verify mg3 and pumas give identical answers + 1 + FALSE + FALSE + nsteps + 7 + $STOP_OPTION + $STOP_N + From 0c2a5c5302a3844647396eae4278b92b125373ae Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 27 Sep 2023 14:18:19 -0600 Subject: [PATCH 40/54] Small perl bug fix in configure --- bld/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/configure b/bld/configure index 1da4cb2ec5..bb2fe18567 100755 --- a/bld/configure +++ b/bld/configure @@ -839,7 +839,7 @@ if (defined $opts{'microphys'}) { $microphys_pkg = lc($opts{'microphys'}); } -if($microphys_pkg == 'pumas') { +if($microphys_pkg eq 'pumas') { $microphys_pkg = 'mg3'; } From 9344b93f53d0ab0fa5b5bb01d170043bf9d38717 Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 5 Oct 2023 16:28:48 -0600 Subject: [PATCH 41/54] Adding new diag history fields and updating some diag names --- src/physics/cam_dev/micro_pumas_cam.F90 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index cb5eb403b0..2005955d46 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -1047,10 +1047,6 @@ subroutine micro_pumas_cam_init(pbuf2d) call addfld ('nctend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from SB2001') call addfld ('qrtend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from SB2001') call addfld ('nrtend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from SB2001') -! call addfld ('qctend_TAU', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from TAU or Emulator code') -! call addfld ('nctend_TAU', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from TAU or Emulator code') -! call addfld ('qrtend_TAU', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from TAU or Emulator code') -! call addfld ('nrtend_TAU', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from TAU or Emulator code') call addfld ('LAMC', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter lambda for liquid' ) call addfld ('LAMR', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter lambda for rain' ) call addfld ('PGAM', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter mu (pgam) for liquid' ) @@ -3260,10 +3256,10 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('ank', proc_rates%ank, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('amk_out', proc_rates%amk_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('ank_out', proc_rates%ank_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QC_TAU_out', proc_rates%qc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NC_TAU_out', proc_rates%nc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('QR_TAU_out', proc_rates%qr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('NR_TAU_out', proc_rates%nr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QC_TAU_out', proc_rates%qc_out_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NC_TAU_out', proc_rates%nc_out_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QR_TAU_out', proc_rates%qr_out_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NR_TAU_out', proc_rates%nr_out_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qctend_TAU', proc_rates%qctend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nctend_TAU', proc_rates%nctend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qrtend_TAU', proc_rates%qrtend_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) @@ -3274,10 +3270,10 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('nc_fixer', proc_rates%nc_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qr_fixer', proc_rates%qr_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nr_fixer', proc_rates%nr_fixer, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('LAMC', proc_rates%lamc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('LAMR', proc_rates%lamr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('PGAM', proc_rates%pgam_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('N0R', proc_rates%n0r_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QC_TAU_in', proc_rates%qc_in_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NC_TAU_in', proc_rates%nc_in_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('QR_TAU_in', proc_rates%qr_in_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('NR_TAU_in', proc_rates%nr_in_TAU, ncol, lchnk, avg_subcol_field=use_subcol_microp) end if if (trim(micro_mg_warm_rain) == 'sb2001') then @@ -3291,6 +3287,10 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('LAMC', proc_rates%lamc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('LAMR', proc_rates%lamr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('PGAM', proc_rates%pgam_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('N0R', proc_rates%n0r_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICLWPI', iclwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) call outfld('MPICIWPI', iciwpi, psetcols, lchnk, avg_subcol_field=use_subcol_microp) From 98b1883bfdb88e6478edeecf2bce6cc29597d18f Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 5 Oct 2023 16:38:57 -0600 Subject: [PATCH 42/54] Update Externals for new new pumas tag --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index a4ed57e401..4c9997daaa 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -tag = pumas_cam-release_v1.32 +tag = pumas_cam-release_v1.33 required = True [pumas-frozen] From 7b34f391c3807a43478c7db16493a2fd2698cdac Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 11 Oct 2023 12:19:31 -0600 Subject: [PATCH 43/54] Adding micro_mg_vtrms namelist for ppe --- bld/build-namelist | 1 + bld/namelist_files/namelist_defaults_cam.xml | 3 +++ bld/namelist_files/namelist_definition.xml | 6 ++++++ src/physics/cam_dev/micro_pumas_cam.F90 | 14 ++++++++++---- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bld/build-namelist b/bld/build-namelist index ae145ead0b..1357078a82 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3083,6 +3083,7 @@ if ($cfg->get('microphys') =~ /^mg|pumas/) { add_default($nl, 'micro_mg_autocon_lwp_exp'); add_default($nl, 'micro_mg_homog_size'); add_default($nl, 'micro_mg_vtrmi_factor'); + add_default($nl, 'micro_mg_vtrms_factor'); add_default($nl, 'micro_mg_effi_factor'); add_default($nl, 'micro_mg_iaccr_factor'); add_default($nl, 'micro_mg_max_nicons'); diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 938abdf77b..534d637a66 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2246,6 +2246,9 @@ 1.D0 0.5D0 + 1.D0 + 0.5D0 + 1.D0 1.D0 diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 31416a408e..2e34d7e14c 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2731,6 +2731,12 @@ Unitless scaling factor for ice fall speed to account for sub-grid scale ice cry Default: 1.0 + +Unitless scaling factor for snow fall speed to account for sub-grid scale ice crystal shape variability. +Default: 1.0 + + Unitless scaling factor for ice effective radius as seen by radiation. This scaling factor adjusts for sub-grid scale ice crystal shape variability. diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 2005955d46..31d3704bbe 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -77,6 +77,7 @@ module micro_pumas_cam real(r8) :: micro_mg_autocon_lwp_exp = unset_r8 ! autoconversion lwp exponent real(r8) :: micro_mg_homog_size = unset_r8 ! size of freezing homogeneous ice real(r8) :: micro_mg_vtrmi_factor = unset_r8 ! ice fall speed factor +real(r8) :: micro_mg_vtrms_factor = unset_r8 ! snow fall speed factor real(r8) :: micro_mg_effi_factor = unset_r8 ! ice effective radius factor real(r8) :: micro_mg_iaccr_factor = unset_r8 ! ice accretion of cloud droplet real(r8) :: micro_mg_max_nicons = unset_r8 ! max allowed ice number concentration @@ -272,8 +273,8 @@ subroutine micro_pumas_cam_readnl(nlfile) microp_uniform, micro_mg_dcs, micro_mg_precip_frac_method, & micro_mg_berg_eff_factor, micro_mg_warm_rain, micro_mg_adjust_cpt, & micro_mg_do_hail, micro_mg_do_graupel, micro_mg_ngcons, micro_mg_ngnst, & - micro_mg_vtrmi_factor, micro_mg_effi_factor, micro_mg_iaccr_factor, & - micro_mg_max_nicons, micro_mg_accre_enhan_fact, & + micro_mg_vtrmi_factor, micro_mg_vtrms_factor, micro_mg_effi_factor, & + micro_mg_iaccr_factor, micro_mg_max_nicons, micro_mg_accre_enhan_fact, & micro_mg_autocon_fact, micro_mg_autocon_nd_exp, micro_mg_autocon_lwp_exp, micro_mg_homog_size, & micro_mg_nccons, micro_mg_nicons, micro_mg_ncnst, micro_mg_ninst, & micro_mg_nrcons, micro_mg_nscons, micro_mg_nrnst, micro_mg_nsnst, & @@ -387,6 +388,9 @@ subroutine micro_pumas_cam_readnl(nlfile) call mpi_bcast(micro_mg_vtrmi_factor, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_vtrmi_factor") + call mpi_bcast(micro_mg_vtrms_factor, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_vtrms_factor") + call mpi_bcast(micro_mg_effi_factor, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: micro_mg_effi_factor") @@ -481,6 +485,7 @@ subroutine micro_pumas_cam_readnl(nlfile) if(micro_mg_autocon_lwp_exp == unset_r8) call endrun(sub//": FATAL: micro_mg_autocon_lwp_exp is not set") if(micro_mg_homog_size == unset_r8) call endrun(sub//": FATAL: micro_mg_homog_size is not set") if(micro_mg_vtrmi_factor == unset_r8) call endrun(sub//": FATAL: micro_mg_vtrmi_factor is not set") + if(micro_mg_vtrms_factor == unset_r8) call endrun(sub//": FATAL: micro_mg_vtrms_factor is not set") if(micro_mg_effi_factor == unset_r8) call endrun(sub//": FATAL: micro_mg_effi_factor is not set") if(micro_mg_iaccr_factor == unset_r8) call endrun(sub//": FATAL: micro_mg_iaccr_factor is not set") if(micro_mg_max_nicons == unset_r8) call endrun(sub//": FATAL: micro_mg_max_nicons is not set") @@ -502,6 +507,7 @@ subroutine micro_pumas_cam_readnl(nlfile) write(iulog,*) ' micro_mg_autocon_lwp_exp = ' , micro_mg_autocon_lwp_exp write(iulog,*) ' micro_mg_homog_size = ', micro_mg_homog_size write(iulog,*) ' micro_mg_vtrmi_factor = ', micro_mg_vtrmi_factor + write(iulog,*) ' micro_mg_vtrms_factor = ', micro_mg_vtrms_factor write(iulog,*) ' micro_mg_effi_factor = ', micro_mg_effi_factor write(iulog,*) ' micro_mg_iaccr_factor = ', micro_mg_iaccr_factor write(iulog,*) ' micro_mg_max_nicons = ', micro_mg_max_nicons @@ -923,8 +929,8 @@ subroutine micro_pumas_cam_init(pbuf2d) micro_mg_precip_frac_method, micro_mg_berg_eff_factor, & micro_mg_accre_enhan_fact , & micro_mg_autocon_fact , micro_mg_autocon_nd_exp, micro_mg_autocon_lwp_exp, micro_mg_homog_size, & - micro_mg_vtrmi_factor, micro_mg_effi_factor, micro_mg_iaccr_factor, & - micro_mg_max_nicons, & + micro_mg_vtrmi_factor, micro_mg_vtrms_factor, micro_mg_effi_factor, & + micro_mg_iaccr_factor, micro_mg_max_nicons, & allow_sed_supersat, micro_mg_warm_rain, & micro_mg_evap_sed_off, micro_mg_icenuc_rh_off, micro_mg_icenuc_use_meyers, & micro_mg_evap_scl_ifs, micro_mg_evap_rhthrsh_ifs, & From 7d5185a62f1b1d6fe309a3e4b22aa45e5b63b76f Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 11 Oct 2023 17:40:11 -0600 Subject: [PATCH 44/54] Update externals to point to pumas tag v1.34 --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 4c9997daaa..8941263962 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -37,7 +37,7 @@ required = True local_path = src/physics/pumas protocol = git repo_url = https://github.com/ESCOMP/PUMAS -tag = pumas_cam-release_v1.33 +tag = pumas_cam-release_v1.34 required = True [pumas-frozen] From d11107652e94328a03a89ae222ae2d17782e4853 Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 12 Oct 2023 16:27:05 -0600 Subject: [PATCH 45/54] Reverting changes to support pumas named microphysics and adding back in tests that I thought were a mistake but definately werent --- .../cam/outfrq9s_mg3_default/shell_commands | 8 ++++++ .../cam/outfrq9s_mg3_default/user_nl_cam | 4 +++ .../cam/outfrq9s_mg3_default/user_nl_clm | 26 +++++++++++++++++++ .../outfrq9s_mg3_nondefault/shell_commands | 8 ++++++ .../cam/outfrq9s_mg3_nondefault/user_nl_cam | 24 +++++++++++++++++ .../cam/outfrq9s_mg3_nondefault/user_nl_clm | 26 +++++++++++++++++++ .../cam/outfrq9s_mg3_pcols1536/shell_commands | 8 ++++++ .../cam/outfrq9s_mg3_pcols1536/user_nl_cam | 4 +++ .../cam/outfrq9s_mg3_pcols1536/user_nl_clm | 26 +++++++++++++++++++ src/physics/cam/cloud_diagnostics.F90 | 2 +- src/physics/cam/convect_shallow.F90 | 2 +- src/physics/cam/microp_driver.F90 | 12 ++++----- src/physics/cam/phys_control.F90 | 10 +++---- src/physics/cam/physpkg.F90 | 6 ++--- src/physics/cam/radiation_data.F90 | 2 +- src/physics/cam_dev/physpkg.F90 | 2 +- 16 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_clm create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam create mode 100644 cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_clm diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands new file mode 100644 index 0000000000..9fdcee8bfd --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/shell_commands @@ -0,0 +1,8 @@ +./xmlchange NTASKS=36 +./xmlchange NTHRDS=1 +./xmlchange ROOTPE='0' +./xmlchange ROF_NCPL=`./xmlquery --value ATM_NCPL` +./xmlchange GLC_NCPL=`./xmlquery --value ATM_NCPL` +./xmlchange CAM_CONFIG_OPTS=' -microphys mg3' --append +./xmlchange TIMER_DETAIL='6' +./xmlchange TIMER_LEVEL='999' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam new file mode 100644 index 0000000000..8482082dce --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_cam @@ -0,0 +1,4 @@ +mfilt=1,1,1,1,1,1 +ndens=1,1,1,1,1,1 +nhtfrq=9,9,9,9,9,9 +inithist='ENDOFRUN' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_clm new file mode 100644 index 0000000000..12d5a36d2b --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_default/user_nl_clm @@ -0,0 +1,26 @@ +!---------------------------------------------------------------------------------- +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +! +! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options +! are set in the CLM_NAMELIST_OPTS env variable. +! +! EXCEPTIONS: +! Set use_cndv by the compset you use and the CLM_BLDNML_OPTS -dynamic_vegetation setting +! Set use_vichydro by the compset you use and the CLM_BLDNML_OPTS -vichydro setting +! Set use_cn by the compset you use and CLM_BLDNML_OPTS -bgc setting +! Set use_crop by the compset you use and CLM_BLDNML_OPTS -crop setting +! Set spinup_state by the CLM_BLDNML_OPTS -bgc_spinup setting +! Set irrigate by the CLM_BLDNML_OPTS -irrig setting +! Set dtime with L_NCPL option +! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options +! Set finidat with RUN_REFCASE/RUN_REFDATE/RUN_REFTOD options for hybrid or branch cases +! (includes $inst_string for multi-ensemble cases) +! Set glc_grid with CISM_GRID option +! Set glc_smb with GLC_SMB option +! Set maxpatch_glcmec with GLC_NEC option +! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable +!---------------------------------------------------------------------------------- +hist_nhtfrq = 9 +hist_mfilt = 1 +hist_ndens = 1 diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands new file mode 100644 index 0000000000..9fdcee8bfd --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/shell_commands @@ -0,0 +1,8 @@ +./xmlchange NTASKS=36 +./xmlchange NTHRDS=1 +./xmlchange ROOTPE='0' +./xmlchange ROF_NCPL=`./xmlquery --value ATM_NCPL` +./xmlchange GLC_NCPL=`./xmlquery --value ATM_NCPL` +./xmlchange CAM_CONFIG_OPTS=' -microphys mg3' --append +./xmlchange TIMER_DETAIL='6' +./xmlchange TIMER_LEVEL='999' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam new file mode 100644 index 0000000000..8bb09f9ffc --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_cam @@ -0,0 +1,24 @@ +mfilt=1,1,1,1,1,1 +ndens=1,1,1,1,1,1 +nhtfrq=9,9,9,9,9,9 +inithist='ENDOFRUN' +micro_mg_do_graupel=.false. +micro_mg_do_hail=.true. +micro_do_sb_physics=.true. +micro_do_massless_droplet_destroyer=.true. +microp_uniform=.true. +micro_mg_nccons=.true. +micro_mg_nicons=.true. +micro_mg_ngcons=.true. +micro_mg_nrcons=.true. +micro_mg_nscons=.true. +micro_mg_evap_sed_off=.true. +micro_mg_icenuc_rh_off=.true. +micro_mg_icenuc_use_meyers=.true. +micro_mg_evap_scl_ifs=.true. +micro_mg_evap_rhthrsh_ifs=.true. +micro_mg_rainfreeze_ifs=.true. +micro_mg_ifs_sed=.true. +micro_mg_precip_fall_corr=.true. +micro_mg_implicit_fall=.false. +micro_mg_accre_sees_auto=.true. diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_clm new file mode 100644 index 0000000000..12d5a36d2b --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_nondefault/user_nl_clm @@ -0,0 +1,26 @@ +!---------------------------------------------------------------------------------- +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +! +! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options +! are set in the CLM_NAMELIST_OPTS env variable. +! +! EXCEPTIONS: +! Set use_cndv by the compset you use and the CLM_BLDNML_OPTS -dynamic_vegetation setting +! Set use_vichydro by the compset you use and the CLM_BLDNML_OPTS -vichydro setting +! Set use_cn by the compset you use and CLM_BLDNML_OPTS -bgc setting +! Set use_crop by the compset you use and CLM_BLDNML_OPTS -crop setting +! Set spinup_state by the CLM_BLDNML_OPTS -bgc_spinup setting +! Set irrigate by the CLM_BLDNML_OPTS -irrig setting +! Set dtime with L_NCPL option +! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options +! Set finidat with RUN_REFCASE/RUN_REFDATE/RUN_REFTOD options for hybrid or branch cases +! (includes $inst_string for multi-ensemble cases) +! Set glc_grid with CISM_GRID option +! Set glc_smb with GLC_SMB option +! Set maxpatch_glcmec with GLC_NEC option +! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable +!---------------------------------------------------------------------------------- +hist_nhtfrq = 9 +hist_mfilt = 1 +hist_ndens = 1 diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands new file mode 100644 index 0000000000..d6e6750eb4 --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/shell_commands @@ -0,0 +1,8 @@ +./xmlchange NTASKS=36 +./xmlchange NTHRDS=1 +./xmlchange ROOTPE='0' +./xmlchange ROF_NCPL=`./xmlquery --value ATM_NCPL` +./xmlchange GLC_NCPL=`./xmlquery --value ATM_NCPL` +./xmlchange CAM_CONFIG_OPTS=' -microphys mg3 -pcols 1536' --append +./xmlchange TIMER_DETAIL='6' +./xmlchange TIMER_LEVEL='999' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam new file mode 100644 index 0000000000..8482082dce --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_cam @@ -0,0 +1,4 @@ +mfilt=1,1,1,1,1,1 +ndens=1,1,1,1,1,1 +nhtfrq=9,9,9,9,9,9 +inithist='ENDOFRUN' diff --git a/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_clm b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_clm new file mode 100644 index 0000000000..12d5a36d2b --- /dev/null +++ b/cime_config/testdefs/testmods_dirs/cam/outfrq9s_mg3_pcols1536/user_nl_clm @@ -0,0 +1,26 @@ +!---------------------------------------------------------------------------------- +! Users should add all user specific namelist changes below in the form of +! namelist_var = new_namelist_value +! +! Include namelist variables for drv_flds_in ONLY if -megan and/or -drydep options +! are set in the CLM_NAMELIST_OPTS env variable. +! +! EXCEPTIONS: +! Set use_cndv by the compset you use and the CLM_BLDNML_OPTS -dynamic_vegetation setting +! Set use_vichydro by the compset you use and the CLM_BLDNML_OPTS -vichydro setting +! Set use_cn by the compset you use and CLM_BLDNML_OPTS -bgc setting +! Set use_crop by the compset you use and CLM_BLDNML_OPTS -crop setting +! Set spinup_state by the CLM_BLDNML_OPTS -bgc_spinup setting +! Set irrigate by the CLM_BLDNML_OPTS -irrig setting +! Set dtime with L_NCPL option +! Set fatmlndfrc with LND_DOMAIN_PATH/LND_DOMAIN_FILE options +! Set finidat with RUN_REFCASE/RUN_REFDATE/RUN_REFTOD options for hybrid or branch cases +! (includes $inst_string for multi-ensemble cases) +! Set glc_grid with CISM_GRID option +! Set glc_smb with GLC_SMB option +! Set maxpatch_glcmec with GLC_NEC option +! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable +!---------------------------------------------------------------------------------- +hist_nhtfrq = 9 +hist_mfilt = 1 +hist_ndens = 1 diff --git a/src/physics/cam/cloud_diagnostics.F90 b/src/physics/cam/cloud_diagnostics.F90 index 181334d2bf..f7a5115914 100644 --- a/src/physics/cam/cloud_diagnostics.F90 +++ b/src/physics/cam/cloud_diagnostics.F90 @@ -58,7 +58,7 @@ subroutine cloud_diagnostics_register call phys_getopts(radiation_scheme_out=rad_pkg,microp_scheme_out=microp_pgk) camrt_rad = rad_pkg .eq. 'camrt' rk_clouds = microp_pgk == 'RK' - mg_clouds = (microp_pgk == 'MG') .or. (microp_pgk == 'PUMAS') + mg_clouds = microp_pgk == 'MG' spcam_m2005_clouds = microp_pgk == 'SPCAM_m2005' spcam_sam1mom_clouds = microp_pgk == 'SPCAM_sam1mom' one_mom_clouds = (rk_clouds .or. spcam_sam1mom_clouds) diff --git a/src/physics/cam/convect_shallow.F90 b/src/physics/cam/convect_shallow.F90 index 95f5b6bf1e..0fa7e3b83d 100644 --- a/src/physics/cam/convect_shallow.F90 +++ b/src/physics/cam/convect_shallow.F90 @@ -730,7 +730,7 @@ subroutine convect_shallow_tend( ztodt , cmfmc , & ! Output new partition of cloud condensate variables, as well as precipitation ! ! ---------------------------------------------------------------------------- ! - if( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then + if( microp_scheme == 'MG' ) then call cnst_get_ind( 'NUMLIQ', ixnumliq ) call cnst_get_ind( 'NUMICE', ixnumice ) endif diff --git a/src/physics/cam/microp_driver.F90 b/src/physics/cam/microp_driver.F90 index 6b1ff55048..baf11c4a9e 100644 --- a/src/physics/cam/microp_driver.F90 +++ b/src/physics/cam/microp_driver.F90 @@ -48,7 +48,7 @@ subroutine microp_driver_readnl(nlfile) call phys_getopts(microp_scheme_out=microp_scheme) select case (microp_scheme) - case ('MG', 'PUMAS') + case ('MG') call micro_pumas_cam_readnl(nlfile) case ('NONE', 'RK', 'SPCAM_sam1mom', 'SPCAM_m2005') continue @@ -65,7 +65,7 @@ subroutine microp_driver_register select case (microp_scheme) - case ('MG','PUMAS') + case ('MG') call micro_pumas_cam_register() case ('RK') ! microp_driver doesn't handle this one @@ -93,7 +93,7 @@ function microp_driver_implements_cnst(name) microp_driver_implements_cnst = .false. select case (microp_scheme) - case ('MG','PUMAS') + case ('MG') microp_driver_implements_cnst = micro_pumas_cam_implements_cnst(name) case ('NONE', 'RK', 'SPCAM_sam1mom', 'SPCAM_m2005') continue @@ -118,7 +118,7 @@ subroutine microp_driver_init_cnst(name, latvals, lonvals, mask, q) !----------------------------------------------------------------------- select case (microp_scheme) - case ('MG','PUMAS') + case ('MG') call micro_pumas_cam_init_cnst(name, latvals, lonvals, mask, q) case ('RK') ! microp_driver doesn't handle this one @@ -145,7 +145,7 @@ subroutine microp_driver_init(pbuf2d) !----------------------------------------------------------------------- select case (microp_scheme) - case ('MG','PUMAS') + case ('MG') call micro_pumas_cam_init(pbuf2d) case ('RK') ! microp_driver doesn't handle this one @@ -184,7 +184,7 @@ subroutine microp_driver_tend(state, ptend, dtime, pbuf) ! Call MG Microphysics select case (microp_scheme) - case ('MG','PUMAS') + case ('MG') call t_startf('microp_mg_tend') call micro_pumas_cam_tend(state, ptend, dtime, pbuf) call t_stopf('microp_mg_tend') diff --git a/src/physics/cam/phys_control.F90 b/src/physics/cam/phys_control.F90 index e5068a8594..92ccac1335 100644 --- a/src/physics/cam/phys_control.F90 +++ b/src/physics/cam/phys_control.F90 @@ -229,11 +229,9 @@ subroutine phys_ctl_readnl(nlfile) endif ! Add a check to make sure CLUBB and MG are used together - if ( do_clubb_sgs .and. .not. use_spcam) then - if ( (microp_scheme .ne. 'MG') .and. (microp_scheme .ne. 'PUMAS') ) then - write(iulog,*)'CLUBB is only compatible with MG or PUMAS microphysics. Quiting' - call endrun('CLUBB and microphysics schemes incompatible') - endif + if ( do_clubb_sgs .and. ( microp_scheme .ne. 'MG') .and. .not. use_spcam) then + write(iulog,*)'CLUBB is only compatible with MG microphysics. Quiting' + call endrun('CLUBB and microphysics schemes incompatible') endif ! Check that eddy_scheme, macrop_scheme, shallow_scheme are all set to CLUBB_SGS if do_clubb_sgs is true @@ -270,7 +268,7 @@ subroutine phys_ctl_readnl(nlfile) ! Macro/micro co-substepping support. if (cld_macmic_num_steps > 1) then - if ((microp_scheme /= "MG" .and. microp_scheme /= "PUMAS") .or. (macrop_scheme /= "park" .and. macrop_scheme /= "CLUBB_SGS")) then + if (microp_scheme /= "MG" .or. (macrop_scheme /= "park" .and. macrop_scheme /= "CLUBB_SGS")) then call endrun ("Setting cld_macmic_num_steps > 1 is only & &supported with Park or CLUBB macrophysics and MG microphysics.") end if diff --git a/src/physics/cam/physpkg.F90 b/src/physics/cam/physpkg.F90 index c5127de696..706b9dcdee 100644 --- a/src/physics/cam/physpkg.F90 +++ b/src/physics/cam/physpkg.F90 @@ -229,7 +229,7 @@ subroutine phys_register ! cloud water if( microp_scheme == 'RK' ) then call rk_stratiform_register() - elseif( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then + elseif( microp_scheme == 'MG' ) then if (.not. do_clubb_sgs) call macrop_driver_register() call microp_aero_register() call microp_driver_register() @@ -919,7 +919,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out ) if( microp_scheme == 'RK' ) then call rk_stratiform_init() - elseif( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then + elseif( microp_scheme == 'MG' ) then if (.not. do_clubb_sgs) call macrop_driver_init(pbuf2d) call microp_aero_init(phys_state,pbuf2d) call microp_driver_init(pbuf2d) @@ -2499,7 +2499,7 @@ subroutine tphysbc (ztodt, state, & call t_stopf('rk_stratiform_tend') - elseif( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then + elseif( microp_scheme == 'MG' ) then ! Start co-substepping of macrophysics and microphysics cld_macmic_ztodt = ztodt/cld_macmic_num_steps diff --git a/src/physics/cam/radiation_data.F90 b/src/physics/cam/radiation_data.F90 index 8e8c788855..517b967f10 100644 --- a/src/physics/cam/radiation_data.F90 +++ b/src/physics/cam/radiation_data.F90 @@ -209,7 +209,7 @@ subroutine rad_data_init( pbuf2d ) if (.not.enabled) return call phys_getopts(microp_scheme_out=microp_scheme, radiation_scheme_out=rad_scheme) - mg_microphys = (trim(microp_scheme) == 'MG' .or. trim(microp_scheme) == 'PUMAS') + mg_microphys = (trim(microp_scheme) == 'MG') volcgeom_ifld = pbuf_get_index('VOLC_RAD_GEOM',errcode=err) ! might need 3 more for 3-mode inputs volcgeom1_ifld = pbuf_get_index('VOLC_RAD_GEOM1',errcode=err) ! might need 3 more for 3-mode inputs diff --git a/src/physics/cam_dev/physpkg.F90 b/src/physics/cam_dev/physpkg.F90 index 67197fd391..b288a17177 100644 --- a/src/physics/cam_dev/physpkg.F90 +++ b/src/physics/cam_dev/physpkg.F90 @@ -1669,7 +1669,7 @@ subroutine tphysac (ztodt, cam_in, & call t_stopf('carma_timestep_tend') - if( microp_scheme == 'MG' .or. microp_scheme == 'PUMAS' ) then + if( microp_scheme == 'MG' ) then ! Start co-substepping of macrophysics and microphysics cld_macmic_ztodt = ztodt/cld_macmic_num_steps From 8a59bd7c1be85c6414612f7a74f3f9057a747e95 Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 12 Oct 2023 16:38:13 -0600 Subject: [PATCH 46/54] Reverting more pumas support that doesn't work yet --- bld/build-namelist | 6 +++--- bld/namelist_files/namelist_defaults_cam.xml | 21 +------------------- bld/namelist_files/namelist_definition.xml | 2 +- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/bld/build-namelist b/bld/build-namelist index 1357078a82..17f08163b3 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3060,7 +3060,7 @@ add_default($nl, 'srf_flux_avg', 'val'=>0); add_default($nl, 'use_subcol_microp'); add_default($nl, 'microp_scheme'); -if ($cfg->get('microphys') =~ /^mg|pumas/) { +if ($cfg->get('microphys') =~ /^mg/) { add_default($nl, 'micro_mg_version'); add_default($nl, 'micro_mg_sub_version'); add_default($nl, 'micro_mg_num_steps'); @@ -3118,7 +3118,7 @@ if ($cfg->get('microphys') =~ /^mg|pumas/) { my $micro_mg_dcs = '400.D-6'; # default for cam5/mg1 - if ($microphys =~ /mg2|mg3|pumas/) { + if ($microphys =~ /mg2|mg3/) { if ($silhs eq '1') { $micro_mg_dcs = '390.D-6'; # default for SIHLS } @@ -4989,7 +4989,7 @@ sub check_snapshot_settings { "'physics_dme_adjust'")); push (@validList_bc, ("'dadadj_tend'", "'convect_deep_tend'", "'convect_shallow_tend'")); - if ($microphys =~ /^mg|pumas/) { + if ($microphys =~ /^mg/) { if ($clubb_sgs =~ /$TRUE/io) { push (@validList_bc, ("'clubb_tend_cam'")); } else { diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 534d637a66..3f1ff1ed11 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2177,7 +2177,6 @@ .false. .false. .true. - .true. .false. NONE @@ -2187,7 +2186,7 @@ SPCAM_m2005 SPCAM_sam1mom MG -PUMAS +MG 1 0 @@ -2201,10 +2200,6 @@ 0 1 - 3 - 0 - 1 - .false. .true. @@ -2273,21 +2268,17 @@ 1 1 3 - 3 2 1 2 1 2 - 1 1.0D0 1.2D0 1.2D0 1.2D0 -1.2D0 1.0D0 @@ -2295,7 +2286,6 @@ 1.2D0 1.2D0 1.2D0 -1.2D0 .false. .true. @@ -2438,7 +2428,6 @@ 0.6D0 1.0D0 1.0D0 -1.0D0 0.1D0 1.0D0 @@ -2560,7 +2549,6 @@ 0.910D0 0.950D0 0.950D0 - 0.950D0 0.8975D0 0.8875D0 0.9125D0 @@ -2727,12 +2715,10 @@ 0.4000D0 0.7000D0 0.7000D0 - 0.7000D0 0.4000D0 0.7000D0 0.7000D0 - 0.7000D0 0.0030D0 0.0059D0 @@ -2750,7 +2736,6 @@ 0.0035D0 0.0075D0 0.0075D0 - 0.0075D0 0.0035D0 0.0035D0 0.0020D0 @@ -2772,7 +2757,6 @@ 0.0035D0 0.0300D0 0.0300D0 - 0.0300D0 0.0035D0 0.0035D0 0.0020D0 @@ -2783,7 +2767,6 @@ 3.0E-6 1.0E-5 1.0E-5 - 1.0E-5 3.0E-6 5.0E-6 @@ -2941,7 +2924,6 @@ 'Q','CLDLIQ','CLDICE' 'Q','CLDLIQ','CLDICE','RAINQM','SNOWQM' 'Q','CLDLIQ','CLDICE','RAINQM','SNOWQM','GRAUQM' -'Q','CLDLIQ','CLDICE','RAINQM','SNOWQM','GRAUQM' @@ -2984,7 +2966,6 @@ 5 6 6 - 6 1 1 3 diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 2e34d7e14c..21eaa98edc 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -3560,7 +3560,7 @@ Default: 'ZM' unless using 'UNICON', 'SPCAM' or 'pbl=none' + group="phys_ctl_nl" valid_values="NONE,RK,MG,SPCAM_m2005,SPCAM_sam1mom" > Type of microphysics scheme employed. 'RK' for Rasch and Kristjansson (1998); 'MG' for Morrison and Gettelman (2008), Gettelman et al (2010) two moment scheme for CAM5 and CAM6 From c1eb7f84dfbb2053a9b07f93160cf4faf5546aff Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 12 Oct 2023 16:41:16 -0600 Subject: [PATCH 47/54] Oops, missed a bracket --- bld/namelist_files/namelist_defaults_cam.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 3f1ff1ed11..327dd4e681 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2272,7 +2272,7 @@ 2 1 2 - 1 1 1.0D0 From 852137e88c34170e197050f6b69029a1ce7895e2 Mon Sep 17 00:00:00 2001 From: katetc Date: Tue, 24 Oct 2023 14:49:21 -0600 Subject: [PATCH 48/54] Changes to addres initial review comments --- cime_config/testdefs/testlist_cam.xml | 6 ------ src/physics/cam_dev/stochastic_emulated_cam.F90 | 9 +-------- src/physics/cam_dev/stochastic_tau_cam.F90 | 6 ++---- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/cime_config/testdefs/testlist_cam.xml b/cime_config/testdefs/testlist_cam.xml index 14110cea3b..2b08d0b812 100644 --- a/cime_config/testdefs/testlist_cam.xml +++ b/cime_config/testdefs/testlist_cam.xml @@ -1388,7 +1388,6 @@ - @@ -1477,7 +1476,6 @@ - @@ -1487,7 +1485,6 @@ - @@ -1496,7 +1493,6 @@ - @@ -1505,7 +1501,6 @@ - @@ -1515,7 +1510,6 @@ - diff --git a/src/physics/cam_dev/stochastic_emulated_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 index 327ba20d07..6680c9baac 100644 --- a/src/physics/cam_dev/stochastic_emulated_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -5,10 +5,8 @@ module stochastic_emulated_cam !output the mass and number mixing ratio tendencies in each bin directly. !this is then wrapped for CAM. -use shr_kind_mod, only: r8=>shr_kind_r8 use shr_kind_mod, only: cl=>shr_kind_cl use cam_history, only: addfld -use micro_pumas_utils, only: pi, rhow, qsmall use cam_logfile, only: iulog use cam_abortutils, only: endrun @@ -28,10 +26,6 @@ module stochastic_emulated_cam character(len=cl) :: stochastic_emulated_filename_input_scale = " " character(len=cl) :: stochastic_emulated_filename_output_scale = " " -real(r8), public :: mmean(ncd), diammean(ncd) ! kg & m at bin mid-points -real(r8), public :: medge(ncdp), diamedge(ncdp) ! kg & m at bin edges -integer, private :: cutoff_id ! cutoff between cloud water and rain drop, D = 40 microns - !=============================================================================== contains !=============================================================================== @@ -74,8 +68,7 @@ subroutine stochastic_emulated_readnl(nlfile) call mpi_bcast(stochastic_emulated_filename_output_scale, cl, mpi_character, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: stochastic_emulated_filename_output_scale") -!CACNOTE - write(0,*) ' Inside stochastic_emulated_readnl, stochastic_emulated_filename_quantile=',& + write(iulog,*) 'PUMAS stochastic_emulated_readnl, stochastic_emulated_filename_quantile=',& stochastic_emulated_filename_quantile end subroutine stochastic_emulated_readnl diff --git a/src/physics/cam_dev/stochastic_tau_cam.F90 b/src/physics/cam_dev/stochastic_tau_cam.F90 index 0fc28c5196..d4d4fce78c 100644 --- a/src/physics/cam_dev/stochastic_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_tau_cam.F90 @@ -5,9 +5,8 @@ module stochastic_tau_cam !output the mass and number mixing ratio tendencies in each bin directly. !this is then wrapped for CAM. -use shr_kind_mod, only: r8=>shr_kind_r8, cl=>shr_kind_cl +use shr_kind_mod, only: cl=>shr_kind_cl use cam_history, only: addfld -use micro_pumas_utils, only: pi, rhow, qsmall use cam_logfile, only: iulog implicit none @@ -57,8 +56,7 @@ subroutine stochastic_tau_readnl(nlfile) call mpi_bcast(pumas_stochastic_tau_kernel_filename, cl, mpi_character, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: pumas_stochastic_tau_kernel_filename") -!CACNOTE - write(0,*) ' Inside stochastic_tau_readnl, pumas_stochastic_tau_kernel_filename=',pumas_stochastic_tau_kernel_filename + write(iulog,*) 'PUMAS stochastic_tau_readnl, pumas_stochastic_tau_kernel_filename=',pumas_stochastic_tau_kernel_filename end subroutine stochastic_tau_readnl From 6443fcb68319296a3828c63611bb5014d146e1b4 Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 2 Nov 2023 11:51:37 -0600 Subject: [PATCH 49/54] Addressing review comments --- bld/configure | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bld/configure b/bld/configure index bb2fe18567..dc76c2c2c6 100755 --- a/bld/configure +++ b/bld/configure @@ -858,7 +858,7 @@ if (defined $opts{'carma'}) { } if ($carma_pkg =~ m/cirrus/i) { - unless ($microphys_pkg =~ /^mg|pumas/) { + unless ($microphys_pkg =~ /^mg/) { die <<"EOF"; ** ERROR: microphysics package set to: $microphys_pkg ** The CARMA cirrus model only works with MG or PUMAS microphysics. @@ -885,7 +885,7 @@ if (defined $opts{'clubb_sgs'}) { # consistency checks... # CLUBB_SGS only works with mg microphysics -if ($clubb_sgs and not ($microphys_pkg =~ m/^mg|pumas/ )) { +if ($clubb_sgs and not ($microphys_pkg =~ m/^mg/ )) { die <<"EOF"; ** ERROR: microphysics package set to: $microphys_pkg ** CLUBB_SGS only works with MG or PUMAS microphysics. @@ -1025,7 +1025,7 @@ if (defined $opts{'pbl'}) { # UW PBL only works with mg microphysics if ($pbl_pkg =~ m/uw/i) { - unless ($microphys_pkg =~ /^mg|pumas/) { + unless ($microphys_pkg =~ /^mg/) { die <<"EOF"; ** ERROR: microphysics package set to: $microphys_pkg ** The UW PBL scheme only works with MG or PUMAS microphysics. @@ -1049,9 +1049,9 @@ my $unicon = $cfg_ref->get('unicon'); # UNICON assumes park macrophysics, uw pbl, and mg microphysics if ($unicon and - ($macrophys_pkg ne 'park' or $pbl_pkg ne 'uw' or $microphys_pkg !~ m/^mg|pumas/) ) { + ($macrophys_pkg ne 'park' or $pbl_pkg ne 'uw' or $microphys_pkg !~ m/^mg/) ) { die <<"EOF"; -** ERROR: UNICON assumes macrophys='park', pbl='uw', microphys='mg*|pumas'. Current values are: +** ERROR: UNICON assumes macrophys='park', pbl='uw', microphys='mg*'. Current values are: ** macrophys: $macrophys_pkg, pbl: $pbl_pkg, microphys: $microphys_pkg. EOF } @@ -1510,7 +1510,7 @@ else { $nadv += 8; if ($print>=2) { print "Advected constituents added by $microphys_pkg microphysics: 8$eol"; } } - elsif ($microphys_pkg =~/^mg3|pumas/) { + elsif ($microphys_pkg =~/^mg3/) { $nadv += 10; if ($print>=2) { print "Advected constituents added by $microphys_pkg microphysics: 10$eol"; } } From 3fe3c8616c6526b946c3f186e1073529405b42e7 Mon Sep 17 00:00:00 2001 From: Katetc Date: Thu, 7 Dec 2023 16:28:01 -0700 Subject: [PATCH 50/54] Fix for FSCAM --- bld/build-namelist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/build-namelist b/bld/build-namelist index 61864725b5..fcf1cfca79 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3088,7 +3088,6 @@ if ($cfg->get('microphys') =~ /^mg/) { add_default($nl, 'micro_mg_autocon_lwp_exp'); add_default($nl, 'micro_mg_homog_size'); add_default($nl, 'micro_mg_vtrmi_factor'); - add_default($nl, 'micro_mg_vtrms_factor'); add_default($nl, 'micro_mg_effi_factor'); add_default($nl, 'micro_mg_iaccr_factor'); add_default($nl, 'micro_mg_max_nicons'); @@ -3099,6 +3098,7 @@ if ($cfg->get('microphys') =~ /^mg/) { if ($phys =~ /cam_dev/) { add_default($nl, 'micro_mg_warm_rain'); add_default($nl, 'micro_mg_accre_sees_auto'); + add_default($nl, 'micro_mg_vtrms_factor'); add_default($nl, 'micro_mg_implicit_fall'); add_default($nl, 'pumas_stochastic_tau_kernel_filename', 'val'=>"$cfgdir/../src/physics/pumas/KBARF_tau_kernel.dat"); From 67097c084c3525483e38a7606c91f0c9412dc6cc Mon Sep 17 00:00:00 2001 From: Katetc Date: Fri, 15 Dec 2023 16:49:24 -0700 Subject: [PATCH 51/54] Addressing review comments --- bld/namelist_files/namelist_definition.xml | 2 +- cime_config/SystemTests/mgp.py | 6 ++-- cime_config/testdefs/testlist_cam.xml | 4 +++ src/physics/cam_dev/micro_pumas_cam.F90 | 31 +++++++++++-------- .../cam_dev/stochastic_emulated_cam.F90 | 10 +++--- src/physics/cam_dev/stochastic_tau_cam.F90 | 9 +++--- 6 files changed, 36 insertions(+), 26 deletions(-) diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 1b63a85371..4a42085572 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -2788,7 +2788,7 @@ Neural net output scaling values file for warm_rain machine learning -Coefficients for the stochastic collection kernel used by the TAU stochastice collection code, invoked in PUMAS with micro_pumas_warm_rain = 'tau' +Coefficients for the stochastic collection kernel used by the TAU stochastic collection code, invoked in PUMAS with micro_pumas_warm_rain = 'tau' + @@ -1489,6 +1490,7 @@ + @@ -1497,6 +1499,7 @@ + @@ -1505,6 +1508,7 @@ + diff --git a/src/physics/cam_dev/micro_pumas_cam.F90 b/src/physics/cam_dev/micro_pumas_cam.F90 index 31d3704bbe..7c38333e95 100644 --- a/src/physics/cam_dev/micro_pumas_cam.F90 +++ b/src/physics/cam_dev/micro_pumas_cam.F90 @@ -1045,14 +1045,18 @@ subroutine micro_pumas_cam_init(pbuf2d) call addfld ('NMELTO', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to Melting of cloud ice ') call addfld ('NMELTS', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'Number Tendency due to Melting of snow') - call addfld ('qctend_KK2000', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from KK2000') - call addfld ('nctend_KK2000', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud number mass tendency due to autoconversion & accretion from KK2000') - call addfld ('qrtend_KK2000', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from KK2000') - call addfld ('nrtend_KK2000', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from KK2000') - call addfld ('qctend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from SB2001') - call addfld ('nctend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from SB2001') - call addfld ('qrtend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from SB2001') - call addfld ('nrtend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from SB2001') + if (trim(micro_mg_warm_rain) == 'kk2000') then + call addfld ('qctend_KK2000', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from KK2000') + call addfld ('nctend_KK2000', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud number mass tendency due to autoconversion & accretion from KK2000') + call addfld ('qrtend_KK2000', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from KK2000') + call addfld ('nrtend_KK2000', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from KK2000') + end if + if (trim(micro_mg_warm_rain) == 'sb2001') then + call addfld ('qctend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'cloud liquid mass tendency due to autoconversion & accretion from SB2001') + call addfld ('nctend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'cloud liquid number tendency due to autoconversion & accretion from SB2001') + call addfld ('qrtend_SB2001', (/ 'trop_cld_lev' /), 'A', 'kg/kg/s', 'rain mass tendency due to autoconversion & accretion from SB2001') + call addfld ('nrtend_SB2001', (/ 'trop_cld_lev' /), 'A', '#/kg/s', 'rain number tendency due to autoconversion & accretion from SB2001') + end if call addfld ('LAMC', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter lambda for liquid' ) call addfld ('LAMR', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter lambda for rain' ) call addfld ('PGAM', (/ 'trop_cld_lev' /), 'A', 'unitless', 'Size distribution parameter mu (pgam) for liquid' ) @@ -3288,11 +3292,12 @@ subroutine micro_pumas_cam_tend(state, ptend, dtime, pbuf) call outfld('qrtend_SB2001', proc_rates%qrtend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('nrtend_SB2001', proc_rates%nrtend_SB2001, ncol, lchnk, avg_subcol_field=use_subcol_microp) end if - - call outfld('qctend_KK2000', proc_rates%qctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) - call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + if (trim(micro_mg_warm_rain) == 'kk2000') then + call outfld('qctend_KK2000', proc_rates%qctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nctend_KK2000', proc_rates%nctend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('qrtend_KK2000', proc_rates%qrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + call outfld('nrtend_KK2000', proc_rates%nrtend_KK2000, ncol, lchnk, avg_subcol_field=use_subcol_microp) + end if call outfld('LAMC', proc_rates%lamc_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('LAMR', proc_rates%lamr_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) call outfld('PGAM', proc_rates%pgam_out, ncol, lchnk, avg_subcol_field=use_subcol_microp) diff --git a/src/physics/cam_dev/stochastic_emulated_cam.F90 b/src/physics/cam_dev/stochastic_emulated_cam.F90 index 6680c9baac..8fbc9e44a1 100644 --- a/src/physics/cam_dev/stochastic_emulated_cam.F90 +++ b/src/physics/cam_dev/stochastic_emulated_cam.F90 @@ -35,9 +35,9 @@ subroutine stochastic_emulated_readnl(nlfile) use namelist_utils, only: find_group_name use units, only: getunit, freeunit use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_character, masterproc + use string_utils, only: int2str character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input - integer :: unitn, ierr character(len=*), parameter :: sub = 'stochastic_emulated_readnl' @@ -51,7 +51,7 @@ subroutine stochastic_emulated_readnl(nlfile) if (ierr == 0) then read(unitn, stochastic_emulated_nl, iostat=ierr) if (ierr /= 0) then - call endrun(sub // ':: ERROR reading namelist') + call endrun(sub // ':: ERROR reading namelist, iostat = ' // int2str(ierr)) end if end if close(unitn) @@ -87,8 +87,8 @@ subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_ou call addfld('amk_c',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') call addfld('ank_c',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','rain mass from bins') + call addfld('ank_r',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','rain number concentration from bins') call addfld('amk',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') call addfld('ank',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','all liquid number concentration from bins') call addfld('amk_out',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') @@ -118,7 +118,7 @@ subroutine stochastic_emulated_init_cam(stochastic_emulated_filename_quantile_ou call addfld('nrtend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code') call addfld('gmnnn_lmnnn_TAU',(/'trop_cld_lev'/),'A','1','sum of mass gain and loss from bin code') - call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency of ML fixer is activated') + call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency that ML fixer is activated') call addfld('qc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qc due to ML fixer') call addfld('nc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nc due to ML fixer') call addfld('qr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qr due to ML fixer') diff --git a/src/physics/cam_dev/stochastic_tau_cam.F90 b/src/physics/cam_dev/stochastic_tau_cam.F90 index d4d4fce78c..b305201e7c 100644 --- a/src/physics/cam_dev/stochastic_tau_cam.F90 +++ b/src/physics/cam_dev/stochastic_tau_cam.F90 @@ -30,6 +30,7 @@ subroutine stochastic_tau_readnl(nlfile) use units, only: getunit, freeunit use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_character, masterproc use cam_abortutils, only: endrun + use string_utils, only: int2str character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input @@ -45,7 +46,7 @@ subroutine stochastic_tau_readnl(nlfile) if (ierr == 0) then read(unitn, pumas_stochastic_tau_nl, iostat=ierr) if (ierr /= 0) then - call endrun(sub // ':: ERROR reading namelist') + call endrun(sub // ':: ERROR reading namelist, iostat = ' // int2str(ierr)) end if end if close(unitn) @@ -73,8 +74,8 @@ subroutine stochastic_tau_init_cam !Note: lev needs to be trop_cld_lev for proc_rates.... call addfld('amk_c',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') call addfld('ank_c',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') - call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','cloud liquid mass from bins') - call addfld('ank_r',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','cloud liquid number concentration from bins') + call addfld('amk_r',(/'trop_cld_lev','bins_ncd '/),'A','kg','rain mass from bins') + call addfld('ank_r',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','rain number concentration from bins') call addfld('amk',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') call addfld('ank',(/'trop_cld_lev','bins_ncd '/),'A','1/kg','all liquid number concentration from bins') call addfld('amk_out',(/'trop_cld_lev','bins_ncd '/),'A','kg','all liquid mass from bins') @@ -104,7 +105,7 @@ subroutine stochastic_tau_init_cam call addfld('nrtend_TAU_diag',(/'trop_cld_lev'/),'A','1/kg/s','nr tendency due to TAU bin code') call addfld('gmnnn_lmnnn_TAU',(/'trop_cld_lev'/),'A','1','sum of mass gain and loss from bin code') - call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency of ML fixer is activated') + call addfld('ML_fixer',(/'trop_cld_lev'/),'A','1','frequency that ML fixer is activated') call addfld('qc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qc due to ML fixer') call addfld('nc_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta nc due to ML fixer') call addfld('qr_fixer',(/'trop_cld_lev'/),'A','kg/kg','delta qr due to ML fixer') From c41dc27265ccae924bd173260ded18fe66385950 Mon Sep 17 00:00:00 2001 From: Katetc Date: Wed, 27 Dec 2023 14:21:10 -0700 Subject: [PATCH 52/54] Revert to non-answer changing for cam_dev compsets --- bld/namelist_files/namelist_defaults_cam.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 1b8ab0038a..84ad141171 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2254,7 +2254,7 @@ 1.D0 1.D0 - 0.5D0 + 1.D0 1.D0 From 616af59ca88bbcc5ef56f603d37ce8f52618362a Mon Sep 17 00:00:00 2001 From: Katetc Date: Tue, 2 Jan 2024 15:05:21 -0700 Subject: [PATCH 53/54] Update ChangeLog and remove comment --- bld/namelist_files/namelist_defaults_cam.xml | 2 - doc/ChangeLog | 119 +++++++++++++++++++ 2 files changed, 119 insertions(+), 2 deletions(-) diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index 84ad141171..ddcef1fdd3 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2252,9 +2252,7 @@ 25.D-6 1.D0 - 1.D0 - 1.D0 1.D0 diff --git a/doc/ChangeLog b/doc/ChangeLog index 0c5a8ebe4d..6000655c45 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,124 @@ =============================================================== +Tag name: cam6_3_144 +Originator(s): katetc, cacraigucar, andrewgettelman, wkchuang, djgagne +Date: 01 Jan 2024 +One-line Summary: Introduce changes needed to support machine learning in PUMAS microphysics +Github PR URL: https://github.com/ESCOMP/CAM/pull/858 + +Purpose of changes (include the issue number and title text for each relevant GitHub issue): + + PR with the tag for PUMAS now including early support for a machine learning kernel. Fixes #801 + - Bring in Machine Learning warm rain capability. Also includes micro_mg_vtrms namelist for the + CAM7 PPE. Also includes addition of an aux_pumas test suite. + +Describe any changes made to build system: + Added "pumas" as a valid microphysics scheme in the configure script. Currently the "pumas" + option is set to "mg3" in configure, as full support is left for a later tag. + +Describe any changes made to the namelist: + +. Added micro_mg_warm_rain: Choices for the PUMAS warm rain accretion formulation. + Options include sb2001, kk2000, tau and emulated (machine learning). kk2000 is default. +. Added micro_mg_vtrms_factor: A microphysics parameter for adjusting the snow fall speed. Default + is 1.0 to maintain answers in cam_dev. +. Added pumas_stochastic_tau_kernal_filename: Coefficients for the stochastic collection kernel used + by the TAU stochastic collection code, invoked in PUMAS with micro_pumas_warm_rain = 'tau' +. Added stochastic_emulated_filename_quantile: Neural net file for warm_rain machine learning +. Added stochastic_emulated_filename_input_scale: Neural net input scaling values file for warm_rain + machine learning +. Added stochastic_emulated_filename_output_scale: Neural net output scaling values file for warm_rain + machine learning + +List any changes to the defaults for the boundary datasets: N/A + +Describe any substantial timing or memory changes: N/A + +Code reviewed by: cacraigucar, peverwhee, nusbaume, sjsprecious + +List all files eliminated: N/A + +List all files added and what they do: + +A cime_config/SystemTests/mgp.py + - Added system test to ensure that "pumas" and "mg3" microphysics options give the same answers. + Used in the aux_puams test suite + +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/shell_commands +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_cam +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_emulated/user_nl_clm + - Added test for the "emulated" pumas warm rain option, used in aux_pumas test suite + +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/shell_commands +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_cam +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_sb2001/user_nl_clm + - Added test for the "sb2001" pumas warm rain option, used in aux_pumas test suite + +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/shell_commands +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_cam +A cime_config/testdefs/testmods_dirs/cam/outfrq9s_pumas_tau/user_nl_clm + - Added test for the "tau" pumas warm rain option, used in aux_pumas test suite + +A src/physics/cam_dev/stochastic_emulated_cam.F90 +A src/physics/cam_dev/stochastic_tau_cam.F90 + - Supporting code for the PUMAS warm rain machine learning neural net + +List all existing files that have been modified, and describe the changes: + +M Externals_CAM.cfg + - New PUMAS external with machine learning support and vtrms namelist support + +M bld/build-namelist +M bld/namelist_files/namelist_defaults_cam.xml +M bld/namelist_files/namelist_definition.xml + - Added support for micro_mg_warm_rain, micro_mg_vtrms and pumas_stochastic_tau_kernal_filename. + Also several namelist fields for pumas machine learning, but not set to default + +M bld/config_files/definition.xml +M bld/configure + - Added "pumas" as a valid configure microphysics option. Currently set to mg3 immediately. + +M cime_config/config_tests.xml +M cime_config/testdefs/testlist_cam.xml + - Added support for the mgp test and the aux_pumas test suite + +M src/physics/cam_dev/micro_pumas_cam.F90 + - Support for the machine learning warm rain options for PUMAS, the vtrms_factor namelist field, + adding some history fields related to the machine learning and new warm rain options. + +If there were any failures reported from running test_driver.sh on any test +platform, and checkin with these failures has been OK'd by the gatekeeper, +then copy the lines from the td.*.status files for the failed tests to the +appropriate machine below. All failed tests must be justified. + +derecho/intel/aux_cam: + ERP_Ln9_Vnuopc.C96_C96_mg17.F2000climo.derecho_intel.cam-outfrq9s_mg3 (Overall: FAIL) + ERP_Ln9_Vnuopc.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL) + - pre-existing failures + + ERP_D_Ln9.ne30pg3_ne30pg3_mg17.FLTHIST.derecho_intel.cam-outfrq9s (Overall: NLFAIL) + ERP_D_Ln9_Vnuopc.ne30pg3_ne30pg3_mg17.F2000dev.derecho_intel.cam-outfrq9s (Overall: NLFAIL) + ERP_Ln9_Vnuopc.f09_f09_mg17.F2000dev.derecho_intel.cam-outfrq9s_mg3 (Overall: NLFAIL) + ERS_Ld3_Vnuopc.f10_f10_mg37.F1850.derecho_intel.cam-outfrq1d_14dec_ghg_cam_dev (Overall: NLFAIL) + SMS_D_Ln9.ne30pg3_ne30pg3_mg17.FMTHIST.derecho_intel.cam-outfrq9s (Overall: NLFAIL) + SMS_D_Ln9_Vnuopc_P1280x1.ne30pg3_ne30pg3_mg17.FCLTHIST.derecho_intel.cam-outfrq9s (Overall: NLFAIL) + SMS_Ld1_Vnuopc.f19_f19.F2000dev.derecho_intel.cam-outfrq1d (Overall: NLFAIL) + - Expected namelist differences due to new PUMAS namelist options (in cam_dev) + +izumi/nag/aux_cam: + DAE_Vnuopc.f45_f45_mg37.FHS94.izumi_nag.cam-dae (Overall: FAIL) details: + - pre-existing failure + +izumi/gnu/aux_cam: + SMS_D_Ln9.f10_f10_mg37.2000_CAM%DEV%GHGMAM4_CLM50%SP_CICE%PRES_DOCN%DOM_MOSART_SGLC_SWAV_SESP.izumi_gnu.cam-outfrq9s (Overall: NLFAIL) + - Expected namelist differences due to new PUMAS namelist options (in cam_dev) + +Summarize any changes to answers: bit-for-bit unchanged + +=============================================================== + +=============================================================== + Tag name: cam6_3_143 Originator(s): fvitt Date: 20 Dec 2023 From 2bb62a480a6237fd231337793e362e33b5d49ef8 Mon Sep 17 00:00:00 2001 From: Katetc Date: Tue, 2 Jan 2024 15:06:55 -0700 Subject: [PATCH 54/54] Correct date for cam6_3_144 --- doc/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 6000655c45..b5109f1d9a 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -2,7 +2,7 @@ Tag name: cam6_3_144 Originator(s): katetc, cacraigucar, andrewgettelman, wkchuang, djgagne -Date: 01 Jan 2024 +Date: 02 Jan 2024 One-line Summary: Introduce changes needed to support machine learning in PUMAS microphysics Github PR URL: https://github.com/ESCOMP/CAM/pull/858