From 399c3c91b2e6bd03c07c66a16e975877c95cb2f6 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Fri, 6 Oct 2023 07:44:35 -0600 Subject: [PATCH 01/11] Merging my changes to 129 --- Externals_CAM.cfg | 4 +- bld/build-namelist | 48 +++ bld/namelist_files/namelist_defaults_cam.xml | 51 +++ bld/namelist_files/namelist_definition.xml | 128 ++++++ how_to_update_branch | 9 + post/postprocess | 207 ++++++++++ post/postprocess_auto | 30 ++ src/physics/cam/clubb_intr.F90 | 406 ++++++++++++++++++- 8 files changed, 873 insertions(+), 10 deletions(-) create mode 100644 how_to_update_branch create mode 100755 post/postprocess create mode 100755 post/postprocess_auto diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index bfba41d0db..8b311068a4 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -22,8 +22,8 @@ required = True [clubb] local_path = src/physics/clubb protocol = svn -repo_url = https://github.com/larson-group/clubb_release/tags/ -tag = clubb_4ncar_20221129_59cb19f_20230330_branchtag/src/CLUBB_core +repo_url = https://github.com/bstephens82/clubb_src/tags/ +tag = bstephens82.clubb_src.aa1d359 required = True [silhs] diff --git a/bld/build-namelist b/bld/build-namelist index 90bd503820..8a0240d8db 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3373,6 +3373,54 @@ if ($clubb_sgs =~ /$TRUE/io) { add_default($nl, 'clubb_tridiag_solve_method'); add_default($nl, 'clubb_up2_sfc_coef'); add_default($nl, 'clubb_wpxp_L_thresh'); + add_default($nl, 'clubb_c1c'); + add_default($nl, 'clubb_c7c'); + add_default($nl, 'clubb_c12'); + add_default($nl, 'clubb_c_wp2_pr_dfsn'); + add_default($nl, 'clubb_c_wp3_pr_tp'); + add_default($nl, 'clubb_c_wp3_pr_dfsn'); + add_default($nl, 'clubb_c6rt_Lscale0'); + add_default($nl, 'clubb_c6thl_Lscale0'); + add_default($nl, 'clubb_c7_Lscale0'); + add_default($nl, 'clubb_c_K'); + add_default($nl, 'clubb_nu1'); + add_default($nl, 'clubb_c_K6'); + add_default($nl, 'clubb_nu6'); + add_default($nl, 'clubb_nu8'); + add_default($nl, 'clubb_nu10'); + add_default($nl, 'clubb_c_K_hm'); + add_default($nl, 'clubb_c_K_hmb'); + add_default($nl, 'clubb_K_hm_min_coef'); + add_default($nl, 'clubb_nu_hm'); + add_default($nl, 'clubb_slope_coef_spread_DG_means_w'); + add_default($nl, 'clubb_pdf_component_stdev_factor_w'); + add_default($nl, 'clubb_coef_spread_DG_means_rt'); + add_default($nl, 'clubb_coef_spread_DG_means_thl'); + add_default($nl, 'clubb_gamma_coefc'); + add_default($nl, 'clubb_mu'); + add_default($nl, 'clubb_omicron'); + add_default($nl, 'clubb_zeta_vrnce_rat'); + add_default($nl, 'clubb_upsilon_precip_frac_rat'); + add_default($nl, 'clubb_taumin'); + add_default($nl, 'clubb_taumax'); + add_default($nl, 'clubb_Lscale_mu_coef'); + add_default($nl, 'clubb_Lscale_pert_coef'); + add_default($nl, 'clubb_alpha_corr'); + add_default($nl, 'clubb_thlp2_rad_coef'); + add_default($nl, 'clubb_thlp2_rad_cloud_frac_thresh'); + add_default($nl, 'clubb_c_invrs_tau_wpxp_Ri'); + add_default($nl, 'clubb_c_invrs_tau_wpxp_N2_thresh'); + add_default($nl, 'clubb_xp3_coef_base'); + add_default($nl, 'clubb_xp3_coef_slope'); + add_default($nl, 'clubb_altitude_threshold'); + add_default($nl, 'clubb_rtp2_clip_coef'); + add_default($nl, 'clubb_cx_min'); + add_default($nl, 'clubb_cx_max'); + add_default($nl, 'clubb_richardson_num_min'); + add_default($nl, 'clubb_richardson_num_max'); + add_default($nl, 'clubb_a3_coef_min'); + add_default($nl, 'clubb_a_const'); + add_default($nl, 'clubb_c11c'); #CLUBB+MF options add_default($nl, 'do_clubb_mf'); diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index fc74b3e978..b0c57bed09 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2119,9 +2119,60 @@ 1 2.0 60.0 + .false. .true. .true. + + 1.0 + 0.5 + 1.0 + 0.0 + 0.0 + 0.0 + 14.0 + 14.0 + 0.85 + 0.2 + 20.0 + 0.375 + 5.0 + 20.0 + 0.0 + 0.75 + 0.75 + 0.1 + 1.5 + 21.0 + 1.0 + 0.8 + 0.8 + 5.0 + 0.001 + 0.5 + 0.0 + 0.55 + 90.0 + 3600.0 + 2.0 + 0.1 + 0.15 + 1.0 + 0.1 + 0.35 + 0.00033 + 0.25 + 0.01 + 100.0 + 0.5 + 0.33 + 0.95 + 0.25 + 400.0 + 1.0 + 1.8 + 0.5 + .true. 0.2 diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index dfe47f84e5..5661819315 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -4302,6 +4302,134 @@ Real: number of plumes in mass flux ensemble Default: 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /dev/null || { echo >&2 "The cesm_pp_activate comand has not been issued. Aborting."; exit 1; } + +export last_yr=$(expr $first_yr + $nyrs - 1) + +# model v obs +if $m2o_test +then + +if [ ! -d "/glade/scratch/$username/archive/$test_case" ]; then +echo "test_case doesn't exist" +exit +fi + +if [ -d "./$test_case" ]; then +echo "removing previous directories..." +rm -rf $test_case +rm -rf ../diagnostics-output/atm/climo/$test_case +rm -rf ../diagnostics-output/atm/diag/$test_case +rm -rf ../diagnostics-output/atm/diag/$test_case-obs.${first_yr}_${nyrs} +fi + +create_postprocess --caseroot /glade/scratch/stepheba/cesm-postprocess/$test_case + +cd /glade/scratch/stepheba/cesm-postprocess/$test_case + +./pp_config --set DOUT_S_ROOT=/glade/scratch/$username/archive/$test_case/ +./pp_config --set ATM_GRID=0.9x1.25 +./pp_config --set ATMDIAG_OUTPUT_ROOT_PATH=/glade/scratch/stepheba/diagnostics-output/atm +./pp_config --set ATMDIAG_test_first_yr=$first_yr +./pp_config --set ATMDIAG_test_nyrs=$nyrs + +vim -E -s atm_averages <<-EOF + :%s/None/$PBS_ACCOUNT/ + :update + :quit +EOF + +qcmd -q $queue -- ./atm_averages --wait + +vim -E -s atm_diagnostics <<-EOF + :%s/None/$PBS_ACCOUNT/ + :update + :quit +EOF + +qcmd -q $queue -- ./atm_diagnostics --wait + +#zip up the output diagnostics file +cd /glade/scratch/stepheba/diagnostics-output/atm/diag/ + +zip -rq $test_case-obs.$first_yr\_$last_yr.zip $test_case-obs.$first_yr\_$last_yr + +else + +echo "m2o_test = False" + +fi + +cd /glade/scratch/stepheba/cesm-postprocess/ + +#model to model comparison for control case +if $m2o_cntl +then + +if [ ! -d "/glade/scratch/$username/archive/$cntl_case" ]; then +echo "cntl_case doesn't exist" +exit +fi + + +if [ -d "./$cntl_case" ]; then +echo "removing previous directories..." +rm -rf $cntl_case +rm -rf ../diagnostics-output/atm/climo/$cntl_case +rm -rf ../diagnostics-output/atm/diag/$cntl_case +rm -rf ../diagnostics-output/atm/diag/$cntl_case-obs.${first_yr}_${nyrs} +fi + +create_postprocess --caseroot /glade/scratch/stepheba/cesm-postprocess/$cntl_case + +cd /glade/scratch/stepheba/cesm-postprocess/$cntl_case + +./pp_config --set DOUT_S_ROOT=/glade/scratch/$username/archive/$cntl_case/ +./pp_config --set ATM_GRID=0.9x1.25 +./pp_config --set ATMDIAG_OUTPUT_ROOT_PATH=/glade/scratch/stepheba/diagnostics-output/atm +./pp_config --set ATMDIAG_test_first_yr=$first_yr +./pp_config --set ATMDIAG_test_nyrs=$nyrs + +vim -E -s atm_averages <<-EOF + :%s/None/$PBS_ACCOUNT/ + :update + :quit +EOF + +qcmd -q $queue -- ./atm_averages --wait + +vim -E -s atm_diagnostics <<-EOF + :%s/None/$PBS_ACCOUNT/ + :update + :quit +EOF + +qcmd -q $queue -- ./atm_diagnostics --wait + +#zip up the output diagnostics file +cd /glade/scratch/stepheba/diagnostics-output/atm/diag/ + +zip -rq $cntl_case-obs.$first_yr\_$last_yr.zip $cntl_case-obs.$first_yr\_$last_yr + +else + +echo "m2o_cntl = False" + +fi + + + + + +#model to model comparison + +if $m2m +then + +cd /glade/scratch/stepheba/cesm-postprocess/$test_case + +./pp_config --set ATMDIAG_cntl_casename=$cntl_case +./pp_config --set ATMDIAG_MODEL_VS_MODEL=True +./pp_config --set ATMDIAG_cntl_first_yr=$first_yr +./pp_config --set ATMDIAG_cntl_nyrs=$nyrs + +# go! +#export last_yr=$(expr $first_yr + $nyrs - 1) + +qcmd -q $queue -- ./atm_diagnostics --wait + +else + +echo "m2m = False" + +fi + + +# run Zhun's plotting code + +if $profiles +then + +cd /glade/scratch/stepheba/DiagnosticsAndTools/ + +vim -E -s ./CAM_CLUBB_diag.py <<-EOF + :%s/\s*case=\s*.*/case="$test_case"/ + :%s/\s*cases=\s*.*/cases=["$test_case"]/ + :%s/\s*casenames=\s*.*/casenames="$test_case"/ + :%s/\s*years=\s*.*/years=[$first_yr]/ + :%s/\s*nyear=\s*.*/nyear=[$nyrs]/ + :update + :quit +EOF + +ml nco +qcmd -q $queue -- python CAM_CLUBB_diag.py --wait + +cd /glade/scratch/stepheba/archive/$test_case/diagout/ + +zip -rq $test_case\_ANN.zip $test_case\_ANN + +else + +echo "profiles = False" + +fi + + diff --git a/post/postprocess_auto b/post/postprocess_auto new file mode 100755 index 0000000000..145a18b90a --- /dev/null +++ b/post/postprocess_auto @@ -0,0 +1,30 @@ +#!/bin/bash + +declare -a tests=( +"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_c7_0.3" +"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_c7_0.4" +) +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_c7_0.5" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_c7_0.6" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_cuushr_0.2" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_c7_0.7" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_cuushr_0.3" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_cuushr_0.4" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_cuushr_0.7" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_cuushr_0.6" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_c7_0.2" +#"113.f2c.taus_zhun_c11b0.8_c80.75_pmf_cuushr_0.5" +#) + + +for test in ${tests[@]}; do + +vim -E -s ./postprocess_m2m <<-EOF + :%s/\s*export test_case\s*=\s*.*/export test_case=${test} + :update + :quit +EOF + +./postprocess_m2m + +done diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index bb38481e39..b4c7d19bd0 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -178,6 +178,55 @@ module clubb_intr real(r8) :: clubb_detliq_rad = unset_r8 real(r8) :: clubb_detice_rad = unset_r8 real(r8) :: clubb_detphase_lowtemp = unset_r8 + real(r8) :: clubb_C1c = unset_r8 + real(r8) :: clubb_C7c = unset_r8 + real(r8) :: clubb_C11c = unset_r8 + real(r8) :: clubb_C12 = unset_r8 + real(r8) :: clubb_C_wp2_pr_dfsn = unset_r8 + real(r8) :: clubb_C_wp3_pr_tp = unset_r8 + real(r8) :: clubb_C_wp3_pr_dfsn = unset_r8 + real(r8) :: clubb_C6rt_Lscale0 = unset_r8 + real(r8) :: clubb_C6thl_Lscale0 = unset_r8 + real(r8) :: clubb_C7_Lscale0 = unset_r8 + real(r8) :: clubb_c_K = unset_r8 + real(r8) :: clubb_nu1 = unset_r8 + real(r8) :: clubb_c_K6 = unset_r8 + real(r8) :: clubb_nu6 = unset_r8 + real(r8) :: clubb_nu8 = unset_r8 + real(r8) :: clubb_nu10 = unset_r8 + real(r8) :: clubb_c_K_hm = unset_r8 + real(r8) :: clubb_c_K_hmb = unset_r8 + real(r8) :: clubb_K_hm_min_coef = unset_r8 + real(r8) :: clubb_nu_hm = unset_r8 + real(r8) :: clubb_slope_coef_spread_DG_means_w = unset_r8 + real(r8) :: clubb_pdf_component_stdev_factor_w = unset_r8 + real(r8) :: clubb_coef_spread_DG_means_rt = unset_r8 + real(r8) :: clubb_coef_spread_DG_means_thl = unset_r8 + real(r8) :: clubb_gamma_coefc = unset_r8 + real(r8) :: clubb_mu = unset_r8 + real(r8) :: clubb_omicron = unset_r8 + real(r8) :: clubb_zeta_vrnce_rat = unset_r8 + real(r8) :: clubb_upsilon_precip_frac_rat = unset_r8 + real(r8) :: clubb_taumin = unset_r8 + real(r8) :: clubb_taumax = unset_r8 + real(r8) :: clubb_Lscale_mu_coef = unset_r8 + real(r8) :: clubb_Lscale_pert_coef = unset_r8 + real(r8) :: clubb_alpha_corr = unset_r8 + real(r8) :: clubb_thlp2_rad_coef = unset_r8 + real(r8) :: clubb_thlp2_rad_cloud_frac_thresh = unset_r8 + real(r8) :: clubb_C_invrs_tau_wpxp_Ri = unset_r8 + real(r8) :: clubb_C_invrs_tau_wpxp_N2_thresh = unset_r8 + real(r8) :: clubb_xp3_coef_base = unset_r8 + real(r8) :: clubb_xp3_coef_slope = unset_r8 + real(r8) :: clubb_altitude_threshold = unset_r8 + real(r8) :: clubb_rtp2_clip_coef = unset_r8 + real(r8) :: clubb_Cx_min = unset_r8 + real(r8) :: clubb_Cx_max = unset_r8 + real(r8) :: clubb_Richardson_num_min = unset_r8 + real(r8) :: clubb_Richardson_num_max = unset_r8 + real(r8) :: clubb_a3_coef_min = unset_r8 + real(r8) :: clubb_a_const = unset_r8 + integer :: & clubb_iiPDF_type, & ! Selected option for the two-component normal @@ -305,7 +354,9 @@ module clubb_intr clubb_l_mono_flux_lim_vm, & ! Flag to turn on monotonic flux limiter for vm clubb_l_mono_flux_lim_spikefix, & ! Flag to implement monotonic flux limiter code that ! eliminates spurious drying tendencies at model top - clubb_l_intr_sfc_flux_smooth = .false.! Add a locally calculated roughness to upwp and vpwp sfc fluxes + clubb_l_intr_sfc_flux_smooth = .false., & ! Add a locally calculated roughness to upwp and vpwp sfc fluxes + clubb_l_use_wp3_lim_with_smth_Heaviside, & + clubb_l_modify_limiters_for_cnvg_test ! Constant parameters logical, parameter, private :: & @@ -801,6 +852,8 @@ subroutine clubb_readnl(nlfile) clubb_l_use_thvm_in_bv_freq, & clubb_l_use_tke_in_wp2_wp3_K_dfsn, & clubb_l_use_tke_in_wp3_pr_turb_term, & + clubb_l_use_wp3_lim_with_smth_Heaviside, & + clubb_l_modify_limiters_for_cnvg_test, & clubb_l_vary_convect_depth, & clubb_l_vert_avg_closure, & clubb_mult_coef, & @@ -811,8 +864,71 @@ subroutine clubb_readnl(nlfile) clubb_skw_max_mag, & clubb_tridiag_solve_method, & clubb_up2_sfc_coef, & - clubb_wpxp_L_thresh - + clubb_wpxp_L_thresh, & + clubb_C1c, & + clubb_C7c, & + clubb_C11c, & + clubb_C12, & + clubb_C_wp2_pr_dfsn, & + clubb_C_wp3_pr_tp, & + clubb_C_wp3_pr_dfsn, & + clubb_C6rt_Lscale0, & + clubb_C6thl_Lscale0, & + clubb_C7_Lscale0, & + clubb_c_K, & + clubb_nu1, & + clubb_c_K6, & + clubb_nu6, & + clubb_nu8, & + clubb_nu10, & + clubb_c_K_hm, & + clubb_c_K_hmb, & + clubb_K_hm_min_coef, & + clubb_nu_hm, & + clubb_slope_coef_spread_DG_means_w, & + clubb_pdf_component_stdev_factor_w, & + clubb_coef_spread_DG_means_rt, & + clubb_coef_spread_DG_means_thl, & + clubb_gamma_coefc, & + clubb_mu, & + clubb_omicron, & + clubb_zeta_vrnce_rat, & + clubb_upsilon_precip_frac_rat, & + clubb_taumin, & + clubb_taumax, & + clubb_Lscale_mu_coef, & + clubb_Lscale_pert_coef, & + clubb_alpha_corr, & + clubb_thlp2_rad_coef, & + clubb_thlp2_rad_cloud_frac_thresh, & + clubb_C_invrs_tau_wpxp_Ri, & + clubb_C_invrs_tau_wpxp_N2_thresh, & + clubb_xp3_coef_base, & + clubb_xp3_coef_slope, & + clubb_altitude_threshold, & + clubb_rtp2_clip_coef, & + clubb_Cx_min, & + clubb_Cx_max, & + clubb_Richardson_num_min, & + clubb_Richardson_num_max, & + clubb_a3_coef_min, & + clubb_a_const, & + clubb_l_use_precip_frac, & + clubb_l_C2_cloud_frac, & + clubb_l_diffuse_rtm_and_thlm, & + clubb_l_stability_correct_Kh_N2_zm, & + clubb_l_calc_thlp2_rad, & + clubb_l_upwind_xm_ma, & + clubb_l_uv_nudge, & + clubb_l_rtm_nudge, & + clubb_l_tke_aniso, & + clubb_l_diagnose_correlations, & + clubb_l_calc_w_corr, & + clubb_l_const_Nc_in_cloud, & + clubb_l_fix_w_chi_eta_correlations, & + clubb_l_prescribed_avg_deltaz, & + clubb_l_linearize_pbl_winds + !----- Begin Code ----- ! Determine if we want clubb_history to be output @@ -871,7 +987,9 @@ subroutine clubb_readnl(nlfile) clubb_l_vary_convect_depth, & ! Out clubb_l_use_tke_in_wp3_pr_turb_term, & ! Out clubb_l_use_tke_in_wp2_wp3_K_dfsn, & ! Out + clubb_l_use_wp3_lim_with_smth_Heaviside, & ! Out clubb_l_smooth_Heaviside_tau_wpxp, & ! Out + clubb_l_modify_limiters_for_cnvg_test, & ! Out clubb_l_enable_relaxed_clipping, & ! Out clubb_l_linearize_pbl_winds, & ! Out clubb_l_mono_flux_lim_thlm, & ! Out @@ -1048,6 +1166,102 @@ subroutine clubb_readnl(nlfile) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_detice_rad") call mpi_bcast(clubb_detphase_lowtemp, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_detphase_lowtemp") + call mpi_bcast(clubb_C1c, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C1c") + call mpi_bcast(clubb_C7c, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C7c") + call mpi_bcast(clubb_C11c, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C11c") + call mpi_bcast(clubb_C12, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C12") + call mpi_bcast(clubb_C_wp2_pr_dfsn, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C_wp2_pr_dfsn") + call mpi_bcast(clubb_C_wp3_pr_tp, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C_wp3_pr_tp") + call mpi_bcast(clubb_C_wp3_pr_dfsn, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C_wp3_pr_dfsn") + call mpi_bcast(clubb_C6rt_Lscale0, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C6rt_Lscale0") + call mpi_bcast(clubb_C6thl_Lscale0, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C6thl_Lscale0") + call mpi_bcast(clubb_C7_Lscale0, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C7_Lscale0") + call mpi_bcast(clubb_c_K, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_c_K") + call mpi_bcast(clubb_nu1, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_nu1") + call mpi_bcast(clubb_c_K6, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_c_K6") + call mpi_bcast(clubb_nu6, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_nu6") + call mpi_bcast(clubb_nu8, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_nu8") + call mpi_bcast(clubb_nu10, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_nu10") + call mpi_bcast(clubb_c_K_hm, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_c_K_hm") + call mpi_bcast(clubb_c_K_hmb, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_c_K_hmb") + call mpi_bcast(clubb_K_hm_min_coef, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_K_hm_min_coef") + call mpi_bcast(clubb_nu_hm, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_nu_hm") + call mpi_bcast(clubb_slope_coef_spread_DG_means_w, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_slope_coef_spread_DG_means_w") + call mpi_bcast(clubb_pdf_component_stdev_factor_w, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_pdf_component_stdev_factor_w") + call mpi_bcast(clubb_coef_spread_DG_means_rt, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_coef_spread_DG_means_rt") + call mpi_bcast(clubb_coef_spread_DG_means_thl, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_coef_spread_DG_means_thl") + call mpi_bcast(clubb_gamma_coefc, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_gamma_coefc") + call mpi_bcast(clubb_mu, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_mu") + call mpi_bcast(clubb_omicron, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_omicron") + call mpi_bcast(clubb_zeta_vrnce_rat, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_zeta_vrnce_rat") + call mpi_bcast(clubb_upsilon_precip_frac_rat, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_upsilon_precip_frac_rat") + call mpi_bcast(clubb_taumin, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_taumin") + call mpi_bcast(clubb_taumax, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_taumax") + call mpi_bcast(clubb_Lscale_mu_coef, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_Lscale_mu_coef") + call mpi_bcast(clubb_Lscale_pert_coef, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_Lscale_pert_coef") + call mpi_bcast(clubb_alpha_corr, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_alpha_corr") + call mpi_bcast(clubb_thlp2_rad_coef, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_thlp2_rad_coef") + call mpi_bcast(clubb_thlp2_rad_cloud_frac_thresh, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_thlp2_rad_cloud_frac_thresh") + call mpi_bcast(clubb_C_invrs_tau_wpxp_Ri, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C_invrs_tau_wpxp_Ri") + call mpi_bcast(clubb_C_invrs_tau_wpxp_N2_thresh, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_C_invrs_tau_wpxp_N2_thresh") + call mpi_bcast(clubb_xp3_coef_base, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_xp3_coef_base") + call mpi_bcast(clubb_xp3_coef_slope, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_xp3_coef_slope") + call mpi_bcast(clubb_altitude_threshold, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_altitude_threshold") + call mpi_bcast(clubb_rtp2_clip_coef, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_rtp2_clip_coef") + call mpi_bcast(clubb_Cx_min, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_Cx_min") + call mpi_bcast(clubb_Cx_max, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_Cx_max") + call mpi_bcast(clubb_Richardson_num_min, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_Richardson_num_min") + call mpi_bcast(clubb_Richardson_num_max, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_Richardson_num_max") + call mpi_bcast(clubb_a3_coef_min, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_a3_coef_min") + call mpi_bcast(clubb_a_const, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_a_const") call mpi_bcast(clubb_l_use_C7_Richardson, 1, mpi_logical, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_use_C7_Richardson") @@ -1127,6 +1341,36 @@ subroutine clubb_readnl(nlfile) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_standard_term_ta") call mpi_bcast(clubb_l_partial_upwind_wp3, 1, mpi_logical, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_partial_upwind_wp3") + call mpi_bcast(clubb_l_use_precip_frac, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_use_precip_frac") + call mpi_bcast(clubb_l_C2_cloud_frac, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_C2_cloud_frac") + call mpi_bcast(clubb_l_diffuse_rtm_and_thlm, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_diffuse_rtm_and_thlm") + call mpi_bcast(clubb_l_stability_correct_Kh_N2_zm, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_stability_correct_Kh_N2_zm") + call mpi_bcast(clubb_l_calc_thlp2_rad, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_calc_thlp2_rad") + call mpi_bcast(clubb_l_upwind_xm_ma, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_upwind_xm_ma") + call mpi_bcast(clubb_l_uv_nudge, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_uv_nudge") + call mpi_bcast(clubb_l_rtm_nudge, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_rtm_nudge") + call mpi_bcast(clubb_l_tke_aniso, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_tke_aniso") + call mpi_bcast(clubb_l_diagnose_correlations, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_diagnose_correlations") + call mpi_bcast(clubb_l_calc_w_corr, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_calc_w_corr") + call mpi_bcast(clubb_l_const_Nc_in_cloud, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_const_Nc_in_cloud") + call mpi_bcast(clubb_l_fix_w_chi_eta_correlations, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_fix_w_chi_eta_correlations") + call mpi_bcast(clubb_l_prescribed_avg_deltaz, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_prescribed_avg_deltaz") + call mpi_bcast(clubb_l_linearize_pbl_winds, 1, mpi_logical, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_linearize_pbl_winds") ! Overwrite defaults if they are true if (clubb_history) l_stats = .true. @@ -1193,6 +1437,54 @@ subroutine clubb_readnl(nlfile) if(clubb_detphase_lowtemp == unset_r8) call endrun(sub//": FATAL: clubb_detphase_lowtemp not set") if(clubb_penta_solve_method == unset_i) call endrun(sub//": FATAL: clubb_penta_solve_method not set") if(clubb_tridiag_solve_method == unset_i) call endrun(sub//": FATAL: clubb_tridiag_solve_method not set") + if(clubb_C1c == unset_r8) call endrun(sub//": FATAL: clubb_c1c is not set") + if(clubb_C7c == unset_r8) call endrun(sub//": FATAL: clubb_c7c is not set") + if(clubb_C11c == unset_r8) call endrun(sub//": FATAL: clubb_c11c is not set") + if(clubb_C12 == unset_r8) call endrun(sub//": FATAL: clubb_c12 is not set") + if(clubb_C_wp2_pr_dfsn == unset_r8) call endrun(sub//": FATAL: clubb_c_wp2_pr_dfsc is not set") + if(clubb_C_wp3_pr_tp == unset_r8) call endrun(sub//": FATAL: clubb_c_wp3_pr_tp is not set") + if(clubb_C_wp3_pr_dfsn == unset_r8) call endrun(sub//": FATAL: clubb_c_wp3_pr_dfsn is not set") + if(clubb_C6rt_Lscale0 == unset_r8) call endrun(sub//": FATAL: clubb_c6rt_Lscale0 is not set") + if(clubb_C6thl_Lscale0 == unset_r8) call endrun(sub//": FATAL: clubb_c6thl_Lscale0 is not set") + if(clubb_C7_Lscale0 == unset_r8) call endrun(sub//": FATAL: clubb_c7_Lscale0 is not set") + if(clubb_c_K == unset_r8) call endrun(sub//": FATAL: clubb_c_K is not set") + if(clubb_nu1 == unset_r8) call endrun(sub//": FATAL: clubb_nu1 is not set") + if(clubb_c_K6 == unset_r8) call endrun(sub//": FATAL: clubb_c_K6 is not set") + if(clubb_nu6 == unset_r8) call endrun(sub//": FATAL: clubb_nu6 is not set") + if(clubb_nu8 == unset_r8) call endrun(sub//": FATAL: clubb_nu8 is not set") + if(clubb_nu10 == unset_r8) call endrun(sub//": FATAL: clubb_nu10 is not set") + if(clubb_c_K_hm == unset_r8) call endrun(sub//": FATAL: clubb_c_K_hm is not set") + if(clubb_c_K_hmb == unset_r8) call endrun(sub//": FATAL: clubb_c_K_hmb is not set") + if(clubb_K_hm_min_coef == unset_r8) call endrun(sub//": FATAL: clubb_c_K_hm_min_coef is not set") + if(clubb_nu_hm == unset_r8) call endrun(sub//": FATAL: clubb_nu_hm is not set") + if(clubb_slope_coef_spread_DG_means_w == unset_r8) call endrun(sub//": FATAL: clubb_slope_coef_spread is not set") + if(clubb_pdf_component_stdev_factor_w == unset_r8) call endrun(sub//": FATAL: clubb_pdf_component is not set") + if(clubb_coef_spread_DG_means_rt == unset_r8) call endrun(sub//": FATAL: clubb_coef_spread_DG_rt is not set") + if(clubb_coef_spread_DG_means_thl == unset_r8) call endrun(sub//": FATAL: clubb_coef_spread_DG_thl is not set") + if(clubb_gamma_coefc == unset_r8) call endrun(sub//": FATAL: clubb_gamma_coefc is not set") + if(clubb_mu == unset_r8) call endrun(sub//": FATAL: clubb_mu is not set") + if(clubb_omicron == unset_r8) call endrun(sub//": FATAL: clubb_omicron is not set") + if(clubb_zeta_vrnce_rat == unset_r8) call endrun(sub//": FATAL: clubb_zeta_vrnce is not set") + if(clubb_upsilon_precip_frac_rat == unset_r8) call endrun(sub//": FATAL: clubb_upsilon_precip is not set") + if(clubb_taumin == unset_r8) call endrun(sub//": FATAL: clubb_taumin is not set") + if(clubb_taumax == unset_r8) call endrun(sub//": FATAL: clubb_taumax is not set") + if(clubb_Lscale_mu_coef == unset_r8) call endrun(sub//": FATAL: clubb_Lscale_mu is not set") + if(clubb_Lscale_pert_coef == unset_r8) call endrun(sub//": FATAL: clubb_Lscale_pert_coef is not set") + if(clubb_alpha_corr == unset_r8) call endrun(sub//": FATAL: clubb_alpha_corr is not set") + if(clubb_thlp2_rad_coef == unset_r8) call endrun(sub//": FATAL: clubb_thlp2_rad_coef is not set") + if(clubb_thlp2_rad_cloud_frac_thresh == unset_r8) call endrun(sub//": FATAL: clubb_thlp2_rad_cloud is not set") + if(clubb_C_invrs_tau_wpxp_Ri == unset_r8) call endrun(sub//": FATAL: clubb_c_invrs_tau_wpxp_Ri is not set") + if(clubb_C_invrs_tau_wpxp_N2_thresh == unset_r8) call endrun(sub//": FATAL: clubb_c_invrs_tau_wpxp_N2_thresh is not set") + if(clubb_xp3_coef_base == unset_r8) call endrun(sub//": FATAL: clubb_xp3_coef_base is not set") + if(clubb_xp3_coef_slope == unset_r8) call endrun(sub//": FATAL: clubb_xp3_coef_slope is not set") + if(clubb_altitude_threshold == unset_r8) call endrun(sub//": FATAL: clubb_altitude_thresh is not set") + if(clubb_rtp2_clip_coef == unset_r8) call endrun(sub//": FATAL: clubb_rtp2_clip_coef is not set") + if(clubb_Cx_min == unset_r8) call endrun(sub//": FATAL: clubb_Cx_min is not set") + if(clubb_Cx_max == unset_r8) call endrun(sub//": FATAL: clubb_Cx_max is not set") + if(clubb_Richardson_num_min == unset_r8) call endrun(sub//": FATAL: clubb_Rich_num_min is not set") + if(clubb_Richardson_num_max == unset_r8) call endrun(sub//": FATAL: clubb_Rich_num_max is not set") + if(clubb_a3_coef_min == unset_r8) call endrun(sub//": FATAL: clubb_a3_coef_min is not set") + if(clubb_a_const == unset_r8) call endrun(sub//": FATAL: clubb_a_const is not set") if(clubb_detphase_lowtemp >= meltpt_temp) & call endrun(sub//": ERROR: clubb_detphase_lowtemp must be less than 268.15 K") @@ -1243,8 +1535,10 @@ subroutine clubb_readnl(nlfile) clubb_l_e3sm_config, & ! In clubb_l_vary_convect_depth, & ! In clubb_l_use_tke_in_wp3_pr_turb_term, & ! In - clubb_l_use_tke_in_wp2_wp3_K_dfsn, & ! In + clubb_l_use_tke_in_wp2_wp3_K_dfsn, & ! In + clubb_l_use_wp3_lim_with_smth_Heaviside, & ! Out clubb_l_smooth_Heaviside_tau_wpxp, & ! In + clubb_l_modify_limiters_for_cnvg_test, & ! Out clubb_l_enable_relaxed_clipping, & ! In clubb_l_linearize_pbl_winds, & ! In clubb_l_mono_flux_lim_thlm, & ! In @@ -1291,7 +1585,55 @@ subroutine clubb_ini_cam(pbuf2d) iSkw_denom_coef, ibeta, iskw_max_mag, & iC_invrs_tau_bkgnd,iC_invrs_tau_sfc,iC_invrs_tau_shear,iC_invrs_tau_N2,iC_invrs_tau_N2_wp2, & iC_invrs_tau_N2_xp2,iC_invrs_tau_N2_wpxp,iC_invrs_tau_N2_clear_wp3,iC_uu_shr,iC_uu_buoy, & - iC2rt, iC2thl, iC2rtthl, ic_K1, ic_K2, inu2, ic_K8, ic_K9, inu9, iC_wp2_splat, params_list + iC2rt, iC2thl, iC2rtthl, ic_K1, ic_K2, inu2, ic_K8, ic_K9, inu9, iC_wp2_splat, params_list, & + iC1c, & + iC7c, & + iC11c, & + iC12, & + iC_wp2_pr_dfsn, & + iC_wp3_pr_tp, & + iC_wp3_pr_dfsn, & + iC6rt_Lscale0, & + iC6thl_Lscale0, & + iC7_Lscale0, & + ic_K, & + inu1, & + ic_K6, & + inu6, & + inu8, & + inu10, & + ic_K_hm, & + ic_K_hmb, & + iK_hm_min_coef, & + inu_hm, & + islope_coef_spread_DG_means_w, & + ipdf_component_stdev_factor_w, & + icoef_spread_DG_means_rt, & + icoef_spread_DG_means_thl, & + igamma_coefc, & + imu, & + iomicron, & + izeta_vrnce_rat, & + iupsilon_precip_frac_rat, & + itaumin, & + itaumax, & + iLscale_mu_coef, & + iLscale_pert_coef, & + ialpha_corr, & + ithlp2_rad_coef, & + ithlp2_rad_cloud_frac_thresh, & + iC_invrs_tau_wpxp_Ri, & + iC_invrs_tau_wpxp_N2_thresh, & + ixp3_coef_base, & + ixp3_coef_slope, & + ialtitude_threshold, & + irtp2_clip_coef, & + iCx_min, & + iCx_max, & + iRichardson_num_min, & + iRichardson_num_max, & + ia3_coef_min, & + ia_const use clubb_api_module, only: & print_clubb_config_flags_api, & @@ -1372,7 +1714,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, & C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & - Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, a3_coef_min + Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, a3_coef_min, a_const !----- Begin Code ----- @@ -1528,7 +1870,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, a3_coef_min ) + Richardson_num_max, a3_coef_min, a_const ) call read_parameters_api( -99, "", & C1, C1b, C1c, C2rt, C2thl, C2rtthl, & @@ -1554,7 +1896,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, a3_coef_min, & + Richardson_num_max, a3_coef_min, a_const, & clubb_params ) clubb_params(iC2rtthl) = clubb_C2rtthl @@ -1606,6 +1948,54 @@ subroutine clubb_ini_cam(pbuf2d) clubb_params(iC_invrs_tau_N2_xp2) = clubb_C_invrs_tau_N2_xp2 clubb_params(iC_invrs_tau_N2_wpxp) = clubb_C_invrs_tau_N2_wpxp clubb_params(iC_invrs_tau_N2_clear_wp3) = clubb_C_invrs_tau_N2_clear_wp3 + clubb_params(iC1c) = clubb_C1c + clubb_params(iC7c) = clubb_C7c + clubb_params(iC11c) = clubb_C11c + clubb_params(iC12) = clubb_C12 + clubb_params(iC_wp2_pr_dfsn) = clubb_C_wp2_pr_dfsn + clubb_params(iC_wp3_pr_tp) = clubb_C_wp3_pr_tp + clubb_params(iC_wp3_pr_dfsn) = clubb_C_wp3_pr_dfsn + clubb_params(iC6rt_Lscale0) = clubb_C6rt_Lscale0 + clubb_params(iC6thl_Lscale0) = clubb_C6thl_Lscale0 + clubb_params(iC7_Lscale0) = clubb_C7_Lscale0 + clubb_params(ic_K) = clubb_c_K + clubb_params(inu1) = clubb_nu1 + clubb_params(ic_K6) = clubb_c_K6 + clubb_params(inu6) = clubb_nu6 + clubb_params(inu8) = clubb_nu8 + clubb_params(inu10) = clubb_nu10 + clubb_params(ic_K_hm) = clubb_c_K_hm + clubb_params(ic_K_hmb) = clubb_c_K_hmb + clubb_params(iK_hm_min_coef) = clubb_K_hm_min_coef + clubb_params(inu_hm) = clubb_nu_hm + clubb_params(islope_coef_spread_DG_means_w) = clubb_slope_coef_spread_DG_means_w + clubb_params(ipdf_component_stdev_factor_w) = clubb_pdf_component_stdev_factor_w + clubb_params(icoef_spread_DG_means_rt) = clubb_coef_spread_DG_means_rt + clubb_params(icoef_spread_DG_means_thl) = clubb_coef_spread_DG_means_thl + clubb_params(igamma_coefc) = clubb_gamma_coefc + clubb_params(imu) = clubb_mu + clubb_params(iomicron) = clubb_omicron + clubb_params(izeta_vrnce_rat) = clubb_zeta_vrnce_rat + clubb_params(iupsilon_precip_frac_rat) = clubb_upsilon_precip_frac_rat + clubb_params(itaumin) = clubb_taumin + clubb_params(itaumax) = clubb_taumax + clubb_params(iLscale_mu_coef) = clubb_Lscale_mu_coef + clubb_params(iLscale_pert_coef) = clubb_Lscale_pert_coef + clubb_params(ialpha_corr) = clubb_alpha_corr + clubb_params(ithlp2_rad_coef) = clubb_thlp2_rad_coef + clubb_params(ithlp2_rad_cloud_frac_thresh) = clubb_thlp2_rad_cloud_frac_thresh + clubb_params(iC_invrs_tau_wpxp_Ri) = clubb_C_invrs_tau_wpxp_Ri + clubb_params(iC_invrs_tau_wpxp_N2_thresh) = clubb_C_invrs_tau_wpxp_N2_thresh + clubb_params(ixp3_coef_base) = clubb_xp3_coef_base + clubb_params(ixp3_coef_slope) = clubb_xp3_coef_slope + clubb_params(ialtitude_threshold) = clubb_altitude_threshold + clubb_params(irtp2_clip_coef) = clubb_rtp2_clip_coef + clubb_params(iCx_min) = clubb_Cx_min + clubb_params(iCx_max) = clubb_Cx_max + clubb_params(iRichardson_num_min) = clubb_Richardson_num_min + clubb_params(iRichardson_num_max) = clubb_Richardson_num_max + clubb_params(ia3_coef_min) = clubb_a3_coef_min + clubb_params(ia_const) = clubb_a_const ! Set up CLUBB core. Note that some of these inputs are overwritten ! when clubb_tend_cam is called. The reason is that heights can change From cea94091edcaaad7260a4720cd66dec8a56aafea Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Mon, 6 Nov 2023 09:51:58 -0700 Subject: [PATCH 02/11] adding two new parameters --- bld/build-namelist | 2 ++ bld/namelist_files/namelist_defaults_cam.xml | 3 +++ bld/namelist_files/namelist_definition.xml | 5 ++++ src/physics/cam/clubb_intr.F90 | 24 ++++++++++++++++---- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/bld/build-namelist b/bld/build-namelist index 8a0240d8db..9e78fe2000 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3421,6 +3421,8 @@ if ($clubb_sgs =~ /$TRUE/io) { add_default($nl, 'clubb_a3_coef_min'); add_default($nl, 'clubb_a_const'); add_default($nl, 'clubb_c11c'); + add_default($nl, 'clubb_bv_efold'); + add_default($nl, 'clubb_wpxp_Ri_exp'); #CLUBB+MF options add_default($nl, 'do_clubb_mf'); diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index b0c57bed09..95d63b84c9 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2172,6 +2172,9 @@ 1.0 1.8 0.5 + 1.0 + 1.0 + .true. diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index 5661819315..dd32d4af07 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -4398,6 +4398,11 @@ Default: 10 group="clubb_params_nl" valid_values="" > + + + diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index b4c7d19bd0..10f8e9922c 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -226,7 +226,8 @@ module clubb_intr real(r8) :: clubb_Richardson_num_max = unset_r8 real(r8) :: clubb_a3_coef_min = unset_r8 real(r8) :: clubb_a_const = unset_r8 - + real(r8) :: clubb_bv_efold = unset_r8 + real(r8) :: clubb_wpxp_Ri_exp = unset_r8 integer :: & clubb_iiPDF_type, & ! Selected option for the two-component normal @@ -913,6 +914,8 @@ subroutine clubb_readnl(nlfile) clubb_Richardson_num_max, & clubb_a3_coef_min, & clubb_a_const, & + clubb_bv_efold, & + clubb_wpxp_Ri_exp, & clubb_l_use_precip_frac, & clubb_l_C2_cloud_frac, & clubb_l_diffuse_rtm_and_thlm, & @@ -1262,6 +1265,10 @@ subroutine clubb_readnl(nlfile) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_a3_coef_min") call mpi_bcast(clubb_a_const, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_a_const") + call mpi_bcast(clubb_bv_efold, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_bv_efold") + call mpi_bcast(clubb_wpxp_Ri_exp, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_wpxp_Ri_exp") call mpi_bcast(clubb_l_use_C7_Richardson, 1, mpi_logical, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_use_C7_Richardson") @@ -1485,6 +1492,8 @@ subroutine clubb_readnl(nlfile) if(clubb_Richardson_num_max == unset_r8) call endrun(sub//": FATAL: clubb_Rich_num_max is not set") if(clubb_a3_coef_min == unset_r8) call endrun(sub//": FATAL: clubb_a3_coef_min is not set") if(clubb_a_const == unset_r8) call endrun(sub//": FATAL: clubb_a_const is not set") + if(clubb_bv_efold == unset_r8) call endrun(sub//": FATAL: clubb_bv_efold is not set") + if(clubb_wpxp_Ri_exp == unset_r8) call endrun(sub//": FATAL: clubb_wpxp_Ri_exp is not set") if(clubb_detphase_lowtemp >= meltpt_temp) & call endrun(sub//": ERROR: clubb_detphase_lowtemp must be less than 268.15 K") @@ -1633,7 +1642,9 @@ subroutine clubb_ini_cam(pbuf2d) iRichardson_num_min, & iRichardson_num_max, & ia3_coef_min, & - ia_const + ia_const, & + ibv_efold, & + iwpxp_Ri_exp use clubb_api_module, only: & print_clubb_config_flags_api, & @@ -1714,7 +1725,8 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, & C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & - Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, a3_coef_min, a_const + Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, a3_coef_min, a_const, & + bv_efold, wpxp_Ri_exp !----- Begin Code ----- @@ -1870,7 +1882,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, a3_coef_min, a_const ) + Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold ) call read_parameters_api( -99, "", & C1, C1b, C1c, C2rt, C2thl, C2rtthl, & @@ -1896,7 +1908,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, a3_coef_min, a_const, & + Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold & clubb_params ) clubb_params(iC2rtthl) = clubb_C2rtthl @@ -1996,6 +2008,8 @@ subroutine clubb_ini_cam(pbuf2d) clubb_params(iRichardson_num_max) = clubb_Richardson_num_max clubb_params(ia3_coef_min) = clubb_a3_coef_min clubb_params(ia_const) = clubb_a_const + clubb_params(ibv_efold) = clubb_bv_efold + clubb_params(iwpxp_Ri_exp) = clubb_wpxp_Ri_exp ! Set up CLUBB core. Note that some of these inputs are overwritten ! when clubb_tend_cam is called. The reason is that heights can change From 0d2c3e3ac2bdf5e588b5b9ba178b24030da59e4c Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Mon, 6 Nov 2023 13:15:20 -0700 Subject: [PATCH 03/11] updsating my clubb external and fixing typo bug --- Externals_CAM.cfg | 2 +- src/physics/cam/clubb_intr.F90 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index a6e3467eba..4d5014f236 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -23,7 +23,7 @@ required = True local_path = src/physics/clubb protocol = svn repo_url = https://github.com/bstephens82/clubb_src/tags/ -tag = bstephens82.clubb_src.aa1d359 +tag = bstephens82.clubb_src.a811ebf required = True [silhs] diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index 10f8e9922c..c5e7724580 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -1908,7 +1908,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold & + Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, & clubb_params ) clubb_params(iC2rtthl) = clubb_C2rtthl From b219c2d8dbf6d1ef21b4b63ae666f75cfb6d2c42 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Mon, 6 Nov 2023 13:27:07 -0700 Subject: [PATCH 04/11] new clubb tag and bug fix --- Externals_CAM.cfg | 2 +- src/physics/cam/clubb_intr.F90 | 133 +-------------------------------- 2 files changed, 2 insertions(+), 133 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 4d5014f236..8887731d36 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -23,7 +23,7 @@ required = True local_path = src/physics/clubb protocol = svn repo_url = https://github.com/bstephens82/clubb_src/tags/ -tag = bstephens82.clubb_src.a811ebf +tag = bstephens82.clubb_src.9647175 required = True [silhs] diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index c5e7724580..e62de87978 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -2023,15 +2023,7 @@ subroutine clubb_ini_cam(pbuf2d) l_host_applies_sfc_fluxes, & ! In saturation_equation, & ! In l_input_fields, & ! In - clubb_config_flags%iiPDF_type, & ! In - clubb_config_flags%ipdf_call_placement, & ! In - clubb_config_flags%l_predict_upwp_vpwp, & ! In - clubb_config_flags%l_min_xp2_from_corr_wx, & ! In - clubb_config_flags%l_prescribed_avg_deltaz, & ! In - clubb_config_flags%l_damp_wp2_using_em, & ! In - clubb_config_flags%l_stability_correct_tau_zm, & ! In - clubb_config_flags%l_enable_relaxed_clipping, & ! In - clubb_config_flags%l_diag_Lscale_from_tau, & ! In + clubb_config_flags, & ! In err_code ) ! Out if ( err_code == clubb_fatal_error ) then @@ -4955,46 +4947,6 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & use clubb_api_module, only: & - ztscr01, & - ztscr02, & - ztscr03, & - ztscr04, & - ztscr05, & - ztscr06, & - ztscr07, & - ztscr08, & - ztscr09, & - ztscr10, & - ztscr11, & - ztscr12, & - ztscr13, & - ztscr14, & - ztscr15, & - ztscr16, & - ztscr17, & - ztscr18, & - ztscr19, & - ztscr20, & - ztscr21 - - use clubb_api_module, only: & - zmscr01, & - zmscr02, & - zmscr03, & - zmscr04, & - zmscr05, & - zmscr06, & - zmscr07, & - zmscr08, & - zmscr09, & - zmscr10, & - zmscr11, & - zmscr12, & - zmscr13, & - zmscr14, & - zmscr15, & - zmscr16, & - zmscr17, & l_stats, & l_output_rad_files, & stats_tsamp, & @@ -5169,53 +5121,6 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_zt%file%grid_avg_var( stats_zt%num_output_fields ) ) allocate( stats_zt%file%z( stats_zt%kk ) ) - first_call = (.not. allocated(ztscr01)) - - ! Allocate scratch space - if (first_call) allocate( ztscr01(stats_zt%kk) ) - if (first_call) allocate( ztscr02(stats_zt%kk) ) - if (first_call) allocate( ztscr03(stats_zt%kk) ) - if (first_call) allocate( ztscr04(stats_zt%kk) ) - if (first_call) allocate( ztscr05(stats_zt%kk) ) - if (first_call) allocate( ztscr06(stats_zt%kk) ) - if (first_call) allocate( ztscr07(stats_zt%kk) ) - if (first_call) allocate( ztscr08(stats_zt%kk) ) - if (first_call) allocate( ztscr09(stats_zt%kk) ) - if (first_call) allocate( ztscr10(stats_zt%kk) ) - if (first_call) allocate( ztscr11(stats_zt%kk) ) - if (first_call) allocate( ztscr12(stats_zt%kk) ) - if (first_call) allocate( ztscr13(stats_zt%kk) ) - if (first_call) allocate( ztscr14(stats_zt%kk) ) - if (first_call) allocate( ztscr15(stats_zt%kk) ) - if (first_call) allocate( ztscr16(stats_zt%kk) ) - if (first_call) allocate( ztscr17(stats_zt%kk) ) - if (first_call) allocate( ztscr18(stats_zt%kk) ) - if (first_call) allocate( ztscr19(stats_zt%kk) ) - if (first_call) allocate( ztscr20(stats_zt%kk) ) - if (first_call) allocate( ztscr21(stats_zt%kk) ) - - ztscr01 = 0.0_r8 - ztscr02 = 0.0_r8 - ztscr03 = 0.0_r8 - ztscr04 = 0.0_r8 - ztscr05 = 0.0_r8 - ztscr06 = 0.0_r8 - ztscr07 = 0.0_r8 - ztscr08 = 0.0_r8 - ztscr09 = 0.0_r8 - ztscr10 = 0.0_r8 - ztscr11 = 0.0_r8 - ztscr12 = 0.0_r8 - ztscr13 = 0.0_r8 - ztscr14 = 0.0_r8 - ztscr15 = 0.0_r8 - ztscr16 = 0.0_r8 - ztscr17 = 0.0_r8 - ztscr18 = 0.0_r8 - ztscr19 = 0.0_r8 - ztscr20 = 0.0_r8 - ztscr21 = 0.0_r8 - ! Default initialization for array indices for zt if (first_call) then call stats_init_zt_api( clubb_vars_zt, l_error, & @@ -5256,42 +5161,6 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & ! Allocate scratch space - if (first_call) allocate( zmscr01(stats_zm%kk) ) - if (first_call) allocate( zmscr02(stats_zm%kk) ) - if (first_call) allocate( zmscr03(stats_zm%kk) ) - if (first_call) allocate( zmscr04(stats_zm%kk) ) - if (first_call) allocate( zmscr05(stats_zm%kk) ) - if (first_call) allocate( zmscr06(stats_zm%kk) ) - if (first_call) allocate( zmscr07(stats_zm%kk) ) - if (first_call) allocate( zmscr08(stats_zm%kk) ) - if (first_call) allocate( zmscr09(stats_zm%kk) ) - if (first_call) allocate( zmscr10(stats_zm%kk) ) - if (first_call) allocate( zmscr11(stats_zm%kk) ) - if (first_call) allocate( zmscr12(stats_zm%kk) ) - if (first_call) allocate( zmscr13(stats_zm%kk) ) - if (first_call) allocate( zmscr14(stats_zm%kk) ) - if (first_call) allocate( zmscr15(stats_zm%kk) ) - if (first_call) allocate( zmscr16(stats_zm%kk) ) - if (first_call) allocate( zmscr17(stats_zm%kk) ) - - zmscr01 = 0.0_r8 - zmscr02 = 0.0_r8 - zmscr03 = 0.0_r8 - zmscr04 = 0.0_r8 - zmscr05 = 0.0_r8 - zmscr06 = 0.0_r8 - zmscr07 = 0.0_r8 - zmscr08 = 0.0_r8 - zmscr09 = 0.0_r8 - zmscr10 = 0.0_r8 - zmscr11 = 0.0_r8 - zmscr12 = 0.0_r8 - zmscr13 = 0.0_r8 - zmscr14 = 0.0_r8 - zmscr15 = 0.0_r8 - zmscr16 = 0.0_r8 - zmscr17 = 0.0_r8 - if (first_call) then call stats_init_zm_api( clubb_vars_zm, l_error, & stats_zm ) From 9593d48e5a766b46916ed5382d9079d377683fe3 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Tue, 7 Nov 2023 07:46:30 -0700 Subject: [PATCH 05/11] fixing output clubb fields problem --- Externals_CAM.cfg | 2 +- src/physics/cam/clubb_intr.F90 | 122 +++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 8887731d36..634e56a72f 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -23,7 +23,7 @@ required = True local_path = src/physics/clubb protocol = svn repo_url = https://github.com/bstephens82/clubb_src/tags/ -tag = bstephens82.clubb_src.9647175 +tag = bstephens82.clubb_src.9fd98fe required = True [silhs] diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index e62de87978..51f9304f14 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -4945,8 +4945,47 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & !----------------------------------------------------------------------- + use clubb_api_module, only: & + ztscr01, & + ztscr02, & + ztscr03, & + ztscr04, & + ztscr05, & + ztscr06, & + ztscr07, & + ztscr08, & + ztscr09, & + ztscr10, & + ztscr11, & + ztscr12, & + ztscr13, & + ztscr14, & + ztscr15, & + ztscr16, & + ztscr17, & + ztscr18, & + ztscr19, & + ztscr20, & + ztscr21 use clubb_api_module, only: & + zmscr01, & + zmscr02, & + zmscr03, & + zmscr04, & + zmscr05, & + zmscr06, & + zmscr07, & + zmscr08, & + zmscr09, & + zmscr10, & + zmscr11, & + zmscr12, & + zmscr13, & + zmscr14, & + zmscr15, & + zmscr16, & + zmscr17, & l_stats, & l_output_rad_files, & stats_tsamp, & @@ -5121,6 +5160,53 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_zt%file%grid_avg_var( stats_zt%num_output_fields ) ) allocate( stats_zt%file%z( stats_zt%kk ) ) + first_call = (.not. allocated(ztscr01)) + + ! Allocate scratch space + if (first_call) allocate( ztscr01(stats_zt%kk) ) + if (first_call) allocate( ztscr02(stats_zt%kk) ) + if (first_call) allocate( ztscr03(stats_zt%kk) ) + if (first_call) allocate( ztscr04(stats_zt%kk) ) + if (first_call) allocate( ztscr05(stats_zt%kk) ) + if (first_call) allocate( ztscr06(stats_zt%kk) ) + if (first_call) allocate( ztscr07(stats_zt%kk) ) + if (first_call) allocate( ztscr08(stats_zt%kk) ) + if (first_call) allocate( ztscr09(stats_zt%kk) ) + if (first_call) allocate( ztscr10(stats_zt%kk) ) + if (first_call) allocate( ztscr11(stats_zt%kk) ) + if (first_call) allocate( ztscr12(stats_zt%kk) ) + if (first_call) allocate( ztscr13(stats_zt%kk) ) + if (first_call) allocate( ztscr14(stats_zt%kk) ) + if (first_call) allocate( ztscr15(stats_zt%kk) ) + if (first_call) allocate( ztscr16(stats_zt%kk) ) + if (first_call) allocate( ztscr17(stats_zt%kk) ) + if (first_call) allocate( ztscr18(stats_zt%kk) ) + if (first_call) allocate( ztscr19(stats_zt%kk) ) + if (first_call) allocate( ztscr20(stats_zt%kk) ) + if (first_call) allocate( ztscr21(stats_zt%kk) ) + + ztscr01 = 0.0_r8 + ztscr02 = 0.0_r8 + ztscr03 = 0.0_r8 + ztscr04 = 0.0_r8 + ztscr05 = 0.0_r8 + ztscr06 = 0.0_r8 + ztscr07 = 0.0_r8 + ztscr08 = 0.0_r8 + ztscr09 = 0.0_r8 + ztscr10 = 0.0_r8 + ztscr11 = 0.0_r8 + ztscr12 = 0.0_r8 + ztscr13 = 0.0_r8 + ztscr14 = 0.0_r8 + ztscr15 = 0.0_r8 + ztscr16 = 0.0_r8 + ztscr17 = 0.0_r8 + ztscr18 = 0.0_r8 + ztscr19 = 0.0_r8 + ztscr20 = 0.0_r8 + ztscr21 = 0.0_r8 + ! Default initialization for array indices for zt if (first_call) then call stats_init_zt_api( clubb_vars_zt, l_error, & @@ -5161,6 +5247,42 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & ! Allocate scratch space + if (first_call) allocate( zmscr01(stats_zm%kk) ) + if (first_call) allocate( zmscr02(stats_zm%kk) ) + if (first_call) allocate( zmscr03(stats_zm%kk) ) + if (first_call) allocate( zmscr04(stats_zm%kk) ) + if (first_call) allocate( zmscr05(stats_zm%kk) ) + if (first_call) allocate( zmscr06(stats_zm%kk) ) + if (first_call) allocate( zmscr07(stats_zm%kk) ) + if (first_call) allocate( zmscr08(stats_zm%kk) ) + if (first_call) allocate( zmscr09(stats_zm%kk) ) + if (first_call) allocate( zmscr10(stats_zm%kk) ) + if (first_call) allocate( zmscr11(stats_zm%kk) ) + if (first_call) allocate( zmscr12(stats_zm%kk) ) + if (first_call) allocate( zmscr13(stats_zm%kk) ) + if (first_call) allocate( zmscr14(stats_zm%kk) ) + if (first_call) allocate( zmscr15(stats_zm%kk) ) + if (first_call) allocate( zmscr16(stats_zm%kk) ) + if (first_call) allocate( zmscr17(stats_zm%kk) ) + + zmscr01 = 0.0_r8 + zmscr02 = 0.0_r8 + zmscr03 = 0.0_r8 + zmscr04 = 0.0_r8 + zmscr05 = 0.0_r8 + zmscr06 = 0.0_r8 + zmscr07 = 0.0_r8 + zmscr08 = 0.0_r8 + zmscr09 = 0.0_r8 + zmscr10 = 0.0_r8 + zmscr11 = 0.0_r8 + zmscr12 = 0.0_r8 + zmscr13 = 0.0_r8 + zmscr14 = 0.0_r8 + zmscr15 = 0.0_r8 + zmscr16 = 0.0_r8 + zmscr17 = 0.0_r8 + if (first_call) then call stats_init_zm_api( clubb_vars_zm, l_error, & stats_zm ) From fefc831c560a75d5a2a51d33e5b714bdf4a5bc0f Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Tue, 7 Nov 2023 12:12:38 -0700 Subject: [PATCH 06/11] new way of determining first_call that avoids the scratch variables --- src/physics/cam/clubb_intr.F90 | 147 ++++----------------------------- 1 file changed, 14 insertions(+), 133 deletions(-) diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index 51f9304f14..26ae3dcb95 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -1701,6 +1701,7 @@ subroutine clubb_ini_cam(pbuf2d) logical, parameter :: l_input_fields = .false. ! Always false for CAM-CLUBB. logical, parameter :: l_update_pressure = .false. ! Always false for CAM-CLUBB. + logical :: do_first_step integer :: nlev @@ -2149,10 +2150,15 @@ subroutine clubb_ini_cam(pbuf2d) if (l_stats) then do i=1, pcols + if (is_first_step()==.true. .and. i==1) then + do_first_step = .true. + else + do_first_step = .false. + end if call stats_init_clubb( .true., dum1, dum2, & nlev+1, nlev+1, nlev+1, dum3, & stats_zt(i), stats_zm(i), stats_sfc(i), & - stats_rad_zt(i), stats_rad_zm(i)) + stats_rad_zt(i), stats_rad_zm(i), do_first_step) end do allocate(out_zt(pcols,pverp,stats_zt(1)%num_output_fields)) @@ -4936,7 +4942,7 @@ end function diag_ustar subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & nnzp, nnrad_zt,nnrad_zm, delt, & stats_zt, stats_zm, stats_sfc, & - stats_rad_zt, stats_rad_zm) + stats_rad_zt, stats_rad_zm, do_first_step) ! ! Description: Initializes the statistics saving functionality of ! the CLUBB model. This is for purpose of CAM-CLUBB interface. Here @@ -4946,46 +4952,6 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & !----------------------------------------------------------------------- use clubb_api_module, only: & - ztscr01, & - ztscr02, & - ztscr03, & - ztscr04, & - ztscr05, & - ztscr06, & - ztscr07, & - ztscr08, & - ztscr09, & - ztscr10, & - ztscr11, & - ztscr12, & - ztscr13, & - ztscr14, & - ztscr15, & - ztscr16, & - ztscr17, & - ztscr18, & - ztscr19, & - ztscr20, & - ztscr21 - - use clubb_api_module, only: & - zmscr01, & - zmscr02, & - zmscr03, & - zmscr04, & - zmscr05, & - zmscr06, & - zmscr07, & - zmscr08, & - zmscr09, & - zmscr10, & - zmscr11, & - zmscr12, & - zmscr13, & - zmscr14, & - zmscr15, & - zmscr16, & - zmscr17, & l_stats, & l_output_rad_files, & stats_tsamp, & @@ -5013,6 +4979,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & ! Input Variables logical, intent(in) :: l_stats_in ! Stats on? T/F + logical, intent(in) :: do_first_step real(kind=time_precision), intent(in) :: & stats_tsamp_in, & ! Sampling interval [s] @@ -5053,8 +5020,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & ! Local Variables - logical :: l_error, & - first_call = .false. + logical :: l_error character(len=200) :: temp1, sub @@ -5160,55 +5126,8 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_zt%file%grid_avg_var( stats_zt%num_output_fields ) ) allocate( stats_zt%file%z( stats_zt%kk ) ) - first_call = (.not. allocated(ztscr01)) - - ! Allocate scratch space - if (first_call) allocate( ztscr01(stats_zt%kk) ) - if (first_call) allocate( ztscr02(stats_zt%kk) ) - if (first_call) allocate( ztscr03(stats_zt%kk) ) - if (first_call) allocate( ztscr04(stats_zt%kk) ) - if (first_call) allocate( ztscr05(stats_zt%kk) ) - if (first_call) allocate( ztscr06(stats_zt%kk) ) - if (first_call) allocate( ztscr07(stats_zt%kk) ) - if (first_call) allocate( ztscr08(stats_zt%kk) ) - if (first_call) allocate( ztscr09(stats_zt%kk) ) - if (first_call) allocate( ztscr10(stats_zt%kk) ) - if (first_call) allocate( ztscr11(stats_zt%kk) ) - if (first_call) allocate( ztscr12(stats_zt%kk) ) - if (first_call) allocate( ztscr13(stats_zt%kk) ) - if (first_call) allocate( ztscr14(stats_zt%kk) ) - if (first_call) allocate( ztscr15(stats_zt%kk) ) - if (first_call) allocate( ztscr16(stats_zt%kk) ) - if (first_call) allocate( ztscr17(stats_zt%kk) ) - if (first_call) allocate( ztscr18(stats_zt%kk) ) - if (first_call) allocate( ztscr19(stats_zt%kk) ) - if (first_call) allocate( ztscr20(stats_zt%kk) ) - if (first_call) allocate( ztscr21(stats_zt%kk) ) - - ztscr01 = 0.0_r8 - ztscr02 = 0.0_r8 - ztscr03 = 0.0_r8 - ztscr04 = 0.0_r8 - ztscr05 = 0.0_r8 - ztscr06 = 0.0_r8 - ztscr07 = 0.0_r8 - ztscr08 = 0.0_r8 - ztscr09 = 0.0_r8 - ztscr10 = 0.0_r8 - ztscr11 = 0.0_r8 - ztscr12 = 0.0_r8 - ztscr13 = 0.0_r8 - ztscr14 = 0.0_r8 - ztscr15 = 0.0_r8 - ztscr16 = 0.0_r8 - ztscr17 = 0.0_r8 - ztscr18 = 0.0_r8 - ztscr19 = 0.0_r8 - ztscr20 = 0.0_r8 - ztscr21 = 0.0_r8 - ! Default initialization for array indices for zt - if (first_call) then + if (do_first_step) then call stats_init_zt_api( clubb_vars_zt, l_error, & stats_zt ) end if @@ -5245,45 +5164,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_zm%file%grid_avg_var( stats_zm%num_output_fields ) ) allocate( stats_zm%file%z( stats_zm%kk ) ) - ! Allocate scratch space - - if (first_call) allocate( zmscr01(stats_zm%kk) ) - if (first_call) allocate( zmscr02(stats_zm%kk) ) - if (first_call) allocate( zmscr03(stats_zm%kk) ) - if (first_call) allocate( zmscr04(stats_zm%kk) ) - if (first_call) allocate( zmscr05(stats_zm%kk) ) - if (first_call) allocate( zmscr06(stats_zm%kk) ) - if (first_call) allocate( zmscr07(stats_zm%kk) ) - if (first_call) allocate( zmscr08(stats_zm%kk) ) - if (first_call) allocate( zmscr09(stats_zm%kk) ) - if (first_call) allocate( zmscr10(stats_zm%kk) ) - if (first_call) allocate( zmscr11(stats_zm%kk) ) - if (first_call) allocate( zmscr12(stats_zm%kk) ) - if (first_call) allocate( zmscr13(stats_zm%kk) ) - if (first_call) allocate( zmscr14(stats_zm%kk) ) - if (first_call) allocate( zmscr15(stats_zm%kk) ) - if (first_call) allocate( zmscr16(stats_zm%kk) ) - if (first_call) allocate( zmscr17(stats_zm%kk) ) - - zmscr01 = 0.0_r8 - zmscr02 = 0.0_r8 - zmscr03 = 0.0_r8 - zmscr04 = 0.0_r8 - zmscr05 = 0.0_r8 - zmscr06 = 0.0_r8 - zmscr07 = 0.0_r8 - zmscr08 = 0.0_r8 - zmscr09 = 0.0_r8 - zmscr10 = 0.0_r8 - zmscr11 = 0.0_r8 - zmscr12 = 0.0_r8 - zmscr13 = 0.0_r8 - zmscr14 = 0.0_r8 - zmscr15 = 0.0_r8 - zmscr16 = 0.0_r8 - zmscr17 = 0.0_r8 - - if (first_call) then + if (do_first_step) then call stats_init_zm_api( clubb_vars_zm, l_error, & stats_zm ) end if @@ -5397,7 +5278,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_sfc%file%grid_avg_var( stats_sfc%num_output_fields ) ) allocate( stats_sfc%file%z( stats_sfc%kk ) ) - if (first_call) then + if (do_first_step) then call stats_init_sfc_api( clubb_vars_sfc, l_error, & stats_sfc ) end if @@ -5409,7 +5290,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & endif ! Now call add fields - if (first_call) then + if (do_first_step) then do i = 1, stats_zt%num_output_fields From 5218b39dd6611fdeebc53553884cea1f913ae76c Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Tue, 7 Nov 2023 12:15:01 -0700 Subject: [PATCH 07/11] new external --- Externals_CAM.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 634e56a72f..b552328dfe 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -23,7 +23,7 @@ required = True local_path = src/physics/clubb protocol = svn repo_url = https://github.com/bstephens82/clubb_src/tags/ -tag = bstephens82.clubb_src.9fd98fe +tag = bstephens82.clubb_src.8d32312 required = True [silhs] From 2a17e7eb47afbdb9fdc7e458c2bca1b4dc06b0f9 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Wed, 15 Nov 2023 12:41:48 -0700 Subject: [PATCH 08/11] Adding support for clubb tunable parameter z_displace --- Externals_CAM.cfg | 2 +- bld/build-namelist | 1 + bld/namelist_files/namelist_defaults_cam.xml | 1 + bld/namelist_files/namelist_definition.xml | 3 ++- src/physics/cam/clubb_intr.F90 | 15 +++++++++++---- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index b552328dfe..791d951189 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -23,7 +23,7 @@ required = True local_path = src/physics/clubb protocol = svn repo_url = https://github.com/bstephens82/clubb_src/tags/ -tag = bstephens82.clubb_src.8d32312 +tag = bstephens82.clubb_src.886f6ea required = True [silhs] diff --git a/bld/build-namelist b/bld/build-namelist index 4e87d9eaef..cb1e6c28f8 100755 --- a/bld/build-namelist +++ b/bld/build-namelist @@ -3424,6 +3424,7 @@ if ($clubb_sgs =~ /$TRUE/io) { add_default($nl, 'clubb_c11c'); add_default($nl, 'clubb_bv_efold'); add_default($nl, 'clubb_wpxp_Ri_exp'); + add_default($nl, 'clubb_z_displace'); #CLUBB+MF options add_default($nl, 'do_clubb_mf'); diff --git a/bld/namelist_files/namelist_defaults_cam.xml b/bld/namelist_files/namelist_defaults_cam.xml index c91f3ec4fa..80c6fafc38 100644 --- a/bld/namelist_files/namelist_defaults_cam.xml +++ b/bld/namelist_files/namelist_defaults_cam.xml @@ -2176,6 +2176,7 @@ 0.5 1.0 1.0 + 25.0 diff --git a/bld/namelist_files/namelist_definition.xml b/bld/namelist_files/namelist_definition.xml index d2e1b1da90..6452641a5c 100644 --- a/bld/namelist_files/namelist_definition.xml +++ b/bld/namelist_files/namelist_definition.xml @@ -4426,7 +4426,8 @@ Default: 10 group="clubb_params_nl" valid_values="" > - + diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index 26ae3dcb95..276d65d722 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -228,6 +228,7 @@ module clubb_intr real(r8) :: clubb_a_const = unset_r8 real(r8) :: clubb_bv_efold = unset_r8 real(r8) :: clubb_wpxp_Ri_exp = unset_r8 + real(r8) :: clubb_z_displace = unset_r8 integer :: & clubb_iiPDF_type, & ! Selected option for the two-component normal @@ -916,6 +917,7 @@ subroutine clubb_readnl(nlfile) clubb_a_const, & clubb_bv_efold, & clubb_wpxp_Ri_exp, & + clubb_z_displace, & clubb_l_use_precip_frac, & clubb_l_C2_cloud_frac, & clubb_l_diffuse_rtm_and_thlm, & @@ -1269,6 +1271,8 @@ subroutine clubb_readnl(nlfile) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_bv_efold") call mpi_bcast(clubb_wpxp_Ri_exp, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_wpxp_Ri_exp") + call mpi_bcast(clubb_z_displace, 1, mpi_real8, mstrid, mpicom, ierr) + if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_z_displace") call mpi_bcast(clubb_l_use_C7_Richardson, 1, mpi_logical, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_use_C7_Richardson") @@ -1494,6 +1498,7 @@ subroutine clubb_readnl(nlfile) if(clubb_a_const == unset_r8) call endrun(sub//": FATAL: clubb_a_const is not set") if(clubb_bv_efold == unset_r8) call endrun(sub//": FATAL: clubb_bv_efold is not set") if(clubb_wpxp_Ri_exp == unset_r8) call endrun(sub//": FATAL: clubb_wpxp_Ri_exp is not set") + if(clubb_z_displace == unset_r8) call endrun(sub//": FATAL: clubb_z_displace is not set") if(clubb_detphase_lowtemp >= meltpt_temp) & call endrun(sub//": ERROR: clubb_detphase_lowtemp must be less than 268.15 K") @@ -1644,7 +1649,8 @@ subroutine clubb_ini_cam(pbuf2d) ia3_coef_min, & ia_const, & ibv_efold, & - iwpxp_Ri_exp + iwpxp_Ri_exp, & + iz_displace use clubb_api_module, only: & print_clubb_config_flags_api, & @@ -1727,7 +1733,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, a3_coef_min, a_const, & - bv_efold, wpxp_Ri_exp + bv_efold, wpxp_Ri_exp, z_displace !----- Begin Code ----- @@ -1883,7 +1889,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold ) + Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace ) call read_parameters_api( -99, "", & C1, C1b, C1c, C2rt, C2thl, C2rtthl, & @@ -1910,7 +1916,7 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, & - clubb_params ) + z_displace, clubb_params ) clubb_params(iC2rtthl) = clubb_C2rtthl clubb_params(iC8) = clubb_C8 @@ -2011,6 +2017,7 @@ subroutine clubb_ini_cam(pbuf2d) clubb_params(ia_const) = clubb_a_const clubb_params(ibv_efold) = clubb_bv_efold clubb_params(iwpxp_Ri_exp) = clubb_wpxp_Ri_exp + clubb_params(iz_displace) = clubb_z_displace ! Set up CLUBB core. Note that some of these inputs are overwritten ! when clubb_tend_cam is called. The reason is that heights can change From cb43f04914a1341c32452493d919b71758da71f8 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Wed, 15 Nov 2023 13:22:23 -0700 Subject: [PATCH 09/11] saving clean_externals.bash --- clean_externals.bash | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 clean_externals.bash diff --git a/clean_externals.bash b/clean_externals.bash new file mode 100755 index 0000000000..f98935da83 --- /dev/null +++ b/clean_externals.bash @@ -0,0 +1,21 @@ +#!/bin/bash +# + +# intended to delete all externals so you can start with a +# clean slate after checking out a new tag + +rm -rf ccs_config +rm -rf chem_proc +rm -rf cime +rm -rf components +rm -rf libraries +rm -rf share +rm -rf post +rm -rf src/atmos_phys +rm -rf src/hemco +rm -rf src/physics/ali_arms +rm -rf clubb +rm -rf pumas +rm -rf pumas-frozen +rm -rf silhs + From 4f3bb323d8d900f3ebdbe40a901e5945eb670324 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Fri, 17 Nov 2023 10:48:59 -0700 Subject: [PATCH 10/11] Changes for new clubb external Nov '23. --- Externals_CAM.cfg | 2 +- src/physics/cam/clubb_intr.F90 | 137 +++++++++++++++------------------ 2 files changed, 63 insertions(+), 76 deletions(-) diff --git a/Externals_CAM.cfg b/Externals_CAM.cfg index 791d951189..a7a7e817c5 100644 --- a/Externals_CAM.cfg +++ b/Externals_CAM.cfg @@ -23,7 +23,7 @@ required = True local_path = src/physics/clubb protocol = svn repo_url = https://github.com/bstephens82/clubb_src/tags/ -tag = bstephens82.clubb_src.886f6ea +tag = bstephens82.clubb_src.bb645bb required = True [silhs] diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index 276d65d722..e3d66a047a 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -31,7 +31,7 @@ module clubb_intr use zm_conv_intr, only: zmconv_microp #ifdef CLUBB_SGS use clubb_api_module, only: pdf_parameter, implicit_coefs_terms - use clubb_api_module, only: clubb_config_flags_type, grid, stats, nu_vertical_res_dep + use clubb_api_module, only: clubb_config_flags_type, grid, stats, nu_vertical_res_dep, stats_metadata_type use clubb_api_module, only: nparams use clubb_mf, only: do_clubb_mf, do_clubb_mf_diag use cloud_fraction, only: dp1, dp2 @@ -49,6 +49,11 @@ module clubb_intr !$omp threadprivate(stats_zt, stats_zm, stats_rad_zt, stats_rad_zm, stats_sfc) + type (stats_metadata_type) :: & + stats_metadata + +!$omp threadprivate(stats_metadata) + #endif private @@ -62,6 +67,7 @@ module clubb_intr #ifdef CLUBB_SGS ! This utilizes CLUBB specific variables in its interface stats_init_clubb, & + stats_metadata, & stats_zt, stats_zm, stats_sfc, & stats_rad_zt, stats_rad_zm, & stats_end_timestep_clubb, & @@ -748,11 +754,10 @@ subroutine clubb_readnl(nlfile) use spmd_utils, only: mpicom, mstrid=>masterprocid, mpi_logical, mpi_real8, & mpi_integer use clubb_mf, only: clubb_mf_readnl - + use clubb_api_module, only: & set_default_clubb_config_flags_api, & ! Procedure(s) - initialize_clubb_config_flags_type_api, & - l_stats, l_output_rad_files + initialize_clubb_config_flags_type_api #endif character(len=*), intent(in) :: nlfile ! filepath for file containing namelist input @@ -938,8 +943,8 @@ subroutine clubb_readnl(nlfile) ! Determine if we want clubb_history to be output clubb_history = .false. ! Initialize to false - l_stats = .false. ! Initialize to false - l_output_rad_files = .false. ! Initialize to false + stats_metadata%l_stats = .false. ! Initialize to false + stats_metadata%l_output_rad_files = .false. ! Initialize to false do_cldcool = .false. ! Initialize to false do_rainturb = .false. ! Initialize to false @@ -1271,7 +1276,7 @@ subroutine clubb_readnl(nlfile) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_bv_efold") call mpi_bcast(clubb_wpxp_Ri_exp, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_wpxp_Ri_exp") - call mpi_bcast(clubb_z_displace, 1, mpi_real8, mstrid, mpicom, ierr) + call mpi_bcast(clubb_z_displace, 1, mpi_real8, mstrid, mpicom, ierr) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_z_displace") call mpi_bcast(clubb_l_use_C7_Richardson, 1, mpi_logical, mstrid, mpicom, ierr) @@ -1384,8 +1389,8 @@ subroutine clubb_readnl(nlfile) if (ierr /= 0) call endrun(sub//": FATAL: mpi_bcast: clubb_l_linearize_pbl_winds") ! Overwrite defaults if they are true - if (clubb_history) l_stats = .true. - if (clubb_rad_history) l_output_rad_files = .true. + if (clubb_history) stats_metadata%l_stats = .true. + if (clubb_rad_history) stats_metadata%l_output_rad_files = .true. if (clubb_cloudtop_cooling) do_cldcool = .true. if (clubb_rainevap_turb) do_rainturb = .true. @@ -1663,9 +1668,6 @@ subroutine clubb_ini_cam(pbuf2d) nparams, & set_default_parameters_api, & read_parameters_api, & - l_stats, & - l_stats_samp, & - l_grads, & w_tol_sqd, & rt_tol, & thl_tol @@ -1810,11 +1812,11 @@ subroutine clubb_ini_cam(pbuf2d) ! Defaults - l_stats_samp = .false. - l_grads = .false. + stats_metadata%l_stats_samp = .false. + stats_metadata%l_grads = .false. ! Overwrite defaults if needbe - if (l_stats) l_stats_samp = .true. + if (stats_metadata%l_stats) stats_metadata%l_stats_samp = .true. ! Define physics buffers indexes cld_idx = pbuf_get_index('CLD') ! Cloud fraction @@ -1915,8 +1917,8 @@ subroutine clubb_ini_cam(pbuf2d) C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & Cx_min, Cx_max, Richardson_num_min, & - Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, & - z_displace, clubb_params ) + Richardson_num_max, wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace, & + clubb_params ) clubb_params(iC2rtthl) = clubb_C2rtthl clubb_params(iC8) = clubb_C8 @@ -2154,7 +2156,7 @@ subroutine clubb_ini_cam(pbuf2d) dum2 = 1200._r8 dum3 = 300._r8 - if (l_stats) then + if (stats_metadata%l_stats) then do i=1, pcols if (is_first_step()==.true. .and. i==1) then @@ -2172,8 +2174,10 @@ subroutine clubb_ini_cam(pbuf2d) allocate(out_zm(pcols,pverp,stats_zm(1)%num_output_fields)) allocate(out_sfc(pcols,1,stats_sfc(1)%num_output_fields)) - allocate(out_radzt(pcols,pverp,stats_rad_zt(1)%num_output_fields)) - allocate(out_radzm(pcols,pverp,stats_rad_zm(1)%num_output_fields)) + if ( stats_metadata%l_output_rad_files ) then + allocate(out_radzt(pcols,pverp,stats_rad_zt(1)%num_output_fields)) + allocate(out_radzm(pcols,pverp,stats_rad_zm(1)%num_output_fields)) + end if endif @@ -2382,10 +2386,6 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & w_tol_sqd, & rt_tol, & thl_tol, & - l_stats, & - stats_tsamp, & - stats_tout, & - l_output_rad_files, & stats_begin_timestep_api, & hydromet_dim, calculate_thlp2_rad_api, update_xp2_mc_api, & sat_mixrat_liq_api, & @@ -3362,12 +3362,12 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & end do ! Set stats output and increment equal to CLUBB and host dt - stats_tsamp = dtime - stats_tout = hdtime + stats_metadata%stats_tsamp = dtime + stats_metadata%stats_tout = hdtime + + stats_nsamp = nint(stats_metadata%stats_tsamp/dtime) + stats_nout = nint(stats_metadata%stats_tout/dtime) - stats_nsamp = nint(stats_tsamp/dtime) - stats_nout = nint(stats_tout/dtime) - ! Heights need to be set at each timestep. Therefore, recall ! setup_grid and setup_parameters for this. @@ -3378,12 +3378,11 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & call setup_grid_api( nlev+1, ncol, sfc_elevation, l_implemented, & ! intent(in) grid_type, zi_g(:,2), zi_g(:,1), zi_g(:,nlev+1), & ! intent(in) zi_g, zt_g, & ! intent(in) - gr, begin_height, end_height ) ! intent(out) + gr ) ! intent(out) - call setup_parameters_api( zi_g(:,2), clubb_params, nlev+1, ncol, grid_type, & ! intent(in) - zi_g, zt_g, & ! intent(in) - clubb_config_flags%l_prescribed_avg_deltaz, & ! intent(in) - lmin, nu_vert_res_dep, err_code ) ! intent(out) + call setup_parameters_api( zi_g(:,2), clubb_params, gr, ncol, grid_type, & ! intent(in) + clubb_config_flags%l_prescribed_avg_deltaz, & ! intent(in) + lmin, nu_vert_res_dep, err_code ) ! intent(out) if ( err_code == clubb_fatal_error ) then call endrun(subr//': Fatal error in CLUBB setup_parameters') end if @@ -3670,8 +3669,9 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & do t=1,nadv ! do needed number of "sub" timesteps for each CAM step ! Increment the statistics then being stats timestep - if (l_stats) then - call stats_begin_timestep_api(t, stats_nsamp, stats_nout) + if (stats_metadata%l_stats) then + call stats_begin_timestep_api( t, stats_nsamp, stats_nout, & + stats_metadata ) endif !####################################################################### @@ -3750,6 +3750,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & grid_dx, grid_dy, & clubb_params, nu_vert_res_dep, lmin, & clubb_config_flags, & + stats_metadata, & stats_zt(:ncol), stats_zm(:ncol), stats_sfc(:ncol), & um_in, vm_in, upwp_in, vpwp_in, up2_in, vp2_in, up3_in, vp3_in, & thlm_in, rtm_in, wprtp_in, wpthlp_in, & @@ -3832,7 +3833,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & ! Check to see if stats should be output, here stats are read into ! output arrays to make them conformable to CAM output - if (l_stats) then + if (stats_metadata%l_stats) then do i=1, ncol call stats_end_timestep_clubb(i, stats_zt(i), stats_zm(i), stats_rad_zt(i), stats_rad_zm(i), stats_sfc(i), & out_zt, out_zm, out_radzt, out_radzm, out_sfc) @@ -4708,7 +4709,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & end if ! Output CLUBB history here - if (l_stats) then + if (stats_metadata%l_stats) then do j=1,stats_zt(1)%num_output_fields @@ -4728,7 +4729,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, & call outfld(trim(sub),out_zm(:,:,j), pcols, lchnk) enddo - if (l_output_rad_files) then + if (stats_metadata%l_output_rad_files) then do j=1,stats_rad_zt(1)%num_output_fields call outfld(trim(stats_rad_zt(1)%file%grid_avg_var(j)%name), out_radzt(:,:,j), pcols, lchnk) enddo @@ -4958,16 +4959,6 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & !----------------------------------------------------------------------- - use clubb_api_module, only: & - l_stats, & - l_output_rad_files, & - stats_tsamp, & - stats_tout, & - l_stats_samp, & - l_stats_last, & - l_netcdf, & - l_grads - use clubb_api_module, only: time_precision, & ! nvarmax_zm, stats_init_zm_api, & ! nvarmax_zt, stats_init_zt_api, & ! @@ -5038,14 +5029,14 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & l_error = .false. ! Set stats_variables variables with inputs from calling subroutine - l_stats = l_stats_in - - stats_tsamp = stats_tsamp_in - stats_tout = stats_tout_in + stats_metadata%l_stats = l_stats_in + + stats_metadata%stats_tsamp = stats_tsamp_in + stats_metadata%stats_tout = stats_tout_in - if ( .not. l_stats ) then - l_stats_samp = .false. - l_stats_last = .false. + if ( .not. stats_metadata%l_stats ) then + stats_metadata%l_stats_samp = .false. + stats_metadata%l_stats_last = .false. return end if @@ -5085,19 +5076,19 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & if (ierr /= 0) call endrun(subr//": FATAL: mpi_bcast: clubb_vars_sfc") ! Hardcode these for use in CAM-CLUBB, don't want either - l_netcdf = .false. - l_grads = .false. + stats_metadata%l_netcdf = .false. + stats_metadata%l_grads = .false. ! Check sampling and output frequencies ! The model time step length, delt (which is dtmain), should multiply ! evenly into the statistical sampling time step length, stats_tsamp. - if ( abs( stats_tsamp/delt - floor(stats_tsamp/delt) ) > 1.e-8_r8 ) then + if ( abs( stats_metadata%stats_tsamp/delt - floor(stats_metadata%stats_tsamp/delt) ) > 1.e-8_r8 ) then l_error = .true. ! This will cause the run to stop. write(fstderr,*) 'Error: stats_tsamp should be an even multiple of ', & 'delt (which is dtmain). Check the appropriate ', & 'model.in file.' - write(fstderr,*) 'stats_tsamp = ', stats_tsamp + write(fstderr,*) 'stats_tsamp = ', stats_metadata%stats_tsamp write(fstderr,*) 'delt = ', delt endif @@ -5136,7 +5127,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & ! Default initialization for array indices for zt if (do_first_step) then call stats_init_zt_api( clubb_vars_zt, l_error, & - stats_zt ) + stats_metadata, stats_zt ) end if ! Initialize zm (momentum points) @@ -5173,12 +5164,12 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & if (do_first_step) then call stats_init_zm_api( clubb_vars_zm, l_error, & - stats_zm ) + stats_metadata, stats_zm ) end if ! Initialize rad_zt (radiation points) - if (l_output_rad_files) then + if (stats_metadata%l_output_rad_files) then i = 1 do while ( ichar(clubb_vars_rad_zt(i)(1:1)) /= 0 .and. & @@ -5212,7 +5203,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_rad_zt%file%z( stats_rad_zt%kk ) ) call stats_init_rad_zt_api( clubb_vars_rad_zt, l_error, & - stats_rad_zt ) + stats_metadata, stats_rad_zt ) ! Initialize rad_zm (radiation points) @@ -5248,7 +5239,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & allocate( stats_rad_zm%file%z( stats_rad_zm%kk ) ) call stats_init_rad_zm_api( clubb_vars_rad_zm, l_error, & - stats_rad_zm ) + stats_metadata, stats_rad_zm ) end if ! l_output_rad_files @@ -5287,7 +5278,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & if (do_first_step) then call stats_init_sfc_api( clubb_vars_sfc, l_error, & - stats_sfc ) + stats_metadata, stats_sfc ) end if ! Check for errors @@ -5319,7 +5310,7 @@ subroutine stats_init_clubb( l_stats_in, stats_tsamp_in, stats_tout_in, & 'A',trim(stats_zm%file%grid_avg_var(i)%units),trim(stats_zm%file%grid_avg_var(i)%description)) enddo - if (l_output_rad_files) then + if (stats_metadata%l_output_rad_files) then do i = 1, stats_rad_zt%num_output_fields call addfld(trim(stats_rad_zt%file%grid_avg_var(i)%name),(/ 'ilev' /),& @@ -5364,10 +5355,6 @@ subroutine stats_end_timestep_clubb(thecol, stats_zt, stats_zm, stats_rad_zt, st use clubb_api_module, only: & fstderr, & ! Constant(s) - l_stats_last, & - stats_tsamp, & - stats_tout, & - l_output_rad_files, & clubb_at_least_debug_level_api ! Procedure(s) use cam_abortutils, only: endrun @@ -5397,7 +5384,7 @@ subroutine stats_end_timestep_clubb(thecol, stats_zt, stats_zm, stats_rad_zt, st ! Check if it is time to write to file - if ( .not. l_stats_last ) return + if ( .not. stats_metadata%l_stats_last ) return ! Initialize l_error = .false. @@ -5405,7 +5392,7 @@ subroutine stats_end_timestep_clubb(thecol, stats_zt, stats_zm, stats_rad_zt, st ! Compute averages call stats_avg( stats_zt%kk, stats_zt%num_output_fields, stats_zt%accum_field_values, stats_zt%accum_num_samples ) call stats_avg( stats_zm%kk, stats_zm%num_output_fields, stats_zm%accum_field_values, stats_zm%accum_num_samples ) - if (l_output_rad_files) then + if (stats_metadata%l_output_rad_files) then call stats_avg( stats_rad_zt%kk, stats_rad_zt%num_output_fields, stats_rad_zt%accum_field_values, & stats_rad_zt%accum_num_samples ) call stats_avg( stats_rad_zm%kk, stats_rad_zm%num_output_fields, stats_rad_zm%accum_field_values, & @@ -5430,7 +5417,7 @@ subroutine stats_end_timestep_clubb(thecol, stats_zt, stats_zm, stats_rad_zt, st enddo enddo - if (l_output_rad_files) then + if (stats_metadata%l_output_rad_files) then do i = 1, stats_rad_zt%num_output_fields do k = 1, stats_rad_zt%kk out_radzt(thecol,pverp-k+1,i) = stats_rad_zt%accum_field_values(1,1,k,i) @@ -5463,7 +5450,7 @@ subroutine stats_end_timestep_clubb(thecol, stats_zt, stats_zm, stats_rad_zt, st stats_zt%accum_num_samples, stats_zt%l_in_update ) call stats_zero( stats_zm%kk, stats_zm%num_output_fields, stats_zm%accum_field_values, & stats_zm%accum_num_samples, stats_zm%l_in_update ) - if (l_output_rad_files) then + if (stats_metadata%l_output_rad_files) then call stats_zero( stats_rad_zt%kk, stats_rad_zt%num_output_fields, stats_rad_zt%accum_field_values, & stats_rad_zt%accum_num_samples, stats_rad_zt%l_in_update ) call stats_zero( stats_rad_zm%kk, stats_rad_zm%num_output_fields, stats_rad_zm%accum_field_values, & From 7ea7f24225f16d0113ebed0538c5b735b5024a50 Mon Sep 17 00:00:00 2001 From: bstephens82 Date: Mon, 27 Nov 2023 21:26:09 -0700 Subject: [PATCH 11/11] fixing restart bug --- src/physics/cam/clubb_intr.F90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/physics/cam/clubb_intr.F90 b/src/physics/cam/clubb_intr.F90 index e3d66a047a..f0b7754cfd 100644 --- a/src/physics/cam/clubb_intr.F90 +++ b/src/physics/cam/clubb_intr.F90 @@ -1681,7 +1681,7 @@ subroutine clubb_ini_cam(pbuf2d) iiedsclr_thl, & iiedsclr_CO2 - use time_manager, only: is_first_step + use time_manager, only: is_first_step, is_first_restart_step use clubb_api_module, only: hydromet_dim use constituents, only: cnst_get_ind use phys_control, only: phys_getopts @@ -2159,7 +2159,7 @@ subroutine clubb_ini_cam(pbuf2d) if (stats_metadata%l_stats) then do i=1, pcols - if (is_first_step()==.true. .and. i==1) then + if ((is_first_step()==.true..or.is_first_restart_step()==.true.) .and. i==1) then do_first_step = .true. else do_first_step = .false.