From f213a1378bf7b3f0c6e840f6eb384ba1564016f0 Mon Sep 17 00:00:00 2001 From: xie7 Date: Mon, 23 Dec 2024 21:02:41 -0800 Subject: [PATCH] Fixed the namelist bug for changing tuning par in oro_drag. modified: control/runtime_opts.F90 modified: physics/cam/clubb_intr.F90 modified: physics/cam/gw_drag.F90 modified: physics/cam/od_common.F90 modified: physics/cam/phys_control.F90 [BFB] --- components/eam/src/control/runtime_opts.F90 | 2 + components/eam/src/physics/cam/clubb_intr.F90 | 3 +- components/eam/src/physics/cam/gw_drag.F90 | 3 +- components/eam/src/physics/cam/od_common.F90 | 58 ++++++++++++++++++- .../eam/src/physics/cam/phys_control.F90 | 7 --- 5 files changed, 63 insertions(+), 10 deletions(-) diff --git a/components/eam/src/control/runtime_opts.F90 b/components/eam/src/control/runtime_opts.F90 index c52c02a5c238..1fcd84806b77 100644 --- a/components/eam/src/control/runtime_opts.F90 +++ b/components/eam/src/control/runtime_opts.F90 @@ -246,6 +246,7 @@ subroutine read_namelist(single_column_in, scmlon_in, scmlat_in, scm_multcols_in use uwshcu, only: uwshcu_readnl use pkg_cld_sediment, only: cld_sediment_readnl use gw_drag, only: gw_drag_readnl + use od_common, only: oro_drag_readnl use qbo, only: qbo_readnl use iondrag, only: iondrag_readnl use phys_debug_util, only: phys_debug_readnl @@ -516,6 +517,7 @@ subroutine read_namelist(single_column_in, scmlon_in, scmlat_in, scm_multcols_in call uwshcu_readnl(nlfilename) call cld_sediment_readnl(nlfilename) call gw_drag_readnl(nlfilename) + call oro_drag_readnl(nlfilename) call qbo_readnl(nlfilename) call iondrag_readnl(nlfilename) call phys_debug_readnl(nlfilename) diff --git a/components/eam/src/physics/cam/clubb_intr.F90 b/components/eam/src/physics/cam/clubb_intr.F90 index 0d45232f8a98..33815759e7ca 100644 --- a/components/eam/src/physics/cam/clubb_intr.F90 +++ b/components/eam/src/physics/cam/clubb_intr.F90 @@ -20,7 +20,8 @@ module clubb_intr use shr_kind_mod, only: r8=>shr_kind_r8 use shr_log_mod , only: errMsg => shr_log_errMsg use ppgrid, only: pver, pverp - use phys_control, only: phys_getopts, use_od_ss, use_od_fd, od_ls_ncleff, od_bl_ncd, od_ss_sncleff + use phys_control, only: phys_getopts, use_od_ss, use_od_fd + use od_common, only: od_ls_ncleff, od_bl_ncd, od_ss_sncleff use physconst, only: rair, cpair, gravit, latvap, latice, zvir, rh2o, karman, & tms_orocnst, tms_z0fac, pi use cam_logfile, only: iulog diff --git a/components/eam/src/physics/cam/gw_drag.F90 b/components/eam/src/physics/cam/gw_drag.F90 index c17ca3b4b36c..2f3c1652a68f 100644 --- a/components/eam/src/physics/cam/gw_drag.F90 +++ b/components/eam/src/physics/cam/gw_drag.F90 @@ -38,7 +38,8 @@ module gw_drag ! These are the actual switches for different gravity wave sources. ! The orographic control switches are also here - use phys_control, only: use_gw_oro, use_gw_front, use_gw_convect, use_gw_energy_fix, use_od_ls, use_od_bl, use_od_ss, od_ls_ncleff, od_bl_ncd, od_ss_sncleff + use phys_control, only: use_gw_oro, use_gw_front, use_gw_convect, use_gw_energy_fix, use_od_ls, use_od_bl, use_od_ss + use od_common, only: od_ls_ncleff, od_bl_ncd, od_ss_sncleff ! Typical module header implicit none diff --git a/components/eam/src/physics/cam/od_common.F90 b/components/eam/src/physics/cam/od_common.F90 index 5d84e718b287..52658d2dbecb 100644 --- a/components/eam/src/physics/cam/od_common.F90 +++ b/components/eam/src/physics/cam/od_common.F90 @@ -13,8 +13,9 @@ module od_common use ppgrid, only: pcols, pver, begchunk, endchunk use cam_logfile, only: iulog use cam_abortutils,only: endrun +use spmd_utils, only: masterproc use pio, only: file_desc_t -use phys_control, only: use_od_ls, use_od_bl, use_od_ss, od_ls_ncleff, od_bl_ncd, od_ss_sncleff +use phys_control, only: use_od_ls, use_od_bl, use_od_ss use physics_buffer,only: dtype_r8, physics_buffer_desc, pbuf_get_chunk use physics_buffer,only: pbuf_get_index, pbuf_get_field, pbuf_add_field, pbuf_set_field @@ -23,6 +24,7 @@ module od_common save ! Public interface. +public :: oro_drag_readnl public :: oro_drag_register public :: oro_drag_init public :: oro_drag_interface @@ -40,10 +42,64 @@ module od_common integer :: oro_drag_efflength_idx = -1 ! Effective length integer :: oro_drag_ribulk_idx = -1 ! bulk richardson number (calculated in CLUBB) +!tunable parameter to the od schemes +real(r8),public, protected :: od_ls_ncleff = 3._r8 !tunable parameter for oGWD +real(r8),public, protected :: od_bl_ncd = 3._r8 !tunable parameter for FBD +real(r8),public, protected :: od_ss_sncleff= 1._r8 !tunable parameter for sGWD + contains !========================================================================== +subroutine oro_drag_readnl(nlfile) + + use namelist_utils, only: find_group_name + use units, only: getunit, freeunit + use mpishorthand + + ! File containing namelist input. + character(len=*), intent(in) :: nlfile + + ! Local variables + integer :: unitn, ierr + character(len=*), parameter :: subname = 'oro_drag_readnl' + + ! More specific name for dc to prevent a name clash or confusion in the + ! namelist. + + namelist /oro_drag_nl/ od_ls_ncleff, od_bl_ncd, od_ss_sncleff + !--------------------------------------------------------------------- + !read oro_drag_nl only when use the od schemes + if (use_od_ls.or.use_od_bl.or.use_od_ss) then + if (masterproc) then + unitn = getunit() + open( unitn, file=trim(nlfile), status='old' ) + call find_group_name(unitn, 'oro_drag_nl', status=ierr) + if (ierr == 0) then + read(unitn, oro_drag_nl, iostat=ierr) + if (ierr /= 0) then + call endrun(subname // ':: ERROR reading namelist') + end if + end if + close(unitn) + call freeunit(unitn) + end if + + if (masterproc) write(iulog,*) "oro_drag_readnl od_ls_ncleff, od_bl_ncd, od_ss_sncleff ",od_ls_ncleff,od_bl_ncd,od_ss_sncleff + +#ifdef SPMD + ! Broadcast namelist variables + call mpibcast(od_ls_ncleff, 1, mpir8, 0, mpicom) + call mpibcast(od_bl_ncd, 1, mpir8, 0, mpicom) + call mpibcast(od_ss_sncleff, 1, mpir8, 0, mpicom) +#endif + ! + endif + +end subroutine oro_drag_readnl + +!========================================================================== + subroutine oro_drag_open_topo_file() use filenames, only: bnd_topo use ioFileMod, only: getfil diff --git a/components/eam/src/physics/cam/phys_control.F90 b/components/eam/src/physics/cam/phys_control.F90 index 1ac5d841dc45..bd25ef8655c0 100644 --- a/components/eam/src/physics/cam/phys_control.F90 +++ b/components/eam/src/physics/cam/phys_control.F90 @@ -182,9 +182,6 @@ module phys_control logical, public, protected :: use_od_bl = .false. logical, public, protected :: use_od_ss = .false. logical, public, protected :: use_od_fd = .false. -real(r8),public, protected :: od_ls_ncleff = 3._r8 !tunable parameter for oGWD -real(r8),public, protected :: od_bl_ncd = 3._r8 !tunable parameter for FBD -real(r8),public, protected :: od_ss_sncleff = 1._r8 !tunable parameter for sGWD ! ! Switches that turn on/off individual parameterizations. ! @@ -259,7 +256,6 @@ subroutine phys_ctl_readnl(nlfile) use_hetfrz_classnuc, use_gw_oro, use_gw_front, use_gw_convect, & use_gw_energy_fix, & use_od_ls,use_od_bl,use_od_ss,use_od_fd,& - od_ls_ncleff,od_bl_ncd,od_ss_sncleff,& cld_macmic_num_steps, micro_do_icesupersat, & fix_g1_err_ndrop, ssalt_tuning, resus_fix, convproc_do_aer, & convproc_do_gas, convproc_method_activate, liqcf_fix, regen_fix, demott_ice_nuc, pergro_mods, pergro_test_active, & @@ -383,9 +379,6 @@ subroutine phys_ctl_readnl(nlfile) call mpibcast(use_od_bl, 1 , mpilog, 0, mpicom) call mpibcast(use_od_ss, 1 , mpilog, 0, mpicom) call mpibcast(use_od_fd, 1 , mpilog, 0, mpicom) - call mpibcast(od_ls_ncleff, 1 , mpilog, 0, mpicom) - call mpibcast(od_bl_ncd, 1 , mpilog, 0, mpicom) - call mpibcast(od_ss_sncleff, 1 , mpilog, 0, mpicom) call mpibcast(fix_g1_err_ndrop, 1 , mpilog, 0, mpicom) call mpibcast(ssalt_tuning, 1 , mpilog, 0, mpicom) call mpibcast(resus_fix, 1 , mpilog, 0, mpicom)