LCOV - code coverage report
Current view: top level - physics/clubb/src/CLUBB_core - parameters_tunable.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 379 620 61.1 %
Date: 2024-12-17 17:57:11 Functions: 6 10 60.0 %

          Line data    Source code
       1             : !-----------------------------------------------------------------------
       2             : ! $Id$ 
       3             : !===============================================================================
       4             : module parameters_tunable
       5             :  
       6             :   ! Description:
       7             :   !   This module contains tunable model parameters.  The purpose of the module is to make it
       8             :   !   easier for the clubb_tuner code to use the clubb_params vector without "knowing" any information
       9             :   !   about the individual parameters contained in the vector itself.  It makes it easier to add
      10             :   !   new parameters to be tuned for, but does not make the CLUBB_core code itself any simpler.
      11             :   !   The parameters within the vector do not need to be the same variables used in the rest of
      12             :   !   CLUBB_core (see for e.g. nu1_vert_res_dep or lmin_coef).
      13             :   !   The parameters in the clubb_params vector only need to be those parameters for which we're not
      14             :   !   sure the correct value and we'd like to tune for.
      15             :   !
      16             :   ! References:
      17             :   !   None
      18             :   ! 
      19             :   ! Notes:
      20             :   !   To make it easier to verify of code correctness, please keep the omp threadprivate
      21             :   !   directives just after the variable declaration.  All parameters in this
      22             :   !   module should be declared threadprivate because of the CLUBB tuner.
      23             :   !-----------------------------------------------------------------------
      24             : 
      25             :   use constants_clubb, only: eps ! Epsilon
      26             : 
      27             :   use parameter_indices, only: nparams ! Variable(s)
      28             : 
      29             :   use clubb_precision, only: &
      30             :       core_rknd ! Variable(s)
      31             : 
      32             :   implicit none
      33             : 
      34             :   ! Default to private
      35             :   private
      36             : 
      37             :   public :: set_default_parameters, setup_parameters, read_parameters, &
      38             :             read_param_minmax, read_param_constraints, &
      39             :             adj_low_res_nu, nu_vertical_res_dep
      40             : 
      41             :   type nu_vertical_res_dep
      42             :     real( kind = core_rknd ), allocatable, dimension(:) :: & 
      43             :       nu1,   & ! Background Coefficient of Eddy Diffusion: wp2      [m^2/s]
      44             :       nu2,   & ! Background Coefficient of Eddy Diffusion: xp2      [m^2/s]
      45             :       nu6,   & ! Background Coefficient of Eddy Diffusion: wpxp     [m^2/s]
      46             :       nu8,   & ! Background Coefficient of Eddy Diffusion: wp3      [m^2/s]
      47             :       nu9,   & ! Background Coefficient of Eddy Diffusion: up2/vp2  [m^2/s]
      48             :       nu10,  & ! Background Coefficient of Eddy Diffusion: edsclrm  [m^2/s]
      49             :       nu_hm    ! Background Coefficient of Eddy Diffusion: hydromet [m^2/s]
      50             :   end type nu_vertical_res_dep
      51             : 
      52             :   ! These are referenced together often enough that it made sense to
      53             :   ! make a list of them.  Note that lmin_coef is the input parameter,
      54             :   ! while the actual lmin model constant is computed from this.
      55             :   !***************************************************************
      56             :   !                    ***** IMPORTANT *****
      57             :   ! If you change the order of the parameters in the parameter_indices,
      58             :   ! you will need to change the order of this list as well or the
      59             :   ! tuner will break!
      60             :   !                    ***** IMPORTANT *****
      61             :   !***************************************************************
      62             :   character(len=28), dimension(nparams), parameter, public ::  & 
      63             :   params_list = & 
      64             :      (/"C1                          ", "C1b                         ", &
      65             :        "C1c                         ", &
      66             :        "C2rt                        ", "C2thl                       ", &
      67             :        "C2rtthl                     ", "C4                          ", &
      68             :        "C_uu_shr                    ", "C_uu_buoy                   ", &
      69             :        "C6rt                        ", &
      70             :        "C6rtb                       ", "C6rtc                       ", &
      71             :        "C6thl                       ", "C6thlb                      ", &
      72             :        "C6thlc                      ", "C7                          ", &
      73             :        "C7b                         ", "C7c                         ", &
      74             :        "C8                          ", "C8b                         ", &
      75             :        "C10                         ", "C11                         ", &
      76             :        "C11b                        ", "C11c                        ", &
      77             :        "C12                         ", "C13                         ", &
      78             :        "C14                         ", "C_wp2_pr_dfsn               ", &
      79             :        "C_wp3_pr_tp                 ", "C_wp3_pr_turb               ", &
      80             :        "C_wp3_pr_dfsn               ", "C_wp2_splat                 ", &
      81             :        "C6rt_Lscale0                ", "C6thl_Lscale0               ", &
      82             :        "C7_Lscale0                  ", "wpxp_L_thresh               ", &
      83             :        "c_K                         ", "c_K1                        ", &
      84             :        "nu1                         ", "c_K2                        ", &
      85             :        "nu2                         ", "c_K6                        ", &
      86             :        "nu6                         ", "c_K8                        ", &
      87             :        "nu8                         ", "c_K9                        ", &
      88             :        "nu9                         ", "nu10                        ", &
      89             :        "c_K_hm                      ", "c_K_hmb                     ", &
      90             :        "K_hm_min_coef               ", "nu_hm                       ", &
      91             :        "slope_coef_spread_DG_means_w", "pdf_component_stdev_factor_w", &
      92             :        "coef_spread_DG_means_rt     ", "coef_spread_DG_means_thl    ", &
      93             :        "gamma_coef                  ", "gamma_coefb                 ", &
      94             :        "gamma_coefc                 ", "mu                          ", &
      95             :        "beta                        ", "lmin_coef                   ", &
      96             :        "omicron                     ", "zeta_vrnce_rat              ", &
      97             :        "upsilon_precip_frac_rat     ", "lambda0_stability_coef      ", &
      98             :        "mult_coef                   ", "taumin                      ", &
      99             :        "taumax                      ", "Lscale_mu_coef              ", &
     100             :        "Lscale_pert_coef            ", "alpha_corr                  ", &
     101             :        "Skw_denom_coef              ", "c_K10                       ", &
     102             :        "c_K10h                      ", "thlp2_rad_coef              ", &
     103             :        "thlp2_rad_cloud_frac_thresh ", "up2_sfc_coef                ", &
     104             :        "Skw_max_mag                 ", "C_invrs_tau_bkgnd           ", &
     105             :        "C_invrs_tau_sfc             ", "C_invrs_tau_shear           ", &
     106             :        "C_invrs_tau_N2              ", "C_invrs_tau_N2_wp2          ", &
     107             :        "C_invrs_tau_N2_xp2          ", "C_invrs_tau_N2_wpxp         ", &
     108             :        "C_invrs_tau_N2_clear_wp3    ", "C_invrs_tau_wpxp_Ri         ", &
     109             :        "C_invrs_tau_wpxp_N2_thresh  ", "xp3_coef_base               ", &
     110             :        "xp3_coef_slope              ", "altitude_threshold          ", &
     111             :        "rtp2_clip_coef              ", "Cx_min                      ", &
     112             :        "Cx_max                      ", "Richardson_num_min          ", &
     113             :        "Richardson_num_max          ", "a3_coef_min                 ", &
     114             :        "a_const                     ", "bv_efold                    ", &
     115             :        "wpxp_Ri_exp                 ", "z_displace                  "/)
     116             : 
     117             :   real( kind = core_rknd ), parameter, private :: &
     118             :     init_value = -999._core_rknd ! Initial value for the parameters, used to detect missing values
     119             : 
     120             : 
     121             :   contains
     122             : 
     123             :   !=============================================================================
     124        1536 :   subroutine set_default_parameters( &
     125             :                C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
     126             :                C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
     127             :                C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
     128             :                C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
     129             :                C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
     130             :                C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
     131             :                c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
     132             :                c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
     133             :                slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
     134             :                coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
     135             :                gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
     136             :                omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
     137             :                lambda0_stability_coef, mult_coef, taumin, taumax, &
     138             :                Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
     139             :                Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
     140             :                thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
     141             :                Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
     142             :                altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
     143             :                C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, & 
     144             :                C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
     145             :                C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
     146             :                C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
     147             :                Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
     148             :                wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace )
     149             : 
     150             :     implicit none
     151             : 
     152             :     ! Output variables
     153             :     real( kind = core_rknd ), intent(out) :: & 
     154             :       C1, C1b, C1c, C2rt, C2thl, C2rtthl, & 
     155             :       C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
     156             :       C7, C7b, C7c, C8, C8b, C10, & 
     157             :       C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
     158             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & 
     159             :       C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
     160             :       c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8,  & 
     161             :       c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
     162             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
     163             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
     164             :       gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
     165             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
     166             :       lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
     167             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
     168             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
     169             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
     170             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
     171             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
     172             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
     173             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
     174             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
     175             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
     176             : 
     177             : 
     178             :     ! NOTE: In CLUBB standalone, as well as some host models, the hardcoded
     179             :     !       default values of some or all of the parameters below have no
     180             :     !       effect, as the values are simply read in using a namelist or set in
     181             :     !       host model specific code.
     182             : 
     183             :     ! Model tunable parameters
     184             :     ! WARNING: THE DEFAULT VALUES OF THE PARAMETERS BELOW MAY BE OVERWRITTEN
     185             :     !    BY NAMELIST VALUES FROM, E.G., clubb_params_nl!!!
     186        1536 :     C1          = 1.000000_core_rknd ! Low Skewness in C1 Skw. Function    [-]
     187        1536 :     C1b         = 1.000000_core_rknd ! High Skewness in C1 Skw. Function   [-]
     188        1536 :     C1c         = 1.000000_core_rknd ! Degree of Slope of C1 Skw. Function [-]
     189        1536 :     C2rt        = 2.000000_core_rknd ! C2 coef. for the rtp2_dp1 term      [-]
     190        1536 :     C2thl       = 2.000000_core_rknd ! C2 coef. for the thlp2_dp1 term     [-]
     191        1536 :     C2rtthl     = 2.000000_core_rknd ! C2 coef. for the rtpthlp_dp1 term   [-]
     192        1536 :     C4          = 2.000000_core_rknd ! Used only when l_tke_aniso is true  [-]
     193        1536 :     C_uu_shr    = 0.400000_core_rknd ! Coef. in pressure terms (shear): w'^2 eqn   [-]
     194        1536 :     C_uu_buoy   = 0.300000_core_rknd ! Coef. in pressure terms (buoyancy): w'^2 eqn [-]
     195        1536 :     C6rt        = 2.000000_core_rknd ! Low Skewness in C6rt Skw. Function  [-]
     196        1536 :     C6rtb       = 2.000000_core_rknd ! High Skewness in C6rt Skw. Function [-]
     197        1536 :     C6rtc       = 1.000000_core_rknd ! Degree of Slope of C6rt Skw. Fnct.  [-]
     198        1536 :     C6thl       = 2.000000_core_rknd ! Low Skewness in C6thl Skw. Function [-]
     199        1536 :     C6thlb      = 2.000000_core_rknd ! High Skewness in C6thl Skw. Fnct.   [-]
     200        1536 :     C6thlc      = 1.000000_core_rknd ! Degree of Slope of C6thl Skw. Fnct. [-]
     201        1536 :     C7          = 0.500000_core_rknd ! Low Skewness in C7 Skw. Function    [-]
     202        1536 :     C7b         = 0.500000_core_rknd ! High Skewness in C7 Skw. Function   [-]
     203        1536 :     C7c         = 0.500000_core_rknd ! Degree of Slope of C7 Skw. Function [-]
     204        1536 :     C8          = 0.500000_core_rknd ! Coef. #1 in C8 Skewness Equation    [-]
     205        1536 :     C8b         = 0.020000_core_rknd ! Coef. #2 in C8 Skewness Equation    [-]
     206        1536 :     C10         = 3.300000_core_rknd ! Currently Not Used in the Model     [-]
     207        1536 :     C11         = 0.400000_core_rknd ! Low Skewness in C11 Skw. Function   [-]
     208        1536 :     C11b        = 0.400000_core_rknd ! High Skewness in C11 Skw. Function  [-]
     209        1536 :     C11c        = 0.500000_core_rknd ! Degree of Slope of C11 Skw. Fnct.   [-]
     210        1536 :     C12         = 1.000000_core_rknd ! Constant in w'^3 Crank-Nich. diff.  [-]
     211        1536 :     C13         = 0.100000_core_rknd ! Not currently used in model         [-]
     212        1536 :     C14         = 1.000000_core_rknd ! Constant for u'^2 and v'^2 terms    [-]
     213        1536 :     C_wp2_pr_dfsn = 0.000000_core_rknd ! Coefficient for the wp2_pr_dfsn term [-]
     214        1536 :     C_wp3_pr_tp   = 0.000000_core_rknd ! Coefficient for the wp3_pr_tp term [-]
     215        1536 :     C_wp3_pr_turb = 0.000000_core_rknd ! Coefficient for the wp3_pr_turb term [-]
     216        1536 :     C_wp3_pr_dfsn = 0.000000_core_rknd ! Coefficient for the wp3_pr_dfsn term [-]
     217        1536 :     C_wp2_splat   = 2.000000_core_rknd ! Coefficient for gustiness near ground [-]
     218        1536 :     C6rt_Lscale0  = 14.0_core_rknd     ! Damp C6rt as a fnct. of Lscale  [-]
     219        1536 :     C6thl_Lscale0 = 14.0_core_rknd     ! Damp C6thl as a fnct. of Lscale [-]
     220        1536 :     C7_Lscale0    = 0.8500000_core_rknd ! Damp C7 as a fnct. of Lscale    [-]
     221        1536 :     wpxp_L_thresh = 60.0_core_rknd      ! Lscale threshold: damp C6 & C7  [m]
     222        1536 :     c_K         = 0.200000_core_rknd ! Constant C_mu^(1/4) in DD 1987 [m^2/s]
     223        1536 :     c_K1        = 0.200000_core_rknd ! Coef. of Eddy Diffusion: wp2   [m^2/s]
     224        1536 :     c_K2        = 0.025000_core_rknd ! Coef. of Eddy Diffusion: xp2   [m^2/s]
     225        1536 :     c_K6        = 0.375000_core_rknd ! Coef. of Eddy Diffusion: wpxp  [m^2/s]
     226        1536 :     c_K8        = 5.000000_core_rknd ! Coef. of Eddy Diffusion: wp3   [m^2/s]
     227        1536 :     c_K9        = 0.100000_core_rknd ! Coef. of Eddy Diff.: up2/vp2   [m^2/s]
     228        1536 :     c_K_hm      = 0.750000_core_rknd ! Coef. of Eddy Diffusion: hmm   [m^2/s]
     229        1536 :     c_K_hmb     = 0.750000_core_rknd ! Coef. of Non-Local Factor, Eddy Diffusion: hmm   [m^2/s]
     230        1536 :     K_hm_min_coef = 0.10000_core_rknd ! Min. of Non-Local Factor, Eddy Diffusion: hmm   [m^2/s]
     231        1536 :     gamma_coef  = 0.250000_core_rknd ! Low Skw.: gamma coef. Skw. Fnct.   [-]
     232        1536 :     gamma_coefb = 0.250000_core_rknd ! High Skw.: gamma coef. Skw. Fnct.  [-]
     233        1536 :     gamma_coefc = 5.000000_core_rknd ! Deg. Slope: gamma coef. Skw. Fnct. [-]
     234        1536 :     mu          = 1.000E-3_core_rknd ! Fract entrain rate per unit alt  [1/m]
     235        1536 :     mult_coef   = 0.500000_core_rknd ! Coef. applied to log(avg dz/thresh)[-]
     236        1536 :     taumin      = 90.00000_core_rknd ! Min. allow. value: time-scale tau  [s]
     237        1536 :     taumax      = 3600.000_core_rknd ! Max. allow. value: time-scale tau  [s]
     238        1536 :     Lscale_mu_coef   = 2.0_core_rknd ! Coef perturb mu: av calc Lscale    [-]
     239        1536 :     Lscale_pert_coef = 0.1_core_rknd ! Coef pert thlm/rtm: av calc Lscale [-]
     240        1536 :     alpha_corr = 0.15_core_rknd   ! Coef. for the corr. diagnosis algorithm  [-]
     241        1536 :     nu1   = 20.00000_core_rknd ! Bg. Coef. Eddy Diffusion: wp2        [m^2/s]
     242        1536 :     nu2   = 1.000000_core_rknd ! Bg. Coef. Eddy Diffusion: xp2        [m^2/s]
     243        1536 :     nu6   = 5.000000_core_rknd ! Bg. Coef. Eddy Diffusion: wpxp       [m^2/s]
     244        1536 :     nu8   = 20.00000_core_rknd ! Bg. Coef. Eddy Diffusion: wp3        [m^2/s]
     245        1536 :     nu9   = 10.00000_core_rknd ! Bg. Coef. Eddy Diffusion: up2/vp2    [m^2/s]
     246        1536 :     nu10  = 0.000000_core_rknd ! Bg. Coef. Eddy Diffusion: edsclrm    [m^2/s]
     247        1536 :     nu_hm = 1.500000_core_rknd ! Bg. Coef. Eddy Diffusion: hmm        [m^2/s]
     248             : 
     249             :     ! Vince Larson added a constant to set plume widths for theta_l and rt
     250             :     ! beta should vary between 0 and 3.
     251        1536 :     beta = 1.000000_core_rknd    ! Beta coefficient     [-]
     252        1536 :     lmin_coef = 0.500000_core_rknd   ! Coefficient of lmin    [-]
     253        1536 :     Skw_max_mag = 10.0_core_rknd     ! Max magnitude of skewness [-]
     254             : 
     255        1536 :     C_invrs_tau_bkgnd          = 1.1_core_rknd 
     256        1536 :     C_invrs_tau_sfc            = 0.1_core_rknd
     257        1536 :     C_invrs_tau_shear          = 0.15_core_rknd
     258        1536 :     C_invrs_tau_N2             = 0.4_core_rknd 
     259        1536 :     C_invrs_tau_N2_wp2         = 0.2_core_rknd
     260        1536 :     C_invrs_tau_N2_xp2         = 0.05_core_rknd
     261        1536 :     C_invrs_tau_N2_wpxp        = 0.0_core_rknd
     262        1536 :     C_invrs_tau_N2_clear_wp3   = 1.0_core_rknd
     263        1536 :     C_invrs_tau_wpxp_Ri        = 0.35_core_rknd
     264        1536 :     C_invrs_tau_wpxp_N2_thresh = 3.3e-4_core_rknd
     265             : 
     266             :     ! Parameters for the new PDF (w, rt, and theta-l).
     267             :     !
     268             :     ! Brian Griffin added a tunable parameter for the PDF of w,
     269             :     ! slope_coef_spread_DG_means_w, to increase or decrease the spread between
     270             :     ! the two PDF component means of w.  When the value of this slope parameter
     271             :     ! is larger, F_w is smaller and the PDF component means of w are closer
     272             :     ! together.
     273             :     ! Valid values are slope_coef_spread_DG_means_w > 0.
     274             :     !
     275             :     ! A second parameter for the PDF of w, pdf_component_stdev_factor_w, is used
     276             :     ! to adjust the standard deviations of the 1st PDF component against the 2nd
     277             :     ! PDF component for w.  This parameter is related to zeta_w, where:
     278             :     !
     279             :     ! 1 + zeta_w = ( mixt_frac * sigma_w_1^2 )
     280             :     !              / ( ( 1 - mixt_frac ) * sigma_w_2^2 );
     281             :     !
     282             :     ! The pdf_component_stdev_factor_w is set such that:
     283             :     !
     284             :     ! pdf_component_stdev_factor_w = zeta_w + 1.
     285             :     !
     286             :     ! Valid values are pdf_component_stdev_factor_w > 0.
     287             :     !
     288             :     ! The parameter for the PDF of rt is coef_spread_DG_means_rt.  Valid values
     289             :     ! are 0 <= coef_spread_DG_means_rt < 1.  When coef_spread_DG_means_rt
     290             :     ! approaches 0, F_rt approaches min_F_rt, and the two PDF component means
     291             :     ! become closer together.  When coef_spread_DG_means_rt approaches 1, F_rt
     292             :     ! approaches max_F_rt, and the two PDF component means are spread farther
     293             :     ! apart.
     294             :     !
     295             :     ! The parameter for the PDF of theta-l is coef_spread_DG_means_thl.
     296             :     ! Valid values are 0 <= coef_spread_DG_means_thl < 1.  When
     297             :     ! coef_spread_DG_means_thl approaches 0, F_thl approaches min_F_thl, and the
     298             :     ! two PDF component means become closer together.  When
     299             :     ! coef_spread_DG_means_thl approaches 1, F_thl approaches max_F_thl, and the
     300             :     ! two PDF component means are spread farther apart.
     301             :     ! Slope coefficient for the spread between the PDF component means of w.
     302        1536 :     slope_coef_spread_DG_means_w = 21.0_core_rknd
     303             :     ! Parameter to adjust the PDF component standard deviations of w.
     304        1536 :     pdf_component_stdev_factor_w = 1.0_core_rknd
     305             :     ! Coefficient for the spread between the PDF component means of rt.
     306        1536 :     coef_spread_DG_means_rt = 0.8_core_rknd
     307             :     ! Coefficient for the spread between the PDF component means of thl.
     308        1536 :     coef_spread_DG_means_thl = 0.8_core_rknd
     309             : 
     310             :     ! Parameters for the hydrometeor portion of the PDF.
     311             :     !
     312             :     ! Brian Griffin added a parameter for hydrometeors, omicron, to increase the
     313             :     ! standard deviation of each component and decrease the spread between the
     314             :     ! component means as the value of omicron inreases.  Valid value are
     315             :     ! 0 < omicron <= 1.
     316             :     ! A second parameter for hydrometeors, zeta, increases the standard
     317             :     ! deviation of component 1 at the expense of the standard deviation of
     318             :     ! component 2 when the value of zeta > 0 (and increasingly so as zeta
     319             :     ! increases).  Valid values are zeta > -1.
     320        1536 :     omicron        = 0.5_core_rknd ! Hydromet width/spread-of-means param [-]
     321        1536 :     zeta_vrnce_rat = 0.0_core_rknd ! Ratio sigma^2/mu^2 comp. 1 / comp. 2 [-]
     322             :     ! ratio mixt_frac*precip_frac_1/precip_frac (precip_frac_calc_type=2)    [-]
     323        1536 :     upsilon_precip_frac_rat = 0.55_core_rknd
     324             : 
     325             :     ! Intensity of stability correction applied to C1 and C6 [-]
     326        1536 :     lambda0_stability_coef = 0.03_core_rknd
     327             :     ! Factor to decrease sensitivity in the denominator of Skw calculation
     328        1536 :     Skw_denom_coef = 4.0_core_rknd
     329             : 
     330             :     ! Momentum coefficient of Kh_zm
     331        1536 :     c_K10 = 1.0_core_rknd
     332             :     ! Thermodynamic coefficient of Kh_zm
     333        1536 :     c_K10h = 1.0_core_rknd
     334             : 
     335        1536 :     thlp2_rad_coef = 1.0_core_rknd ! Coefficient of thlp2_rad               [-]
     336        1536 :     thlp2_rad_cloud_frac_thresh = 0.1_core_rknd ! Minimum cloud fraction for
     337             :                                                 ! computation of thlp2_rad  [-]
     338             : 
     339        1536 :     up2_sfc_coef = 4.0_core_rknd ! Coefficients of up2 and vp2    [-]
     340             : 
     341        1536 :     xp3_coef_base  = 0.25_core_rknd ! "Base" value of xp3_coef in simple eqn
     342        1536 :     xp3_coef_slope = 0.01_core_rknd ! Slope in regards to Brunt-Vaisla freq.
     343             : 
     344        1536 :     altitude_threshold = 100.0_core_rknd ! Altitude above which damping should occur for wpxp
     345        1536 :     rtp2_clip_coef = 0.5_core_rknd       ! Coef. appled the clipping threshold on rtp2
     346             : 
     347        1536 :     Cx_min = 0.33_core_rknd              ! Threshold on Cx_fnc_Richardson
     348        1536 :     Cx_max = 0.95_core_rknd              ! Threshold on Cx_fnc_Richardson
     349        1536 :     Richardson_num_min = 0.25_core_rknd  ! Threshold on Richardson number
     350        1536 :     Richardson_num_max = 400.0_core_rknd ! Threshold on Richardson number
     351             : 
     352        1536 :     a3_coef_min = 1.0_core_rknd  ! Minimum threshold on the a3 coefficient
     353        1536 :     a_const = 1.8_core_rknd ! Used in sfc_varnce_module.F90 to set surface values
     354        1536 :     bv_efold = 5._core_rknd ! Control parameter for inverse e-folding of
     355             :                             ! cloud fraction in the mixed Brunt Vaisala frequency
     356        1536 :     wpxp_Ri_exp = .5_core_rknd  ! Exponent determining the influence of
     357             :                                 ! the Richardson number on invrs_tau_wpxp
     358        1536 :     z_displace = 25.0_core_rknd   ! displacement of log law profile above ground   [m]
     359        1536 :     return
     360             : 
     361             :   end subroutine set_default_parameters
     362             : 
     363             :   !=============================================================================
     364     4467528 :   subroutine setup_parameters( & 
     365     4467528 :               deltaz, clubb_params, gr, ngrdcol, grid_type, &
     366             :               l_prescribed_avg_deltaz, &
     367             :               lmin, nu_vert_res_dep, err_code_out )
     368             : 
     369             :     ! Description:
     370             :     ! Subroutine to setup model parameters
     371             : 
     372             :     ! References:
     373             :     ! None
     374             :     !-----------------------------------------------------------------------
     375             : 
     376             : 
     377             :     use constants_clubb, only: &
     378             :         three,   & ! Variable(s)
     379             :         one,     &
     380             :         zero,    &
     381             :         fstderr
     382             : 
     383             :     use grid_class, only: &
     384             :         grid    ! Type(s)
     385             : 
     386             :     use clubb_precision, only: &
     387             :         core_rknd ! Variable(s)
     388             : 
     389             :     use error_code, only: &
     390             :         err_code,                    & ! Error Indicator
     391             :         clubb_fatal_error              ! Constant
     392             : 
     393             :     use parameter_indices, only: &
     394             :         izeta_vrnce_rat
     395             : 
     396             :     implicit none
     397             : 
     398             :     ! Constant Parameters
     399             :     real( kind = core_rknd ), parameter :: &
     400             :       lmin_deltaz = 40.0_core_rknd ! Fixed value for minimum value for the length scale.
     401             : 
     402             :     ! Input Variables
     403             : 
     404             :     ! Grid definition
     405             :     type(grid), target, intent(in) :: &
     406             :       gr
     407             : 
     408             :     integer, intent(in) :: &
     409             :       ngrdcol   ! Number of grid columns          [#]
     410             :       
     411             :     real( kind = core_rknd ), dimension(ngrdcol), intent(in) ::  & 
     412             :       deltaz  ! Change per height level        [m]
     413             : 
     414             :     real( kind = core_rknd ), intent(in), dimension(ngrdcol,nparams) :: & 
     415             :       clubb_params  ! Tuneable model parameters      [-]
     416             : 
     417             :     ! If CLUBB is running on its own, this option determines
     418             :     ! if it is using:
     419             :     ! 1) an evenly-spaced grid,
     420             :     ! 2) a stretched (unevenly-spaced) grid entered on the
     421             :     !    thermodynamic grid levels (with momentum levels set
     422             :     !    halfway between thermodynamic levels), or
     423             :     ! 3) a stretched (unevenly-spaced) grid entered on the
     424             :     !    momentum grid levels (with thermodynamic levels set
     425             :     !    halfway between momentum levels).
     426             :     integer, intent(in) :: grid_type
     427             : 
     428             :     logical, intent(in) :: &
     429             :       l_prescribed_avg_deltaz ! used in adj_low_res_nu. If .true., avg_deltaz = deltaz
     430             : 
     431             :     real( kind = core_rknd ), intent(out) :: &
     432             :       lmin    ! Min. value for the length scale    [m]
     433             : 
     434             :     type(nu_vertical_res_dep), intent(out) :: &
     435             :       nu_vert_res_dep    ! Vertical resolution dependent nu values
     436             : 
     437             :     integer, intent(out) :: &
     438             :       err_code_out  ! Error code indicator
     439             : 
     440             :     integer :: k, i    ! loop variable
     441             : 
     442             :     real( kind = core_rknd ) :: & 
     443             :       C1, C1b, C1c, C2rt, C2thl, C2rtthl, & 
     444             :       C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
     445             :       C7, C7b, C7c, C8, C8b, C10, & 
     446             :       C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
     447             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & 
     448             :       C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
     449             :       c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8,  & 
     450             :       c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
     451             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
     452             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
     453             :       gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
     454             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
     455             :       lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
     456             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
     457             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
     458             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
     459             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
     460             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
     461             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
     462             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
     463             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
     464             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
     465             : 
     466             :     !-------------------- Begin code --------------------
     467             : 
     468             :     ! ### Adjust Constant Diffusivity Coefficients Based On Grid Spacing ###
     469             :     call adj_low_res_nu( gr, ngrdcol, grid_type, deltaz,  & ! Intent(in)
     470             :                          clubb_params,                    & ! Intent(in)
     471             :                          l_prescribed_avg_deltaz,         & ! Intent(in)
     472     4467528 :                          nu_vert_res_dep )                  ! Intent(out)
     473             : 
     474    74597328 :     do i = 1, ngrdcol
     475             : 
     476             :       ! Ensure all variables are greater than 0, and zeta_vrnce_rat is greater than -1
     477  7223369400 :       do k = 1, nparams
     478             : 
     479  7223369400 :         if ( k /= izeta_vrnce_rat .and. clubb_params(i,k) < zero ) then
     480             : 
     481           0 :             write(fstderr,*) params_list(k), " = ", clubb_params(i,k)
     482           0 :             write(fstderr,*) params_list(k), " must satisfy 0.0 <= ", params_list(k)
     483           0 :             err_code = clubb_fatal_error
     484             : 
     485  7153239600 :         else if ( clubb_params(i,k) < -one ) then
     486             : 
     487           0 :             write(fstderr,*) "zeta_vrnce_rat = ", zeta_vrnce_rat
     488           0 :             write(fstderr,*) "zeta_vrnce_rat must satisfy -1.0 <= zeta_vrnce_rat"
     489           0 :             err_code = clubb_fatal_error
     490             : 
     491             :         end if
     492             : 
     493             :       end do
     494             : 
     495             :       call unpack_parameters & 
     496    70129800 :               ( clubb_params(i,:), & ! intent(in)
     497             :                 C1, C1b, C1c, C2rt, C2thl, C2rtthl, & ! intent(out)
     498             :                 C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & ! intent(out)
     499             :                 C7, C7b, C7c, C8, C8b, C10, & ! intent(out)
     500             :                 C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, & ! intent(out)
     501             :                 C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & ! intent(out)
     502             :                 C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, & ! intent(out)
     503             :                 c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, & ! intent(out)
     504             :                 c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, & ! intent(out)
     505             :                 slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, & ! intent(out)
     506             :                 coef_spread_DG_means_rt, coef_spread_DG_means_thl, & ! intent(out)
     507             :                 gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, & ! intent(out)
     508             :                 omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, & ! intent(out)
     509             :                 lambda0_stability_coef, mult_coef, taumin, taumax, & ! intent(out)
     510             :                 Lscale_mu_coef, Lscale_pert_coef, alpha_corr, & ! intent(out)
     511             :                 Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, & ! intent(out)
     512             :                 thlp2_rad_cloud_frac_thresh, up2_sfc_coef, & ! intent(out)
     513             :                 Skw_max_mag, xp3_coef_base, xp3_coef_slope, & ! intent(out)
     514             :                 altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, & ! intent(out)
     515             :                 C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, & ! intent(out)
     516             :                 C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, & ! intent(out)
     517             :                 C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & ! intent(out)
     518             :                 C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & ! intent(out)
     519             :                 Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, & ! intent(out)
     520  7293499200 :                 wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace ) ! intent(out)
     521             : 
     522             : 
     523             :       ! It was decided after some experimentation, that the best
     524             :       ! way to produce grid independent results is to set lmin to be
     525             :       ! some fixed value. -dschanen 21 May 2007
     526             :       !lmin = lmin_coef * deltaz  ! Old
     527    70129800 :       lmin = lmin_coef * lmin_deltaz ! New fixed value
     528             : 
     529    70129800 :       if ( beta < zero .or. beta > three ) then
     530             : 
     531             :         ! Constraints on beta
     532           0 :         write(fstderr,*) "beta = ", beta
     533           0 :         write(fstderr,*) "beta cannot be < 0 or > 3"
     534           0 :         err_code = clubb_fatal_error
     535             : 
     536             :       endif ! beta < 0 or beta > 3
     537             : 
     538    70129800 :       if ( slope_coef_spread_DG_means_w <= zero ) then
     539             : 
     540             :         ! Constraint on slope_coef_spread_DG_means_w
     541           0 :         write(fstderr,*) "slope_coef_spread_DG_means_w = ", &
     542           0 :                           slope_coef_spread_DG_means_w
     543           0 :         write(fstderr,*) "slope_coef_spread_DG_means_w cannot be <= 0"
     544           0 :         err_code = clubb_fatal_error
     545             : 
     546             :       endif ! slope_coef_spread_DG_means_w <= 0
     547             : 
     548    70129800 :       if ( pdf_component_stdev_factor_w <= zero ) then
     549             : 
     550             :         ! Constraint on pdf_component_stdev_factor_w
     551           0 :         write(fstderr,*) "pdf_component_stdev_factor_w = ", &
     552           0 :                           pdf_component_stdev_factor_w
     553           0 :         write(fstderr,*) "pdf_component_stdev_factor_w cannot be <= 0"
     554           0 :         err_code = clubb_fatal_error
     555             : 
     556             :       endif ! pdf_component_stdev_factor_w <= 0
     557             : 
     558             :       if ( coef_spread_DG_means_rt < zero &
     559    70129800 :           .or. coef_spread_DG_means_rt >= one ) then
     560             : 
     561             :         ! Constraint on coef_spread_DG_means_rt
     562           0 :         write(fstderr,*) "coef_spread_DG_means_rt = ", coef_spread_DG_means_rt
     563           0 :         write(fstderr,*) "coef_spread_DG_means_rt cannot be < 0 or >= 1"
     564           0 :         err_code = clubb_fatal_error
     565             : 
     566             :       endif ! coef_spread_DG_means_rt < 0 or coef_spread_DG_means_rt >= 1
     567             : 
     568             :       if ( coef_spread_DG_means_thl < zero &
     569    70129800 :           .or. coef_spread_DG_means_thl >= one ) then
     570             : 
     571             :         ! Constraint on coef_spread_DG_means_thl
     572           0 :         write(fstderr,*) "coef_spread_DG_means_thl = ", coef_spread_DG_means_thl
     573           0 :         write(fstderr,*) "coef_spread_DG_means_thl cannot be < 0 or >= 1"
     574           0 :         err_code = clubb_fatal_error
     575             : 
     576             :       endif ! coef_spread_DG_means_thl < 0 or coef_spread_DG_means_thl >= 1
     577             : 
     578    70129800 :       if ( omicron <= zero .or. omicron > one ) then
     579             : 
     580             :         ! Constraints on omicron
     581           0 :         write(fstderr,*) "omicron = ", omicron
     582           0 :         write(fstderr,*) "omicron cannot be <= 0 or > 1"
     583           0 :         err_code = clubb_fatal_error
     584             : 
     585             :       endif ! omicron <= 0 or omicron > 1
     586             : 
     587    70129800 :       if ( zeta_vrnce_rat <= -one ) then
     588             : 
     589             :         ! Constraints on zeta_vrnce_rat
     590           0 :         write(fstderr,*) "zeta_vrnce_rat = ", zeta_vrnce_rat
     591           0 :         write(fstderr,*) "zeta_vrnce_rat cannot be <= -1"
     592           0 :         err_code = clubb_fatal_error
     593             : 
     594             :       endif ! zeta_vrnce_rat <= -1
     595             : 
     596             :       if ( upsilon_precip_frac_rat < zero &
     597    70129800 :           .or. upsilon_precip_frac_rat > one ) then
     598             : 
     599             :         ! Constraints on upsilon_precip_frac_rat
     600           0 :         write(fstderr,*) "upsilon_precip_frac_rat = ", upsilon_precip_frac_rat
     601           0 :         write(fstderr,*) "upsilon_precip_frac_rat cannot be < 0 or > 1"
     602           0 :         err_code = clubb_fatal_error
     603             : 
     604             :       endif ! upsilon_precip_frac_rat < 0 or upsilon_precip_frac_rat > 1
     605             : 
     606    70129800 :       if ( mu < zero ) then
     607             : 
     608             :         ! Constraints on entrainment rate, mu.
     609           0 :         write(fstderr,*) "mu = ", mu
     610           0 :         write(fstderr,*) "mu cannot be < 0"
     611           0 :         err_code = clubb_fatal_error
     612             : 
     613             :       endif ! mu < 0.0
     614             : 
     615    70129800 :       if ( lmin < 1.0_core_rknd ) then
     616             : 
     617             :         ! Constraints on mixing length
     618           0 :         write(fstderr,*) "lmin = ", lmin
     619           0 :         write(fstderr,*) "lmin is < 1.0_core_rknd"
     620           0 :         err_code = clubb_fatal_error
     621             : 
     622             :       endif ! lmin < 1.0
     623             : 
     624             :       ! The C6rt parameters must be set equal to the C6thl parameters.
     625             :       ! Otherwise, the wpthlp pr1 term will be calculated inconsistently.
     626             : 
     627    70129800 :       if ( abs(C6rt - C6thl) > abs(C6rt + C6thl) / 2 * eps ) then
     628           0 :           write(fstderr,*) "C6rt = ", C6rt
     629           0 :           write(fstderr,*) "C6thl = ", C6thl
     630           0 :           write(fstderr,*) "C6rt and C6thl must be equal."
     631           0 :           err_code = clubb_fatal_error
     632             :       endif ! C6rt /= C6thl
     633             : 
     634    70129800 :       if ( abs(C6rtb - C6thlb) > abs(C6rtb + C6thlb) / 2 * eps ) then
     635           0 :           write(fstderr,*) "C6rtb = ", C6rtb
     636           0 :           write(fstderr,*) "C6thlb = ", C6thlb
     637           0 :           write(fstderr,*) "C6rtb and C6thlb must be equal."
     638           0 :           err_code = clubb_fatal_error
     639             :       endif ! C6rtb /= C6thlb
     640             : 
     641    70129800 :       if ( abs(C6rtc - C6thlc) > abs(C6rtc + C6thlc) / 2 * eps ) then
     642           0 :           write(fstderr,*) "C6rtc = ", C6rtc
     643           0 :           write(fstderr,*) "C6thlc = ", C6thlc
     644           0 :           write(fstderr,*) "C6rtc and C6thlc must be equal."
     645           0 :           err_code = clubb_fatal_error
     646             :       endif ! C6rtc /= C6thlc
     647             : 
     648    70129800 :       if ( abs(C6rt_Lscale0 - C6thl_Lscale0) > abs(C6rt_Lscale0 + C6thl_Lscale0) / 2 * eps ) then
     649           0 :           write(fstderr,*) "C6rt_Lscale0 = ", C6rt_Lscale0
     650           0 :           write(fstderr,*) "C6thl_Lscale0 = ", C6thl_Lscale0
     651           0 :           write(fstderr,*) "C6rt_Lscale0 and C6thl_Lscale0 must be equal."
     652           0 :           err_code = clubb_fatal_error
     653             :       endif ! C6rt_Lscale0 /= C6thl_Lscale0
     654             : 
     655             : 
     656             : 
     657             : 
     658    70129800 :       if ( C1 < zero ) then
     659           0 :           write(fstderr,*) "C1 = ", C1
     660           0 :           write(fstderr,*) "C1 must satisfy 0.0 <= C1"
     661           0 :           err_code = clubb_fatal_error
     662             :       end if
     663             : 
     664    70129800 :       if ( C7 > one .or. C7 < zero ) then
     665           0 :           write(fstderr,*) "C7 = ", C7
     666           0 :           write(fstderr,*) "C7 must satisfy 0.0 <= C7 <= 1.0"
     667           0 :           err_code = clubb_fatal_error
     668             :       end if
     669             : 
     670    70129800 :       if ( C7b > one .or. C7b < zero ) then
     671           0 :           write(fstderr,*) "C7b = ", C7b
     672           0 :           write(fstderr,*) "C7b must satisfy 0.0 <= C7b <= 1.0"
     673           0 :           err_code = clubb_fatal_error
     674             :       end if
     675             : 
     676    70129800 :       if ( C11 > one .or. C11 < zero ) then
     677           0 :           write(fstderr,*) "C11 = ", C11
     678           0 :           write(fstderr,*) "C11 must satisfy 0.0 <= C11 <= 1.0"
     679           0 :           err_code = clubb_fatal_error
     680             :       end if
     681             : 
     682    70129800 :       if ( C11b > one .or. C11b < zero ) then
     683           0 :           write(fstderr,*) "C11b = ", C11b
     684           0 :           write(fstderr,*) "C11b must satisfy 0.0 <= C11b <= 1.0"
     685           0 :           err_code = clubb_fatal_error
     686             :       end if
     687             : 
     688    74597328 :       if ( C_wp2_splat < zero ) then
     689           0 :           write(fstderr,*) "C_wp2_splat = ", C_wp2_splat
     690           0 :           write(fstderr,*) "C_wp2_splat must satisfy C_wp2_splat >= 0"
     691           0 :           err_code = clubb_fatal_error
     692             :       end if
     693             : 
     694             :     end do
     695             :     
     696     4467528 :     err_code_out = err_code
     697             : 
     698     4467528 :     return
     699             : 
     700             :   end subroutine setup_parameters
     701             : 
     702             :   !=============================================================================
     703     4467528 :   subroutine adj_low_res_nu( gr, ngrdcol, grid_type, deltaz, & ! Intent(in)
     704     4467528 :                              clubb_params,                   & ! Intent(in)
     705             :                              l_prescribed_avg_deltaz,        & ! Intent(in)
     706             :                              nu_vert_res_dep )                 ! Intent(out)
     707             : 
     708             :     ! Description:
     709             :     !   Adjust the values of background eddy diffusivity based on
     710             :     !   vertical grid spacing.
     711             :     !   This code was made into a public subroutine so that it may be
     712             :     !   called multiple times per model run in scenarios where grid
     713             :     !   altitudes, and hence average grid spacing, change through space
     714             :     !   and/or time.  This occurs, for example, when CLUBB is
     715             :     !   implemented in WRF.  --ldgrant Jul 2010
     716             :     !----------------------------------------------------------------------
     717             : 
     718             :     use constants_clubb, only: &
     719             :         fstderr ! Constant(s)
     720             : 
     721             :     use grid_class, only: &
     722             :         grid    ! Type(s)
     723             : 
     724             :     use clubb_precision, only: &
     725             :         core_rknd ! Variable(s)
     726             : 
     727             :     use parameter_indices, only: & 
     728             :       imult_coef, &
     729             :       inu1, &
     730             :       inu2, &
     731             :       inu6, &
     732             :       inu8, &
     733             :       inu9, &
     734             :       inu10, &
     735             :       inu_hm
     736             : 
     737             :     implicit none
     738             : 
     739             :     ! Flag for adjusting the values of the constant background eddy diffusivity
     740             :     ! coefficients based on the average vertical grid spacing.  If this flag is
     741             :     ! turned off, the values of the various nu coefficients will remain as they
     742             :     ! are declared in the tunable_parameters.in file.
     743             :     logical, parameter :: l_adj_low_res_nu = .true.
     744             : 
     745             :     ! The size of the average vertical grid spacing that serves as a threshold
     746             :     ! for when to increase the size of the background eddy diffusivity
     747             :     ! coefficients (nus) by a certain factor above what the background
     748             :     ! coefficients are specified to be in tunable_parameters.in.  At any average
     749             :     ! grid spacing at or below this value, the values of the background
     750             :     ! diffusivities remain the same.  However, at any average vertical grid
     751             :     ! spacing above this value, the values of the background eddy diffusivities
     752             :     ! are increased.  Traditionally, the threshold grid spacing has been set to
     753             :     ! 40.0 meters.  This is only relevant if l_adj_low_res_nu is turned on.
     754             :     real( kind = core_rknd ), parameter :: &
     755             :       grid_spacing_thresh = 40.0_core_rknd  ! grid spacing threshold  [m]
     756             : 
     757             :     ! Input Variables
     758             : 
     759             :     ! Grid definition
     760             :     type(grid), target, intent(in) :: &
     761             :       gr
     762             : 
     763             :     integer, intent(in) :: &
     764             :       ngrdcol
     765             : 
     766             :     ! If CLUBB is running on it's own, this option determines
     767             :     ! if it is using:
     768             :     ! 1) an evenly-spaced grid,
     769             :     ! 2) a stretched (unevenly-spaced) grid entered on the
     770             :     !    thermodynamic grid levels (with momentum levels set
     771             :     !    halfway between thermodynamic levels), or
     772             :     ! 3) a stretched (unevenly-spaced) grid entered on the
     773             :     !    momentum grid levels (with thermodynamic levels set
     774             :     !    halfway between momentum levels).
     775             :     integer, intent(in) :: grid_type
     776             : 
     777             :     real( kind = core_rknd ), dimension(ngrdcol), intent(in) ::  & 
     778             :       deltaz  ! Change per height level        [m]
     779             : 
     780             :     logical, intent(in) :: &
     781             :       l_prescribed_avg_deltaz ! used in adj_low_res_nu. If .true., avg_deltaz = deltaz
     782             : 
     783             :     real( kind = core_rknd ), intent(in), dimension(ngrdcol,nparams) :: & 
     784             :       clubb_params  ! Tuneable model parameters      [-]
     785             : 
     786             :     ! Output Variables
     787             :     type(nu_vertical_res_dep), intent(out) :: &
     788             :       nu_vert_res_dep    ! Vertical resolution dependent nu values
     789             : 
     790             :     ! Local Variables
     791             : 
     792             :     real( kind = core_rknd ) :: &
     793             :       mult_coef, & ! CLUBB tunable parameter mult_coef
     794             :       nu1,       & ! CLUBB tunable parameter nu1
     795             :       nu2,       & ! CLUBB tunable parameter nu2
     796             :       nu6,       & ! CLUBB tunable parameter nu6
     797             :       nu8,       & ! CLUBB tunable parameter nu8
     798             :       nu9,       & ! CLUBB tunable parameter nu9
     799             :       nu10,      & ! CLUBB tunable parameter nu10
     800             :       nu_hm        ! CLUBB tunable parameter nu_hm
     801             : 
     802             :     real( kind = core_rknd ) :: avg_deltaz  ! Average grid box height   [m]
     803             : 
     804             :     ! The factor by which to multiply the coefficients of background eddy
     805             :     ! diffusivity if the grid spacing threshold is exceeded and l_adj_low_res_nu
     806             :     ! is turned on.
     807             :     real( kind = core_rknd ) :: &
     808             :       mult_factor_zt, &  ! Uses gr%dzt(1,:) for nu values on zt levels
     809             :       mult_factor_zm     ! Uses gr%dzm(1,:) for nu values on zm levels
     810             : 
     811             :     integer :: i
     812             : 
     813             :     !--------------- Begin code -------------------------
     814             :     
     815           0 :     allocate( nu_vert_res_dep%nu1(1:ngrdcol), &
     816           0 :               nu_vert_res_dep%nu2(1:ngrdcol), &
     817           0 :               nu_vert_res_dep%nu6(1:ngrdcol), &
     818           0 :               nu_vert_res_dep%nu8(1:ngrdcol), &
     819           0 :               nu_vert_res_dep%nu9(1:ngrdcol), &
     820           0 :               nu_vert_res_dep%nu10(1:ngrdcol), &
     821    44675280 :               nu_vert_res_dep%nu_hm(1:ngrdcol) )
     822             :               
     823    74597328 :     do i = 1, ngrdcol
     824             : 
     825    70129800 :       mult_coef = clubb_params(i,imult_coef)
     826    70129800 :       nu1       = clubb_params(i,inu1)
     827    70129800 :       nu2       = clubb_params(i,inu2)
     828    70129800 :       nu6       = clubb_params(i,inu6)
     829    70129800 :       nu8       = clubb_params(i,inu8)
     830    70129800 :       nu9       = clubb_params(i,inu9)
     831    70129800 :       nu10      = clubb_params(i,inu10)
     832    70129800 :       nu_hm     = clubb_params(i,inu_hm)
     833             : 
     834             :       ! Flag for adjusting the values of the constant diffusivity coefficients
     835             :       ! based on the grid spacing.  If this flag is turned off, the values of the
     836             :       ! various nu coefficients will remain as they are declared in the
     837             :       ! parameters.in file.
     838     4467528 :       if ( l_adj_low_res_nu ) then
     839             : 
     840             :         ! ### Adjust Constant Diffusivity Coefficients Based On Grid Spacing ###
     841             : 
     842             :         ! All of the background coefficients of eddy diffusivity, as well as the
     843             :         ! constant coefficient for 4th-order hyper-diffusion, must be adjusted
     844             :         ! based on the size of the grid spacing.  For a case that uses an
     845             :         ! evenly-spaced grid, the adjustment is based on the constant grid
     846             :         ! spacing deltaz.  For a case that uses a stretched grid, the adjustment
     847             :         ! is based on avg_deltaz, which is the average grid spacing over the
     848             :         ! vertical domain.
     849             :    
     850    70129800 :         if ( l_prescribed_avg_deltaz ) then
     851             :           
     852           0 :           avg_deltaz = deltaz(i)
     853             : 
     854    70129800 :         else if ( grid_type == 3 ) then
     855             : 
     856             :           ! CLUBB is implemented in a host model, or is using grid_type = 3
     857             : 
     858             :           ! Find the average deltaz over the grid based on momentum level
     859             :           ! inputs.
     860    70129800 :           avg_deltaz = ( gr%zm(i,gr%nz) - gr%zm(i,1) )  &
     861   140259600 :                        / real( gr%nz - 1, kind = core_rknd )
     862             : 
     863           0 :         else if ( grid_type == 1 ) then
     864             : 
     865             :           ! Evenly-spaced grid.
     866             : 
     867           0 :           avg_deltaz = deltaz(i)
     868             : 
     869           0 :         else if ( grid_type == 2 ) then
     870             : 
     871             :           ! Stretched (unevenly-spaced) grid:  stretched thermodynamic level
     872             :           ! input.
     873             : 
     874             :           ! Find the average deltaz over the stretched grid based on
     875             :           ! thermodynamic level inputs.
     876           0 :           avg_deltaz = ( gr%zt(i,gr%nz) - gr%zt(i,1) ) &
     877           0 :                        / real( gr%nz - 1, kind = core_rknd )
     878             : 
     879             :         else
     880             : 
     881             :           ! Eric Raut added to remove compiler warning. (Obviously, this value is not used)
     882           0 :           avg_deltaz = 0.0_core_rknd
     883           0 :           write(fstderr,*) "Invalid grid_type:", grid_type
     884           0 :           error stop "Fatal error"
     885             : 
     886             :         end if ! grid_type
     887             : 
     888             :         ! The nu's are chosen for deltaz <= 40 m. Looks like they must
     889             :         ! be adjusted for larger grid spacings (Vince Larson)
     890             : 
     891             :         ! Use a constant mult_factor so nu does not depend on grid spacing
     892    70129800 :         if( avg_deltaz > grid_spacing_thresh ) then
     893    70129800 :           mult_factor_zt = 1.0_core_rknd + mult_coef * log( avg_deltaz / grid_spacing_thresh )
     894    70129800 :           mult_factor_zm = mult_factor_zt
     895             :         else
     896             :           mult_factor_zt = 1.0_core_rknd
     897             :           mult_factor_zm = 1.0_core_rknd
     898             :         end if
     899             : 
     900             :         !mult_factor = 1.0_core_rknd + mult_coef * log( avg_deltaz / grid_spacing_thresh )
     901    70129800 :         nu_vert_res_dep%nu1(i)   =  nu1 * mult_factor_zm
     902    70129800 :         nu_vert_res_dep%nu2(i)   =  nu2 * mult_factor_zm
     903    70129800 :         nu_vert_res_dep%nu6(i)   =  nu6 * mult_factor_zm
     904    70129800 :         nu_vert_res_dep%nu8(i)   =  nu8 * mult_factor_zt
     905    70129800 :         nu_vert_res_dep%nu9(i)   =  nu9 * mult_factor_zm
     906    70129800 :         nu_vert_res_dep%nu10(i)  =  nu10 * mult_factor_zt !We're unsure of the grid
     907    70129800 :         nu_vert_res_dep%nu_hm(i) =  nu_hm * mult_factor_zt
     908             : 
     909             :       else ! nu values are not adjusted
     910             : 
     911             :         nu_vert_res_dep%nu1(i)   =  nu1
     912             :         nu_vert_res_dep%nu2(i)   =  nu2
     913             :         nu_vert_res_dep%nu6(i)   =  nu6
     914             :         nu_vert_res_dep%nu8(i)   =  nu8
     915             :         nu_vert_res_dep%nu9(i)   =  nu9
     916             :         nu_vert_res_dep%nu10(i)  =  nu10
     917             :         nu_vert_res_dep%nu_hm(i) =  nu_hm
     918             : 
     919             :       end if  ! l_adj_low_res_nu
     920             :       
     921             :     end do
     922             : 
     923     4467528 :     return
     924             :   end subroutine adj_low_res_nu
     925             : 
     926             :   !=============================================================================
     927        1536 :   subroutine read_parameters( ngrdcol, iunit, filename, &
     928             :                               C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
     929             :                               C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
     930             :                               C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
     931             :                               C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
     932             :                               C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
     933             :                               C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
     934             :                               c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
     935             :                               c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
     936             :                               slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
     937             :                               coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
     938             :                               gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
     939             :                               omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
     940             :                               lambda0_stability_coef, mult_coef, taumin, taumax, &
     941             :                               Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
     942             :                               Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
     943             :                               thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
     944             :                               Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
     945             :                               altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
     946             :                               C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, & 
     947             :                               C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
     948             :                               C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
     949             :                               C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
     950             :                               Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
     951             :                               wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace, &
     952        1536 :                               clubb_params )
     953             : 
     954             :     ! Description:
     955             :     ! Read a namelist containing the model parameters
     956             : 
     957             :     ! References:
     958             :     ! None
     959             :     !-----------------------------------------------------------------------
     960             : !    use constants_clubb, only: fstderr ! Constant
     961             : 
     962             :     implicit none
     963             : 
     964             :     ! Input variables
     965             :     integer, intent(in) :: &
     966             :       ngrdcol, &
     967             :       iunit
     968             : 
     969             :     character(len=*), intent(in) :: filename
     970             : 
     971             :     ! Input/Output variables
     972             :     real( kind = core_rknd ), intent(inout) :: & 
     973             :       C1, C1b, C1c, C2rt, C2thl, C2rtthl, & 
     974             :       C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
     975             :       C7, C7b, C7c, C8, C8b, C10, & 
     976             :       C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
     977             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & 
     978             :       C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
     979             :       c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8,  & 
     980             :       c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
     981             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
     982             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
     983             :       gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
     984             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
     985             :       lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
     986             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
     987             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
     988             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
     989             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
     990             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
     991             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
     992             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
     993             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
     994             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
     995             : 
     996             :     ! Output variables
     997             :     real( kind = core_rknd ), intent(out), dimension(ngrdcol,nparams) :: &
     998             :       clubb_params
     999             : 
    1000             :     ! Local variables
    1001             : !    integer :: i
    1002             : 
    1003             : !    logical :: l_error
    1004             : 
    1005             :     ! Since we lack a devious way to do this just once, this namelist
    1006             :     ! must be changed as well when a new parameter is added.
    1007             :     namelist /clubb_params_nl/  & 
    1008             :       C1, C1b, C1c, & 
    1009             :       C2rt, C2thl, C2rtthl, C4, C_uu_shr, C_uu_buoy, & 
    1010             :       C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
    1011             :       C7, C7b, C7c, C8, C8b, C10, C11, C11b, C11c, & 
    1012             :       C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    1013             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & 
    1014             :       C6rt_Lscale0, C6thl_Lscale0, &
    1015             :       C7_Lscale0, wpxp_L_thresh, c_K, c_K1, nu1, c_K2, nu2, & 
    1016             :       c_K6, nu6, c_K8, nu8, c_K9, nu9, nu10, &
    1017             :       c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    1018             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    1019             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    1020             :       beta, gamma_coef, gamma_coefb, gamma_coefc, lmin_coef, &
    1021             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    1022             :       lambda0_stability_coef, mult_coef, taumin, taumax, mu, Lscale_mu_coef, &
    1023             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
    1024             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    1025             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
    1026             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
    1027             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
    1028             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    1029             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    1030             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    1031             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
    1032             : 
    1033             :     ! ---- Begin Code ----
    1034             : 
    1035             :     ! If the filename is empty, assume we're using a `working' set of
    1036             :     ! parameters that are set statically here (handy for host models).
    1037             :     ! Read the namelist
    1038        1536 :     if ( filename /= "" ) then
    1039             :       ! Read the namelist
    1040           0 :       open(unit=iunit, file=filename, status='old', action='read')
    1041             : 
    1042           0 :       read(unit=iunit, nml=clubb_params_nl)
    1043             : 
    1044           0 :       close(unit=iunit)
    1045             : 
    1046             :     end if
    1047             : 
    1048             :     ! Put the variables in the output array
    1049             :     call pack_parameters( ngrdcol, &
    1050             :                C1, C1b, C1c, C2rt, C2thl, C2rtthl, & ! intent(in)
    1051             :                C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & ! intent(in)
    1052             :                C7, C7b, C7c, C8, C8b, C10, & ! intent(in)
    1053             :                C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, & ! intent(in)
    1054             :                C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & ! intent(in)
    1055             :                C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, & ! intent(in)
    1056             :                c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, & ! intent(in)
    1057             :                c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, & ! intent(in)
    1058             :                slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, & ! intent(in)
    1059             :                coef_spread_DG_means_rt, coef_spread_DG_means_thl, & ! intent(in)
    1060             :                gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, & ! intent(in)
    1061             :                omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, & ! intent(in)
    1062             :                lambda0_stability_coef, mult_coef, taumin, taumax, & ! intent(in)
    1063             :                Lscale_mu_coef, Lscale_pert_coef, alpha_corr, & ! intent(in)
    1064             :                Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, & ! intent(in)
    1065             :                thlp2_rad_cloud_frac_thresh, up2_sfc_coef, & ! intent(in)
    1066             :                Skw_max_mag, xp3_coef_base, xp3_coef_slope, & ! intent(in)
    1067             :                altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, & ! intent(in)
    1068             :                C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, & ! intent(in)
    1069             :                C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &   ! intent(in)
    1070             :                C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, & ! intent(in)
    1071             :                C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, & ! intent(in)
    1072             :                Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, & ! intent(in)
    1073             :                wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace, & ! intent(in)
    1074        1536 :                clubb_params ) ! intent(out)
    1075             : 
    1076             : !    l_error = .false.
    1077             : 
    1078             : !    This error check is currently broken since we are not initializing the
    1079             : !    parameters to -999 ( = init_value).
    1080             : !    do i = 1, nparams
    1081             : !      if ( abs(clubb_params(i)-init_value) < abs(clubb_params(i)+init_value) / 2 * eps) then
    1082             : !        write(fstderr,*) "Tuning parameter "//trim( params_list(i) )// &
    1083             : !          " was missing from "//trim( filename )
    1084             : !        l_error = .true.
    1085             : !      end if
    1086             : !    end do
    1087             : 
    1088             : !    if ( l_error ) error stop "Fatal error."
    1089             : 
    1090        1536 :     return
    1091             : 
    1092             :   end subroutine read_parameters
    1093             : 
    1094             :   !=============================================================================
    1095           0 :   subroutine read_param_minmax & 
    1096             :            ( iunit, filename, nindex, params_minmax, ndim )
    1097             : 
    1098             :     ! Description:
    1099             :     ! Read a namelist containing the amount to vary model parameters.
    1100             :     ! Used by the downhill simplex / simulated annealing algorithm.
    1101             : 
    1102             :     ! References:
    1103             :     ! None
    1104             :     !-----------------------------------------------------------------------
    1105             :     use constants_clubb, only: fstderr ! Constant
    1106             : 
    1107             :     use clubb_precision, only: &
    1108             :         core_rknd ! Variable(s)
    1109             : 
    1110             :    use parameter_indices, only: &
    1111             :         iC1,  & ! Variable(s)
    1112             :         iC1b, &
    1113             :         iC1c, &
    1114             :         iC2rt, &
    1115             :         iC2thl, &
    1116             :         iC2rtthl, &
    1117             :         iC4, &
    1118             :         iC_uu_shr, &
    1119             :         iC_uu_buoy, &
    1120             :         iC6rt, &
    1121             :         iC6rtb, &
    1122             :         iC6rtc, &
    1123             :         iC6thl, &
    1124             :         iC6thlb, &
    1125             :         iC6thlc, &
    1126             :         iC7, &
    1127             :         iC7b, &
    1128             :         iC7c, &
    1129             :         iC8, &
    1130             :         iC8b, &
    1131             :         iC10, &
    1132             :         iC11, &
    1133             :         iC11b, &
    1134             :         iC11c, &
    1135             :         iC12, &
    1136             :         iC13, &
    1137             :         iC14, &
    1138             :         iC_wp2_pr_dfsn, &
    1139             :         iC_wp3_pr_tp, &
    1140             :         iC_wp3_pr_turb, &
    1141             :         iC_wp3_pr_dfsn, &
    1142             :         iC_wp2_splat
    1143             : 
    1144             :     use parameter_indices, only: &
    1145             :         iC6rt_Lscale0, &
    1146             :         iC6thl_Lscale0, &
    1147             :         iC7_Lscale0, &
    1148             :         iwpxp_L_thresh
    1149             : 
    1150             :     use parameter_indices, only: &
    1151             :         ic_K,  &
    1152             :         ic_K1, &
    1153             :         inu1, &
    1154             :         ic_K2, &
    1155             :         inu2, &
    1156             :         ic_K6, &
    1157             :         inu6, &
    1158             :         ic_K8, &
    1159             :         inu8, &
    1160             :         ic_K9, &
    1161             :         inu9, &
    1162             :         inu10, &
    1163             :         ic_K_hm, &
    1164             :         ic_K_hmb, &
    1165             :         iK_hm_min_coef, &
    1166             :         inu_hm, &
    1167             :         islope_coef_spread_DG_means_w, &
    1168             :         ipdf_component_stdev_factor_w, &
    1169             :         icoef_spread_DG_means_rt, &
    1170             :         icoef_spread_DG_means_thl, &
    1171             :         igamma_coef, &
    1172             :         igamma_coefb, &
    1173             :         igamma_coefc, &
    1174             :         imu, &
    1175             :         ibeta, &
    1176             :         ilmin_coef, &
    1177             :         iomicron, &
    1178             :         izeta_vrnce_rat, &
    1179             :         iupsilon_precip_frac_rat, &
    1180             :         ilambda0_stability_coef, &
    1181             :         imult_coef, &
    1182             :         itaumin, &
    1183             :         itaumax, &
    1184             :         iLscale_mu_coef, &
    1185             :         iLscale_pert_coef, &
    1186             :         ialpha_corr, &
    1187             :         iSkw_denom_coef, &
    1188             :         ic_K10, &
    1189             :         ic_K10h, &
    1190             :         ithlp2_rad_coef, &
    1191             :         ithlp2_rad_cloud_frac_thresh, &
    1192             :         iup2_sfc_coef, &
    1193             :         iSkw_max_mag, &
    1194             :         ixp3_coef_base, &
    1195             :         ixp3_coef_slope, &
    1196             :         ialtitude_threshold, &
    1197             :         irtp2_clip_coef, &
    1198             :         iC_invrs_tau_bkgnd, &
    1199             :         iC_invrs_tau_sfc, &
    1200             :         iC_invrs_tau_shear, &
    1201             :         iC_invrs_tau_N2, &
    1202             :         iC_invrs_tau_N2_wp2, &
    1203             :         iC_invrs_tau_N2_xp2, &
    1204             :         iC_invrs_tau_N2_wpxp, &
    1205             :         iC_invrs_tau_N2_clear_wp3, &
    1206             :         iC_invrs_tau_wpxp_Ri, &
    1207             :         iC_invrs_tau_wpxp_N2_thresh, &
    1208             :         iCx_min, &
    1209             :         iCx_max, &
    1210             :         iRichardson_num_min, &
    1211             :         iRichardson_num_max, &
    1212             :         ia3_coef_min, &
    1213             :         ia_const, &
    1214             :         ibv_efold, &
    1215             :         iwpxp_Ri_exp, &
    1216             :         iz_displace
    1217             : 
    1218             :     implicit none
    1219             : 
    1220             :     ! Input variables
    1221             :     integer, intent(in) :: iunit
    1222             : 
    1223             :     character(len=*), intent(in) :: filename
    1224             : 
    1225             :     ! Output variables
    1226             : 
    1227             :     ! An array of array indices (i.e. which elements of the array `clubb_params'
    1228             :     ! are contained within the simplex and the max variable)
    1229             :     integer, intent(out), dimension(nparams) :: nindex
    1230             : 
    1231             :     real( kind = core_rknd ), intent(out), dimension(2,nparams) ::  & 
    1232             :       params_minmax  ! Amount to vary the parameter in the initial simplex
    1233             : 
    1234             :     integer, intent(out) :: &
    1235             :       ndim  ! Number of variables, e.g. rcm, to be tuned. Dimension of the init simplex
    1236             : 
    1237             :     ! Local variables
    1238             :     integer :: i
    1239             : 
    1240             :     ! Amount to change each parameter for the initial simplex
    1241             :     ! This MUST be changed to match the clubb_params_nl namelist if parameters are added.
    1242             :     real ( kind = core_rknd ), dimension(2) :: &
    1243             :       C1_minmax, C1b_minmax, C1c_minmax, C2rt_minmax, C2thl_minmax, C2rtthl_minmax, C4_minmax, &
    1244             :       C_uu_shr_minmax, C_uu_buoy_minmax, C6rt_minmax, C6rtb_minmax, C6rtc_minmax, C6thl_minmax, &
    1245             :       C6thlb_minmax, C6thlc_minmax, C7_minmax, C7b_minmax, C7c_minmax, C8_minmax, C8b_minmax, &
    1246             :       C10_minmax, C11_minmax, C11b_minmax, C11c_minmax, C12_minmax, C13_minmax, C14_minmax, &
    1247             :       C_wp2_pr_dfsn_minmax, C_wp3_pr_tp_minmax, C_wp3_pr_turb_minmax, C_wp3_pr_dfsn_minmax, &
    1248             :       C_wp2_splat_minmax, C6rt_Lscale0_minmax, C6thl_Lscale0_minmax, C7_Lscale0_minmax, &
    1249             :       wpxp_L_thresh_minmax, c_K_minmax, c_K1_minmax, nu1_minmax, c_K2_minmax, nu2_minmax, &
    1250             :       c_K6_minmax, nu6_minmax, c_K8_minmax, nu8_minmax, c_K9_minmax, nu9_minmax, nu10_minmax, &
    1251             :       c_K_hm_minmax, c_K_hmb_minmax, K_hm_min_coef_minmax, nu_hm_minmax, &
    1252             :       slope_coef_spread_DG_means_w_minmax, pdf_component_stdev_factor_w_minmax, &
    1253             :       coef_spread_DG_means_rt_minmax, coef_spread_DG_means_thl_minmax, &
    1254             :       beta_minmax, gamma_coef_minmax, gamma_coefb_minmax, gamma_coefc_minmax, lmin_coef_minmax, &
    1255             :       omicron_minmax, zeta_vrnce_rat_minmax, upsilon_precip_frac_rat_minmax, &
    1256             :       lambda0_stability_coef_minmax, mult_coef_minmax, taumin_minmax, taumax_minmax, &
    1257             :       mu_minmax, Lscale_mu_coef_minmax, Lscale_pert_coef_minmax, alpha_corr_minmax, &
    1258             :       Skw_denom_coef_minmax, c_K10_minmax, c_K10h_minmax, thlp2_rad_coef_minmax, &
    1259             :       thlp2_rad_cloud_frac_thresh_minmax, up2_sfc_coef_minmax, Skw_max_mag_minmax, &
    1260             :       xp3_coef_base_minmax, xp3_coef_slope_minmax, altitude_threshold_minmax, &
    1261             :       rtp2_clip_coef_minmax, C_invrs_tau_bkgnd_minmax, C_invrs_tau_sfc_minmax, &
    1262             :       C_invrs_tau_shear_minmax, C_invrs_tau_N2_minmax, C_invrs_tau_N2_wp2_minmax, &
    1263             :       C_invrs_tau_N2_xp2_minmax, C_invrs_tau_N2_wpxp_minmax, C_invrs_tau_N2_clear_wp3_minmax, &
    1264             :       C_invrs_tau_wpxp_Ri_minmax, C_invrs_tau_wpxp_N2_thresh_minmax, Cx_min_minmax, &
    1265             :       Cx_max_minmax, Richardson_num_min_minmax, Richardson_num_max_minmax, &
    1266             :       wpxp_Ri_exp_minmax, a3_coef_min_minmax, a_const_minmax, bv_efold_minmax, &
    1267             :       z_displace_minmax
    1268             : 
    1269             :     namelist /init_minmax/  & 
    1270             :       C1_minmax, C1b_minmax, C1c_minmax, C2rt_minmax, C2thl_minmax, C2rtthl_minmax, C4_minmax, &
    1271             :       C_uu_shr_minmax, C_uu_buoy_minmax, C6rt_minmax, C6rtb_minmax, C6rtc_minmax, C6thl_minmax, &
    1272             :       C6thlb_minmax, C6thlc_minmax, C7_minmax, C7b_minmax, C7c_minmax, C8_minmax, C8b_minmax, &
    1273             :       C10_minmax, C11_minmax, C11b_minmax, C11c_minmax, C12_minmax, C13_minmax, C14_minmax, &
    1274             :       C_wp2_pr_dfsn_minmax, C_wp3_pr_tp_minmax, C_wp3_pr_turb_minmax, C_wp3_pr_dfsn_minmax, &
    1275             :       C_wp2_splat_minmax, C6rt_Lscale0_minmax, C6thl_Lscale0_minmax, C7_Lscale0_minmax, &
    1276             :       wpxp_L_thresh_minmax, c_K_minmax, c_K1_minmax, nu1_minmax, c_K2_minmax, nu2_minmax, &
    1277             :       c_K6_minmax, nu6_minmax, c_K8_minmax, nu8_minmax, c_K9_minmax, nu9_minmax, nu10_minmax, &
    1278             :       c_K_hm_minmax, c_K_hmb_minmax, K_hm_min_coef_minmax, nu_hm_minmax, &
    1279             :       slope_coef_spread_DG_means_w_minmax, pdf_component_stdev_factor_w_minmax, &
    1280             :       coef_spread_DG_means_rt_minmax, coef_spread_DG_means_thl_minmax, &
    1281             :       beta_minmax, gamma_coef_minmax, gamma_coefb_minmax, gamma_coefc_minmax, lmin_coef_minmax, &
    1282             :       omicron_minmax, zeta_vrnce_rat_minmax, upsilon_precip_frac_rat_minmax, &
    1283             :       lambda0_stability_coef_minmax, mult_coef_minmax, taumin_minmax, taumax_minmax, &
    1284             :       mu_minmax, Lscale_mu_coef_minmax, Lscale_pert_coef_minmax, alpha_corr_minmax, &
    1285             :       Skw_denom_coef_minmax, c_K10_minmax, c_K10h_minmax, thlp2_rad_coef_minmax, &
    1286             :       thlp2_rad_cloud_frac_thresh_minmax, up2_sfc_coef_minmax, Skw_max_mag_minmax, &
    1287             :       xp3_coef_base_minmax, xp3_coef_slope_minmax, altitude_threshold_minmax, &
    1288             :       rtp2_clip_coef_minmax, C_invrs_tau_bkgnd_minmax, C_invrs_tau_sfc_minmax, &
    1289             :       C_invrs_tau_shear_minmax, C_invrs_tau_N2_minmax, C_invrs_tau_N2_wp2_minmax, &
    1290             :       C_invrs_tau_N2_xp2_minmax, C_invrs_tau_N2_wpxp_minmax, C_invrs_tau_N2_clear_wp3_minmax, &
    1291             :       C_invrs_tau_wpxp_Ri_minmax, C_invrs_tau_wpxp_N2_thresh_minmax, Cx_min_minmax, &
    1292             :       Cx_max_minmax, Richardson_num_min_minmax, Richardson_num_max_minmax, a3_coef_min_minmax, &
    1293             :       a_const_minmax, bv_efold_minmax, wpxp_Ri_exp_minmax, z_displace_minmax
    1294             : 
    1295             : 
    1296             : ! ----- Begin code -------------
    1297             : 
    1298             :     ! Read the namelist
    1299           0 :     open(unit=iunit, file=filename, status='old', action='read')
    1300           0 :     read(unit=iunit, nml=init_minmax)
    1301           0 :     close(unit=iunit)
    1302             : 
    1303             :     ! Put min/max values into params_minmax output array
    1304           0 :     params_minmax(:,iC1) = C1_minmax
    1305           0 :     params_minmax(:,iC1b) = C1b_minmax
    1306           0 :     params_minmax(:,iC1c) = C1c_minmax
    1307           0 :     params_minmax(:,iC2rt) = C2rt_minmax
    1308           0 :     params_minmax(:,iC2thl) = C2thl_minmax
    1309           0 :     params_minmax(:,iC2rtthl) = C2rtthl_minmax
    1310           0 :     params_minmax(:,iC4) = C4_minmax
    1311           0 :     params_minmax(:,iC_uu_shr) = C_uu_shr_minmax
    1312           0 :     params_minmax(:,iC_uu_buoy) = C_uu_buoy_minmax
    1313           0 :     params_minmax(:,iC6rt) = C6rt_minmax
    1314           0 :     params_minmax(:,iC6rtb) = C6rtb_minmax
    1315           0 :     params_minmax(:,iC6rtc) = C6rtc_minmax
    1316           0 :     params_minmax(:,iC6thl) = C6thl_minmax
    1317           0 :     params_minmax(:,iC6thlb) = C6thlb_minmax
    1318           0 :     params_minmax(:,iC6thlc) = C6thlc_minmax
    1319           0 :     params_minmax(:,iC7) = C7_minmax
    1320           0 :     params_minmax(:,iC7b) = C7b_minmax
    1321           0 :     params_minmax(:,iC7c) = C7c_minmax
    1322           0 :     params_minmax(:,iC8) = C8_minmax
    1323           0 :     params_minmax(:,iC8b) = C8b_minmax
    1324           0 :     params_minmax(:,iC10) = C10_minmax
    1325           0 :     params_minmax(:,iC11) = C11_minmax
    1326           0 :     params_minmax(:,iC11b) = C11b_minmax
    1327           0 :     params_minmax(:,iC11c) = C11c_minmax
    1328           0 :     params_minmax(:,iC12) = C12_minmax
    1329           0 :     params_minmax(:,iC13) = C13_minmax
    1330           0 :     params_minmax(:,iC14) = C14_minmax
    1331           0 :     params_minmax(:,iC_wp2_pr_dfsn) = C_wp2_pr_dfsn_minmax
    1332           0 :     params_minmax(:,iC_wp3_pr_tp) = C_wp3_pr_tp_minmax
    1333           0 :     params_minmax(:,iC_wp3_pr_turb) = C_wp3_pr_turb_minmax
    1334           0 :     params_minmax(:,iC_wp3_pr_dfsn) = C_wp3_pr_dfsn_minmax
    1335           0 :     params_minmax(:,iC_wp2_splat) = C_wp2_splat_minmax
    1336           0 :     params_minmax(:,iC6rt_Lscale0) = C6rt_Lscale0_minmax
    1337           0 :     params_minmax(:,iC6thl_Lscale0) = C6thl_Lscale0_minmax
    1338           0 :     params_minmax(:,iC7_Lscale0) = C7_Lscale0_minmax
    1339           0 :     params_minmax(:,iwpxp_L_thresh) = wpxp_L_thresh_minmax
    1340           0 :     params_minmax(:,ic_K) = c_K_minmax
    1341           0 :     params_minmax(:,ic_K1) = c_K1_minmax
    1342           0 :     params_minmax(:,inu1) = nu1_minmax
    1343           0 :     params_minmax(:,ic_K2) = c_K2_minmax
    1344           0 :     params_minmax(:,inu2) = nu2_minmax
    1345           0 :     params_minmax(:,ic_K6) = c_K6_minmax
    1346           0 :     params_minmax(:,inu6) = nu6_minmax
    1347           0 :     params_minmax(:,ic_K8) = c_K8_minmax
    1348           0 :     params_minmax(:,inu8) = nu8_minmax
    1349           0 :     params_minmax(:,ic_K9) = c_K9_minmax
    1350           0 :     params_minmax(:,inu9) = nu9_minmax
    1351           0 :     params_minmax(:,inu10) = nu10_minmax
    1352           0 :     params_minmax(:,ic_K_hm) = c_K_hm_minmax
    1353           0 :     params_minmax(:,ic_K_hmb) = c_K_hmb_minmax
    1354           0 :     params_minmax(:,iK_hm_min_coef) = K_hm_min_coef_minmax
    1355           0 :     params_minmax(:,inu_hm) = nu_hm_minmax
    1356           0 :     params_minmax(:,islope_coef_spread_DG_means_w) = slope_coef_spread_DG_means_w_minmax
    1357           0 :     params_minmax(:,ipdf_component_stdev_factor_w) = pdf_component_stdev_factor_w_minmax
    1358           0 :     params_minmax(:,icoef_spread_DG_means_rt) = coef_spread_DG_means_rt_minmax
    1359           0 :     params_minmax(:,icoef_spread_DG_means_thl) = coef_spread_DG_means_thl_minmax
    1360           0 :     params_minmax(:,igamma_coef) = gamma_coef_minmax
    1361           0 :     params_minmax(:,igamma_coefb) = gamma_coefb_minmax
    1362           0 :     params_minmax(:,igamma_coefc) = gamma_coefc_minmax
    1363           0 :     params_minmax(:,imu) = mu_minmax
    1364           0 :     params_minmax(:,ibeta) = beta_minmax
    1365           0 :     params_minmax(:,ilmin_coef) = lmin_coef_minmax
    1366           0 :     params_minmax(:,iomicron) = omicron_minmax
    1367           0 :     params_minmax(:,izeta_vrnce_rat) = zeta_vrnce_rat_minmax
    1368           0 :     params_minmax(:,iupsilon_precip_frac_rat) = upsilon_precip_frac_rat_minmax
    1369           0 :     params_minmax(:,ilambda0_stability_coef) = lambda0_stability_coef_minmax
    1370           0 :     params_minmax(:,imult_coef) = mult_coef_minmax
    1371           0 :     params_minmax(:,itaumin) = taumin_minmax
    1372           0 :     params_minmax(:,itaumax) = taumax_minmax
    1373           0 :     params_minmax(:,iLscale_mu_coef) = Lscale_mu_coef_minmax
    1374           0 :     params_minmax(:,iLscale_pert_coef) = Lscale_pert_coef_minmax
    1375           0 :     params_minmax(:,ialpha_corr) = alpha_corr_minmax
    1376           0 :     params_minmax(:,iSkw_denom_coef) = Skw_denom_coef_minmax
    1377           0 :     params_minmax(:,ic_K10) = c_K10_minmax
    1378           0 :     params_minmax(:,ic_K10h) = c_K10h_minmax
    1379           0 :     params_minmax(:,ithlp2_rad_coef) = thlp2_rad_coef_minmax
    1380           0 :     params_minmax(:,ithlp2_rad_cloud_frac_thresh) = thlp2_rad_cloud_frac_thresh_minmax
    1381           0 :     params_minmax(:,iup2_sfc_coef) = up2_sfc_coef_minmax
    1382           0 :     params_minmax(:,iSkw_max_mag) = Skw_max_mag_minmax
    1383           0 :     params_minmax(:,ixp3_coef_base) = xp3_coef_base_minmax
    1384           0 :     params_minmax(:,ixp3_coef_slope) = xp3_coef_slope_minmax
    1385           0 :     params_minmax(:,ialtitude_threshold) = altitude_threshold_minmax
    1386           0 :     params_minmax(:,irtp2_clip_coef) = rtp2_clip_coef_minmax
    1387           0 :     params_minmax(:,iC_invrs_tau_bkgnd) = C_invrs_tau_bkgnd_minmax
    1388           0 :     params_minmax(:,iC_invrs_tau_sfc) = C_invrs_tau_sfc_minmax
    1389           0 :     params_minmax(:,iC_invrs_tau_shear) = C_invrs_tau_shear_minmax
    1390           0 :     params_minmax(:,iC_invrs_tau_N2) = C_invrs_tau_N2_minmax
    1391           0 :     params_minmax(:,iC_invrs_tau_N2_wp2) = C_invrs_tau_N2_wp2_minmax
    1392           0 :     params_minmax(:,iC_invrs_tau_N2_xp2) = C_invrs_tau_N2_xp2_minmax
    1393           0 :     params_minmax(:,iC_invrs_tau_N2_wpxp) = C_invrs_tau_N2_wpxp_minmax
    1394           0 :     params_minmax(:,iC_invrs_tau_N2_clear_wp3) = C_invrs_tau_N2_clear_wp3_minmax
    1395           0 :     params_minmax(:,iC_invrs_tau_wpxp_Ri) = C_invrs_tau_wpxp_Ri_minmax
    1396           0 :     params_minmax(:,iC_invrs_tau_wpxp_N2_thresh) = C_invrs_tau_wpxp_N2_thresh_minmax
    1397           0 :     params_minmax(:,iRichardson_num_min) = Richardson_num_min_minmax
    1398           0 :     params_minmax(:,iRichardson_num_max) = Richardson_num_max_minmax
    1399           0 :     params_minmax(:,iCx_min) = Cx_min_minmax
    1400           0 :     params_minmax(:,iCx_max) = Cx_max_minmax
    1401           0 :     params_minmax(:,ia3_coef_min) = a3_coef_min_minmax
    1402           0 :     params_minmax(:,ia_const) = a_const_minmax
    1403           0 :     params_minmax(:,ibv_efold) = bv_efold_minmax
    1404           0 :     params_minmax(:,iwpxp_Ri_exp) = wpxp_Ri_exp_minmax
    1405           0 :     params_minmax(:,iz_displace) = z_displace_minmax
    1406             : 
    1407             :     ! Error checks:  if a minimum value is entered, it must have a
    1408             :     ! corresponding maximum value of greater value; the min and max values
    1409             :     ! should not be equal or too close together (current threshold 0.01,
    1410             :     ! although there may be circumstances where the user might want to adjust
    1411             :     ! this); and neither min or max should be less than zero.
    1412           0 :     do i = 1, nparams, 1
    1413           0 :       if ( params_minmax(1,i) > params_minmax(2,i) ) then
    1414             :         write(fstderr,*) "Check init_minmax namelist: " // trim(params_list(i)) // &
    1415           0 :                    " has a minimum value greater than its maximum value."
    1416           0 :         error stop
    1417           0 :       elseif ( params_minmax(1,i) > 0.0_core_rknd .and. &
    1418             :                abs( params_minmax(2,i) - params_minmax(1,i) ) < 0.01_core_rknd ) then
    1419             :         write(fstderr,*) "Check init_minmax namelist: " // trim(params_list(i)) // &
    1420           0 :                    " has a minimum value too close to its maximum value."
    1421           0 :         error stop
    1422           0 :       elseif (params_minmax(1,i) < 0.0_core_rknd .or. params_minmax(2,i) < 0.0_core_rknd ) then
    1423             :         write(fstderr,*) "Check init_minmax namelist: " // trim(params_list(i)) // &
    1424           0 :                    " has a minimum and/or maximum value less than zero."
    1425           0 :         error stop
    1426             :       end if
    1427             :     end do
    1428             : 
    1429             :     ! Initialize to zero
    1430           0 :     nindex(1:nparams) = 0
    1431           0 :     ndim = 0
    1432             : 
    1433             :     ! Determine how many variables are being changed
    1434           0 :     do i = 1, nparams, 1
    1435           0 :       if ( abs(params_minmax(2,i)) > eps) then
    1436           0 :         ndim = ndim + 1   ! Increase the total
    1437           0 :         nindex(ndim) = i  ! Set the next array index
    1438             :       endif
    1439             :     enddo
    1440             : 
    1441           0 :     return
    1442             : 
    1443             :   end subroutine read_param_minmax
    1444             : 
    1445             :   !=============================================================================
    1446           0 :   subroutine read_param_constraints &
    1447             :            ( iunit, filename, param_constraints )
    1448             : 
    1449             :     ! Description:
    1450             :     ! For the tuner.  While tuning it can be useful to keep certain parameters
    1451             :     ! equal to each other.  This subroutine reads in a namelist that specifies
    1452             :     ! which parameters should be kept equal to another.
    1453             : 
    1454             :     ! References:
    1455             :     ! None
    1456             :     !-----------------------------------------------------------------------
    1457             : 
    1458             :     use constants_clubb, only: fstderr ! Constant
    1459             : 
    1460             :     use parameter_indices, only: &
    1461             :       iC1, &
    1462             :       iC1b, &
    1463             :       iC6rt, &
    1464             :       iC6rtb, &
    1465             :       iC6rtc, &
    1466             :       iC6thl, &
    1467             :       iC6thlb, &
    1468             :       iC6thlc, &
    1469             :       iC7, &
    1470             :       iC7b, &
    1471             :       iC11, &
    1472             :       iC11b, &
    1473             :       iC14, &
    1474             :       iC6rt_Lscale0, &
    1475             :       iC6thl_Lscale0, &
    1476             :       igamma_coef, &
    1477             :       igamma_coefb
    1478             : 
    1479             :     implicit none
    1480             : 
    1481             :     ! Input variables
    1482             :     integer, intent(in) :: iunit
    1483             : 
    1484             :     character(len=*), intent(in) :: filename
    1485             : 
    1486             :     ! Output variables
    1487             :     character(len=28), dimension(nparams), intent(out) ::  &
    1488             :       param_constraints  ! Which variables should be kept equal to others
    1489             : 
    1490             :     ! Local variables
    1491             :     character(len=28) ::  &
    1492             :       C1_equals, C1b_equals, C6rt_equals, C6rtb_equals, C6rtc_equals, &
    1493             :       C6thl_equals, C6thlb_equals, C6thlc_equals, C7_equals, C7b_equals, &
    1494             :       C11_equals, C11b_equals, C14_equals, C6rt_Lscale0_equals, &
    1495             :       C6thl_Lscale0_equals, gamma_coef_equals, gamma_coefb_equals
    1496             : 
    1497             :     integer :: i
    1498             : 
    1499             :     ! This namelist specifies if a variable should be kept equal to another.
    1500             :     namelist /parameter_constraints/  &
    1501             :       C1_equals, C1b_equals, C6rt_equals, C6rtb_equals, C6rtc_equals, &
    1502             :       C6thl_equals, C6thlb_equals, C6thlc_equals, C7_equals, C7b_equals, &
    1503             :       C11_equals, C11b_equals, C14_equals, C6rt_Lscale0_equals, &
    1504             :       C6thl_Lscale0_equals, gamma_coef_equals, gamma_coefb_equals
    1505             : 
    1506             :     ! Initialize output array
    1507           0 :     param_constraints = ""
    1508             : 
    1509             :     ! Read the namelist
    1510           0 :     open(unit=iunit, file=filename, status='old', action='read')
    1511             : 
    1512           0 :     read(unit=iunit, nml=parameter_constraints)
    1513             : 
    1514           0 :     close(unit=iunit)
    1515             : 
    1516             :     ! Put the variables in the output array
    1517           0 :     param_constraints(iC1)            = C1_equals
    1518           0 :     param_constraints(iC1b)           = C1b_equals
    1519           0 :     param_constraints(iC6rt)          = C6rt_equals
    1520           0 :     param_constraints(iC6rtb)         = C6rtb_equals
    1521           0 :     param_constraints(iC6rtc)         = C6rtc_equals
    1522           0 :     param_constraints(iC6thl)         = C6thl_equals
    1523           0 :     param_constraints(iC6thlb)        = C6thlb_equals
    1524           0 :     param_constraints(iC6thlc)        = C6thlc_equals
    1525           0 :     param_constraints(iC7)            = C7_equals
    1526           0 :     param_constraints(iC7b)           = C7b_equals
    1527           0 :     param_constraints(iC11)           = C11_equals
    1528           0 :     param_constraints(iC11b)          = C11b_equals
    1529           0 :     param_constraints(iC14)           = C14_equals
    1530           0 :     param_constraints(iC6rt_Lscale0)  = C6rt_Lscale0_equals
    1531           0 :     param_constraints(iC6thl_Lscale0) = C6thl_Lscale0_equals
    1532           0 :     param_constraints(igamma_coef)    = gamma_coef_equals
    1533           0 :     param_constraints(igamma_coefb)   = gamma_coefb_equals
    1534             : 
    1535             :     ! Error check to make sure no constraint parameter is set equal to itself.
    1536           0 :     do i = 1, nparams, 1
    1537           0 :       if ( params_list(i) == param_constraints(i) ) then
    1538             :         write(fstderr,*) "Check parameter_constraints namelist: "//trim( params_list(i) )// &
    1539           0 :           " was set equal to itself."
    1540           0 :         error stop
    1541             :       end if
    1542             :     end do
    1543             : 
    1544           0 :     return
    1545             : 
    1546             :   end subroutine read_param_constraints
    1547             : 
    1548             :   !=============================================================================
    1549        1536 :   subroutine pack_parameters( ngrdcol, &
    1550             :                C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
    1551             :                C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, &
    1552             :                C7, C7b, C7c, C8, C8b, C10, &
    1553             :                C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    1554             :                C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
    1555             :                C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
    1556             :                c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
    1557             :                c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    1558             :                slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    1559             :                coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    1560             :                gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
    1561             :                omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    1562             :                lambda0_stability_coef, mult_coef, taumin, taumax, &
    1563             :                Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
    1564             :                Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
    1565             :                thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    1566             :                Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
    1567             :                altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
    1568             :                C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, &
    1569             :                C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
    1570             :                C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    1571             :                C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    1572             :                Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    1573        1536 :                wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace, clubb_params )
    1574             : 
    1575             :     ! Description:
    1576             :     ! Takes the list of scalar variables and puts them into a 1D vector.
    1577             :     ! It is here for the purpose of keeping the code generalized
    1578             :     ! when new variables are added.
    1579             : 
    1580             :     ! References:
    1581             :     ! None
    1582             :     !-----------------------------------------------------------------------
    1583             : 
    1584             :     use parameter_indices, only: & 
    1585             :         iC1,  & ! Variable(s)
    1586             :         iC1b, & 
    1587             :         iC1c, & 
    1588             :         iC2rt, & 
    1589             :         iC2thl, & 
    1590             :         iC2rtthl, & 
    1591             :         iC4, & 
    1592             :         iC_uu_shr, &
    1593             :         iC_uu_buoy, & 
    1594             :         iC6rt, & 
    1595             :         iC6rtb, & 
    1596             :         iC6rtc, & 
    1597             :         iC6thl, & 
    1598             :         iC6thlb, & 
    1599             :         iC6thlc, & 
    1600             :         iC7, & 
    1601             :         iC7b, & 
    1602             :         iC7c, & 
    1603             :         iC8, & 
    1604             :         iC8b, & 
    1605             :         iC10, & 
    1606             :         iC11, & 
    1607             :         iC11b, & 
    1608             :         iC11c, & 
    1609             :         iC12, & 
    1610             :         iC13, & 
    1611             :         iC14, &
    1612             :         iC_wp2_pr_dfsn, &
    1613             :         iC_wp3_pr_tp, &
    1614             :         iC_wp3_pr_turb, &
    1615             :         iC_wp3_pr_dfsn, &
    1616             :         iC_wp2_splat
    1617             : 
    1618             :     use parameter_indices, only: &
    1619             :         iC6rt_Lscale0, &
    1620             :         iC6thl_Lscale0, &
    1621             :         iC7_Lscale0, &
    1622             :         iwpxp_L_thresh
    1623             : 
    1624             :     use parameter_indices, only: & 
    1625             :         ic_K,  & 
    1626             :         ic_K1, & 
    1627             :         inu1, & 
    1628             :         ic_K2, & 
    1629             :         inu2, & 
    1630             :         ic_K6, & 
    1631             :         inu6, & 
    1632             :         ic_K8, & 
    1633             :         inu8, & 
    1634             :         ic_K9, & 
    1635             :         inu9, & 
    1636             :         inu10, &
    1637             :         ic_K_hm, & 
    1638             :         ic_K_hmb, & 
    1639             :         iK_hm_min_coef, &
    1640             :         inu_hm, & 
    1641             :         islope_coef_spread_DG_means_w, &
    1642             :         ipdf_component_stdev_factor_w, &
    1643             :         icoef_spread_DG_means_rt, &
    1644             :         icoef_spread_DG_means_thl, &
    1645             :         igamma_coef, & 
    1646             :         igamma_coefb, & 
    1647             :         igamma_coefc, & 
    1648             :         imu, & 
    1649             :         ibeta, & 
    1650             :         ilmin_coef, &
    1651             :         iomicron, &
    1652             :         izeta_vrnce_rat, &
    1653             :         iupsilon_precip_frac_rat, &
    1654             :         ilambda0_stability_coef, &
    1655             :         imult_coef, &
    1656             :         itaumin, & 
    1657             :         itaumax, & 
    1658             :         iLscale_mu_coef, &
    1659             :         iLscale_pert_coef, &
    1660             :         ialpha_corr, &
    1661             :         iSkw_denom_coef, &
    1662             :         ic_K10, &
    1663             :         ic_K10h, &
    1664             :         ithlp2_rad_coef, &
    1665             :         ithlp2_rad_cloud_frac_thresh, &
    1666             :         iup2_sfc_coef, &
    1667             :         iSkw_max_mag, &
    1668             :         ixp3_coef_base, &
    1669             :         ixp3_coef_slope, &
    1670             :         ialtitude_threshold, &
    1671             :         irtp2_clip_coef, &
    1672             :         iC_invrs_tau_bkgnd, &
    1673             :         iC_invrs_tau_sfc, &
    1674             :         iC_invrs_tau_shear, &
    1675             :         iC_invrs_tau_N2, &
    1676             :         iC_invrs_tau_N2_wp2, &
    1677             :         iC_invrs_tau_N2_xp2, &
    1678             :         iC_invrs_tau_N2_wpxp, &
    1679             :         iC_invrs_tau_N2_clear_wp3, &
    1680             :         iC_invrs_tau_wpxp_Ri, &
    1681             :         iC_invrs_tau_wpxp_N2_thresh, &
    1682             :         iCx_min, &
    1683             :         iCx_max, &
    1684             :         iRichardson_num_min, &
    1685             :         iRichardson_num_max, &
    1686             :         ia3_coef_min, &
    1687             :         ia_const, &
    1688             :         ibv_efold, &
    1689             :         iwpxp_Ri_exp, &
    1690             :         iz_displace
    1691             : 
    1692             :     implicit none
    1693             : 
    1694             :     !------------------------- Input Variables -------------------------
    1695             :     integer, intent(in) :: &
    1696             :       ngrdcol
    1697             : 
    1698             :     real( kind = core_rknd ), intent(in) :: & 
    1699             :       C1, C1b, C1c, C2rt, C2thl, C2rtthl, & 
    1700             :       C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
    1701             :       C7, C7b, C7c, C8, C8b, C10, & 
    1702             :       C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    1703             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
    1704             :       C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
    1705             :       c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8,  & 
    1706             :       c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    1707             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    1708             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    1709             :       gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
    1710             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    1711             :       lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
    1712             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
    1713             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    1714             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
    1715             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
    1716             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
    1717             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    1718             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    1719             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    1720             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
    1721             : 
    1722             :     !------------------------- Output Variables -------------------------
    1723             :     real( kind = core_rknd ), intent(out), dimension(ngrdcol,nparams) :: &
    1724             :       clubb_params
    1725             : 
    1726             :     !------------------------- Local Variables -------------------------
    1727             :     integer :: i
    1728             : 
    1729             :     !------------------------- Begin Code -------------------------
    1730             : 
    1731        3072 :     do i = 1, ngrdcol
    1732        1536 :       clubb_params(i,iC1)      = C1
    1733        1536 :       clubb_params(i,iC1b)     = C1b
    1734        1536 :       clubb_params(i,iC1c)     = C1c
    1735        1536 :       clubb_params(i,iC2rt)    = C2rt
    1736        1536 :       clubb_params(i,iC2thl)   = C2thl
    1737        1536 :       clubb_params(i,iC2rtthl) = C2rtthl
    1738        1536 :       clubb_params(i,iC4)      = C4
    1739        1536 :       clubb_params(i,iC_uu_shr) = C_uu_shr
    1740        1536 :       clubb_params(i,iC_uu_buoy) = C_uu_buoy
    1741        1536 :       clubb_params(i,iC6rt)    = C6rt
    1742        1536 :       clubb_params(i,iC6rtb)   = C6rtb
    1743        1536 :       clubb_params(i,iC6rtc)   = C6rtc
    1744        1536 :       clubb_params(i,iC6thl)   = C6thl
    1745        1536 :       clubb_params(i,iC6thlb)  = C6thlb
    1746        1536 :       clubb_params(i,iC6thlc)  = C6thlc
    1747        1536 :       clubb_params(i,iC7)      = C7
    1748        1536 :       clubb_params(i,iC7b)     = C7b
    1749        1536 :       clubb_params(i,iC7c)     = C7c
    1750        1536 :       clubb_params(i,iC8)      = C8
    1751        1536 :       clubb_params(i,iC8b)     = C8b
    1752        1536 :       clubb_params(i,iC10)     = C10
    1753        1536 :       clubb_params(i,iC11)     = C11
    1754        1536 :       clubb_params(i,iC11b)    = C11b
    1755        1536 :       clubb_params(i,iC11c)    = C11c
    1756        1536 :       clubb_params(i,iC12)     = C12
    1757        1536 :       clubb_params(i,iC13)     = C13
    1758        1536 :       clubb_params(i,iC14)     = C14
    1759        1536 :       clubb_params(i,iC_wp2_pr_dfsn)      = C_wp2_pr_dfsn
    1760        1536 :       clubb_params(i,iC_wp3_pr_tp)        = C_wp3_pr_tp
    1761        1536 :       clubb_params(i,iC_wp3_pr_turb)      = C_wp3_pr_turb
    1762        1536 :       clubb_params(i,iC_wp3_pr_dfsn)      = C_wp3_pr_dfsn
    1763        1536 :       clubb_params(i,iC_wp2_splat)        = C_wp2_splat
    1764        1536 :       clubb_params(i,iC6rt_Lscale0)       = C6rt_Lscale0
    1765        1536 :       clubb_params(i,iC6thl_Lscale0)      = C6thl_Lscale0
    1766        1536 :       clubb_params(i,iC7_Lscale0)         = C7_Lscale0
    1767        1536 :       clubb_params(i,iwpxp_L_thresh)    = wpxp_L_thresh
    1768        1536 :       clubb_params(i,ic_K)       = c_K
    1769        1536 :       clubb_params(i,ic_K1)      = c_K1
    1770        1536 :       clubb_params(i,inu1)       = nu1
    1771        1536 :       clubb_params(i,ic_K2)      = c_K2
    1772        1536 :       clubb_params(i,inu2)       = nu2
    1773        1536 :       clubb_params(i,ic_K6)      = c_K6
    1774        1536 :       clubb_params(i,inu6)       = nu6
    1775        1536 :       clubb_params(i,ic_K8)      = c_K8
    1776        1536 :       clubb_params(i,inu8)       = nu8
    1777        1536 :       clubb_params(i,ic_K9)      = c_K9
    1778        1536 :       clubb_params(i,inu9)       = nu9
    1779        1536 :       clubb_params(i,inu10)      = nu10
    1780        1536 :       clubb_params(i,ic_K_hm)    = c_K_hm
    1781        1536 :       clubb_params(i,ic_K_hmb)   = c_K_hmb
    1782        1536 :       clubb_params(i,iK_hm_min_coef)   = K_hm_min_coef
    1783        1536 :       clubb_params(i,inu_hm)     = nu_hm
    1784        1536 :       clubb_params(i,islope_coef_spread_DG_means_w) = slope_coef_spread_DG_means_w
    1785        1536 :       clubb_params(i,ipdf_component_stdev_factor_w) = pdf_component_stdev_factor_w
    1786        1536 :       clubb_params(i,icoef_spread_DG_means_rt) = coef_spread_DG_means_rt
    1787        1536 :       clubb_params(i,icoef_spread_DG_means_thl) = coef_spread_DG_means_thl
    1788        1536 :       clubb_params(i,igamma_coef)  = gamma_coef
    1789        1536 :       clubb_params(i,igamma_coefb) = gamma_coefb
    1790        1536 :       clubb_params(i,igamma_coefc) = gamma_coefc
    1791        1536 :       clubb_params(i,imu) = mu
    1792        1536 :       clubb_params(i,ibeta) = beta
    1793        1536 :       clubb_params(i,ilmin_coef) = lmin_coef
    1794        1536 :       clubb_params(i,iomicron) = omicron
    1795        1536 :       clubb_params(i,izeta_vrnce_rat) = zeta_vrnce_rat
    1796        1536 :       clubb_params(i,iupsilon_precip_frac_rat) = upsilon_precip_frac_rat
    1797        1536 :       clubb_params(i,ilambda0_stability_coef) = lambda0_stability_coef
    1798        1536 :       clubb_params(i,imult_coef) = mult_coef
    1799        1536 :       clubb_params(i,itaumin) = taumin
    1800        1536 :       clubb_params(i,itaumax) = taumax
    1801        1536 :       clubb_params(i,iLscale_mu_coef) = Lscale_mu_coef
    1802        1536 :       clubb_params(i,iLscale_pert_coef) = Lscale_pert_coef
    1803        1536 :       clubb_params(i,ialpha_corr) = alpha_corr
    1804        1536 :       clubb_params(i,iSkw_denom_coef) = Skw_denom_coef
    1805        1536 :       clubb_params(i,ic_K10) = c_K10
    1806        1536 :       clubb_params(i,ic_K10h) = c_K10h
    1807        1536 :       clubb_params(i,ithlp2_rad_coef) = thlp2_rad_coef
    1808        1536 :       clubb_params(i,ithlp2_rad_cloud_frac_thresh) = thlp2_rad_cloud_frac_thresh
    1809        1536 :       clubb_params(i,iup2_sfc_coef) = up2_sfc_coef
    1810        1536 :       clubb_params(i,iSkw_max_mag) = Skw_max_mag
    1811        1536 :       clubb_params(i,ixp3_coef_base) = xp3_coef_base
    1812        1536 :       clubb_params(i,ixp3_coef_slope) = xp3_coef_slope
    1813        1536 :       clubb_params(i,ialtitude_threshold) = altitude_threshold
    1814        1536 :       clubb_params(i,irtp2_clip_coef) = rtp2_clip_coef
    1815        1536 :       clubb_params(i,iC_invrs_tau_bkgnd)          = C_invrs_tau_bkgnd
    1816        1536 :       clubb_params(i,iC_invrs_tau_sfc)            = C_invrs_tau_sfc
    1817        1536 :       clubb_params(i,iC_invrs_tau_shear)          = C_invrs_tau_shear
    1818        1536 :       clubb_params(i,iC_invrs_tau_N2)             = C_invrs_tau_N2
    1819        1536 :       clubb_params(i,iC_invrs_tau_N2_wp2)         = C_invrs_tau_N2_wp2
    1820        1536 :       clubb_params(i,iC_invrs_tau_N2_xp2)         = C_invrs_tau_N2_xp2
    1821        1536 :       clubb_params(i,iC_invrs_tau_N2_wpxp)        = C_invrs_tau_N2_wpxp
    1822        1536 :       clubb_params(i,iC_invrs_tau_N2_clear_wp3)   = C_invrs_tau_N2_clear_wp3
    1823        1536 :       clubb_params(i,iC_invrs_tau_wpxp_Ri)        = C_invrs_tau_wpxp_Ri
    1824        1536 :       clubb_params(i,iC_invrs_tau_wpxp_N2_thresh) = C_invrs_tau_wpxp_N2_thresh
    1825        1536 :       clubb_params(i,iCx_min) = Cx_min
    1826        1536 :       clubb_params(i,iCx_max) = Cx_max
    1827        1536 :       clubb_params(i,iRichardson_num_min) = Richardson_num_min
    1828        1536 :       clubb_params(i,iRichardson_num_max) = Richardson_num_max
    1829        1536 :       clubb_params(i,ia3_coef_min) = a3_coef_min
    1830        1536 :       clubb_params(i,ia_const) = a_const
    1831        1536 :       clubb_params(i,ibv_efold) = bv_efold
    1832        1536 :       clubb_params(i,iwpxp_Ri_exp) = wpxp_Ri_exp
    1833        3072 :       clubb_params(i,iz_displace) = z_displace
    1834             :     end do
    1835             : 
    1836        1536 :     return
    1837             :   end subroutine pack_parameters
    1838             : 
    1839             :   !=============================================================================
    1840    70129800 :   subroutine unpack_parameters & 
    1841             :              ( clubb_params, & 
    1842             :                C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
    1843             :                C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, &
    1844             :                C7, C7b, C7c, C8, C8b, C10, &
    1845             :                C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    1846             :                C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
    1847             :                C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
    1848             :                c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
    1849             :                c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    1850             :                slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    1851             :                coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    1852             :                gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
    1853             :                omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    1854             :                lambda0_stability_coef, mult_coef, taumin, taumax, &
    1855             :                Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
    1856             :                Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
    1857             :                thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    1858             :                Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
    1859             :                altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
    1860             :                C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, & 
    1861             :                C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
    1862             :                C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    1863             :                C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    1864             :                Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    1865             :                wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace )
    1866             : 
    1867             :     ! Description:
    1868             :     ! Takes the 1D vector and returns the list of scalar variables.
    1869             :     ! Here for the purposes of keeping the code generalized
    1870             :     ! when new variables are added.
    1871             : 
    1872             :     ! References:
    1873             :     ! None
    1874             :     !-----------------------------------------------------------------------
    1875             : 
    1876             :     use parameter_indices, only: & 
    1877             :         iC1,  & ! Variable(s)
    1878             :         iC1b, & 
    1879             :         iC1c, & 
    1880             :         iC2rt, & 
    1881             :         iC2thl, & 
    1882             :         iC2rtthl, & 
    1883             :         iC4, & 
    1884             :         iC_uu_shr, &
    1885             :         iC_uu_buoy, & 
    1886             :         iC6rt, & 
    1887             :         iC6rtb, & 
    1888             :         iC6rtc, & 
    1889             :         iC6thl, & 
    1890             :         iC6thlb, & 
    1891             :         iC6thlc, & 
    1892             :         iC7, & 
    1893             :         iC7b, & 
    1894             :         iC7c, & 
    1895             :         iC8, & 
    1896             :         iC8b, & 
    1897             :         iC10, & 
    1898             :         iC11, & 
    1899             :         iC11b, & 
    1900             :         iC11c, & 
    1901             :         iC12, & 
    1902             :         iC13, & 
    1903             :         iC14, &
    1904             :         iC_wp2_pr_dfsn, &
    1905             :         iC_wp3_pr_tp, &
    1906             :         iC_wp3_pr_turb, &
    1907             :         iC_wp3_pr_dfsn, &
    1908             :         iC_wp2_splat
    1909             : 
    1910             :     use parameter_indices, only: &
    1911             :         iC6rt_Lscale0, &
    1912             :         iC6thl_Lscale0, &
    1913             :         iC7_Lscale0, &
    1914             :         iwpxp_L_thresh
    1915             : 
    1916             :     use parameter_indices, only: & 
    1917             :         ic_K,  & 
    1918             :         ic_K1, & 
    1919             :         inu1, & 
    1920             :         ic_K2, & 
    1921             :         inu2, & 
    1922             :         ic_K6, & 
    1923             :         inu6, & 
    1924             :         ic_K8, & 
    1925             :         inu8, & 
    1926             :         ic_K9, & 
    1927             :         inu9, & 
    1928             :         inu10, &
    1929             :         ic_K_hm, & 
    1930             :         ic_K_hmb, & 
    1931             :         iK_hm_min_coef, & 
    1932             :         inu_hm, & 
    1933             :         islope_coef_spread_DG_means_w, &
    1934             :         ipdf_component_stdev_factor_w, &
    1935             :         icoef_spread_DG_means_rt, &
    1936             :         icoef_spread_DG_means_thl, &
    1937             :         igamma_coef, & 
    1938             :         igamma_coefb, & 
    1939             :         igamma_coefc, & 
    1940             :         imu, & 
    1941             :         ibeta, & 
    1942             :         ilmin_coef, &
    1943             :         iomicron, &
    1944             :         izeta_vrnce_rat, &
    1945             :         iupsilon_precip_frac_rat, &
    1946             :         ilambda0_stability_coef, &
    1947             :         imult_coef, &
    1948             :         itaumin, & 
    1949             :         itaumax, & 
    1950             :         iLscale_mu_coef, &
    1951             :         iLscale_pert_coef, &
    1952             :         ialpha_corr, &
    1953             :         iSkw_denom_coef, &
    1954             :         ic_K10, &
    1955             :         ic_K10h, & 
    1956             :         ithlp2_rad_coef, &
    1957             :         ithlp2_rad_cloud_frac_thresh, &
    1958             :         iup2_sfc_coef, &
    1959             :         iSkw_max_mag, &
    1960             :         ixp3_coef_base, &
    1961             :         ixp3_coef_slope, &
    1962             :         ialtitude_threshold, &
    1963             :         irtp2_clip_coef, &
    1964             :         iC_invrs_tau_bkgnd, &
    1965             :         iC_invrs_tau_sfc, &
    1966             :         iC_invrs_tau_shear, &
    1967             :         iC_invrs_tau_N2, &
    1968             :         iC_invrs_tau_N2_wp2, &
    1969             :         iC_invrs_tau_N2_xp2, &
    1970             :         iC_invrs_tau_N2_wpxp, &
    1971             :         iC_invrs_tau_N2_clear_wp3, &
    1972             :         iC_invrs_tau_wpxp_Ri, &
    1973             :         iC_invrs_tau_wpxp_N2_thresh, &
    1974             :         iCx_min, &
    1975             :         iCx_max, &
    1976             :         iRichardson_num_min, &
    1977             :         iRichardson_num_max, &
    1978             :         ia3_coef_min, &
    1979             :         ia_const, &
    1980             :         ibv_efold, &
    1981             :         iwpxp_Ri_exp, &
    1982             :         iz_displace, &
    1983             :         nparams
    1984             : 
    1985             :     implicit none
    1986             : 
    1987             :     ! Input variables
    1988             :     real( kind = core_rknd ), intent(in), dimension(nparams) :: clubb_params
    1989             : 
    1990             :     ! Output variables
    1991             :     real( kind = core_rknd ), intent(out) :: & 
    1992             :       C1, C1b, C1c, C2rt, C2thl, C2rtthl, & 
    1993             :       C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
    1994             :       C7, C7b, C7c, C8, C8b, C10, & 
    1995             :       C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    1996             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & 
    1997             :       C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
    1998             :       c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8,  & 
    1999             :       c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    2000             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    2001             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    2002             :       gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
    2003             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    2004             :       lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
    2005             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
    2006             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    2007             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
    2008             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
    2009             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
    2010             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    2011             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    2012             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    2013             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
    2014             : 
    2015    70129800 :     C1      = clubb_params(iC1)
    2016    70129800 :     C1b     = clubb_params(iC1b)
    2017    70129800 :     C1c     = clubb_params(iC1c)
    2018    70129800 :     C2rt    = clubb_params(iC2rt)
    2019    70129800 :     C2thl   = clubb_params(iC2thl)
    2020    70129800 :     C2rtthl = clubb_params(iC2rtthl)
    2021    70129800 :     C4      = clubb_params(iC4)
    2022    70129800 :     C_uu_shr = clubb_params(iC_uu_shr)
    2023    70129800 :     C_uu_buoy = clubb_params(iC_uu_buoy)
    2024    70129800 :     C6rt    = clubb_params(iC6rt)
    2025    70129800 :     C6rtb   = clubb_params(iC6rtb)
    2026    70129800 :     C6rtc   = clubb_params(iC6rtc)
    2027    70129800 :     C6thl   = clubb_params(iC6thl)
    2028    70129800 :     C6thlb  = clubb_params(iC6thlb)
    2029    70129800 :     C6thlc  = clubb_params(iC6thlc)
    2030    70129800 :     C7      = clubb_params(iC7)
    2031    70129800 :     C7b     = clubb_params(iC7b)
    2032    70129800 :     C7c     = clubb_params(iC7c)
    2033    70129800 :     C8      = clubb_params(iC8)
    2034    70129800 :     C8b     = clubb_params(iC8b)
    2035    70129800 :     C10     = clubb_params(iC10)
    2036    70129800 :     C11     = clubb_params(iC11)
    2037    70129800 :     C11b    = clubb_params(iC11b)
    2038    70129800 :     C11c    = clubb_params(iC11c)
    2039    70129800 :     C12     = clubb_params(iC12)
    2040    70129800 :     C13     = clubb_params(iC13)
    2041    70129800 :     C14     = clubb_params(iC14)
    2042             : 
    2043    70129800 :     C_wp2_pr_dfsn      = clubb_params(iC_wp2_pr_dfsn)
    2044    70129800 :     C_wp3_pr_tp        = clubb_params(iC_wp3_pr_tp)
    2045    70129800 :     C_wp3_pr_turb      = clubb_params(iC_wp3_pr_turb)
    2046    70129800 :     C_wp3_pr_dfsn      = clubb_params(iC_wp3_pr_dfsn)
    2047    70129800 :     C_wp2_splat        = clubb_params(iC_wp2_splat)
    2048             : 
    2049    70129800 :     C6rt_Lscale0       = clubb_params(iC6rt_Lscale0)
    2050    70129800 :     C6thl_Lscale0      = clubb_params(iC6thl_Lscale0)
    2051    70129800 :     C7_Lscale0         = clubb_params(iC7_Lscale0)
    2052    70129800 :     wpxp_L_thresh      = clubb_params(iwpxp_L_thresh)
    2053             : 
    2054    70129800 :     c_K       = clubb_params(ic_K)
    2055    70129800 :     c_K1      = clubb_params(ic_K1)
    2056    70129800 :     nu1       = clubb_params(inu1)
    2057    70129800 :     c_K2      = clubb_params(ic_K2)
    2058    70129800 :     nu2       = clubb_params(inu2)
    2059    70129800 :     c_K6      = clubb_params(ic_K6)
    2060    70129800 :     nu6       = clubb_params(inu6)
    2061    70129800 :     c_K8      = clubb_params(ic_K8)
    2062    70129800 :     nu8       = clubb_params(inu8)
    2063    70129800 :     c_K9      = clubb_params(ic_K9)
    2064    70129800 :     nu9       = clubb_params(inu9)
    2065    70129800 :     nu10      = clubb_params(inu10)
    2066    70129800 :     c_K_hm    = clubb_params(ic_K_hm)
    2067    70129800 :     c_K_hmb   = clubb_params(ic_K_hmb)
    2068    70129800 :     K_hm_min_coef   = clubb_params(iK_hm_min_coef)
    2069    70129800 :     nu_hm     = clubb_params(inu_hm)
    2070             : 
    2071    70129800 :     slope_coef_spread_DG_means_w = clubb_params(islope_coef_spread_DG_means_w)
    2072    70129800 :     pdf_component_stdev_factor_w = clubb_params(ipdf_component_stdev_factor_w)
    2073    70129800 :     coef_spread_DG_means_rt = clubb_params(icoef_spread_DG_means_rt)
    2074    70129800 :     coef_spread_DG_means_thl = clubb_params(icoef_spread_DG_means_thl)
    2075             : 
    2076    70129800 :     gamma_coef  = clubb_params(igamma_coef)
    2077    70129800 :     gamma_coefb = clubb_params(igamma_coefb)
    2078    70129800 :     gamma_coefc = clubb_params(igamma_coefc)
    2079             : 
    2080    70129800 :     mu = clubb_params(imu)
    2081             : 
    2082    70129800 :     beta = clubb_params(ibeta)
    2083             : 
    2084    70129800 :     lmin_coef = clubb_params(ilmin_coef)
    2085             : 
    2086    70129800 :     omicron = clubb_params(iomicron)
    2087    70129800 :     zeta_vrnce_rat = clubb_params(izeta_vrnce_rat)
    2088             : 
    2089    70129800 :     upsilon_precip_frac_rat = clubb_params(iupsilon_precip_frac_rat)
    2090    70129800 :     lambda0_stability_coef = clubb_params(ilambda0_stability_coef)
    2091    70129800 :     mult_coef = clubb_params(imult_coef)
    2092             : 
    2093    70129800 :     taumin = clubb_params(itaumin)
    2094    70129800 :     taumax = clubb_params(itaumax)
    2095             : 
    2096    70129800 :     Lscale_mu_coef = clubb_params(iLscale_mu_coef)
    2097    70129800 :     Lscale_pert_coef = clubb_params(iLscale_pert_coef)
    2098    70129800 :     alpha_corr = clubb_params(ialpha_corr)
    2099    70129800 :     Skw_denom_coef = clubb_params(iSkw_denom_coef)
    2100    70129800 :     c_K10 = clubb_params(ic_K10)
    2101    70129800 :     c_K10h = clubb_params(ic_K10h)
    2102             : 
    2103    70129800 :     thlp2_rad_coef = clubb_params(ithlp2_rad_coef)
    2104    70129800 :     thlp2_rad_cloud_frac_thresh = clubb_params(ithlp2_rad_cloud_frac_thresh)
    2105    70129800 :     up2_sfc_coef = clubb_params(iup2_sfc_coef)
    2106    70129800 :     Skw_max_mag = clubb_params(iSkw_max_mag)
    2107    70129800 :     xp3_coef_base = clubb_params(ixp3_coef_base)
    2108    70129800 :     xp3_coef_slope = clubb_params(ixp3_coef_slope)
    2109    70129800 :     altitude_threshold = clubb_params(ialtitude_threshold)
    2110    70129800 :     rtp2_clip_coef = clubb_params(irtp2_clip_coef)
    2111    70129800 :     C_invrs_tau_bkgnd          = clubb_params(iC_invrs_tau_bkgnd)
    2112    70129800 :     C_invrs_tau_sfc            = clubb_params(iC_invrs_tau_sfc )
    2113    70129800 :     C_invrs_tau_shear          = clubb_params(iC_invrs_tau_shear)
    2114    70129800 :     C_invrs_tau_N2             = clubb_params(iC_invrs_tau_N2)
    2115    70129800 :     C_invrs_tau_N2_wp2         = clubb_params(iC_invrs_tau_N2_wp2)
    2116    70129800 :     C_invrs_tau_N2_xp2         = clubb_params(iC_invrs_tau_N2_xp2)
    2117    70129800 :     C_invrs_tau_N2_wpxp        = clubb_params(iC_invrs_tau_N2_wpxp)
    2118    70129800 :     C_invrs_tau_N2_clear_wp3   = clubb_params(iC_invrs_tau_N2_clear_wp3)
    2119    70129800 :     C_invrs_tau_wpxp_Ri        = clubb_params(iC_invrs_tau_wpxp_Ri)
    2120    70129800 :     C_invrs_tau_wpxp_N2_thresh = clubb_params(iC_invrs_tau_wpxp_N2_thresh)
    2121    70129800 :     Cx_min = clubb_params(iCx_min)
    2122    70129800 :     Cx_max = clubb_params(iCx_max)
    2123    70129800 :     Richardson_num_min = clubb_params(iRichardson_num_min)
    2124    70129800 :     Richardson_num_max = clubb_params(iRichardson_num_max)
    2125    70129800 :     a3_coef_min = clubb_params(ia3_coef_min)
    2126    70129800 :     a_const = clubb_params(ia_const)
    2127    70129800 :     bv_efold = clubb_params(ibv_efold)
    2128    70129800 :     wpxp_Ri_exp = clubb_params(iwpxp_Ri_exp)
    2129    70129800 :     z_displace = clubb_params(iz_displace)
    2130             : 
    2131    70129800 :     return
    2132             :   end subroutine unpack_parameters
    2133             : 
    2134             :   !=============================================================================
    2135             :   subroutine init_parameters_999( &
    2136             :                C1, C1b, C1c, C2rt, C2thl, C2rtthl, &
    2137             :                C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, &
    2138             :                C6thl, C6thlb, C6thlc, C7, C7b, C7c, C8, C8b, C10, &
    2139             :                C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    2140             :                C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, &
    2141             :                C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
    2142             :                c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8, &
    2143             :                c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    2144             :                slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    2145             :                coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    2146             :                gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
    2147             :                omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    2148             :                lambda0_stability_coef, mult_coef, taumin, taumax, &
    2149             :                Lscale_mu_coef, Lscale_pert_coef, alpha_corr, &
    2150             :                Skw_denom_coef, c_K10, c_K10h, thlp2_rad_coef, &
    2151             :                thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    2152             :                Skw_max_mag, xp3_coef_base, xp3_coef_slope, &
    2153             :                altitude_threshold, rtp2_clip_coef, C_invrs_tau_bkgnd, &
    2154             :                C_invrs_tau_sfc, C_invrs_tau_shear, C_invrs_tau_N2, & 
    2155             :                C_invrs_tau_N2_wp2, C_invrs_tau_N2_xp2, &
    2156             :                C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    2157             :                C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    2158             :                Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    2159             :                wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace )
    2160             : 
    2161             :     ! Description:
    2162             :     ! Set all tunable parameters to NaN
    2163             : 
    2164             :     ! References:
    2165             :     ! None
    2166             :     !-----------------------------------------------------------------------
    2167             : 
    2168             :     implicit none
    2169             : 
    2170             :     ! Output variables
    2171             :     real( kind = core_rknd ), intent(out) :: & 
    2172             :       C1, C1b, C1c, C2rt, C2thl, C2rtthl, & 
    2173             :       C4, C_uu_shr, C_uu_buoy, C6rt, C6rtb, C6rtc, C6thl, C6thlb, C6thlc, & 
    2174             :       C7, C7b, C7c, C8, C8b, C10, & 
    2175             :       C11, C11b, C11c, C12, C13, C14, C_wp2_pr_dfsn, C_wp3_pr_tp, &
    2176             :       C_wp3_pr_turb, C_wp3_pr_dfsn, C_wp2_splat, & 
    2177             :       C6rt_Lscale0, C6thl_Lscale0, C7_Lscale0, wpxp_L_thresh, &
    2178             :       c_K, c_K1, nu1, c_K2, nu2, c_K6, nu6, c_K8, nu8,  & 
    2179             :       c_K9, nu9, nu10, c_K_hm, c_K_hmb, K_hm_min_coef, nu_hm, &
    2180             :       slope_coef_spread_DG_means_w, pdf_component_stdev_factor_w, &
    2181             :       coef_spread_DG_means_rt, coef_spread_DG_means_thl, &
    2182             :       gamma_coef, gamma_coefb, gamma_coefc, mu, beta, lmin_coef, &
    2183             :       omicron, zeta_vrnce_rat, upsilon_precip_frac_rat, &
    2184             :       lambda0_stability_coef, mult_coef, taumin, taumax, Lscale_mu_coef, &
    2185             :       Lscale_pert_coef, alpha_corr, Skw_denom_coef, c_K10, c_K10h, &
    2186             :       thlp2_rad_coef, thlp2_rad_cloud_frac_thresh, up2_sfc_coef, &
    2187             :       Skw_max_mag, xp3_coef_base, xp3_coef_slope, altitude_threshold, &
    2188             :       rtp2_clip_coef, C_invrs_tau_bkgnd, C_invrs_tau_sfc, &
    2189             :       C_invrs_tau_shear, C_invrs_tau_N2, C_invrs_tau_N2_wp2, &
    2190             :       C_invrs_tau_N2_xp2, C_invrs_tau_N2_wpxp, C_invrs_tau_N2_clear_wp3, &
    2191             :       C_invrs_tau_wpxp_Ri, C_invrs_tau_wpxp_N2_thresh, &
    2192             :       Cx_min, Cx_max, Richardson_num_min, Richardson_num_max, &
    2193             :       wpxp_Ri_exp, a3_coef_min, a_const, bv_efold, z_displace
    2194             : 
    2195             :     ! --- Begin Code ---
    2196             : 
    2197             :     C1                           = init_value
    2198             :     C1b                          = init_value
    2199             :     C1c                          = init_value
    2200             :     C2rt                         = init_value
    2201             :     C2thl                        = init_value
    2202             :     C2rtthl                      = init_value
    2203             :     C4                           = init_value
    2204             :     C_uu_shr                     = init_value
    2205             :     C_uu_buoy                    = init_value
    2206             :     C6rt                         = init_value
    2207             :     C6rtb                        = init_value
    2208             :     C6rtc                        = init_value
    2209             :     C6thl                        = init_value
    2210             :     C6thlb                       = init_value
    2211             :     C6thlc                       = init_value
    2212             :     C7                           = init_value
    2213             :     C7b                          = init_value
    2214             :     C7c                          = init_value
    2215             :     C8                           = init_value
    2216             :     C8b                          = init_value
    2217             :     C10                          = init_value
    2218             :     C11                          = init_value
    2219             :     C11b                         = init_value
    2220             :     C11c                         = init_value
    2221             :     C12                          = init_value
    2222             :     C13                          = init_value
    2223             :     C14                          = init_value
    2224             :     C_wp2_pr_dfsn                = init_value
    2225             :     C_wp3_pr_tp                  = init_value
    2226             :     C_wp3_pr_turb                = init_value
    2227             :     C_wp3_pr_dfsn                = init_value
    2228             :     C_wp2_splat                  = init_value 
    2229             :     C6rt_Lscale0                 = init_value
    2230             :     C6thl_Lscale0                = init_value
    2231             :     C7_Lscale0                   = init_value
    2232             :     wpxp_L_thresh                = init_value
    2233             :     c_K                          = init_value
    2234             :     c_K1                         = init_value
    2235             :     nu1                          = init_value
    2236             :     c_K2                         = init_value
    2237             :     nu2                          = init_value
    2238             :     c_K6                         = init_value
    2239             :     nu6                          = init_value
    2240             :     c_K8                         = init_value
    2241             :     nu8                          = init_value
    2242             :     c_K9                         = init_value
    2243             :     nu9                          = init_value
    2244             :     nu10                         = init_value
    2245             :     c_K_hm                       = init_value
    2246             :     c_K_hmb                      = init_value
    2247             :     K_hm_min_coef                = init_value
    2248             :     nu_hm                        = init_value
    2249             :     slope_coef_spread_DG_means_w = init_value
    2250             :     pdf_component_stdev_factor_w = init_value
    2251             :     coef_spread_DG_means_rt      = init_value
    2252             :     coef_spread_DG_means_thl     = init_value
    2253             :     beta                         = init_value
    2254             :     gamma_coef                   = init_value
    2255             :     gamma_coefb                  = init_value
    2256             :     gamma_coefc                  = init_value
    2257             :     mult_coef                    = init_value
    2258             :     taumin                       = init_value
    2259             :     taumax                       = init_value
    2260             :     lmin_coef                    = init_value
    2261             :     omicron                      = init_value
    2262             :     zeta_vrnce_rat               = init_value
    2263             :     upsilon_precip_frac_rat      = init_value
    2264             :     lambda0_stability_coef       = init_value
    2265             :     mu                           = init_value
    2266             :     Lscale_mu_coef               = init_value
    2267             :     Lscale_pert_coef             = init_value
    2268             :     alpha_corr                   = init_value
    2269             :     Skw_denom_coef               = init_value
    2270             :     c_K10                        = init_value
    2271             :     c_K10h                       = init_value
    2272             :     thlp2_rad_coef               = init_value
    2273             :     thlp2_rad_cloud_frac_thresh  = init_value
    2274             :     up2_sfc_coef                 = init_value
    2275             :     Skw_max_mag                  = init_value
    2276             :     xp3_coef_base                = init_value
    2277             :     xp3_coef_slope               = init_value
    2278             :     altitude_threshold           = init_value
    2279             :     rtp2_clip_coef               = init_value
    2280             :     C_invrs_tau_bkgnd            = init_value 
    2281             :     C_invrs_tau_sfc              = init_value 
    2282             :     C_invrs_tau_shear            = init_value 
    2283             :     C_invrs_tau_N2               = init_value 
    2284             :     C_invrs_tau_N2_xp2           = init_value
    2285             :     C_invrs_tau_N2_wp2           = init_value
    2286             :     C_invrs_tau_N2_wpxp          = init_value
    2287             :     C_invrs_tau_N2_clear_wp3     = init_value
    2288             :     C_invrs_tau_wpxp_Ri          = init_value
    2289             :     C_invrs_tau_wpxp_N2_thresh   = init_value
    2290             :     Cx_min                       = init_value
    2291             :     Cx_max                       = init_value
    2292             :     Richardson_num_min           = init_value
    2293             :     Richardson_num_max           = init_value
    2294             :     a3_coef_min                  = init_value
    2295             :     a_const                      = init_value
    2296             :     bv_efold                     = init_value
    2297             :     wpxp_Ri_exp                  = init_value
    2298             :     z_displace                   = init_value
    2299             :     return
    2300             : 
    2301             :   end subroutine init_parameters_999
    2302             : 
    2303             : !===============================================================================
    2304             : 
    2305           0 : end module parameters_tunable

Generated by: LCOV version 1.14