LCOV - code coverage report
Current view: top level - physics/clubb/src/CLUBB_core - stats_zm_module.F90 (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 986 0.0 %
Date: 2025-03-13 18:42:46 Functions: 0 1 0.0 %

          Line data    Source code
       1             : !-----------------------------------------------------------------------
       2             : ! $Id$
       3             : !===============================================================================
       4             : module stats_zm_module
       5             : 
       6             :   implicit none
       7             : 
       8             :   private ! Default Scope
       9             : 
      10             :   public :: stats_init_zm
      11             : 
      12             :   ! Constant parameters
      13             :   integer, parameter, public :: nvarmax_zm = 350  ! Maximum variables allowed
      14             : 
      15             :   contains
      16             : 
      17             : !-----------------------------------------------------------------------
      18           0 :   subroutine stats_init_zm( vars_zm,                    & ! intent(in)
      19             :                             l_error,                    & ! intent(inout)
      20             :                             stats_metadata, stats_zm )    ! intent(inout)
      21             : 
      22             : ! Description:
      23             : !   Initializes array indices for stats_zm
      24             : 
      25             : ! Note:
      26             : !   All code that is within subroutine stats_init_zm, including variable
      27             : !   allocation code, is not called if l_stats is false.  This subroutine is
      28             : !   called only when l_stats is true.
      29             : 
      30             : !-----------------------------------------------------------------------
      31             : 
      32             :     use constants_clubb, only: &
      33             :         fstderr ! Constant(s)
      34             : 
      35             :     use stats_type_utilities, only: &
      36             :         stat_assign ! Procedure
      37             : 
      38             :     use parameters_model, only: &
      39             :         hydromet_dim, & ! Variable(s)
      40             :         sclr_dim,     &
      41             :         edsclr_dim
      42             : 
      43             :     use array_index, only: &
      44             :         hydromet_list, & ! Variable(s)
      45             :         l_mix_rat_hm
      46             : 
      47             :     use stats_type, only: &
      48             :         stats ! Type
      49             : 
      50             :     use stats_variables, only: &
      51             :         stats_metadata_type
      52             : 
      53             :     implicit none
      54             : 
      55             :     ! External
      56             :     intrinsic :: trim
      57             : 
      58             :     !--------------------- Input Variable ---------------------
      59             :     character(len= * ), dimension(nvarmax_zm), intent(in) :: &
      60             :       vars_zm ! stats_zm variable names
      61             : 
      62             :     !--------------------- InOut Variables ---------------------      
      63             :     type (stats_metadata_type), intent(inout) :: &
      64             :       stats_metadata
      65             : 
      66             :     type (stats), target, intent(inout) :: &
      67             :       stats_zm
      68             : 
      69             :     logical, intent(inout) :: l_error
      70             : 
      71             :     !--------------------- Local Varables ---------------------
      72             :     integer :: tot_zm_loops
      73             : 
      74             :     integer :: hm_idx, hmx_idx, hmy_idx
      75             : 
      76             :     character(len=10) :: hm_type, hmx_type, hmy_type
      77             : 
      78             :     integer :: i, j, k
      79             : 
      80             :     character(len=50) :: sclr_idx
      81             : 
      82             :     !--------------------- Begin Code ---------------------
      83             : 
      84             :     ! The default initialization for array indices for stats_zm is zero (see module
      85             :     ! stats_variables)
      86             : 
      87             :     ! If any of the index arrays are allocated, then we have called this before
      88             :     ! to set up stats_metadata, so all we want to do is set stats_zm via stats_assign
      89           0 :     if ( .not. allocated(stats_metadata%ihydrometp2) ) then
      90             : 
      91           0 :       allocate( stats_metadata%ihydrometp2(1:hydromet_dim) )
      92           0 :       allocate( stats_metadata%iwphydrometp(1:hydromet_dim) )
      93           0 :       allocate( stats_metadata%irtphmp(1:hydromet_dim) )
      94           0 :       allocate( stats_metadata%ithlphmp(1:hydromet_dim) )
      95           0 :       allocate( stats_metadata%ihmxphmyp(1:hydromet_dim,1:hydromet_dim) )
      96           0 :       allocate( stats_metadata%iK_hm(1:hydromet_dim) )
      97             : 
      98           0 :       stats_metadata%ihydrometp2(:) = 0
      99           0 :       stats_metadata%iwphydrometp(:) = 0
     100           0 :       stats_metadata%irtphmp(:) = 0
     101           0 :       stats_metadata%ithlphmp(:) = 0
     102           0 :       stats_metadata%ihmxphmyp(:,:) = 0
     103           0 :       stats_metadata%iK_hm(:) = 0
     104             : 
     105             :       ! Allocate and then zero out passive scalar arrays on the stats_zm grid (fluxes,
     106             :       ! variances and other high-order moments)
     107           0 :       allocate( stats_metadata%isclrprtp(1:sclr_dim) )
     108           0 :       allocate( stats_metadata%isclrp2(1:sclr_dim) )
     109           0 :       allocate( stats_metadata%isclrpthvp(1:sclr_dim) )
     110           0 :       allocate( stats_metadata%isclrpthlp(1:sclr_dim) )
     111           0 :       allocate( stats_metadata%isclrprcp(1:sclr_dim) )
     112           0 :       allocate( stats_metadata%iwpsclrp(1:sclr_dim) )
     113           0 :       allocate( stats_metadata%iwp2sclrp(1:sclr_dim) )
     114           0 :       allocate( stats_metadata%iwpsclrp2(1:sclr_dim) )
     115           0 :       allocate( stats_metadata%iwpsclrprtp(1:sclr_dim) )
     116           0 :       allocate( stats_metadata%iwpsclrpthlp(1:sclr_dim) )
     117           0 :       allocate( stats_metadata%iwpedsclrp(1:edsclr_dim) )
     118             : 
     119           0 :       stats_metadata%isclrprtp(:)    = 0
     120           0 :       stats_metadata%isclrp2(:)      = 0
     121           0 :       stats_metadata%isclrpthvp(:)   = 0
     122           0 :       stats_metadata%isclrpthlp(:)   = 0
     123           0 :       stats_metadata%isclrprcp(:)    = 0
     124           0 :       stats_metadata%iwpsclrp(:)     = 0
     125           0 :       stats_metadata%iwp2sclrp(:)    = 0
     126           0 :       stats_metadata%iwpsclrp2(:)    = 0
     127           0 :       stats_metadata%iwpsclrprtp(:)  = 0
     128           0 :       stats_metadata%iwpsclrpthlp(:) = 0
     129           0 :       stats_metadata%iwpedsclrp(:)   = 0
     130             : 
     131             :     end if
     132             : 
     133             :     ! Assign pointers for statistics variables stats_zm using stat_assign
     134             : 
     135           0 :     tot_zm_loops = stats_zm%num_output_fields
     136             : 
     137           0 :     if ( any( vars_zm == "hydrometp2" ) ) then
     138             :        ! Correct for number of variables found under "hydrometp2".
     139             :        ! Subtract 1 from the loop size for each hydrometeor.
     140           0 :        tot_zm_loops = tot_zm_loops - hydromet_dim
     141             :        ! Add 1 for "hydrometp2" to the loop size.
     142           0 :        tot_zm_loops = tot_zm_loops + 1
     143             :     endif
     144             : 
     145           0 :     if ( any( vars_zm == "wphydrometp" ) ) then
     146             :        ! Correct for number of variables found under "wphydrometp".
     147             :        ! Subtract 1 from the loop size for each hydrometeor.
     148           0 :        tot_zm_loops = tot_zm_loops - hydromet_dim
     149             :        ! Add 1 for "wphydrometp" to the loop size.
     150           0 :        tot_zm_loops = tot_zm_loops + 1
     151             :     endif
     152             : 
     153           0 :     if ( any( vars_zm == "rtphmp" ) ) then
     154             :        ! Correct for number of variables found under "rtphmp".
     155             :        ! Subtract 1 from the loop size for each hydrometeor.
     156           0 :        tot_zm_loops = tot_zm_loops - hydromet_dim
     157             :        ! Add 1 for "rtphmp" to the loop size.
     158           0 :        tot_zm_loops = tot_zm_loops + 1
     159             :     endif
     160             : 
     161           0 :     if ( any( vars_zm == "thlphmp" ) ) then
     162             :        ! Correct for number of variables found under "thlphmp".
     163             :        ! Subtract 1 from the loop size for each hydrometeor.
     164           0 :        tot_zm_loops = tot_zm_loops - hydromet_dim
     165             :        ! Add 1 for "thlphmp" to the loop size.
     166           0 :        tot_zm_loops = tot_zm_loops + 1
     167             :     endif
     168             : 
     169           0 :     if ( any( vars_zm == "hmxphmyp" ) ) then
     170             :        ! Correct for number of variables found under "hmxphmyp".
     171             :        ! Subtract the number of overall covariances of two hydrometeors, which
     172             :        ! is found by:  (1/2) * hydromet_dim * ( hydromet_dim - 1 );
     173             :        ! from the loop size.
     174           0 :        tot_zm_loops = tot_zm_loops - hydromet_dim * ( hydromet_dim - 1 ) / 2
     175             :        ! Add 1 for "hmxphmyp" to the loop size.
     176           0 :        tot_zm_loops = tot_zm_loops + 1
     177             :     endif
     178             : 
     179           0 :     if ( any( vars_zm == "K_hm" ) ) then
     180             :        ! Correct for number of variables found under "K_hm".
     181             :        ! Subtract 1 from the loop size for each hydrometeor.
     182           0 :        tot_zm_loops = tot_zm_loops - hydromet_dim
     183             :        ! Add 1 for "K_hm" to the loop size.
     184           0 :        tot_zm_loops = tot_zm_loops + 1
     185             :     endif
     186             : 
     187           0 :      if ( any( vars_zm == "sclrprtp" ) ) then
     188             :        ! Correct for number of variables found under "sclrprtp".
     189             :        ! Subtract 1 from the loop size for each scalar.
     190           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     191             :        ! Add 1 for "sclrprtp" to the loop size.
     192           0 :        tot_zm_loops = tot_zm_loops + 1
     193             :     endif
     194             : 
     195           0 :     if ( any( vars_zm == "sclrp2" ) ) then
     196             :        ! Correct for number of variables found under "sclrp2".
     197             :        ! Subtract 1 from the loop size for each scalar.
     198           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     199             :        ! Add 1 for "sclrp2" to the loop size.
     200           0 :        tot_zm_loops = tot_zm_loops + 1
     201             :     endif
     202             : 
     203           0 :     if ( any( vars_zm == "sclrpthvp" ) ) then
     204             :        ! Correct for number of variables found under "sclrpthvp".
     205             :        ! Subtract 1 from the loop size for each scalar.
     206           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     207             :        ! Add 1 for "sclrpthvp" to the loop size.
     208           0 :        tot_zm_loops = tot_zm_loops + 1
     209             :     endif
     210             : 
     211           0 :     if ( any( vars_zm == "sclrpthlp" ) ) then
     212             :        ! Correct for number of variables found under "sclrpthlp".
     213             :        ! Subtract 1 from the loop size for each scalar.
     214           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     215             :        ! Add 1 for "sclrpthlp" to the loop size.
     216           0 :        tot_zm_loops = tot_zm_loops + 1
     217             :     endif
     218             : 
     219           0 :     if ( any( vars_zm == "sclrprcp" ) ) then
     220             :        ! Correct for number of variables found under "sclrprcp".
     221             :        ! Subtract 1 from the loop size for each scalar.
     222           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     223             :        ! Add 1 for "sclrprcp" to the loop size.
     224           0 :        tot_zm_loops = tot_zm_loops + 1
     225             :     endif
     226             : 
     227           0 :     if ( any( vars_zm == "wpsclrp" ) ) then
     228             :        ! Correct for number of variables found under "wpsclrp".
     229             :        ! Subtract 1 from the loop size for each scalar.
     230           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     231             :        ! Add 1 for "wpsclrp" to the loop size.
     232           0 :        tot_zm_loops = tot_zm_loops + 1
     233             :     endif
     234             : 
     235           0 :     if ( any( vars_zm == "wpsclrp2" ) ) then
     236             :        ! Correct for number of variables found under "wpsclrp2".
     237             :        ! Subtract 1 from the loop size for each scalar.
     238           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     239             :        ! Add 1 for "wpsclrp2" to the loop size.
     240           0 :        tot_zm_loops = tot_zm_loops + 1
     241             :     endif
     242             : 
     243           0 :     if ( any( vars_zm == "wp2sclrp" ) ) then
     244             :        ! Correct for number of variables found under "wp2sclrp".
     245             :        ! Subtract 1 from the loop size for each scalar.
     246           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     247             :        ! Add 1 for "wp2sclrp" to the loop size.
     248           0 :        tot_zm_loops = tot_zm_loops + 1
     249             :     endif
     250             : 
     251           0 :     if ( any( vars_zm == "wpsclrprtp" ) ) then
     252             :        ! Correct for number of variables found under "wpsclrprtp".
     253             :        ! Subtract 1 from the loop size for each scalar.
     254           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     255             :        ! Add 1 for "wpsclrprtp" to the loop size.
     256           0 :        tot_zm_loops = tot_zm_loops + 1
     257             :     endif
     258             : 
     259           0 :     if ( any( vars_zm == "wpsclrpthlp" ) ) then
     260             :        ! Correct for number of variables found under "wpsclrpthlp".
     261             :        ! Subtract 1 from the loop size for each scalar.
     262           0 :        tot_zm_loops = tot_zm_loops - sclr_dim
     263             :        ! Add 1 for "wpsclrpthlp" to the loop size.
     264           0 :        tot_zm_loops = tot_zm_loops + 1
     265             :     endif
     266             : 
     267           0 :     if ( any( vars_zm == "wpedsclrp" ) ) then
     268             :        ! Correct for number of variables found under "wpedsclrp".
     269             :        ! Subtract 1 from the loop size for each scalar.
     270           0 :        tot_zm_loops = tot_zm_loops - edsclr_dim
     271             :        ! Add 1 for "wpedsclrp" to the loop size.
     272           0 :        tot_zm_loops = tot_zm_loops + 1
     273             :   endif
     274             : 
     275             : 
     276             : 
     277           0 :     k = 1
     278             : 
     279           0 :     do i = 1, tot_zm_loops
     280             : 
     281           0 :       select case ( trim( vars_zm(i) ) )
     282             : 
     283             :       case ('wp2')
     284           0 :         stats_metadata%iwp2 = k
     285             :         call stat_assign( var_index=stats_metadata%iwp2, var_name="wp2", &
     286             :              var_description="w'^2, Variance of vertical air velocity", &
     287           0 :              var_units="m^2/s^2", l_silhs=.false., grid_kind=stats_zm )
     288           0 :         k = k + 1
     289             : 
     290             :       case ('rtp2')
     291           0 :         stats_metadata%irtp2 = k
     292             :         call stat_assign( var_index=stats_metadata%irtp2, var_name="rtp2", &
     293             :              var_description="rt'^2, Variance of total water, rt", var_units="(kg/kg)^2", &
     294           0 :              l_silhs=.false., grid_kind=stats_zm )
     295           0 :         k = k + 1
     296             : 
     297             :       case ('thlp2')
     298           0 :         stats_metadata%ithlp2 = k
     299             :         call stat_assign( var_index=stats_metadata%ithlp2, var_name="thlp2", &
     300             :              var_description="thl'^2, Variance of theta_l", var_units="K^2", l_silhs=.false., &
     301           0 :              grid_kind=stats_zm )
     302           0 :         k = k + 1
     303             : 
     304             :       case ('rtpthlp')
     305           0 :         stats_metadata%irtpthlp = k
     306             :         call stat_assign( var_index=stats_metadata%irtpthlp, var_name="rtpthlp", &
     307             :              var_description="rt'thl', Covariance of rt and theta_l", &
     308           0 :              var_units="(kg K)/kg", l_silhs=.false., grid_kind=stats_zm )
     309           0 :         k = k + 1
     310             : 
     311             :       case ('wprtp')
     312           0 :         stats_metadata%iwprtp = k
     313             : 
     314             :         call stat_assign( var_index=stats_metadata%iwprtp, var_name="wprtp", &
     315             :              var_description="w'rt', Vertical turbulent flux of total water, rt", &
     316           0 :              var_units="(m kg)/(s kg)", l_silhs=.false., grid_kind=stats_zm )
     317           0 :         k = k + 1
     318             : 
     319             :       case ('wpthlp')
     320           0 :         stats_metadata%iwpthlp = k
     321             : 
     322             :         call stat_assign( var_index=stats_metadata%iwpthlp, var_name="wpthlp", &
     323             :              var_description="w'thl', Vertical turbulent flux of theta_l", &
     324           0 :              var_units="(m K)/s", l_silhs=.false., grid_kind=stats_zm )
     325           0 :         k = k + 1
     326             : 
     327             :       case ('wp3_zm')
     328           0 :         stats_metadata%iwp3_zm = k
     329             :         call stat_assign( var_index=stats_metadata%iwp3_zm, var_name="wp3_zm", &
     330             :              var_description="w'^3_zm, w'^3 interpolated to moment. levels", &
     331           0 :              var_units="(m^3)/(s^3)", l_silhs=.false., grid_kind=stats_zm )
     332           0 :         k = k + 1
     333             : 
     334             :       case ('thlp3_zm')
     335           0 :         stats_metadata%ithlp3_zm = k
     336             :         call stat_assign( var_index=stats_metadata%ithlp3_zm, var_name="thlp3_zm", &
     337             :              var_description="thl'^3 interpolated to moment. levels", &
     338           0 :              var_units="K^3", l_silhs=.false., grid_kind=stats_zm )
     339           0 :         k = k + 1
     340             : 
     341             :       case ('rtp3_zm')
     342           0 :         stats_metadata%irtp3_zm = k
     343             :         call stat_assign( var_index=stats_metadata%irtp3_zm, var_name="rtp3_zm", &
     344             :              var_description="rt'^3 interpolated to moment. levels", &
     345           0 :              var_units="(kg^3)/(kg^3)", l_silhs=.false., grid_kind=stats_zm )
     346           0 :         k = k + 1
     347             : 
     348             :       case ('wp2up2')
     349           0 :         stats_metadata%iwp2up2 = k
     350             :         call stat_assign( var_index=stats_metadata%iwp2up2, var_name="wp2up2", &
     351             :              var_description="w'^2u'^2, 4th-order moment of vertical and zonal air velocity", &
     352           0 :              var_units="(m^4)/(s^4)", l_silhs=.false., grid_kind=stats_zm )
     353           0 :         k = k + 1
     354             : 
     355             :       case ('wp2vp2')
     356           0 :         stats_metadata%iwp2vp2 = k
     357             :         call stat_assign( var_index=stats_metadata%iwp2vp2, var_name="wp2vp2", &
     358             :              var_description &
     359             :                ="w'^2v'^2, 4th-order moment of vert. and merid. air velocity", &
     360           0 :              var_units="(m^4)/(s^4)", l_silhs=.false., grid_kind=stats_zm )
     361           0 :         k = k + 1
     362             : 
     363             :       case ('wp4')
     364           0 :         stats_metadata%iwp4 = k
     365             :         call stat_assign( var_index=stats_metadata%iwp4, var_name="wp4", &
     366             :              var_description="w'^4, Fourth-order moment of vertical air velocity", &
     367           0 :              var_units="(m^4)/(s^4)", l_silhs=.false., grid_kind=stats_zm )
     368           0 :         k = k + 1
     369             : 
     370             :       case ('wpthvp')
     371           0 :         stats_metadata%iwpthvp = k
     372             :         call stat_assign( var_index=stats_metadata%iwpthvp, var_name="wpthvp", &
     373             :              var_description="w'thv', Buoyancy flux", var_units="K m/s", l_silhs=.false., &
     374           0 :              grid_kind=stats_zm )
     375           0 :         k = k + 1
     376             : 
     377             :       case ('rtpthvp')
     378           0 :         stats_metadata%irtpthvp = k
     379             :         call stat_assign( var_index=stats_metadata%irtpthvp, var_name="rtpthvp", &
     380             :              var_description="rt'thv', Covariance of rt and theta_v", var_units="(kg/kg) K", &
     381             :              l_silhs=.false., &
     382           0 :              grid_kind=stats_zm )
     383           0 :         k = k + 1
     384             : 
     385             :       case ('thlpthvp')
     386           0 :         stats_metadata%ithlpthvp = k
     387             :         call stat_assign( var_index=stats_metadata%ithlpthvp, var_name="thlpthvp", &
     388             :           var_description="thl'thv', Covariance of theta_l and theta_v", var_units="K^2", &
     389           0 :           l_silhs=.false., grid_kind=stats_zm )
     390           0 :         k = k + 1
     391             : 
     392             :       case ('tau_zm')
     393           0 :         stats_metadata%itau_zm = k
     394             : 
     395             :         call stat_assign( var_index=stats_metadata%itau_zm, var_name="tau_zm", &
     396             :              var_description="tau_zm, Time-scale tau on momentum levels", var_units="s", &
     397           0 :              l_silhs=.false., grid_kind=stats_zm )
     398           0 :         k = k + 1
     399             : 
     400             :       case ('invrs_tau_zm')
     401           0 :         stats_metadata%iinvrs_tau_zm = k
     402             : 
     403             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_zm, var_name="invrs_tau_zm", &
     404             :              var_description="invrs tau on momentum levels [s-1]", &
     405           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     406           0 :         k = k + 1
     407             : 
     408             :       case ('invrs_tau_xp2_zm')
     409           0 :         stats_metadata%iinvrs_tau_xp2_zm = k
     410             : 
     411             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_xp2_zm, var_name="invrs_tau_xp2_zm", &
     412             :              var_description="invrs tau xp2 on momentum levels [s-1]", &
     413           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     414           0 :         k = k + 1
     415             : 
     416             :       case ('invrs_tau_wp2_zm')
     417           0 :         stats_metadata%iinvrs_tau_wp2_zm = k
     418             : 
     419             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_wp2_zm, var_name="invrs_tau_wp2_zm", &
     420             :              var_description="invrs tau wp2 on momentum levels [s-1]", &
     421           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     422           0 :         k = k + 1
     423             : 
     424             :       case ('invrs_tau_wpxp_zm')
     425           0 :         stats_metadata%iinvrs_tau_wpxp_zm = k
     426             : 
     427             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_wpxp_zm, var_name="invrs_tau_wpxp_zm", &
     428             :              var_description="invrs tau wpxp on momentum levels [s-1]", &
     429           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     430           0 :         k = k + 1
     431             : 
     432             :       case ('invrs_tau_wp3_zm')
     433           0 :         stats_metadata%iinvrs_tau_wp3_zm = k
     434             : 
     435             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_wp3_zm, var_name="invrs_tau_wp3_zm", &
     436             :              var_description="invrs tau wp3 on momentum levels [s-1]", &
     437           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     438           0 :         k = k + 1
     439             : 
     440             :       case ('invrs_tau_no_N2_zm')
     441           0 :         stats_metadata%iinvrs_tau_no_N2_zm = k
     442             : 
     443             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_no_N2_zm, var_name="invrs_tau_no_N2_zm", &
     444             :              var_description="invrs tau_no_N2 on momentum levels [s-1]", &
     445           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     446           0 :         k = k + 1
     447             : 
     448             :       case ('invrs_tau_bkgnd')
     449           0 :         stats_metadata%iinvrs_tau_bkgnd = k
     450             : 
     451             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_bkgnd, var_name="invrs_tau_bkgnd", &
     452             :              var_description="invrs tau of bkgnd on momentum levels [s-1]", &
     453           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     454           0 :         k = k + 1
     455             : 
     456             :       case ('invrs_tau_sfc')
     457           0 :         stats_metadata%iinvrs_tau_sfc = k
     458             : 
     459             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_sfc, var_name="invrs_tau_sfc", &
     460             :              var_description="invrs tau of surface on momentum levels [s-1]", &
     461           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     462           0 :         k = k + 1
     463             : 
     464             :       case ('invrs_tau_shear')
     465           0 :         stats_metadata%iinvrs_tau_shear = k
     466             : 
     467             :         call stat_assign( var_index=stats_metadata%iinvrs_tau_shear, var_name="invrs_tau_shear", &
     468             :              var_description="invrs tau of shear on momentum levels [s-1]", &
     469           0 :              var_units="s^-1", l_silhs=.false., grid_kind=stats_zm )
     470           0 :         k = k + 1
     471             : 
     472             :       case ('Kh_zm')
     473           0 :         stats_metadata%iKh_zm = k
     474             : 
     475             :         call stat_assign( var_index=stats_metadata%iKh_zm, var_name="Kh_zm", &
     476             :              var_description="Kh_zm, Eddy diffusivity on momentum levels", &
     477           0 :              var_units="m^2/s", l_silhs=.false., grid_kind=stats_zm )
     478           0 :         k = k + 1
     479             : 
     480             :       case ('K_hm')
     481             : 
     482           0 :          do hm_idx = 1, hydromet_dim, 1
     483             : 
     484           0 :             hm_type = hydromet_list(hm_idx)
     485             : 
     486           0 :             stats_metadata%iK_hm(hm_idx) = k
     487             : 
     488             : 
     489           0 :             call stat_assign( var_index=stats_metadata%iK_hm(hm_idx), &
     490             :                                  var_name="K_hm_"//trim( hm_type(1:2) ), &
     491             :                                  var_description="Eddy. diff. coef. of "  &
     492             :                                  // trim(hm_type(1:2)) &
     493             :                                  // " [m^2/s]", &
     494             :                                  var_units="[m^2/s]", &
     495           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     496             : 
     497           0 :             k = k + 1
     498             : 
     499             :           end do
     500             : 
     501             : 
     502             :       case ('wprcp')
     503           0 :         stats_metadata%iwprcp = k
     504             :         call stat_assign( var_index=stats_metadata%iwprcp, var_name="wprcp", &
     505             :              var_description="w'rc'", var_units="(m/s) (kg/kg)", &
     506           0 :              l_silhs=.false., grid_kind=stats_zm )
     507           0 :         k = k + 1
     508             : 
     509             :       case ('rc_coef_zm')
     510           0 :         stats_metadata%irc_coef_zm = k
     511             :         call stat_assign( var_index=stats_metadata%irc_coef_zm, var_name="rc_coef_zm", &
     512             :              var_description="rc_coef_zm, Coefficient of X'r_c'", &
     513           0 :              var_units="K/(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
     514           0 :         k = k + 1
     515             : 
     516             :       case ('thlprcp')
     517           0 :         stats_metadata%ithlprcp = k
     518             :         call stat_assign( var_index=stats_metadata%ithlprcp, var_name="thlprcp", &
     519             :              var_description="thl'rc'", var_units="K (kg/kg)", l_silhs=.false., &
     520           0 :              grid_kind=stats_zm )
     521           0 :         k = k + 1
     522             : 
     523             :       case ('rtprcp')
     524           0 :         stats_metadata%irtprcp = k
     525             : 
     526             :         call stat_assign( var_index=stats_metadata%irtprcp, var_name="rtprcp", &
     527             :              var_description="rt'rc'", var_units="(kg^2)/(kg^2)", &
     528           0 :              l_silhs=.false., grid_kind=stats_zm )
     529           0 :         k = k + 1
     530             : 
     531             :       case ('rcp2')
     532           0 :         stats_metadata%ircp2 = k
     533             :         call stat_assign( var_index=stats_metadata%ircp2, var_name="rcp2", &
     534             :              var_description="rc'^2, Variance of cloud water mixing ratio", &
     535             :              var_units="(kg^2)/(kg^2)", l_silhs=.false., &
     536           0 :              grid_kind=stats_zm )
     537           0 :         k = k + 1
     538             :       case ('upwp')
     539           0 :         stats_metadata%iupwp = k
     540             :         call stat_assign( var_index=stats_metadata%iupwp, var_name="upwp", &
     541             :              var_description="u'w', Vertical turbulent flux of eastward (u) wind", &
     542           0 :              var_units="m^2/s^2", l_silhs=.false., grid_kind=stats_zm )
     543           0 :         k = k + 1
     544             :       case ('vpwp')
     545           0 :         stats_metadata%ivpwp = k
     546             :         call stat_assign( var_index=stats_metadata%ivpwp, var_name="vpwp", &
     547             :              var_description="v'w', Vertical turbulent flux of northward (v) wind", &
     548           0 :              var_units="m^2/s^2", l_silhs=.false., grid_kind=stats_zm )
     549           0 :         k = k + 1
     550             :       case ('upthlp')
     551           0 :         stats_metadata%iupthlp = k
     552             :         call stat_assign( var_index=stats_metadata%iupthlp, var_name="upthlp", &
     553             :              var_description="u'thl', Eastward theta_l flux", &
     554           0 :              var_units="(m/s)K", l_silhs=.false., grid_kind=stats_zm )
     555           0 :         k = k + 1
     556             :       case ('uprtp')
     557           0 :         stats_metadata%iuprtp = k
     558             :         call stat_assign( var_index=stats_metadata%iuprtp, var_name="uprtp", &
     559             :              var_description="u'rt', Eastward total water flux", &
     560           0 :              var_units="(m/s)(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
     561           0 :         k = k + 1
     562             :       case ('vpthlp')
     563           0 :         stats_metadata%ivpthlp = k
     564             :         call stat_assign( var_index=stats_metadata%ivpthlp, var_name="vpthlp", &
     565             :              var_description="v'thl', Northward theta_l flux", &
     566           0 :              var_units="(m/s)K", l_silhs=.false., grid_kind=stats_zm )
     567           0 :         k = k + 1
     568             :       case ('vprtp')
     569           0 :         stats_metadata%ivprtp = k
     570             :         call stat_assign( var_index=stats_metadata%ivprtp, var_name="vprtp", &
     571             :              var_description="v'rt', Northward total water flux", &
     572           0 :              var_units="(m/s)(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
     573           0 :         k = k + 1
     574             :       case ('upthvp')
     575           0 :         stats_metadata%iupthvp = k
     576             :         call stat_assign( var_index=stats_metadata%iupthvp, var_name="upthvp", &
     577             :              var_description="u'thv', Eastward theta_v flux", &
     578           0 :              var_units="(m/s)K", l_silhs=.false., grid_kind=stats_zm )
     579           0 :         k = k + 1
     580             :       case ('uprcp')
     581           0 :         stats_metadata%iuprcp = k
     582             :         call stat_assign( var_index=stats_metadata%iuprcp, var_name="uprcp", &
     583             :              var_description="u'rc', Eastward liquid water flux", &
     584           0 :              var_units="(m/s)(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
     585           0 :         k = k + 1
     586             :       case ('vpthvp')
     587           0 :         stats_metadata%ivpthvp = k
     588             :         call stat_assign( var_index=stats_metadata%ivpthvp, var_name="vpthvp", &
     589             :              var_description="v'thv', Northward theta_v flux", &
     590           0 :              var_units="(m/s)K", l_silhs=.false., grid_kind=stats_zm )
     591           0 :         k = k + 1
     592             :       case ('vprcp')
     593           0 :         stats_metadata%ivprcp = k
     594             :         call stat_assign( var_index=stats_metadata%ivprcp, var_name="vprcp", &
     595             :              var_description="v'rc', Northward liquid water flux", &
     596           0 :              var_units="(m/s)(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
     597           0 :         k = k + 1
     598             :       case ('rho_zm')
     599           0 :         stats_metadata%irho_zm = k
     600             :         call stat_assign( var_index=stats_metadata%irho_zm, var_name="rho_zm", &
     601             :              var_description="rho_zm, Density on momentum levels", var_units="kg m^{-3}", &
     602           0 :              l_silhs=.false., grid_kind=stats_zm )
     603           0 :         k = k + 1
     604             :       case ('sigma_sqd_w')
     605           0 :         stats_metadata%isigma_sqd_w = k
     606             :         call stat_assign( var_index=stats_metadata%isigma_sqd_w, var_name="sigma_sqd_w", &
     607             :              var_description="sigma_sqd_w, Nondim w variance of Gaussian component", &
     608           0 :              var_units="-", l_silhs=.false., grid_kind=stats_zm )
     609           0 :         k = k + 1
     610             :       case ('rho_ds_zm')
     611           0 :         stats_metadata%irho_ds_zm = k
     612             :         call stat_assign( var_index=stats_metadata%irho_ds_zm, var_name="rho_ds_zm", &
     613             :              var_description="rho_ds_zm, Dry static, base-state density", var_units="kg m^{-3}", &
     614           0 :              l_silhs=.false., grid_kind=stats_zm )
     615           0 :         k = k + 1
     616             :       case ('thv_ds_zm')
     617           0 :         stats_metadata%ithv_ds_zm = k
     618             :         call stat_assign( var_index=stats_metadata%ithv_ds_zm, var_name="thv_ds_zm", &
     619             :              var_description="thv_ds_zm, Dry, base-state theta_v", var_units="K", l_silhs=.false.,&
     620           0 :              grid_kind=stats_zm )
     621           0 :         k = k + 1
     622             :       case ('em')
     623           0 :         stats_metadata%iem = k
     624             :         call stat_assign( var_index=stats_metadata%iem, var_name="em", &
     625             :              var_description="em, Turbulent kinetic energy, usu. 0.5*(u'^2+v'^2+w'^2)", &
     626           0 :              var_units="m^2/s^2", l_silhs=.false., grid_kind=stats_zm )
     627           0 :         k = k + 1
     628             :       case ('shear')      ! Brian
     629           0 :         stats_metadata%ishear = k
     630             :         call stat_assign( var_index=stats_metadata%ishear, var_name="shear", &
     631             :              var_description="shear, Wind shear production term", var_units="m^2/s^3", &
     632           0 :              l_silhs=.false., grid_kind=stats_zm )
     633           0 :         k = k + 1
     634             :       case ('mean_w_up')
     635           0 :         stats_metadata%imean_w_up = k
     636             :         call stat_assign( var_index=stats_metadata%imean_w_up, var_name="mean_w_up", &
     637             :              var_description="mean_w_up, Mean w >= w_ref", var_units="m/s", l_silhs=.false., &
     638           0 :              grid_kind=stats_zm )
     639           0 :         k = k + 1
     640             :       case ('mean_w_down')
     641           0 :         stats_metadata%imean_w_down = k
     642             :         call stat_assign( var_index=stats_metadata%imean_w_down, var_name="mean_w_down", &
     643             :              var_description="mean_w_down, Mean w <= w_ref", var_units="m/s", l_silhs=.false., &
     644           0 :              grid_kind=stats_zm )
     645           0 :         k = k + 1
     646             :       case ('Frad')
     647           0 :         stats_metadata%iFrad = k
     648             :         call stat_assign( var_index=stats_metadata%iFrad, var_name="Frad", &
     649             :              var_description="Frad, Total (sw+lw) net (up+down) radiative flux", &
     650           0 :              var_units="W/m^2", l_silhs=.false., grid_kind=stats_zm )
     651           0 :         k = k + 1
     652             :       case ('Frad_LW')    ! Brian
     653           0 :         stats_metadata%iFrad_LW = k
     654             :         call stat_assign( var_index=stats_metadata%iFrad_LW, var_name="Frad_LW", &
     655             :              var_description="Frad_LW, Net long-wave radiative flux", var_units="W/m^2", &
     656           0 :              l_silhs=.false., grid_kind=stats_zm )
     657           0 :         k = k + 1
     658             :       case ('Frad_SW')    ! Brian
     659           0 :         stats_metadata%iFrad_SW = k
     660             : 
     661             :         call stat_assign( var_index=stats_metadata%iFrad_SW, var_name="Frad_SW", &
     662             :              var_description="Frad_SW, Net short-wave radiative flux", var_units="W/m^2", &
     663           0 :              l_silhs=.false., grid_kind=stats_zm )
     664           0 :         k = k + 1
     665             : 
     666             :       case ('Frad_LW_up')    ! Brian
     667           0 :         stats_metadata%iFrad_LW_up = k
     668             :         call stat_assign( var_index=stats_metadata%iFrad_LW_up, var_name="Frad_LW_up", &
     669             :              var_description="Frad_LW_up, Long-wave upwelling radiative flux", &
     670             :              var_units="W/m^2", &
     671           0 :              l_silhs=.false., grid_kind=stats_zm )
     672           0 :         k = k + 1
     673             :       case ('Frad_SW_up')    ! Brian
     674           0 :         stats_metadata%iFrad_SW_up = k
     675             : 
     676             :         call stat_assign( var_index=stats_metadata%iFrad_SW_up, var_name="Frad_SW_up", &
     677             :              var_description="Frad_SW_up, Short-wave upwelling radiative flux", &
     678             :              var_units="W/m^2", &
     679           0 :              l_silhs=.false., grid_kind=stats_zm )
     680           0 :         k = k + 1
     681             : 
     682             :       case ('Frad_LW_down')    ! Brian
     683           0 :         stats_metadata%iFrad_LW_down = k
     684             :         call stat_assign( var_index=stats_metadata%iFrad_LW_down, var_name="Frad_LW_down", &
     685             :              var_description="Frad_LW_down, Long-wave downwelling radiative flux", &
     686             :              var_units="W/m^2", &
     687           0 :              l_silhs=.false., grid_kind=stats_zm )
     688           0 :         k = k + 1
     689             :       case ('Frad_SW_down')    ! Brian
     690           0 :         stats_metadata%iFrad_SW_down = k
     691             : 
     692             :         call stat_assign( var_index=stats_metadata%iFrad_SW_down, var_name="Frad_SW_down", &
     693             :              var_description="Frad_SW_down, Short-wave downwelling radiative flux", &
     694             :              var_units="W/m^2", &
     695           0 :              l_silhs=.false., grid_kind=stats_zm )
     696           0 :         k = k + 1
     697             : 
     698             : 
     699             :       case ('Fprec')      ! Brian
     700           0 :         stats_metadata%iFprec = k
     701             : 
     702             :         call stat_assign( var_index=stats_metadata%iFprec, var_name="Fprec", &
     703             :              var_description="Fprec, Rain flux", var_units="W/m^2", l_silhs=.false., &
     704           0 :              grid_kind=stats_zm )
     705           0 :         k = k + 1
     706             : 
     707             :       case ('Fcsed')      ! Brian
     708           0 :         stats_metadata%iFcsed = k
     709             : 
     710             :         call stat_assign( var_index=stats_metadata%iFcsed, var_name="Fcsed", &
     711             :              var_description="Fcsed, cloud water sedimentation flux", &
     712           0 :              var_units="kg/(s*m^2)", l_silhs=.false., grid_kind=stats_zm )
     713           0 :         k = k + 1
     714             : 
     715             :       case('hydrometp2')
     716             : 
     717           0 :          do hm_idx = 1, hydromet_dim, 1
     718             : 
     719           0 :             hm_type = hydromet_list(hm_idx)
     720             : 
     721             :             ! The overall variance of the hydrometeor.
     722           0 :             stats_metadata%ihydrometp2(hm_idx) = k
     723             : 
     724           0 :             if ( l_mix_rat_hm(hm_idx) ) then
     725             : 
     726           0 :                call stat_assign( var_index=stats_metadata%ihydrometp2(hm_idx), &
     727             :                                  var_name=trim( hm_type(1:2) )//"p2", &
     728             :                                  var_description="<" &
     729             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     730             :                                  // "'^2> [(kg/kg)^2]", &
     731             :                                  var_units="(kg/kg)^2", &
     732           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     733             : 
     734             :             else ! Concentration
     735             : 
     736           0 :                call stat_assign( var_index=stats_metadata%ihydrometp2(hm_idx), &
     737             :                                  var_name=trim( hm_type(1:2) )//"p2", &
     738             :                                  var_description="<" &
     739             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     740             :                                  // "'^2> [(num/kg)^2]", &
     741             :                                  var_units="(num/kg)^2", &
     742           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     743             : 
     744             :             endif ! l_mix_rat_hm(hm_idx)
     745             : 
     746           0 :             k = k + 1
     747             : 
     748             :          enddo ! hm_idx = 1, hydromet_dim, 1
     749             : 
     750             :       case ('wphydrometp')
     751             : 
     752           0 :          do hm_idx = 1, hydromet_dim, 1
     753             : 
     754           0 :             hm_type = hydromet_list(hm_idx)
     755             : 
     756           0 :             stats_metadata%iwphydrometp(hm_idx) = k
     757             : 
     758           0 :             if ( l_mix_rat_hm(hm_idx) ) then
     759             : 
     760           0 :                call stat_assign( var_index=stats_metadata%iwphydrometp(hm_idx), &
     761             :                                  var_name="wp"//trim( hm_type(1:2) )//"p", &
     762             :                                  var_description="Covariance of w and " &
     763             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     764             :                                  // " [(m/s) kg/kg]", &
     765             :                                  var_units="(m/s) kg/kg", &
     766           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     767             : 
     768             :             else ! Concentration
     769             : 
     770           0 :                call stat_assign( var_index=stats_metadata%iwphydrometp(hm_idx), &
     771             :                                  var_name="wp"//trim( hm_type(1:2) )//"p", &
     772             :                                  var_description="Covariance of w and " &
     773             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     774             :                                  // " [(m/s) num/kg]", &
     775             :                                  var_units="(m/s) num/kg", &
     776           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     777             : 
     778             :             endif ! l_mix_rat_hm(hm_idx)
     779             : 
     780           0 :             k = k + 1
     781             : 
     782             :          enddo ! hm_idx = 1, hydromet_dim, 1
     783             : 
     784             :       case ('wpNcp')
     785           0 :         stats_metadata%iwpNcp = k
     786             : 
     787             :         call stat_assign( var_index=stats_metadata%iwpNcp, var_name="wpNcp", &
     788             :                           var_description="w'Nc', Covariance of w and " &
     789             :                                           // "N_c", &
     790             :                           var_units="(m/s) num/kg", &
     791           0 :                           l_silhs=.false., grid_kind=stats_zm )
     792           0 :         k = k + 1
     793             : 
     794             :       case ('rtphmp')
     795             : 
     796           0 :          do hm_idx = 1, hydromet_dim, 1
     797             : 
     798           0 :             hm_type = hydromet_list(hm_idx)
     799             : 
     800           0 :             stats_metadata%irtphmp(hm_idx) = k
     801             : 
     802           0 :             if ( l_mix_rat_hm(hm_idx) ) then
     803             : 
     804           0 :                call stat_assign( var_index=stats_metadata%irtphmp(hm_idx), &
     805             :                                  var_name="rtp"//trim( hm_type(1:2) )//"p", &
     806             :                                  var_description="Covariance of r_t and " &
     807             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     808             :                                  // " [kg^2/kg^2]", &
     809             :                                  var_units="kg^2/kg^2", &
     810           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     811             : 
     812             :             else ! Concentration
     813             : 
     814           0 :                call stat_assign( var_index=stats_metadata%irtphmp(hm_idx), &
     815             :                                  var_name="rtp"//trim( hm_type(1:2) )//"p", &
     816             :                                  var_description="Covariance of r_t and " &
     817             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     818             :                                  // " [(kg/kg) num/kg]", &
     819             :                                  var_units="(kg/kg) num/kg", &
     820           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     821             : 
     822             :             endif ! l_mix_rat_hm(hm_idx)
     823             : 
     824           0 :             k = k + 1
     825             : 
     826             :          enddo ! hm_idx = 1, hydromet_dim, 1
     827             : 
     828             :       case ('thlphmp')
     829             : 
     830           0 :          do hm_idx = 1, hydromet_dim, 1
     831             : 
     832           0 :             hm_type = hydromet_list(hm_idx)
     833             : 
     834           0 :             stats_metadata%ithlphmp(hm_idx) = k
     835             : 
     836           0 :             if ( l_mix_rat_hm(hm_idx) ) then
     837             : 
     838           0 :                call stat_assign( var_index=stats_metadata%ithlphmp(hm_idx), &
     839             :                                  var_name="thlp"//trim( hm_type(1:2) )//"p", &
     840             :                                  var_description="Covariance of th_l and " &
     841             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     842             :                                  // " [K kg/kg]", &
     843             :                                  var_units="K kg/kg", &
     844           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     845             : 
     846             :             else ! Concentration
     847             : 
     848           0 :                call stat_assign( var_index=stats_metadata%ithlphmp(hm_idx), &
     849             :                                  var_name="thlp"//trim( hm_type(1:2) )//"p", &
     850             :                                  var_description="Covariance of th_l and " &
     851             :                                  // hm_type(1:1)//"_"//trim( hm_type(2:2) ) &
     852             :                                  // " [K num/kg]", &
     853             :                                  var_units="K num/kg", &
     854           0 :                                  l_silhs=.false., grid_kind=stats_zm )
     855             : 
     856             :             endif ! l_mix_rat_hm(hm_idx)
     857             : 
     858           0 :             k = k + 1
     859             : 
     860             :          enddo ! hm_idx = 1, hydromet_dim, 1
     861             : 
     862             :       case ('hmxphmyp')
     863             : 
     864           0 :          do hmx_idx = 1, hydromet_dim, 1
     865             : 
     866           0 :             hmx_type = hydromet_list(hmx_idx)
     867             : 
     868           0 :             do hmy_idx = hmx_idx+1, hydromet_dim, 1
     869             : 
     870           0 :                hmy_type = hydromet_list(hmy_idx)
     871             : 
     872             :                ! The covariance (overall) of hmx and hmy.
     873           0 :                stats_metadata%ihmxphmyp(hmy_idx,hmx_idx) = k
     874             : 
     875           0 :                if ( l_mix_rat_hm(hmx_idx) .and. l_mix_rat_hm(hmy_idx) ) then
     876             : 
     877             :                   ! Both hydrometeors are mixing ratios.
     878           0 :                   call stat_assign( var_index=stats_metadata%ihmxphmyp(hmy_idx,hmx_idx), &
     879             :                                     var_name=trim( hmx_type(1:2) )//"p" &
     880             :                                     // trim( hmy_type(1:2) )//"p", &
     881             :                                     var_description="Covariance of " &
     882             :                                     // hmx_type(1:1)//"_"//trim(hmx_type(2:2)) &
     883             :                                     // " and " &
     884             :                                     // hmy_type(1:1)//"_"//trim(hmy_type(2:2)) &
     885             :                                     // " [(kg/kg)^2]", &
     886             :                                     var_units="(kg/kg)^2", l_silhs=.false., &
     887           0 :                                     grid_kind=stats_zm )
     888             : 
     889             :                elseif ( ( .not. l_mix_rat_hm(hmx_idx) ) &
     890           0 :                         .and. ( .not. l_mix_rat_hm(hmy_idx) ) ) then
     891             : 
     892             :                   ! Both hydrometeors are concentrations.
     893           0 :                   call stat_assign( var_index=stats_metadata%ihmxphmyp(hmy_idx,hmx_idx), &
     894             :                                     var_name=trim( hmx_type(1:2) )//"p" &
     895             :                                     // trim( hmy_type(1:2) )//"p", &
     896             :                                     var_description="Covariance of " &
     897             :                                     // hmx_type(1:1)//"_"//trim(hmx_type(2:2)) &
     898             :                                     // " and " &
     899             :                                     // hmy_type(1:1)//"_"//trim(hmy_type(2:2)) &
     900             :                                     // " [(num/kg)^2]", &
     901             :                                     var_units="(num/kg)^2", l_silhs=.false., &
     902           0 :                                     grid_kind=stats_zm )
     903             : 
     904             :                else
     905             : 
     906             :                   ! One hydrometeor is a mixing ratio and the other hydrometeor
     907             :                   ! is a concentration.
     908           0 :                   call stat_assign( var_index=stats_metadata%ihmxphmyp(hmy_idx,hmx_idx), &
     909             :                                     var_name=trim( hmx_type(1:2) )//"p" &
     910             :                                     // trim( hmy_type(1:2) )//"p", &
     911             :                                     var_description="Covariance of " &
     912             :                                     // hmx_type(1:1)//"_"//trim(hmx_type(2:2)) &
     913             :                                     // " and " &
     914             :                                     // hmy_type(1:1)//"_"//trim(hmy_type(2:2)) &
     915             :                                     // " [(kg/kg) num/kg]", &
     916             :                                     var_units="(kg/kg) num/kg", &
     917           0 :                                     l_silhs=.false., grid_kind=stats_zm )
     918             : 
     919             :                endif
     920             : 
     921           0 :                k = k + 1
     922             : 
     923             :             enddo ! hmy_idx = hmx_idx+1, hydromet_dim, 1
     924             : 
     925             :          enddo ! hmx_idx = 1, hydromet_dim, 1
     926             : 
     927             :       case ('VNr')
     928           0 :         stats_metadata%iVNr = k
     929             : 
     930             :         call stat_assign( var_index=stats_metadata%iVNr, var_name="VNr", &
     931             :              var_description="VNr, rrm concentration fallspeed", var_units="m/s", &
     932           0 :              l_silhs=.false., grid_kind=stats_zm )
     933           0 :         k = k + 1
     934             : 
     935             :       case ('Vrr')
     936           0 :         stats_metadata%iVrr = k
     937             : 
     938             :         call stat_assign( var_index=stats_metadata%iVrr, var_name="Vrr", &
     939             :              var_description="Vrr, rrm mixing ratio fallspeed", var_units="m/s", &
     940           0 :              l_silhs=.false., grid_kind=stats_zm )
     941           0 :         k = k + 1
     942             : 
     943             :       case ('VNc')
     944           0 :         stats_metadata%iVNc = k
     945             : 
     946             :         call stat_assign( var_index=stats_metadata%iVNc, var_name="VNc", &
     947             :              var_description="VNc, Nrm concentration fallspeed", var_units="m/s", &
     948           0 :              l_silhs=.false., grid_kind=stats_zm )
     949           0 :         k = k + 1
     950             : 
     951             :       case ('Vrc')
     952           0 :         stats_metadata%iVrc = k
     953             : 
     954             :         call stat_assign( var_index=stats_metadata%iVrc, var_name="Vrc", &
     955             :              var_description="Vrc, Nrm mixing ratio fallspeed", var_units="m/s", &
     956           0 :              l_silhs=.false., grid_kind=stats_zm )
     957           0 :         k = k + 1
     958             : 
     959             :       case ('VNs')
     960           0 :         stats_metadata%iVNs = k
     961             : 
     962             :         call stat_assign( var_index=stats_metadata%iVNs, var_name="VNs", &
     963             :              var_description="VNs, Snow concentration fallspeed", var_units="m/s", &
     964           0 :              l_silhs=.false., grid_kind=stats_zm )
     965           0 :         k = k + 1
     966             : 
     967             :       case ('Vrs')
     968           0 :         stats_metadata%iVrs = k
     969             : 
     970             :         call stat_assign( var_index=stats_metadata%iVrs, var_name="Vrs", &
     971             :              var_description="Vrs, Snow mixing ratio fallspeed", var_units="m/s", &
     972           0 :              l_silhs=.false., grid_kind=stats_zm )
     973           0 :         k = k + 1
     974             : 
     975             :       case ('Vrg')
     976           0 :         stats_metadata%iVrg = k
     977             : 
     978             :         call stat_assign( var_index=stats_metadata%iVrg, var_name="Vrg", &
     979             :              var_description="Vrg, Graupel sedimentation velocity", var_units="m/s", &
     980           0 :              l_silhs=.false., grid_kind=stats_zm )
     981           0 :         k = k + 1
     982             : 
     983             :       case ('VNi')
     984           0 :         stats_metadata%iVNi = k
     985             : 
     986             :         call stat_assign( var_index=stats_metadata%iVNi, var_name="VNi", &
     987             :              var_description="VNi, Cloud ice concentration fallspeed", var_units="m/s", &
     988           0 :              l_silhs=.false., grid_kind=stats_zm )
     989           0 :         k = k + 1
     990             : 
     991             :       case ('Vri')
     992           0 :         stats_metadata%iVri = k
     993             : 
     994             :         call stat_assign( var_index=stats_metadata%iVri, var_name="Vri", &
     995             :              var_description="Vri, Cloud ice mixing ratio fallspeed", var_units="m/s", &
     996           0 :              l_silhs=.false., grid_kind=stats_zm )
     997           0 :         k = k + 1
     998             : 
     999             :       case ('Vrrprrp')
    1000           0 :         stats_metadata%iVrrprrp = k
    1001             : 
    1002             :         call stat_assign( var_index=stats_metadata%iVrrprrp, var_name="Vrrprrp", &
    1003             :              var_description="Vrr'rr', Covariance of V_rr (r_r sed. vel.) and r_r", &
    1004           0 :              var_units="(m/s)(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
    1005           0 :         k = k + 1
    1006             : 
    1007             :       case ('VNrpNrp')
    1008           0 :         stats_metadata%iVNrpNrp = k
    1009             : 
    1010             :         call stat_assign( var_index=stats_metadata%iVNrpNrp, var_name="VNrpNrp", &
    1011             :              var_description="VNr'Nr', Covariance of V_Nr (N_r sed. vel.) and N_r", &
    1012           0 :              var_units="(m/s)(num/kg)", l_silhs=.false., grid_kind=stats_zm )
    1013           0 :         k = k + 1
    1014             : 
    1015             :       case ('Vrrprrp_expcalc')
    1016           0 :         stats_metadata%iVrrprrp_expcalc = k
    1017             : 
    1018             :         call stat_assign( var_index=stats_metadata%iVrrprrp_expcalc, var_name="Vrrprrp_expcalc", &
    1019             :              var_description="Vrr'rr'_expcalc, completely explicit calculation", &
    1020           0 :              var_units="(m/s)(kg/kg)", l_silhs=.false., grid_kind=stats_zm )
    1021           0 :         k = k + 1
    1022             : 
    1023             :       case ('VNrpNrp_expcalc')
    1024           0 :         stats_metadata%iVNrpNrp_expcalc = k
    1025             : 
    1026             :         call stat_assign( var_index=stats_metadata%iVNrpNrp_expcalc, var_name="VNrpNrp_expcalc", &
    1027             :              var_description="VNr'Nr'_expcalc, V_Nr'N_r' completely explicit calculation", &
    1028           0 :              var_units="(m/s)(num/kg)", l_silhs=.false., grid_kind=stats_zm )
    1029           0 :         k = k + 1
    1030             : 
    1031             :       case ('wp2_bt')
    1032           0 :         stats_metadata%iwp2_bt = k
    1033             : 
    1034             :         call stat_assign( var_index=stats_metadata%iwp2_bt, var_name="wp2_bt", &
    1035             :              var_description="w'^2_bt, wp2 budget: wp2 time tendency", var_units="m^2/s^3", &
    1036           0 :              l_silhs=.false., grid_kind=stats_zm )
    1037           0 :         k = k + 1
    1038             : 
    1039             :       case ('wp2_ma')
    1040           0 :         stats_metadata%iwp2_ma = k
    1041             : 
    1042             :         call stat_assign( var_index=stats_metadata%iwp2_ma, var_name="wp2_ma", &
    1043             :              var_description="w'^2_ma, wp2 budget: wp2 vertical mean advection", &
    1044           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1045           0 :         k = k + 1
    1046             : 
    1047             :       case ('wp2_ta')
    1048           0 :         stats_metadata%iwp2_ta = k
    1049             : 
    1050             :         call stat_assign( var_index=stats_metadata%iwp2_ta, var_name="wp2_ta", &
    1051             :              var_description="w'^2_ta, wp2 budget: wp2 turbulent advection", &
    1052           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1053           0 :         k = k + 1
    1054             : 
    1055             :       case ('wp2_ac')
    1056           0 :         stats_metadata%iwp2_ac = k
    1057             : 
    1058             :         call stat_assign( var_index=stats_metadata%iwp2_ac, var_name="wp2_ac", &
    1059             :              var_description="w'^2_ac, wp2 budget: wp2 accumulation term", var_units="m^2/s^3", &
    1060           0 :              l_silhs=.false., grid_kind=stats_zm )
    1061           0 :         k = k + 1
    1062             : 
    1063             :       case ('wp2_bp')
    1064           0 :         stats_metadata%iwp2_bp = k
    1065             : 
    1066             :         call stat_assign( var_index=stats_metadata%iwp2_bp, var_name="wp2_bp", &
    1067             :              var_description="w'^2_bp, wp2 budget: wp2 buoyancy production", &
    1068           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1069           0 :         k = k + 1
    1070             : 
    1071             :       case ('wp2_pr1')
    1072           0 :         stats_metadata%iwp2_pr1 = k
    1073             : 
    1074             :         call stat_assign( var_index=stats_metadata%iwp2_pr1, var_name="wp2_pr1", &
    1075             :              var_description="w'^2_pr1, wp2 budget: wp2 pressure term 1", var_units="m^2/s^3", &
    1076           0 :              l_silhs=.false., grid_kind=stats_zm )
    1077           0 :         k = k + 1
    1078             : 
    1079             :       case ('wp2_pr2')
    1080           0 :         stats_metadata%iwp2_pr2 = k
    1081             :         call stat_assign( var_index=stats_metadata%iwp2_pr2, var_name="wp2_pr2", &
    1082             :              var_description="w'^2_pr2, wp2 budget: wp2 pressure term 2", var_units="m^2/s^3", &
    1083           0 :              l_silhs=.false., grid_kind=stats_zm )
    1084           0 :         k = k + 1
    1085             : 
    1086             :       case ('wp2_pr3')
    1087           0 :         stats_metadata%iwp2_pr3 = k
    1088             :         call stat_assign( var_index=stats_metadata%iwp2_pr3, var_name="wp2_pr3", &
    1089             :              var_description="w'^2_pr3, wp2 budget: wp2 pressure term 3", var_units="m^2/s^3", &
    1090           0 :              l_silhs=.false., grid_kind=stats_zm )
    1091             : 
    1092           0 :         k = k + 1
    1093             : 
    1094             :       case ('wp2_pr_dfsn')
    1095           0 :         stats_metadata%iwp2_pr_dfsn = k
    1096             :         call stat_assign( var_index=stats_metadata%iwp2_pr_dfsn, var_name="wp2_pr_dfsn", &
    1097             :              var_description="w'^2_pr_dfsn, wp2 budget: wp2 pressure diffusion term", &
    1098             :               var_units="m^2/s^3", &
    1099           0 :              l_silhs=.false., grid_kind=stats_zm )
    1100             : 
    1101           0 :         k = k + 1
    1102             : 
    1103             :       case ('wp2_dp1')
    1104           0 :         stats_metadata%iwp2_dp1 = k
    1105             :         call stat_assign( var_index=stats_metadata%iwp2_dp1, var_name="wp2_dp1", &
    1106             :              var_description="w'^2_dp1, wp2 budget: wp2 dissipation term 1", &
    1107             :              var_units="m^2/s^3", &
    1108           0 :              l_silhs=.false., grid_kind=stats_zm )
    1109           0 :         k = k + 1
    1110             : 
    1111             :       case ('wp2_dp2')
    1112           0 :         stats_metadata%iwp2_dp2 = k
    1113             :         call stat_assign( var_index=stats_metadata%iwp2_dp2, var_name="wp2_dp2", &
    1114             :              var_description="w'^2_d'^2, wp2 budget: wp2 dissipation term 2", &
    1115             :              var_units="m^2/s^3", &
    1116           0 :              l_silhs=.false., grid_kind=stats_zm )
    1117             : 
    1118           0 :         k = k + 1
    1119             : 
    1120             :       case ('wp2_sdmp')
    1121           0 :         stats_metadata%iwp2_sdmp = k
    1122             :         call stat_assign( var_index=stats_metadata%iwp2_sdmp, var_name="wp2_sdmp", &
    1123             :              var_description="w'^2_sdmp, wp2 budget: wp2 sponge damping term", &
    1124             :              var_units="m^2/s^3", &
    1125           0 :              l_silhs=.false., grid_kind=stats_zm )
    1126           0 :         k = k + 1
    1127             : 
    1128             :       case ('wp2_cl')
    1129           0 :         stats_metadata%iwp2_cl = k
    1130             : 
    1131             :         call stat_assign( var_index=stats_metadata%iwp2_cl, var_name="wp2_cl", &
    1132             :              var_description="w'^2_cl, wp2 budget: wp2 clipping term", var_units="m^2/s^3", &
    1133           0 :              l_silhs=.false., grid_kind=stats_zm )
    1134             : 
    1135           0 :         k = k + 1
    1136             : 
    1137             :       case ('wp2_pd')
    1138           0 :         stats_metadata%iwp2_pd = k
    1139             : 
    1140             :         call stat_assign( var_index=stats_metadata%iwp2_pd, var_name="wp2_pd", &
    1141             :              var_description="w'^2_pd, wp2 budget: wp2 positive definite adjustment", &
    1142           0 :              var_units="m2/s3", l_silhs=.false., grid_kind=stats_zm )
    1143             : 
    1144           0 :         k = k + 1
    1145             : 
    1146             :       case ('wp2_sf')
    1147           0 :         stats_metadata%iwp2_sf = k
    1148             : 
    1149             :         call stat_assign( var_index=stats_metadata%iwp2_sf, var_name="wp2_sf", &
    1150             :              var_description="w'^2_sf, wp2 budget: wp2 surface variance", var_units="m2/s3", &
    1151           0 :              l_silhs=.false., grid_kind=stats_zm )
    1152             : 
    1153           0 :         k = k + 1
    1154             : 
    1155             :       case ('wp2_splat')
    1156           0 :         stats_metadata%iwp2_splat = k
    1157             : 
    1158             :         call stat_assign( var_index=stats_metadata%iwp2_splat, var_name="wp2_splat", &
    1159             :              var_description="w'^2_splat, wp2 budget: wp2 splatting", &
    1160           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1161             : 
    1162           0 :         k = k + 1
    1163             : 
    1164             :       case ('wprtp_bt')
    1165           0 :         stats_metadata%iwprtp_bt = k
    1166             :         call stat_assign( var_index=stats_metadata%iwprtp_bt, var_name="wprtp_bt", &
    1167             :              var_description="w'rt'_bt, wprtp budget: wprtp time tendency", &
    1168           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1169           0 :         k = k + 1
    1170             : 
    1171             :       case ('wprtp_ma')
    1172           0 :         stats_metadata%iwprtp_ma = k
    1173             : 
    1174             :         call stat_assign( var_index=stats_metadata%iwprtp_ma, var_name="wprtp_ma", &
    1175             :              var_description="w'rt'_ma, wprtp budget: wprtp mean advection", &
    1176           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1177           0 :         k = k + 1
    1178             : 
    1179             :       case ('wprtp_ta')
    1180           0 :         stats_metadata%iwprtp_ta = k
    1181             : 
    1182             :         call stat_assign( var_index=stats_metadata%iwprtp_ta, var_name="wprtp_ta", &
    1183             :              var_description="w'rt'_ta, wprtp budget: wprtp turbulent advection", &
    1184           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1185           0 :         k = k + 1
    1186             : 
    1187             :       case ('wprtp_tp')
    1188           0 :         stats_metadata%iwprtp_tp = k
    1189             : 
    1190             :         call stat_assign( var_index=stats_metadata%iwprtp_tp, var_name="wprtp_tp", &
    1191             :              var_description="w'rt'_t', wprtp budget: wprtp turbulent production", &
    1192           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1193           0 :         k = k + 1
    1194             : 
    1195             :       case ('wprtp_ac')
    1196           0 :         stats_metadata%iwprtp_ac = k
    1197             : 
    1198             :         call stat_assign( var_index=stats_metadata%iwprtp_ac, var_name="wprtp_ac", &
    1199             :              var_description="w'rt'_ac, wprtp budget: wprtp accumulation term", &
    1200           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1201           0 :         k = k + 1
    1202             : 
    1203             :       case ('wprtp_bp')
    1204           0 :         stats_metadata%iwprtp_bp = k
    1205             : 
    1206             :         call stat_assign( var_index=stats_metadata%iwprtp_bp, var_name="wprtp_bp", &
    1207             :              var_description="w'rt'_b', wprtp budget: wprtp buoyancy production", &
    1208           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1209           0 :         k = k + 1
    1210             : 
    1211             :       case ('wprtp_pr1')
    1212           0 :         stats_metadata%iwprtp_pr1 = k
    1213             : 
    1214             :         call stat_assign( var_index=stats_metadata%iwprtp_pr1, var_name="wprtp_pr1", &
    1215             :              var_description="w'rt'_pr1, wprtp budget: wprtp pressure term 1", &
    1216           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1217           0 :         k = k + 1
    1218             : 
    1219             :       case ('wprtp_pr2')
    1220           0 :         stats_metadata%iwprtp_pr2 = k
    1221             : 
    1222             :         call stat_assign( var_index=stats_metadata%iwprtp_pr2, var_name="wprtp_pr2", &
    1223             :              var_description="w'rt'_pr2, wprtp budget: wprtp pressure term 2", &
    1224           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1225           0 :         k = k + 1
    1226             : 
    1227             :       case ('wprtp_pr3')
    1228           0 :         stats_metadata%iwprtp_pr3 = k
    1229             : 
    1230             :         call stat_assign( var_index=stats_metadata%iwprtp_pr3, var_name="wprtp_pr3", &
    1231             :              var_description="w'rt'_pr3, wprtp budget: wprtp pressure term 3", &
    1232           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1233           0 :         k = k + 1
    1234             : 
    1235             :       case ('wprtp_dp1')
    1236           0 :         stats_metadata%iwprtp_dp1 = k
    1237             : 
    1238             :         call stat_assign( var_index=stats_metadata%iwprtp_dp1, var_name="wprtp_dp1", &
    1239             :              var_description="w'rt'_dp1, wprtp budget: wprtp dissipation term 1", &
    1240           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1241           0 :         k = k + 1
    1242             : 
    1243             :       case ('wprtp_mfl')
    1244           0 :         stats_metadata%iwprtp_mfl = k
    1245             : 
    1246             :         call stat_assign( var_index=stats_metadata%iwprtp_mfl, var_name="wprtp_mfl", &
    1247             :              var_description="w'rt'_mfl, wprtp budget: wprtp monotonic flux limiter", &
    1248           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1249           0 :         k = k + 1
    1250             : 
    1251             :       case ('wprtp_cl')
    1252           0 :         stats_metadata%iwprtp_cl = k
    1253             : 
    1254             :         call stat_assign( var_index=stats_metadata%iwprtp_cl, var_name="wprtp_cl", &
    1255             :              var_description="w'rt'_cl, wprtp budget: wprtp clipping term", &
    1256           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1257           0 :         k = k + 1
    1258             : 
    1259             :       case ('wprtp_sicl')
    1260           0 :         stats_metadata%iwprtp_sicl = k
    1261             : 
    1262             :         call stat_assign( var_index=stats_metadata%iwprtp_sicl, var_name="wprtp_sicl", &
    1263             :              var_description="w'rt'_sicl, wprtp budget: wprtp semi-implicit clipping term", &
    1264           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1265           0 :         k = k + 1
    1266             : 
    1267             :       case ('wprtp_pd')
    1268           0 :         stats_metadata%iwprtp_pd = k
    1269             : 
    1270             :         call stat_assign( var_index=stats_metadata%iwprtp_pd, var_name="wprtp_pd", &
    1271             :              var_description="w'rt'_pd, wprtp budget: wprtp flux corrected trans. term", &
    1272           0 :              var_units="(m kg)/(s^2 kg)", l_silhs=.false., grid_kind=stats_zm )
    1273           0 :         k = k + 1
    1274             : 
    1275             :       case ('wprtp_forcing')
    1276           0 :         stats_metadata%iwprtp_forcing = k
    1277             : 
    1278             :         call stat_assign( var_index=stats_metadata%iwprtp_forcing, var_name="wprtp_forcing", &
    1279             :              var_description="w'rt'_forcing, wprtp budget: wprtp forcing " &
    1280             :              // "(includes microphysics tendency)", &
    1281           0 :              var_units="(m kg/kg)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1282           0 :         k = k + 1
    1283             : 
    1284             :       case ('wprtp_mc')
    1285           0 :         stats_metadata%iwprtp_mc = k
    1286             : 
    1287             :         call stat_assign( var_index=stats_metadata%iwprtp_mc, var_name="wprtp_mc", &
    1288             :              var_description="w'rt'_mc, Microphysics tendency for wprtp (not in budget)", &
    1289           0 :              var_units="(m kg/kg)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1290           0 :         k = k + 1
    1291             : 
    1292             :       case ('wpthlp_bt')
    1293           0 :         stats_metadata%iwpthlp_bt = k
    1294             : 
    1295             :         call stat_assign( var_index=stats_metadata%iwpthlp_bt, var_name="wpthlp_bt", &
    1296             :              var_description="w'thl'_bt, wpthlp budget", var_units="(m K)/s^2", &
    1297           0 :              l_silhs=.false., grid_kind=stats_zm )
    1298           0 :         k = k + 1
    1299             : 
    1300             :       case ('wpthlp_ma')
    1301           0 :         stats_metadata%iwpthlp_ma = k
    1302             :         call stat_assign( var_index=stats_metadata%iwpthlp_ma, var_name="wpthlp_ma", &
    1303             :              var_description="w'thl'_ma, wpthlp budget: wpthlp mean advection", &
    1304           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1305             : 
    1306           0 :         k = k + 1
    1307             : 
    1308             :       case ('wpthlp_ta')
    1309           0 :         stats_metadata%iwpthlp_ta = k
    1310             :         call stat_assign( var_index=stats_metadata%iwpthlp_ta, var_name="wpthlp_ta", &
    1311             :              var_description="w'thl'_ta, wpthlp budget: wpthlp turbulent advection", &
    1312           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1313             : 
    1314           0 :         k = k + 1
    1315             : 
    1316             :       case ('wpthlp_tp')
    1317           0 :         stats_metadata%iwpthlp_tp = k
    1318             :         call stat_assign( var_index=stats_metadata%iwpthlp_tp, var_name="wpthlp_tp", &
    1319             :              var_description="w'thl'_tp, wpthlp budget: wpthlp turbulent production", &
    1320           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1321             : 
    1322           0 :         k = k + 1
    1323             : 
    1324             :       case ('wpthlp_ac')
    1325           0 :         stats_metadata%iwpthlp_ac = k
    1326             :         call stat_assign( var_index=stats_metadata%iwpthlp_ac, var_name="wpthlp_ac", &
    1327             :              var_description="w'thl'_ac, wpthlp budget: wpthlp accumulation term", &
    1328           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1329             : 
    1330           0 :         k = k + 1
    1331             : 
    1332             :       case ('wpthlp_bp')
    1333           0 :         stats_metadata%iwpthlp_bp = k
    1334             :         call stat_assign( var_index=stats_metadata%iwpthlp_bp, var_name="wpthlp_bp", &
    1335             :              var_description="w'thl'_b', wpthlp budget: wpthlp buoyancy production", &
    1336           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1337           0 :         k = k + 1
    1338             : 
    1339             :       case ('wpthlp_pr1')
    1340           0 :         stats_metadata%iwpthlp_pr1 = k
    1341             : 
    1342             :         call stat_assign( var_index=stats_metadata%iwpthlp_pr1, var_name="wpthlp_pr1", &
    1343             :              var_description="w'thl'_pr1, wpthlp budget: wpthlp pressure term 1", &
    1344           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1345           0 :         k = k + 1
    1346             : 
    1347             :       case ('wpthlp_pr2')
    1348           0 :         stats_metadata%iwpthlp_pr2 = k
    1349             : 
    1350             :         call stat_assign( var_index=stats_metadata%iwpthlp_pr2, var_name="wpthlp_pr2", &
    1351             :              var_description="w'thl'_pr2, wpthlp budget: wpthlp pressure term 2", &
    1352           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1353           0 :         k = k + 1
    1354             : 
    1355             :       case ('wpthlp_pr3')
    1356           0 :         stats_metadata%iwpthlp_pr3 = k
    1357             :         call stat_assign( var_index=stats_metadata%iwpthlp_pr3, var_name="wpthlp_pr3", &
    1358             :              var_description="w'thl'_pr3, wpthlp budget: wpthlp pressure term 3", &
    1359           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1360           0 :         k = k + 1
    1361             : 
    1362             :       case ('wpthlp_dp1')
    1363           0 :         stats_metadata%iwpthlp_dp1 = k
    1364             :         call stat_assign( var_index=stats_metadata%iwpthlp_dp1, var_name="wpthlp_dp1", &
    1365             :              var_description="w'thl'_dp1, wpthlp budget: wpthlp dissipation term 1", &
    1366           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1367           0 :         k = k + 1
    1368             : 
    1369             :       case ('wpthlp_mfl')
    1370           0 :         stats_metadata%iwpthlp_mfl = k
    1371             :         call stat_assign( var_index=stats_metadata%iwpthlp_mfl, var_name="wpthlp_mfl", &
    1372             :              var_description="w'thl'_mfl, wpthlp budget: wpthlp monotonic flux limiter", &
    1373           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1374           0 :         k = k + 1
    1375             : 
    1376             :       case ('wpthlp_cl')
    1377           0 :         stats_metadata%iwpthlp_cl = k
    1378             :         call stat_assign( var_index=stats_metadata%iwpthlp_cl, var_name="wpthlp_cl", &
    1379             :              var_description="w'thl'_cl, wpthlp budget: wpthlp clipping term", &
    1380           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1381           0 :         k = k + 1
    1382             : 
    1383             :       case ('wpthlp_sicl')
    1384           0 :         stats_metadata%iwpthlp_sicl = k
    1385             :         call stat_assign( var_index=stats_metadata%iwpthlp_sicl, var_name="wpthlp_sicl", &
    1386             :              var_description="w'thl'_sicl, wpthlp budget: wpthlp semi-implicit clipping term", &
    1387           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1388           0 :         k = k + 1
    1389             : 
    1390             :       case ('wpthlp_forcing')
    1391           0 :         stats_metadata%iwpthlp_forcing = k
    1392             : 
    1393             :         call stat_assign( var_index=stats_metadata%iwpthlp_forcing, var_name="wpthlp_forcing", &
    1394             :              var_description="w'thl'_forcing, wpthlp budget: wpthlp forcing " &
    1395             :              // "(includes microphysics tendency)", &
    1396           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1397           0 :         k = k + 1
    1398             : 
    1399             :       case ('wpthlp_mc')
    1400           0 :         stats_metadata%iwpthlp_mc = k
    1401             : 
    1402             :         call stat_assign( var_index=stats_metadata%iwpthlp_mc, var_name="wpthlp_mc", &
    1403             :              var_description="w'thl'_mc, Microphysics tendency for wpthlp (not in budget)", &
    1404           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    1405           0 :         k = k + 1
    1406             : 
    1407             :       case ('upwp_bt')
    1408           0 :         stats_metadata%iupwp_bt = k
    1409             :         call stat_assign( var_index=stats_metadata%iupwp_bt, var_name="upwp_bt", &
    1410             :              var_description="u'w'_bt, upwp budget: upwp time tendency", &
    1411           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1412           0 :         k = k + 1
    1413             : 
    1414             :       case ('upwp_ma')
    1415           0 :         stats_metadata%iupwp_ma = k
    1416             :         call stat_assign( var_index=stats_metadata%iupwp_ma, var_name="upwp_ma", &
    1417             :              var_description="u'w'_ma, upwp budget: upwp mean advection", &
    1418           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1419           0 :         k = k + 1
    1420             : 
    1421             :       case ('upwp_ta')
    1422           0 :         stats_metadata%iupwp_ta = k
    1423             :         call stat_assign( var_index=stats_metadata%iupwp_ta, var_name="upwp_ta", &
    1424             :              var_description="u'w'_ta, upwp budget: upwp turbulent advection", &
    1425           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1426           0 :         k = k + 1
    1427             : 
    1428             :       case ('upwp_tp')
    1429           0 :         stats_metadata%iupwp_tp = k
    1430             :         call stat_assign( var_index=stats_metadata%iupwp_tp, var_name="upwp_tp", &
    1431             :              var_description="u'w'_t', upwp budget: upwp turbulent production", &
    1432           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1433           0 :         k = k + 1
    1434             : 
    1435             :       case ('upwp_ac')
    1436           0 :         stats_metadata%iupwp_ac = k
    1437             :         call stat_assign( var_index=stats_metadata%iupwp_ac, var_name="upwp_ac", &
    1438             :              var_description="u'w'_ac, upwp budget: upwp accumulation term", &
    1439           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1440           0 :         k = k + 1
    1441             : 
    1442             :       case ('upwp_bp')
    1443           0 :         stats_metadata%iupwp_bp = k
    1444             :         call stat_assign( var_index=stats_metadata%iupwp_bp, var_name="upwp_bp", &
    1445             :              var_description="u'w'_b', upwp budget: upwp buoyancy production", &
    1446           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1447           0 :         k = k + 1
    1448             : 
    1449             :       case ('upwp_pr1')
    1450           0 :         stats_metadata%iupwp_pr1 = k
    1451             :         call stat_assign( var_index=stats_metadata%iupwp_pr1, var_name="upwp_pr1", &
    1452             :              var_description="u'w'_pr1, upwp budget: upwp pressure term 1", &
    1453           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1454           0 :         k = k + 1
    1455             : 
    1456             :       case ('upwp_pr2')
    1457           0 :         stats_metadata%iupwp_pr2 = k
    1458             :         call stat_assign( var_index=stats_metadata%iupwp_pr2, var_name="upwp_pr2", &
    1459             :              var_description="u'w'_pr2, upwp budget: upwp pressure term 2", &
    1460           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1461           0 :         k = k + 1
    1462             : 
    1463             :       case ('upwp_pr3')
    1464           0 :         stats_metadata%iupwp_pr3 = k
    1465             :         call stat_assign( var_index=stats_metadata%iupwp_pr3, var_name="upwp_pr3", &
    1466             :              var_description="u'w'_pr3, upwp budget: upwp pressure term 3", &
    1467           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1468           0 :         k = k + 1
    1469             : 
    1470             :       case ('upwp_pr4')
    1471           0 :         stats_metadata%iupwp_pr4 = k
    1472             :         call stat_assign( var_index=stats_metadata%iupwp_pr4, var_name="upwp_pr4", &
    1473             :              var_description="u'w'_pr4, upwp budget: upwp pressure term 4", &
    1474           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1475           0 :         k = k + 1
    1476             : 
    1477             :       case ('upwp_dp1')
    1478           0 :         stats_metadata%iupwp_dp1 = k
    1479             :         call stat_assign( var_index=stats_metadata%iupwp_dp1, var_name="upwp_dp1", &
    1480             :              var_description="u'w'_dp1, upwp budget: upwp dissipation term 1", &
    1481           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1482           0 :         k = k + 1
    1483             : 
    1484             :       case ('upwp_mfl')
    1485           0 :         stats_metadata%iupwp_mfl = k
    1486             :         call stat_assign( var_index=stats_metadata%iupwp_mfl, var_name="upwp_mfl", &
    1487             :              var_description="u'w'_mfl, upwp budget: upwp monotonic flux limiter", &
    1488           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1489           0 :         k = k + 1
    1490             : 
    1491             :       case ('upwp_cl')
    1492           0 :         stats_metadata%iupwp_cl = k
    1493             :         call stat_assign( var_index=stats_metadata%iupwp_cl, var_name="upwp_cl", &
    1494             :              var_description="u'w'_cl, upwp budget: upwp clipping term", &
    1495           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1496           0 :         k = k + 1
    1497             : 
    1498             :       case ('vpwp_bt')
    1499           0 :         stats_metadata%ivpwp_bt = k
    1500             :         call stat_assign( var_index=stats_metadata%ivpwp_bt, var_name="vpwp_bt", &
    1501             :              var_description="v'w'_bt, vpwp budget: vpwp time tendency", &
    1502           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1503           0 :         k = k + 1
    1504             : 
    1505             :       case ('vpwp_ma')
    1506           0 :         stats_metadata%ivpwp_ma = k
    1507             :         call stat_assign( var_index=stats_metadata%ivpwp_ma, var_name="vpwp_ma", &
    1508             :              var_description="v'w'_ma, vpwp budget: vpwp mean advection", &
    1509           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1510           0 :         k = k + 1
    1511             : 
    1512             :       case ('vpwp_ta')
    1513           0 :         stats_metadata%ivpwp_ta = k
    1514             :         call stat_assign( var_index=stats_metadata%ivpwp_ta, var_name="vpwp_ta", &
    1515             :              var_description="v'w'_ta, vpwp budget: vpwp turbulent advection", &
    1516           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1517           0 :         k = k + 1
    1518             : 
    1519             :       case ('vpwp_tp')
    1520           0 :         stats_metadata%ivpwp_tp = k
    1521             :         call stat_assign( var_index=stats_metadata%ivpwp_tp, var_name="vpwp_tp", &
    1522             :              var_description="v'w'_t', vpwp budget: vpwp turbulent production", &
    1523           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1524           0 :         k = k + 1
    1525             : 
    1526             :       case ('vpwp_ac')
    1527           0 :         stats_metadata%ivpwp_ac = k
    1528             :         call stat_assign( var_index=stats_metadata%ivpwp_ac, var_name="vpwp_ac", &
    1529             :              var_description="v'w'_ac, vpwp budget: vpwp accumulation term", &
    1530           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1531           0 :         k = k + 1
    1532             : 
    1533             :       case ('vpwp_bp')
    1534           0 :         stats_metadata%ivpwp_bp = k
    1535             :         call stat_assign( var_index=stats_metadata%ivpwp_bp, var_name="vpwp_bp", &
    1536             :              var_description="v'w'_b', vpwp budget: vpwp buoyancy production", &
    1537           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1538           0 :         k = k + 1
    1539             : 
    1540             :       case ('vpwp_pr1')
    1541           0 :         stats_metadata%ivpwp_pr1 = k
    1542             :         call stat_assign( var_index=stats_metadata%ivpwp_pr1, var_name="vpwp_pr1", &
    1543             :              var_description="v'w'_pr1, vpwp budget: vpwp pressure term 1", &
    1544           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1545           0 :         k = k + 1
    1546             : 
    1547             :       case ('vpwp_pr2')
    1548           0 :         stats_metadata%ivpwp_pr2 = k
    1549             :         call stat_assign( var_index=stats_metadata%ivpwp_pr2, var_name="vpwp_pr2", &
    1550             :              var_description="v'w'_pr2, vpwp budget: vpwp pressure term 2", &
    1551           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1552           0 :         k = k + 1
    1553             : 
    1554             :       case ('vpwp_pr3')
    1555           0 :         stats_metadata%ivpwp_pr3 = k
    1556             :         call stat_assign( var_index=stats_metadata%ivpwp_pr3, var_name="vpwp_pr3", &
    1557             :              var_description="v'w'_pr3, vpwp budget: vpwp pressure term 3", &
    1558           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1559           0 :         k = k + 1
    1560             : 
    1561             :       case ('vpwp_pr4')
    1562           0 :         stats_metadata%ivpwp_pr4 = k
    1563             :         call stat_assign( var_index=stats_metadata%ivpwp_pr4, var_name="vpwp_pr4", &
    1564             :              var_description="v'w'_pr4, vpwp budget: vpwp pressure term 4", &
    1565           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1566           0 :         k = k + 1
    1567             : 
    1568             :       case ('vpwp_dp1')
    1569           0 :         stats_metadata%ivpwp_dp1 = k
    1570             :         call stat_assign( var_index=stats_metadata%ivpwp_dp1, var_name="vpwp_dp1", &
    1571             :              var_description="v'w'_dp1, vpwp budget: vpwp dissipation term 1", &
    1572           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1573           0 :         k = k + 1
    1574             : 
    1575             :       case ('vpwp_mfl')
    1576           0 :         stats_metadata%ivpwp_mfl = k
    1577             :         call stat_assign( var_index=stats_metadata%ivpwp_mfl, var_name="vpwp_mfl", &
    1578             :              var_description="v'w'_mfl, vpwp budget: vpwp monotonic flux limiter", &
    1579           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1580           0 :         k = k + 1
    1581             : 
    1582             :       case ('vpwp_cl')
    1583           0 :         stats_metadata%ivpwp_cl = k
    1584             :         call stat_assign( var_index=stats_metadata%ivpwp_cl, var_name="vpwp_cl", &
    1585             :              var_description="v'w'_cl, vpwp budget: vpwp clipping term", &
    1586           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1587           0 :         k = k + 1
    1588             : 
    1589             :         ! Variance budgets
    1590             :       case ('rtp2_bt')
    1591           0 :         stats_metadata%irtp2_bt = k
    1592             :         call stat_assign( var_index=stats_metadata%irtp2_bt, var_name="rtp2_bt", &
    1593             :              var_description="rt'^2_bt, rt'2 budget: rtp2 time tendency", &
    1594           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1595           0 :         k = k + 1
    1596             :       case ('rtp2_ma')
    1597           0 :         stats_metadata%irtp2_ma = k
    1598             :         call stat_assign( var_index=stats_metadata%irtp2_ma, var_name="rtp2_ma", &
    1599             :              var_description="rt'^2_ma, rtp2 budget: rtp2 mean advection", &
    1600           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1601           0 :         k = k + 1
    1602             :       case ('rtp2_ta')
    1603           0 :         stats_metadata%irtp2_ta = k
    1604             :         call stat_assign( var_index=stats_metadata%irtp2_ta, var_name="rtp2_ta", &
    1605             :              var_description="rt'^2_ta, rtp2 budget: rtp2 turbulent advection", &
    1606           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1607           0 :         k = k + 1
    1608             :       case ('rtp2_tp')
    1609           0 :         stats_metadata%irtp2_tp = k
    1610             :         call stat_assign( var_index=stats_metadata%irtp2_tp, var_name="rtp2_tp", &
    1611             :              var_description="rt'^2_tp, rtp2 budget: rtp2 turbulent production", &
    1612           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1613           0 :         k = k + 1
    1614             :       case ('rtp2_dp1')
    1615           0 :         stats_metadata%irtp2_dp1 = k
    1616             :         call stat_assign( var_index=stats_metadata%irtp2_dp1, var_name="rtp2_dp1", &
    1617             :              var_description="rt'^2_dp1, rtp2 budget: rtp2 dissipation term 1", &
    1618           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1619           0 :         k = k + 1
    1620             :       case ('rtp2_dp2')
    1621           0 :         stats_metadata%irtp2_dp2 = k
    1622             :         call stat_assign( var_index=stats_metadata%irtp2_dp2, var_name="rtp2_dp2", &
    1623             :              var_description="rt'^2_dp2, rtp2 budget: rtp2 dissipation term 2", &
    1624           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1625           0 :         k = k + 1
    1626             :       case ('rtp2_cl')
    1627           0 :         stats_metadata%irtp2_cl = k
    1628             :         call stat_assign( var_index=stats_metadata%irtp2_cl, var_name="rtp2_cl", &
    1629             :              var_description="rt'^2_cl, rtp2 budget: rtp2 clipping term", &
    1630           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1631           0 :         k = k + 1
    1632             : 
    1633             :       case ('rtp2_pd')
    1634           0 :         stats_metadata%irtp2_pd = k
    1635             :         call stat_assign( var_index=stats_metadata%irtp2_pd, var_name="rtp2_pd", &
    1636             :              var_description="rt'^2_pd, rtp2 budget: rtp2 positive definite adjustment", &
    1637           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1638           0 :         k = k + 1
    1639             : 
    1640             :       case ('rtp2_sf')
    1641           0 :         stats_metadata%irtp2_sf = k
    1642             :         call stat_assign( var_index=stats_metadata%irtp2_sf, var_name="rtp2_sf", &
    1643             :              var_description="rt'^2_sf, rtp2 budget: rtp2 surface variance", &
    1644           0 :              var_units="(kg^2)/(kg^2 s)", l_silhs=.false., grid_kind=stats_zm )
    1645           0 :         k = k + 1
    1646             : 
    1647             :       case ('rtp2_forcing')
    1648           0 :         stats_metadata%irtp2_forcing = k
    1649             : 
    1650             :         call stat_assign( var_index=stats_metadata%irtp2_forcing, var_name="rtp2_forcing", &
    1651             :              var_description="rt'^2_forcing, rtp2 budget: rtp2 forcing " &
    1652             :              // "(includes microphysics tendency)", &
    1653           0 :              var_units="(kg/kg)^2/s", l_silhs=.false., grid_kind=stats_zm )
    1654           0 :         k = k + 1
    1655             : 
    1656             :       case ('rtp2_mc')
    1657           0 :         stats_metadata%irtp2_mc = k
    1658             : 
    1659             :         call stat_assign( var_index=stats_metadata%irtp2_mc, var_name="rtp2_mc", &
    1660             :              var_description="rt'^2_mc, Microphysics tendency for rtp2 (not in budget)", &
    1661           0 :              var_units="(kg/kg)^2/s", l_silhs=.false., grid_kind=stats_zm )
    1662           0 :         k = k + 1
    1663             : 
    1664             :       case ('thlp2_bt')
    1665           0 :         stats_metadata%ithlp2_bt = k
    1666             :         call stat_assign( var_index=stats_metadata%ithlp2_bt, var_name="thlp2_bt", &
    1667             :              var_description="thl'^2_bt, thlp2 budget: thlp2 time tendency", &
    1668             :              var_units="(K^2)/s", &
    1669           0 :              l_silhs=.false., grid_kind=stats_zm )
    1670           0 :         k = k + 1
    1671             :       case ('thlp2_ma')
    1672           0 :         stats_metadata%ithlp2_ma = k
    1673             :         call stat_assign( var_index=stats_metadata%ithlp2_ma, var_name="thlp2_ma", &
    1674             :              var_description="thl'^2_ma, thlp2 budget: thlp2 mean advection", &
    1675             :              var_units="(K^2)/s", &
    1676           0 :              l_silhs=.false., grid_kind=stats_zm )
    1677           0 :         k = k + 1
    1678             :       case ('thlp2_ta')
    1679           0 :         stats_metadata%ithlp2_ta = k
    1680             :         call stat_assign( var_index=stats_metadata%ithlp2_ta, var_name="thlp2_ta", &
    1681             :              var_description="thl'^2_ta, thlp2 budget: thlp2 turbulent advection", &
    1682           0 :              var_units="(K^2)/s", l_silhs=.false., grid_kind=stats_zm )
    1683           0 :         k = k + 1
    1684             :       case ('thlp2_tp')
    1685           0 :         stats_metadata%ithlp2_tp = k
    1686             :         call stat_assign( var_index=stats_metadata%ithlp2_tp, var_name="thlp2_tp", &
    1687             :              var_description="thl'^2_t', thlp2 budget: thlp2 turbulent production", &
    1688           0 :              var_units="(K^2)/s", l_silhs=.false., grid_kind=stats_zm )
    1689           0 :         k = k + 1
    1690             :       case ('thlp2_dp1')
    1691           0 :         stats_metadata%ithlp2_dp1 = k
    1692             :         call stat_assign( var_index=stats_metadata%ithlp2_dp1, var_name="thlp2_dp1", &
    1693             :              var_description="thl'^2_dp1, thlp2 budget: thlp2 dissipation term 1", &
    1694           0 :              var_units="(K^2)/s", l_silhs=.false., grid_kind=stats_zm )
    1695           0 :         k = k + 1
    1696             :       case ('thlp2_dp2')
    1697           0 :         stats_metadata%ithlp2_dp2 = k
    1698             :         call stat_assign( var_index=stats_metadata%ithlp2_dp2, var_name="thlp2_dp2", &
    1699             :              var_description="thl'^2_dp2, thlp2 budget: thlp2 dissipation term 2", &
    1700           0 :              var_units="(K^2)/s", l_silhs=.false., grid_kind=stats_zm )
    1701           0 :         k = k + 1
    1702             :       case ('thlp2_cl')
    1703           0 :         stats_metadata%ithlp2_cl = k
    1704             :         call stat_assign( var_index=stats_metadata%ithlp2_cl, var_name="thlp2_cl", &
    1705             :              var_description="thl'^2_cl, thlp2 budget: thlp2 clipping term", &
    1706             :              var_units="(K^2)/s", &
    1707           0 :              l_silhs=.false., grid_kind=stats_zm )
    1708           0 :         k = k + 1
    1709             : 
    1710             :       case ('thlp2_pd')
    1711           0 :         stats_metadata%ithlp2_pd = k
    1712             :         call stat_assign( var_index=stats_metadata%ithlp2_pd, var_name="thlp2_pd", &
    1713             :              var_description="thl'^2_pd, thlp2 budget: thlp2 positive definite adjustment", &
    1714           0 :              var_units="K^2/s", l_silhs=.false., grid_kind=stats_zm )
    1715           0 :         k = k + 1
    1716             : 
    1717             :       case ('thlp2_sf')
    1718           0 :         stats_metadata%ithlp2_sf = k
    1719             :         call stat_assign( var_index=stats_metadata%ithlp2_sf, var_name="thlp2_sf", &
    1720             :              var_description="thl'^2_sf, thl'^2 budget: thlp2 surface variance", &
    1721             :              var_units="K^2/s", &
    1722           0 :              l_silhs=.false., grid_kind=stats_zm )
    1723           0 :         k = k + 1
    1724             :       case ('thlp2_forcing')
    1725           0 :         stats_metadata%ithlp2_forcing = k
    1726             :         call stat_assign( var_index=stats_metadata%ithlp2_forcing, var_name="thlp2_forcing", &
    1727             :              var_description="thlp2 budget: thlp2 forcing (includes microphysics tendency) &
    1728             :              &[K^2/s]", &
    1729           0 :              var_units="K^2/s", l_silhs=.false., grid_kind=stats_zm )
    1730           0 :         k = k + 1
    1731             :       case ('thlp2_mc')
    1732           0 :         stats_metadata%ithlp2_mc = k
    1733             :         call stat_assign( var_index=stats_metadata%ithlp2_mc, var_name="thlp2_mc", &
    1734             :              var_description="thl'^2_mc, Microphysics tendency for thlp2 (not in budget)", &
    1735           0 :              var_units="K^2/s", l_silhs=.false., grid_kind=stats_zm )
    1736           0 :         k = k + 1
    1737             : 
    1738             :       case ('rtpthlp_bt')
    1739           0 :         stats_metadata%irtpthlp_bt = k
    1740             :         call stat_assign( var_index=stats_metadata%irtpthlp_bt, var_name="rtpthlp_bt", &
    1741             :              var_description="rt'thl'_bt, rtpthlp budget: rtpthlp time tendency", &
    1742           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1743           0 :         k = k + 1
    1744             :       case ('rtpthlp_ma')
    1745           0 :         stats_metadata%irtpthlp_ma = k
    1746             :         call stat_assign( var_index=stats_metadata%irtpthlp_ma, var_name="rtpthlp_ma", &
    1747             :              var_description="rt'thl'_ma, rtpthlp budget: rtpthlp mean advection", &
    1748           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1749           0 :         k = k + 1
    1750             :       case ('rtpthlp_ta')
    1751           0 :         stats_metadata%irtpthlp_ta = k
    1752             :         call stat_assign( var_index=stats_metadata%irtpthlp_ta, var_name="rtpthlp_ta", &
    1753             :              var_description="rt'thl'_ta, rtpthlp budget: rtpthlp turbulent advection", &
    1754           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1755           0 :         k = k + 1
    1756             :       case ('rtpthlp_tp1')
    1757           0 :         stats_metadata%irtpthlp_tp1 = k
    1758             :         call stat_assign( var_index=stats_metadata%irtpthlp_tp1, var_name="rtpthlp_tp1", &
    1759             :              var_description="rt'thl'_tp1, rtpthlp budget: rtpthlp turbulent production 1", &
    1760           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1761           0 :         k = k + 1
    1762             :       case ('rtpthlp_tp2')
    1763           0 :         stats_metadata%irtpthlp_tp2 = k
    1764             :         call stat_assign( var_index=stats_metadata%irtpthlp_tp2, var_name="rtpthlp_tp2", &
    1765             :              var_description="rt'thl'_t'^2, rtpthlp budget: rtpthlp turbulent production 2", &
    1766           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1767           0 :         k = k + 1
    1768             :       case ('rtpthlp_dp1')
    1769           0 :         stats_metadata%irtpthlp_dp1 = k
    1770             :         call stat_assign( var_index=stats_metadata%irtpthlp_dp1, var_name="rtpthlp_dp1", &
    1771             :              var_description="rt'thl'_d'1, rtpthlp budget: rtpthlp dissipation term 1", &
    1772           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1773           0 :         k = k + 1
    1774             :       case ('rtpthlp_dp2')
    1775           0 :         stats_metadata%irtpthlp_dp2 = k
    1776             :         call stat_assign( var_index=stats_metadata%irtpthlp_dp2, var_name="rtpthlp_dp2", &
    1777             :              var_description="rt'thl'_dp2, rtpthlp budget: rtpthlp dissipation term 2", &
    1778           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1779           0 :         k = k + 1
    1780             :       case ('rtpthlp_cl')
    1781           0 :         stats_metadata%irtpthlp_cl = k
    1782             :         call stat_assign( var_index=stats_metadata%irtpthlp_cl, var_name="rtpthlp_cl", &
    1783             :              var_description="rt'thl'_cl, rtpthlp budget: rtpthlp clipping term", &
    1784           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1785           0 :         k = k + 1
    1786             :       case ('rtpthlp_sf')
    1787           0 :         stats_metadata%irtpthlp_sf = k
    1788             :         call stat_assign( var_index=stats_metadata%irtpthlp_sf, var_name="rtpthlp_sf", &
    1789             :              var_description="rt'thl'_sf, rtpthlp budget: rtpthlp surface variance", &
    1790           0 :              var_units="(kg K)/(kg s)", l_silhs=.false., grid_kind=stats_zm )
    1791           0 :         k = k + 1
    1792             :       case ('rtpthlp_forcing')
    1793           0 :         stats_metadata%irtpthlp_forcing = k
    1794             :         call stat_assign( var_index=stats_metadata%irtpthlp_forcing, var_name="rtpthlp_forcing", &
    1795             :              var_description="rt'thl'_forcing, rtpthlp budget: rtpthlp forcing "&
    1796             :              // "(includes microphysics tendency)", &
    1797           0 :              var_units="(K kg/kg)/s", l_silhs=.false., grid_kind=stats_zm )
    1798           0 :         k = k + 1
    1799             :       case ('rtpthlp_mc')
    1800           0 :         stats_metadata%irtpthlp_mc = k
    1801             :         call stat_assign( var_index=stats_metadata%irtpthlp_mc, var_name="rtpthlp_mc", &
    1802             :              var_description="rt'thl'_mc, Microphysics tendency for rtpthlp (not in budget)", &
    1803           0 :              var_units="(K kg/kg)/s", l_silhs=.false., grid_kind=stats_zm )
    1804           0 :         k = k + 1
    1805             : 
    1806             :       case ('up2')
    1807           0 :         stats_metadata%iup2 = k
    1808             :         call stat_assign( var_index=stats_metadata%iup2, var_name="up2", &
    1809             :              var_description="u'^2, Variance of eastward (u) wind", var_units="m^2/s^2", &
    1810           0 :              l_silhs=.false., grid_kind=stats_zm )
    1811           0 :         k = k + 1
    1812             : 
    1813             :       case ('vp2')
    1814           0 :         stats_metadata%ivp2 = k
    1815             :         call stat_assign( var_index=stats_metadata%ivp2, var_name="vp2", &
    1816             :              var_description="v'^2, Variance of northward (v) wind", var_units="m^2/s^2", &
    1817           0 :              l_silhs=.false., grid_kind=stats_zm )
    1818           0 :         k = k + 1
    1819             : 
    1820             :       case ('up2_bt')
    1821           0 :         stats_metadata%iup2_bt = k
    1822             :         call stat_assign( var_index=stats_metadata%iup2_bt, var_name="up2_bt", &
    1823             :              var_description="u'^2_bt, up2 budget: up2 time tendency", var_units="m^2/s^3", &
    1824           0 :              l_silhs=.false., grid_kind=stats_zm )
    1825           0 :         k = k + 1
    1826             : 
    1827             :       case ('up2_ma')
    1828           0 :         stats_metadata%iup2_ma = k
    1829             :         call stat_assign( var_index=stats_metadata%iup2_ma, var_name="up2_ma", &
    1830             :              var_description="u'^2_ma, up2 budget: up2 mean advection", var_units="m^2/s^3", &
    1831           0 :              l_silhs=.false., grid_kind=stats_zm )
    1832           0 :         k = k + 1
    1833             : 
    1834             :       case ('up2_ta')
    1835           0 :         stats_metadata%iup2_ta = k
    1836             :         call stat_assign( var_index=stats_metadata%iup2_ta, var_name="up2_ta", &
    1837             :              var_description="u'^2_ta, up2 budget: up2 turbulent advection", &
    1838           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1839           0 :         k = k + 1
    1840             : 
    1841             :       case ('up2_tp')
    1842           0 :         stats_metadata%iup2_tp = k
    1843             :         call stat_assign( var_index=stats_metadata%iup2_tp, var_name="up2_tp", &
    1844             :              var_description="u'^2_tp, up2 budget: up2 turbulent production", &
    1845           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1846           0 :         k = k + 1
    1847             : 
    1848             :       case ('up2_dp1')
    1849           0 :         stats_metadata%iup2_dp1 = k
    1850             :         call stat_assign( var_index=stats_metadata%iup2_dp1, var_name="up2_dp1", &
    1851             :              var_description="u'^2_dp1, up2 budget: up2 dissipation term 1", &
    1852             :              var_units="m^2/s^3", &
    1853           0 :              l_silhs=.false., grid_kind=stats_zm )
    1854           0 :         k = k + 1
    1855             : 
    1856             :       case ('up2_dp2')
    1857           0 :         stats_metadata%iup2_dp2 = k
    1858             :         call stat_assign( var_index=stats_metadata%iup2_dp2, var_name="up2_dp2", &
    1859             :              var_description="u'^2_d'^2, up2 budget: up2 dissipation term 2", &
    1860             :              var_units="m^2/s^3", &
    1861           0 :              l_silhs=.false., grid_kind=stats_zm )
    1862           0 :         k = k + 1
    1863             : 
    1864             :       case ('up2_pr1')
    1865           0 :         stats_metadata%iup2_pr1 = k
    1866             :         call stat_assign( var_index=stats_metadata%iup2_pr1, var_name="up2_pr1", &
    1867             :              var_description="u'^2_pr1, up2 budget: up2 pressure term 1", var_units="m^2/s^3", &
    1868           0 :              l_silhs=.false., grid_kind=stats_zm )
    1869           0 :         k = k + 1
    1870             : 
    1871             :       case ('up2_pr2')
    1872           0 :         stats_metadata%iup2_pr2 = k
    1873             :         call stat_assign( var_index=stats_metadata%iup2_pr2, var_name="up2_pr2", &
    1874             :              var_description="u'^2_pr2, up2 budget: up2 pressure term 2", var_units="m^2/s^3", &
    1875           0 :              l_silhs=.false., grid_kind=stats_zm )
    1876           0 :         k = k + 1
    1877             : 
    1878             :       case ('up2_sdmp')
    1879           0 :         stats_metadata%iup2_sdmp = k
    1880             :         call stat_assign( var_index=stats_metadata%iup2_sdmp, var_name="up2_sdmp", &
    1881             :              var_description="u'^2_sdmp, up2 budget: up2 sponge damping term", &
    1882             :              var_units="m^2/s^3", &
    1883           0 :              l_silhs=.false., grid_kind=stats_zm )
    1884           0 :         k = k + 1
    1885             : 
    1886             :       case ('up2_cl')
    1887           0 :         stats_metadata%iup2_cl = k
    1888             :         call stat_assign( var_index=stats_metadata%iup2_cl, var_name="up2_cl", &
    1889             :              var_description="u'^2_cl, up2 budget: up2 clipping", var_units="m^2/s^3", &
    1890           0 :              l_silhs=.false., grid_kind=stats_zm )
    1891           0 :         k = k + 1
    1892             : 
    1893             :       case ('up2_pd')
    1894           0 :         stats_metadata%iup2_pd = k
    1895             :         call stat_assign( var_index=stats_metadata%iup2_pd, var_name="up2_pd", &
    1896             :              var_description="u'^2_pd, up2 budget: up2 positive definite adjustment", &
    1897           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1898           0 :         k = k + 1
    1899             : 
    1900             :       case ('up2_sf')
    1901           0 :         stats_metadata%iup2_sf = k
    1902             :         call stat_assign( var_index=stats_metadata%iup2_sf, var_name="up2_sf", &
    1903             :              var_description="u'^2_sf, up2 budget: up2 surface variance", var_units="m^2/s^3", &
    1904           0 :              l_silhs=.false., grid_kind=stats_zm )
    1905           0 :         k = k + 1
    1906             : 
    1907             :       case ('up2_splat')
    1908           0 :         stats_metadata%iup2_splat = k
    1909             :         call stat_assign( var_index=stats_metadata%iup2_splat, var_name="up2_splat", &
    1910             :              var_description="u'^2_splat, up2 budget: up2 splatting", var_units="m^2/s^3", &
    1911           0 :              l_silhs=.false., grid_kind=stats_zm )
    1912           0 :         k = k + 1
    1913             : 
    1914             :       case ('vp2_bt')
    1915           0 :         stats_metadata%ivp2_bt = k
    1916             :         call stat_assign( var_index=stats_metadata%ivp2_bt, var_name="vp2_bt", &
    1917             :              var_description="v'2_bt, vp2 budget: vp2 time tendency", var_units="m^2/s^3", &
    1918           0 :              l_silhs=.false., grid_kind=stats_zm )
    1919           0 :         k = k + 1
    1920             : 
    1921             :       case ('vp2_ma')
    1922           0 :         stats_metadata%ivp2_ma = k
    1923             :         call stat_assign( var_index=stats_metadata%ivp2_ma, var_name="vp2_ma", &
    1924             :              var_description="v'^2_ma, vp2 budget: vp2 mean advection", var_units="m^2/s^3", &
    1925           0 :              l_silhs=.false., grid_kind=stats_zm )
    1926           0 :         k = k + 1
    1927             : 
    1928             :       case ('vp2_ta')
    1929           0 :         stats_metadata%ivp2_ta = k
    1930             :         call stat_assign( var_index=stats_metadata%ivp2_ta, var_name="vp2_ta", &
    1931             :              var_description="v'^2_ta, vp2 budget: vp2 turbulent advection", &
    1932           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1933           0 :         k = k + 1
    1934             : 
    1935             :       case ('vp2_tp')
    1936           0 :         stats_metadata%ivp2_tp = k
    1937             :         call stat_assign( var_index=stats_metadata%ivp2_tp, var_name="vp2_tp", &
    1938             :              var_description="v'^2_tp, vp2 budget: vp2 turbulent production", &
    1939           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1940           0 :         k = k + 1
    1941             : 
    1942             :       case ('vp2_dp1')
    1943           0 :         stats_metadata%ivp2_dp1 = k
    1944             :         call stat_assign( var_index=stats_metadata%ivp2_dp1, var_name="vp2_dp1", &
    1945             :              var_description="v'^2_dp1, vp2 budget: vp2 dissipation term 1", &
    1946             :              var_units="m^2/s^3", &
    1947           0 :              l_silhs=.false., grid_kind=stats_zm )
    1948           0 :         k = k + 1
    1949             : 
    1950             :       case ('vp2_dp2')
    1951           0 :         stats_metadata%ivp2_dp2 = k
    1952             :         call stat_assign( var_index=stats_metadata%ivp2_dp2, var_name="vp2_dp2", &
    1953             :              var_description="v'^2_dp2, vp2 budget: vp2 dissipation term 2", &
    1954             :              var_units="m^2/s^3", &
    1955           0 :              l_silhs=.false., grid_kind=stats_zm )
    1956           0 :         k = k + 1
    1957             : 
    1958             :       case ('vp2_pr1')
    1959           0 :         stats_metadata%ivp2_pr1 = k
    1960             :         call stat_assign( var_index=stats_metadata%ivp2_pr1, var_name="vp2_pr1", &
    1961             :              var_description="v'^2_pr1, vp2 budget: vp2 pressure term 1", var_units="m^2/s^3", &
    1962           0 :              l_silhs=.false., grid_kind=stats_zm )
    1963           0 :         k = k + 1
    1964             : 
    1965             :       case ('vp2_pr2')
    1966           0 :         stats_metadata%ivp2_pr2 = k
    1967             :         call stat_assign( var_index=stats_metadata%ivp2_pr2, var_name="vp2_pr2", &
    1968             :              var_description="v'^2_pr2, vp2 budget: vp2 pressure term 2", var_units="m^2/s^3", &
    1969           0 :              l_silhs=.false., grid_kind=stats_zm )
    1970           0 :         k = k + 1
    1971             : 
    1972             :       case ('vp2_sdmp')
    1973           0 :         stats_metadata%ivp2_sdmp = k
    1974             :         call stat_assign( var_index=stats_metadata%ivp2_sdmp, var_name="vp2_sdmp", &
    1975             :              var_description="v'^2_sdmp, vp2 budget: vp2 sponge damping term", &
    1976             :              var_units="m^2/s^3", &
    1977           0 :              l_silhs=.false., grid_kind=stats_zm )
    1978           0 :         k = k + 1
    1979             : 
    1980             :       case ('vp2_cl')
    1981           0 :         stats_metadata%ivp2_cl = k
    1982             :         call stat_assign( var_index=stats_metadata%ivp2_cl, var_name="vp2_cl", &
    1983             :              var_description="v'^2_cl, vp2 budget: vp2 clipping", var_units="m^2/s^3", &
    1984           0 :              l_silhs=.false., grid_kind=stats_zm )
    1985           0 :         k = k + 1
    1986             : 
    1987             :       case ('vp2_pd')
    1988           0 :         stats_metadata%ivp2_pd = k
    1989             :         call stat_assign( var_index=stats_metadata%ivp2_pd, var_name="vp2_pd", &
    1990             :              var_description="v'^2_pd, vp2 budget: vp2 positive definite adjustment", &
    1991           0 :              var_units="m^2/s^3", l_silhs=.false., grid_kind=stats_zm )
    1992           0 :         k = k + 1
    1993             : 
    1994             :       case ('vp2_sf')
    1995           0 :         stats_metadata%ivp2_sf = k
    1996             :         call stat_assign( var_index=stats_metadata%ivp2_sf, var_name="vp2_sf", &
    1997             :              var_description="v'^2_sf, vp2 budget: vp2 surface variance", var_units="m^2/s^3", &
    1998           0 :              l_silhs=.false., grid_kind=stats_zm )
    1999           0 :         k = k + 1
    2000             : 
    2001             :       case ('vp2_splat')
    2002           0 :         stats_metadata%ivp2_splat = k
    2003             :         call stat_assign( var_index=stats_metadata%ivp2_splat, var_name="vp2_splat", &
    2004             :              var_description="v'^2_splat, vp2 budget: vp2 splatting", var_units="m^2/s^3", &
    2005           0 :              l_silhs=.false., grid_kind=stats_zm )
    2006           0 :         k = k + 1
    2007             : 
    2008             :       case ('wpthlp_enter_mfl')
    2009           0 :         stats_metadata%iwpthlp_enter_mfl = k
    2010             :         call stat_assign( var_index=stats_metadata%iwpthlp_enter_mfl, var_name="wpthlp_enter_mfl", &
    2011             :              var_description="w'thl'_enter_mfl, Wpthlp entering flux limiter", &
    2012             :              var_units="(m K)/s", &
    2013           0 :              l_silhs=.false., grid_kind=stats_zm )
    2014           0 :         k = k + 1
    2015             : 
    2016             :       case ('wpthlp_exit_mfl')
    2017           0 :         stats_metadata%iwpthlp_exit_mfl = k
    2018             :         call stat_assign( var_index=stats_metadata%iwpthlp_exit_mfl, var_name="wpthlp_exit_mfl", &
    2019             :              var_description="w'thl'_exit_mfl, Wpthlp exiting flux limiter", &
    2020             :              var_units="(m K)/s", &
    2021           0 :              l_silhs=.false., grid_kind=stats_zm )
    2022           0 :         k = k + 1
    2023             : 
    2024             :       case ('wpthlp_mfl_min')
    2025           0 :         stats_metadata%iwpthlp_mfl_min = k
    2026             :         call stat_assign( var_index=stats_metadata%iwpthlp_mfl_min, var_name="wpthlp_mfl_min", &
    2027             :              var_description="w'thl'_mfl_min, Minimum allowable wpthlp", var_units="(m K)/s", &
    2028           0 :              l_silhs=.false., grid_kind=stats_zm )
    2029           0 :         k = k + 1
    2030             : 
    2031             :       case ('wpthlp_mfl_max')
    2032           0 :         stats_metadata%iwpthlp_mfl_max = k
    2033             :         call stat_assign( var_index=stats_metadata%iwpthlp_mfl_max, var_name="wpthlp_mfl_max", &
    2034             :              var_description="w'thl'_mfl_max, Maximum allowable wpthlp", var_units="(m K)/s", &
    2035           0 :              l_silhs=.false., grid_kind=stats_zm )
    2036           0 :         k = k + 1
    2037             : 
    2038             :       case ('wprtp_mfl_min')
    2039           0 :         stats_metadata%iwprtp_mfl_min = k
    2040             :         call stat_assign( var_index=stats_metadata%iwprtp_mfl_min, var_name="wprtp_mfl_min", &
    2041             :              var_description="w'rt'_mfl_min, Minimum allowable wprtp", &
    2042           0 :              var_units="(m kg)/(s kg)", l_silhs=.false., grid_kind=stats_zm )
    2043           0 :         k = k + 1
    2044             : 
    2045             :       case ('wprtp_mfl_max')
    2046           0 :         stats_metadata%iwprtp_mfl_max = k
    2047             :         call stat_assign( var_index=stats_metadata%iwprtp_mfl_max, var_name="wprtp_mfl_max", &
    2048             :              var_description="w'rt'_mfl_max, Maximum allowable wprtp", &
    2049           0 :              var_units="(m kg)/(s kg)", l_silhs=.false., grid_kind=stats_zm )
    2050           0 :         k = k + 1
    2051             : 
    2052             :       case ('wprtp_enter_mfl')
    2053           0 :         stats_metadata%iwprtp_enter_mfl = k
    2054             :         call stat_assign( var_index=stats_metadata%iwprtp_enter_mfl, var_name="wprtp_enter_mfl", &
    2055             :              var_description="w'rt'_enter_mfl, Wprtp entering flux limiter", &
    2056           0 :              var_units="(m kg)/(s kg)", l_silhs=.false., grid_kind=stats_zm )
    2057           0 :         k = k + 1
    2058             : 
    2059             :       case ('wprtp_exit_mfl')
    2060           0 :         stats_metadata%iwprtp_exit_mfl = k
    2061             :         call stat_assign( var_index=stats_metadata%iwprtp_exit_mfl, var_name="wprtp_exit_mfl", &
    2062             :              var_description="w'rt'_exit_mfl, Wprtp exiting flux limiter", &
    2063           0 :              var_units="(m kg)/(s kg)", l_silhs=.false., grid_kind=stats_zm )
    2064           0 :         k = k + 1
    2065             : 
    2066             :       case ('wm_zm')
    2067           0 :         stats_metadata%iwm_zm = k
    2068             :         call stat_assign( var_index=stats_metadata%iwm_zm, var_name="wm_zm", &
    2069             :              var_description="wm_zm, Vertical (w) wind", var_units="m/s", l_silhs=.false., &
    2070           0 :              grid_kind=stats_zm )
    2071           0 :         k = k + 1
    2072             : 
    2073             :       case ('cloud_frac_zm')
    2074           0 :         stats_metadata%icloud_frac_zm = k
    2075             :         call stat_assign( var_index=stats_metadata%icloud_frac_zm, var_name="cloud_frac_zm", &
    2076             :           var_description="cloud_frac_zm, Cloud fraction", &
    2077           0 :           var_units="-", l_silhs=.false., grid_kind=stats_zm)
    2078           0 :         k = k + 1
    2079             : 
    2080             :       case ('ice_supersat_frac_zm')
    2081           0 :         stats_metadata%iice_supersat_frac_zm = k
    2082             :         call stat_assign( var_index=stats_metadata%iice_supersat_frac_zm, var_name="ice_supersat_frac_zm", &
    2083             :              var_description="ice_supersat_frac_zm, Ice cloud fraction", &
    2084             :              var_units="count", l_silhs=.false., &
    2085           0 :              grid_kind=stats_zm )
    2086           0 :         k = k + 1
    2087             : 
    2088             :       case ('rcm_zm')
    2089           0 :         stats_metadata%ircm_zm = k
    2090             :         call stat_assign( var_index=stats_metadata%ircm_zm, var_name="rcm_zm", &
    2091             :              var_description="rcm_zm, Total water mixing ratio", var_units="kg/kg", &
    2092           0 :              l_silhs=.false., grid_kind=stats_zm )
    2093           0 :         k = k + 1
    2094             : 
    2095             :       case ('rtm_zm')
    2096           0 :         stats_metadata%irtm_zm = k
    2097             :         call stat_assign( var_index=stats_metadata%irtm_zm, var_name="rtm_zm", &
    2098             :              var_description="rtm_zm, Total water mixing ratio", var_units="kg/kg", &
    2099           0 :              l_silhs=.false., grid_kind=stats_zm )
    2100           0 :         k = k + 1
    2101             : 
    2102             :       case ('thlm_zm')
    2103           0 :         stats_metadata%ithlm_zm = k
    2104             :         call stat_assign( var_index=stats_metadata%ithlm_zm, var_name="thlm_zm", &
    2105             :              var_description="thlm_zm, Liquid potential temperature", &
    2106             :              var_units="K", l_silhs=.false., &
    2107           0 :              grid_kind=stats_zm )
    2108           0 :         k = k + 1
    2109             : 
    2110             :       case ('w_1_zm')
    2111           0 :         stats_metadata%iw_1_zm = k
    2112             :         call stat_assign( var_index=stats_metadata%iw_1_zm, var_name="w_1_zm", &
    2113             :              var_description="w_1_zm, pdf parameter zm: mean w of component 1", &
    2114           0 :              var_units="m/s", l_silhs=.false., grid_kind=stats_zm )
    2115           0 :         k = k + 1
    2116             : 
    2117             :       case ('w_2_zm')
    2118           0 :         stats_metadata%iw_2_zm = k
    2119             :         call stat_assign( var_index=stats_metadata%iw_2_zm, var_name="w_2_zm", &
    2120             :              var_description="w_2_zm, pdf parameter zm: mean w of component 2", &
    2121           0 :              var_units="m/s", l_silhs=.false., grid_kind=stats_zm )
    2122           0 :         k = k + 1
    2123             : 
    2124             :       case ('varnce_w_1_zm')
    2125           0 :         stats_metadata%ivarnce_w_1_zm = k
    2126             :         call stat_assign( var_index=stats_metadata%ivarnce_w_1_zm, var_name="varnce_w_1_zm", &
    2127             :              var_description="varnce_w_1_zm, pdf parameter zm: w variance of component 1", &
    2128           0 :              var_units="m^2/s^2", l_silhs=.false., grid_kind=stats_zm )
    2129           0 :         k = k + 1
    2130             : 
    2131             :       case ('varnce_w_2_zm')
    2132           0 :         stats_metadata%ivarnce_w_2_zm = k
    2133             :         call stat_assign( var_index=stats_metadata%ivarnce_w_2_zm, var_name="varnce_w_2_zm", &
    2134             :              var_description="varnce_w_2_zm, pdf parameter zm: w variance of component 2", &
    2135           0 :              var_units="m^2/s^2", l_silhs=.false., grid_kind=stats_zm )
    2136           0 :         k = k + 1
    2137             : 
    2138             :       case ('mixt_frac_zm')
    2139           0 :         stats_metadata%imixt_frac_zm = k
    2140             :         call stat_assign( var_index=stats_metadata%imixt_frac_zm, var_name="mixt_frac_zm", &
    2141             :              var_description="mixt_frac_zm, pdf parameter zm: mixture fraction", &
    2142           0 :              var_units="-", l_silhs=.false., grid_kind=stats_zm )
    2143           0 :         k = k + 1
    2144             : 
    2145             :       case ( 'Skw_velocity' )
    2146           0 :         stats_metadata%iSkw_velocity = k
    2147             :         call stat_assign( var_index=stats_metadata%iSkw_velocity, var_name="Skw_velocity", &
    2148             :              var_description="Skw_velocity, Skewness velocity", &
    2149             :              var_units="m/s", l_silhs=.false., &
    2150           0 :              grid_kind=stats_zm )
    2151           0 :         k = k + 1
    2152             : 
    2153             :       case ( 'gamma_Skw_fnc' )
    2154           0 :         stats_metadata%igamma_Skw_fnc = k
    2155             :         call stat_assign( var_index=stats_metadata%igamma_Skw_fnc, var_name="gamma_Skw_fnc", &
    2156             :              var_description="gamma_Skw_fnc, Gamma as a function of skewness", var_units="-", &
    2157           0 :              l_silhs=.false., grid_kind=stats_zm )
    2158           0 :         k = k + 1
    2159             : 
    2160             :       case ( 'C6rt_Skw_fnc' )
    2161           0 :         stats_metadata%iC6rt_Skw_fnc = k
    2162             :         call stat_assign( var_index=stats_metadata%iC6rt_Skw_fnc, var_name="C6rt_Skw_fnc", &
    2163             :              var_description="C6rt_Skw_fnc, C_6rt parameter with Sk_w applied", var_units="-", &
    2164           0 :              l_silhs=.false., grid_kind=stats_zm )
    2165           0 :         k = k + 1
    2166             : 
    2167             :       case ( 'C6thl_Skw_fnc' )
    2168           0 :         stats_metadata%iC6thl_Skw_fnc = k
    2169             :         call stat_assign( var_index=stats_metadata%iC6thl_Skw_fnc, var_name="C6thl_Skw_fnc", &
    2170             :              var_description="C6thl_Skw_fnc, C_6thl parameter with Sk_w applied", var_units="-", &
    2171           0 :              l_silhs=.false., grid_kind=stats_zm )
    2172           0 :         k = k + 1
    2173             : 
    2174             :       case ( 'C6_term' )
    2175           0 :         stats_metadata%iC6_term = k
    2176             :         call stat_assign( var_index=stats_metadata%iC6_term, var_name="C6_term", &
    2177             :              var_description="C6 term [-]", var_units="-", &
    2178           0 :              l_silhs=.false., grid_kind=stats_zm )
    2179           0 :         k = k + 1
    2180             : 
    2181             :       case ( 'C7_Skw_fnc' )
    2182           0 :         stats_metadata%iC7_Skw_fnc = k
    2183             :         call stat_assign( var_index=stats_metadata%iC7_Skw_fnc, var_name="C7_Skw_fnc", &
    2184             :              var_description="C7_Skw_fnc, C_7 parameter with Sk_w applied", var_units="-", &
    2185           0 :              l_silhs=.false., grid_kind=stats_zm )
    2186           0 :         k = k + 1
    2187             : 
    2188             :       case ( 'C1_Skw_fnc' )
    2189           0 :         stats_metadata%iC1_Skw_fnc = k
    2190             :         call stat_assign( var_index=stats_metadata%iC1_Skw_fnc, var_name="C1_Skw_fnc", &
    2191             :              var_description="C1_Skw_fnc, C_1 parameter with Sk_w applied", var_units="-", &
    2192           0 :              l_silhs=.false., grid_kind=stats_zm )
    2193           0 :         k = k + 1
    2194             : 
    2195             :       case ( 'coef_wp4_implicit' )
    2196           0 :         stats_metadata%icoef_wp4_implicit = k
    2197             :         call stat_assign( var_index=stats_metadata%icoef_wp4_implicit, &
    2198             :                           var_name="coef_wp4_implicit", &
    2199             :                           var_description="coef_wp4_implicit, wp4 = coef_wp4_implicit * wp2^2" &
    2200             :                                           // " (new PDF)", &
    2201           0 :                           var_units="-", l_silhs=.false., grid_kind=stats_zm )
    2202           0 :         k = k + 1
    2203             : 
    2204             :       case ( 'bv_freq_sqd' )
    2205           0 :         stats_metadata%ibrunt_vaisala_freq_sqd = k
    2206             :         call stat_assign( var_index=stats_metadata%ibrunt_vaisala_freq_sqd, var_name="bv_freq_sqd", &
    2207             :              var_description="Brunt-Vaisala frequency squared", &
    2208             :              var_units="1/s^2", &
    2209           0 :              l_silhs=.false., grid_kind=stats_zm )
    2210           0 :         k = k + 1
    2211             : 
    2212             :       case ( 'bv_freq_sqd_splat' )
    2213           0 :         stats_metadata%ibrunt_vaisala_freq_sqd_splat = k
    2214             :         call stat_assign( var_index=stats_metadata%ibrunt_vaisala_freq_sqd_splat, var_name="bv_freq_sqd_splat", &
    2215             :              var_description="Brunt-Vaisala freq. squared for splatting", &
    2216             :              var_units="1/s^2", &
    2217           0 :              l_silhs=.false., grid_kind=stats_zm )
    2218           0 :         k = k + 1
    2219             : 
    2220             :       case ( 'bv_freq_sqd_mixed' )
    2221           0 :         stats_metadata%ibrunt_vaisala_freq_sqd_mixed = k
    2222             :         call stat_assign( var_index=stats_metadata%ibrunt_vaisala_freq_sqd_mixed, var_name="bv_freq_sqd_mixed", &
    2223             :              var_description="Interpolated Brunt-Vaisala freq. squared between moist and dry air", &
    2224             :              var_units="1/s^2", &
    2225           0 :              l_silhs=.false., grid_kind=stats_zm )
    2226           0 :         k = k + 1
    2227             : 
    2228             :       case ( 'bv_freq_sqd_moist' )
    2229           0 :         stats_metadata%ibrunt_vaisala_freq_sqd_moist = k
    2230             :         call stat_assign( var_index=stats_metadata%ibrunt_vaisala_freq_sqd_moist, var_name="bv_freq_sqd_moist", &
    2231             :              var_description="Brunt-Vaisala freq. squared in moist air", &
    2232             :              var_units="1/s^2", &
    2233           0 :              l_silhs=.false., grid_kind=stats_zm )
    2234           0 :         k = k + 1
    2235             : 
    2236             :       case ( 'bv_freq_sqd_dry' )
    2237           0 :         stats_metadata%ibrunt_vaisala_freq_sqd_dry = k
    2238             :         call stat_assign( var_index=stats_metadata%ibrunt_vaisala_freq_sqd_dry, var_name="bv_freq_sqd_dry", &
    2239             :              var_description="Brunt-Vaisala freq. squared in dry air", &
    2240             :              var_units="1/s^2", &
    2241           0 :              l_silhs=.false., grid_kind=stats_zm )
    2242           0 :         k = k + 1
    2243             : 
    2244             :       case ( 'Ri_zm' )
    2245           0 :         stats_metadata%iRi_zm = k
    2246             :         call stat_assign( var_index=stats_metadata%iRi_zm,var_name="Ri_zm", &
    2247             :              var_description="Richardson number [-]", var_units="-", &
    2248           0 :              l_silhs=.false., grid_kind=stats_zm )
    2249           0 :         k = k + 1
    2250             : 
    2251             :       case ( 'shear_sqd' )
    2252           0 :         stats_metadata%ishear_sqd = k
    2253             :         call stat_assign( var_index=stats_metadata%ishear_sqd, var_name="shear_sqd", &
    2254             :              var_description="shear_sqd, shear_sqd", var_units="-", &
    2255           0 :              l_silhs=.false., grid_kind=stats_zm )
    2256           0 :         k = k + 1
    2257             : 
    2258             :       case ( 'a3_coef' )
    2259           0 :         stats_metadata%ia3_coef = k
    2260             :         call stat_assign( var_index=stats_metadata%ia3_coef, var_name="a3_coef", &
    2261             :              var_description="a3_coef, Quantity in formula 25 from Equations for CLUBB", &
    2262           0 :              var_units="count", l_silhs=.false., grid_kind=stats_zm )
    2263           0 :         k = k + 1
    2264             : 
    2265             :       case ( 'wp3_on_wp2' )
    2266           0 :         stats_metadata%iwp3_on_wp2 = k
    2267             :         call stat_assign( var_index=stats_metadata%iwp3_on_wp2, var_name="wp3_on_wp2", &
    2268             :              var_description="w'^3_on_w'^2, Smoothed version of wp3 / wp2", var_units="m/s", &
    2269           0 :              l_silhs=.false., grid_kind=stats_zm )
    2270           0 :         k = k + 1
    2271             : 
    2272             :       case ( 'wp3_on_wp2_cfl_num' )
    2273           0 :         stats_metadata%iwp3_on_wp2_cfl_num = k
    2274             :         call stat_assign( var_index=stats_metadata%iwp3_on_wp2_cfl_num, var_name="wp3_on_wp2_cfl_num", &
    2275             :              var_description="w'^3_on_w'^2 CFL number", var_units="-", &
    2276           0 :              l_silhs=.false., grid_kind=stats_zm )
    2277           0 :         k = k + 1
    2278             : 
    2279             :       case ( 'Skw_zm' )
    2280           0 :         stats_metadata%iSkw_zm = k
    2281             :         call stat_assign( var_index=stats_metadata%iSkw_zm, var_name="Skw_zm", &
    2282             :              var_description="Skw_zm, Skewness of w on momentum levels", var_units="-", &
    2283           0 :              l_silhs=.false., grid_kind=stats_zm )
    2284           0 :         k = k + 1
    2285             : 
    2286             :       case ( 'Skthl_zm' )
    2287           0 :         stats_metadata%iSkthl_zm = k
    2288             :         call stat_assign( var_index=stats_metadata%iSkthl_zm, var_name="Skthl_zm", &
    2289             :              var_description="Skthl_zm, Skewness of thl on momentum levels", var_units="-", &
    2290           0 :              l_silhs=.false., grid_kind=stats_zm )
    2291           0 :         k = k + 1
    2292             : 
    2293             :       case ( 'Skrt_zm' )
    2294           0 :         stats_metadata%iSkrt_zm = k
    2295             :         call stat_assign( var_index=stats_metadata%iSkrt_zm, var_name="Skrt_zm", &
    2296             :              var_description="Skrt_zm, Skewness of rt on momentum levels", var_units="-", &
    2297           0 :              l_silhs=.false., grid_kind=stats_zm )
    2298           0 :         k = k + 1
    2299             : 
    2300             :       case ( 'stability_correction' )
    2301           0 :         stats_metadata%istability_correction = k
    2302             :         call stat_assign( var_index=stats_metadata%istability_correction, var_name="stability_correction", &
    2303             :              var_description="stability_correction, Stability applied to "&
    2304             :              // "diffusion of rtm and thlm", var_units="-", &
    2305           0 :              l_silhs=.false., grid_kind=stats_zm )
    2306           0 :         k = k + 1
    2307             : 
    2308             :       case ( 'rtp2_from_chi' )
    2309           0 :         stats_metadata%irtp2_from_chi = k
    2310             :         call stat_assign( var_index=stats_metadata%irtp2_from_chi, var_name="rtp2_from_chi", &
    2311             :              var_description="rtp2_from_chi, Variance of rt, computed from the " &
    2312             :              // "chi/eta distribution", &
    2313           0 :              var_units="(kg/kg)^2", l_silhs=.false., grid_kind=stats_zm )
    2314           0 :         k = k + 1
    2315             : 
    2316             :       case ( 'lh_rtp2_mc' )
    2317           0 :         stats_metadata%ilh_rtp2_mc = k
    2318             :         call stat_assign( var_index=stats_metadata%ilh_rtp2_mc, var_name="lh_rtp2_mc", &
    2319             :              var_description="lh_rtp2_mc, LH est. of rtp2_mc", &
    2320           0 :              var_units="(kg/kg)^2/s", l_silhs=.false., grid_kind=stats_zm )
    2321           0 :         k = k + 1
    2322             : 
    2323             :       case ( 'lh_thlp2_mc' )
    2324           0 :         stats_metadata%ilh_thlp2_mc = k
    2325             :         call stat_assign( var_index=stats_metadata%ilh_thlp2_mc, var_name="lh_thlp2_mc", &
    2326             :              var_description="lh_thl'^2_mc, LH est. of thlp2_mc", &
    2327           0 :              var_units="K^2/s", l_silhs=.false., grid_kind=stats_zm )
    2328           0 :         k = k + 1
    2329             : 
    2330             :       case ( 'lh_wprtp_mc' )
    2331           0 :         stats_metadata%ilh_wprtp_mc = k
    2332             :         call stat_assign( var_index=stats_metadata%ilh_wprtp_mc, var_name="lh_wprtp_mc", &
    2333             :              var_description="lh_w'rt'_mc, LH est. of wprtp_mc", &
    2334           0 :              var_units="(m kg/kg)/s^2", l_silhs=.false., grid_kind=stats_zm )
    2335           0 :         k = k + 1
    2336             : 
    2337             :       case ( 'lh_wpthlp_mc' )
    2338           0 :         stats_metadata%ilh_wpthlp_mc = k
    2339             :         call stat_assign( var_index=stats_metadata%ilh_wpthlp_mc, var_name="lh_wpthlp_mc", &
    2340             :              var_description="lh_w'thl'_mc, LH est. of wpthlp_mc", &
    2341           0 :              var_units="(m K)/s^2", l_silhs=.false., grid_kind=stats_zm )
    2342           0 :         k = k + 1
    2343             : 
    2344             :       case ( 'lh_rtpthlp_mc' )
    2345           0 :         stats_metadata%ilh_rtpthlp_mc = k
    2346             :         call stat_assign( var_index=stats_metadata%ilh_rtpthlp_mc, var_name="lh_rtpthlp_mc", &
    2347             :              var_description="lh_rt'thl'_mc, LH est. of rtpthlp_mc", &
    2348           0 :              var_units="(K kg/kg)/s", l_silhs=.false., grid_kind=stats_zm )
    2349           0 :         k = k + 1
    2350             : 
    2351             :       case ( 'sclrprtp' )
    2352           0 :         do j = 1, sclr_dim, 1
    2353           0 :           write( sclr_idx, * ) j
    2354           0 :           sclr_idx = adjustl(sclr_idx)
    2355           0 :           stats_metadata%isclrprtp(j) = k
    2356           0 :           call stat_assign( var_index=stats_metadata%isclrprtp(j), var_name="sclr"//trim(sclr_idx)//"prtp", &
    2357             :             var_description="scalar("//trim(sclr_idx)//")'rt'", var_units="unknown", &
    2358           0 :             l_silhs=.false., grid_kind=stats_zm )
    2359           0 :           k = k + 1
    2360             :         end do
    2361             : 
    2362             :       case ( 'sclrp2' )
    2363           0 :         do j = 1, sclr_dim, 1
    2364           0 :           write( sclr_idx, * ) j
    2365           0 :           sclr_idx = adjustl(sclr_idx)
    2366           0 :           stats_metadata%isclrp2(j) = k
    2367           0 :           call stat_assign( var_index=stats_metadata%isclrp2(j), var_name="sclr"//trim(sclr_idx)//"p2", &
    2368             :             var_description="scalar("//trim(sclr_idx)//")'^2'", var_units="unknown", &
    2369           0 :             l_silhs=.false., grid_kind=stats_zm )
    2370           0 :           k = k + 1
    2371             :         end do
    2372             : 
    2373             :       case ( 'sclrpthvp' )
    2374           0 :         do j = 1, sclr_dim, 1
    2375           0 :           write( sclr_idx, * ) j
    2376           0 :           sclr_idx = adjustl(sclr_idx)
    2377           0 :           stats_metadata%isclrpthvp(j) = k
    2378           0 :           call stat_assign( var_index=stats_metadata%isclrpthvp(j), var_name="sclr"//trim(sclr_idx)//"pthvp", &
    2379             :             var_description="scalar("//trim(sclr_idx)//")'th_v'", var_units="unknown", &
    2380           0 :             l_silhs=.false., grid_kind=stats_zm )
    2381           0 :           k = k + 1
    2382             :         end do
    2383             : 
    2384             :       case ( 'sclrpthlp' )
    2385           0 :         do j = 1, sclr_dim, 1
    2386           0 :           write( sclr_idx, * ) j
    2387           0 :           sclr_idx = adjustl(sclr_idx)
    2388           0 :           stats_metadata%isclrpthlp(j) = k
    2389           0 :           call stat_assign( var_index=stats_metadata%isclrpthlp(j), var_name="sclr"//trim(sclr_idx)//"pthlp", &
    2390             :             var_description="scalar("//trim(sclr_idx)//")'th_l'", var_units="unknown", &
    2391           0 :             l_silhs=.false., grid_kind=stats_zm )
    2392           0 :           k = k + 1
    2393             :         end do
    2394             : 
    2395             :       case ( 'sclrprcp' )
    2396           0 :         do j = 1, sclr_dim, 1
    2397           0 :           write( sclr_idx, * ) j
    2398           0 :           sclr_idx = adjustl(sclr_idx)
    2399           0 :           stats_metadata%isclrprcp(j) = k
    2400           0 :           call stat_assign( var_index=stats_metadata%isclrprcp(j), var_name="sclr"//trim(sclr_idx)//"prcp", &
    2401             :             var_description="scalar("//trim(sclr_idx)//")'rc'", var_units="unknown", &
    2402           0 :             l_silhs=.false., grid_kind=stats_zm )
    2403           0 :           k = k + 1
    2404             :         end do
    2405             : 
    2406             :       case ( 'wpsclrp' )
    2407           0 :         do j = 1, sclr_dim, 1
    2408           0 :           write( sclr_idx, * ) j
    2409           0 :           sclr_idx = adjustl(sclr_idx)
    2410           0 :           stats_metadata%iwpsclrp(j) = k
    2411           0 :           call stat_assign( var_index=stats_metadata%iwpsclrp(j), var_name="wpsclr"//trim(sclr_idx)//"p", &
    2412             :             var_description="'w'scalar("//trim(sclr_idx)//")", var_units="unknown", &
    2413           0 :             l_silhs=.false., grid_kind=stats_zm )
    2414           0 :           k = k + 1
    2415             :         end do
    2416             : 
    2417             :       case ( 'wpsclrp2' )
    2418           0 :         do j = 1, sclr_dim, 1
    2419           0 :           write( sclr_idx, * ) j
    2420           0 :           sclr_idx = adjustl(sclr_idx)
    2421           0 :           stats_metadata%iwpsclrp2(j) = k
    2422           0 :           call stat_assign( var_index=stats_metadata%iwpsclrp2(j), var_name="wpsclr"//trim(sclr_idx)//"p2", &
    2423             :             var_description="'w'scalar("//trim(sclr_idx)//")'^2'", var_units="unknown", &
    2424           0 :             l_silhs=.false., grid_kind=stats_zm )
    2425           0 :           k = k + 1
    2426             :         end do
    2427             : 
    2428             :       case ( 'wp2sclrp' )
    2429           0 :         do j = 1, sclr_dim, 1
    2430           0 :           write( sclr_idx, * ) j
    2431           0 :           sclr_idx = adjustl(sclr_idx)
    2432           0 :           stats_metadata%iwp2sclrp(j) = k
    2433           0 :           call stat_assign( var_index=stats_metadata%iwp2sclrp(j), var_name="wp2sclr"//trim(sclr_idx)//"p", &
    2434             :             var_description="'w'^2 scalar("//trim(sclr_idx)//")", var_units="unknown", &
    2435           0 :             l_silhs=.false., grid_kind=stats_zm )
    2436           0 :           k = k + 1
    2437             :         end do
    2438             : 
    2439             :       case ( 'wpsclrprtp' )
    2440           0 :         do j = 1, sclr_dim, 1
    2441           0 :           write( sclr_idx, * ) j
    2442           0 :           sclr_idx = adjustl(sclr_idx)
    2443           0 :           stats_metadata%iwpsclrprtp(j) = k
    2444           0 :           call stat_assign( var_index=stats_metadata%iwpsclrprtp(j), var_name="wpsclr"//trim(sclr_idx)//"prtp", &
    2445             :             var_description="'w' scalar("//trim(sclr_idx)//")'rt'", var_units="unknown", &
    2446           0 :             l_silhs=.false., grid_kind=stats_zm )
    2447           0 :           k = k + 1
    2448             :         end do
    2449             : 
    2450             :       case ( 'wpsclrpthlp' )
    2451           0 :         do j = 1, sclr_dim, 1
    2452           0 :           write( sclr_idx, * ) j
    2453           0 :           sclr_idx = adjustl(sclr_idx)
    2454           0 :           stats_metadata%iwpsclrpthlp(j) = k
    2455           0 :           call stat_assign( var_index=stats_metadata%iwpsclrpthlp(j), &
    2456             :             var_name="wpsclr"//trim(sclr_idx)//"pthlp", &
    2457             :             var_description="'w' scalar("//trim(sclr_idx)//")'th_l'", var_units="unknown", &
    2458           0 :             l_silhs=.false., grid_kind=stats_zm )
    2459           0 :           k = k + 1
    2460             :         end do
    2461             : 
    2462             :       case ( 'wpedsclrp' )
    2463           0 :         do j = 1, edsclr_dim, 1
    2464           0 :           write( sclr_idx, * ) j
    2465           0 :           sclr_idx = adjustl(sclr_idx)
    2466           0 :           stats_metadata%iwpedsclrp(j) = k
    2467           0 :           call stat_assign( var_index=stats_metadata%iwpedsclrp(j), var_name="wpedsclr"//trim(sclr_idx)//"p", &
    2468             :             var_description="eddy scalar("//trim(sclr_idx)//")'w'", var_units="unknown", &
    2469           0 :             l_silhs=.false., grid_kind=stats_zm )
    2470           0 :           k = k + 1
    2471             :         end do
    2472             : 
    2473             :       case default
    2474           0 :         write(fstderr,*) 'Error:  unrecognized variable in vars_zm:  ',  trim(vars_zm(i))
    2475           0 :         l_error = .true.  ! This will stop the run.
    2476             : 
    2477             :       end select
    2478             : 
    2479             :     end do ! i = 1 .. stats_zm%num_output_fields
    2480             : 
    2481           0 :     return
    2482             :   end subroutine stats_init_zm
    2483             : 
    2484             : end module stats_zm_module

Generated by: LCOV version 1.14