!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
#if defined (DOC)
*
***comdeck p_pbl.cdk
*
*revision
* v2_20 - Pellerin P.            - adaptation to physics 3.6.6
* v3_02 - Dugas B.               - add P_pbl_dumpbus
* v3_03 - Bilodeau B.            - add P_pbl_as and P_pbl_beta
* v3_12 - Leduc/Bilodeau         - add P_pbl_z0tlat and remove P_pbl_z0tcst
* v3_12 - Bilodeau B.            - character*8 to character*16
*______________________________________________________________________
*                                                                      |
*  VARIABLES ASSOCIATED WITH PLANETARY BOUNDARY LAYER                  |
*______________________________________________________________________|
*                    |                                                 |
* NAME               | DESCRIPTION                                     |
*--------------------|-------------------------------------------------|
* CNMAXAD            | maximum number of coefficients in P_pbl_spng    |
* P_pbl_bndlr_S      | FLUVERT: name of boundary layer processes       |
* P_pbl_schsl_S      | SCHMSOL: name of land surface processes         |
* P_pbl_mix_S        | name of the mixing lenght formulation           |
*      The following switches are activated if TRUE                    |
* P_pbl_drag_L       | DRAG: surface friction  (simplified Physics)    |
* P_pbl_ocean_L      | CHAUF:surface heat flux from oceans(simp.Physics|
* P_pbl_evap_L       | EVAP: surface evaporation                       |
* P_pbl_dumpbus      | DUMPBUS: timestep frequency at which to print   |
*                    |          statistics on all physics buses        |
* P_pbl_dbgvv_L      | DBGMEM: debug physics memory                    |
* P_pbl_truew_L      | true: the physic interface will receive geograph|
*                    |      -ical wind components (meridionnal and     |
*                    |       zonal components) from the model. The     |
*                    |       returned tendencies will be rotated back  |
*                    |       into the model's frame of reference.      |
* Other switches:    |                                                 |
* P_pbl_albkg_L      | .true. to use background albedo (no snow)       |
*                    | .false. to compute albedo considering snow, ice,|
*                    |         and vegetation                          |
*  The following 6 variables are thermal parameters for the ground     |
* P_pbl_cst          | heat capacity of soil                           |
* P_pbl_csn          | heat capacity of snow                           |
* P_pbl_csg          | heat capacity of ice                            |
* P_pbl_kst          | heat diffusivity of soil                        |
* P_pbl_ksn          | heat diffusivity of snow                        |
* P_pbl_ksg          | heat diffusivity of ice                         |
* P_pbl_prsol        | stores the above 6 values for the call to       |
*                    | configure the physics package:                  |
*                    | P_pbl_prsol(1)=P_pbl_cst                        |
*                    | P_pbl_prsol(2)=P_pbl_csn                        |
*                    | P_pbl_prsol(3)=P_pbl_csg                        |
*                    | P_pbl_prsol(4)=P_pbl_kst                        |
*                    | P_pbl_prsol(5)=P_pbl_ksn                        |
*                    | P_pbl_prsol(6)=P_pbl_ksg                        |
* P_pbl_spng         | EPONGE:coefficients that multiply KM to simulate|
*                    |        sponge layer near the top of the model   |
* P_pbl_as           | AS parameter for stability function             |
*                    | (stable case only)                              |
* P_pbl_beta         | beta parameter for stability function           |
* P_pbl_z0tlat       | latitude (2 elements, in degrees) used to       |
*                    | specify Z0T over water                          |
*                    | If |lat| <= Z0TLAT(1)  constant Z0T             |
*                    | If |lat| >= Z0TLAT(2)  Charnock's relation      |
*                    | In between, linear interpolation is used        |
* P_pbl_zua          | height of wind input for surface flux calculatio|
* P_pbl_zta          | height of temperature and humidity input for    |
*                    |     surface flux calculations                   | 
*                                                                      |
* The following variables are to help compute latitudinal modulation of|
*  vertical diffusion coefficient on momentum by fitting a cubic btwn  |
*  values P_pbl_valml_8 and P_pbl_valeq_8 at latitudes P_pbl_mllat_8   |
*                                                  and P_pbl_eqlat_8   |
* P_pbl_valml_8      | background value of multiplication factor of    |
*                    | P_pbl_spng out of equator                       |
* P_pbl_mllat_8      | latitude at which the multiplication factor     |
*                    | becomes P_pbl_valml_8 out of equator            |
* P_pbl_valeq_8      | equatorial value of multiplication factor of    |
*                    | P_pbl_spng                                      |
* P_pbl_eqlat_8      | equatorial latitude at which the multiplication |
*                    | factor becomes P_pbl_valeq_8                    |
* P_pbl_snoalb_L     | .true.  when SNOALEN analysis is used           |
*                    | .false. when SNOALEN is derived in physics      |
* P_pbl_impflx_L     | .true.   ==> implicit surface fluxes            |
*                    | .false. 	==> explicit surface fluxes (default)  |
*----------------------------------------------------------------------
*
*
#endif
      integer CNMAXAD
      parameter (CNMAXAD = 55)
*
      character*16 P_pbl_bndlr_S, P_pbl_schsl_S, P_pbl_mix_S
      logical P_pbl_drag_L   ,P_pbl_ocean_L  ,
     $        P_pbl_evap_L   ,P_pbl_dbgvv_L  ,P_pbl_truew_L  ,
     $        P_pbl_snwmlt_L ,P_pbl_stomat_L ,P_pbl_typsol_L ,
     $        P_pbl_albkg_L  ,P_pbl_cortm_L  ,P_pbl_corts_L  ,
     $        P_pbl_drylp_L  ,P_pbl_monta_L  ,P_pbl_iceme_L  ,
     $        P_pbl_agreg_L  ,P_pbl_snoalb_L ,P_pbl_advectke_L,
     $        P_pbl_impflx_L
      integer P_pbl_nslof    ,P_pbl_dumpbus
      real                 P_pbl_cst        ,P_pbl_csn      ,
     $     P_pbl_csg      ,P_pbl_kst        ,P_pbl_ksn      ,
     $     P_pbl_ksg      ,P_pbl_prsol(6)   ,P_pbl_spng(CNMAXAD),
     $     P_pbl_as       ,P_pbl_beta       ,P_pbl_z0tlat(2),
     $     P_pbl_zua      ,P_pbl_zta
      real*8
     $     P_pbl_valml_8  ,P_pbl_mllat_8  ,
     $     P_pbl_valeq_8  ,P_pbl_eqlat_8  
*
      MARK_COMMON_BEG (ppbl_c)
      common /ppbl_c/ P_pbl_bndlr_S, P_pbl_schsl_S, P_pbl_mix_S
      MARK_COMMON_END (ppbl_c)

      MARK_COMMON_BEG (ppbl_l)
      common /ppbl_l/
     $     P_pbl_drag_L   ,P_pbl_ocean_L  ,P_pbl_advectke_L,
     $     P_pbl_evap_L   ,P_pbl_dbgvv_L  ,P_pbl_truew_L   ,
     $     P_pbl_snwmlt_L ,P_pbl_stomat_L ,P_pbl_typsol_L  ,
     $     P_pbl_albkg_L  ,P_pbl_cortm_L  ,P_pbl_corts_L   ,
     $     P_pbl_drylp_L  ,P_pbl_monta_L  ,P_pbl_iceme_L   ,
     $     P_pbl_agreg_L  ,P_pbl_snoalb_L ,P_pbl_impflx_L
      MARK_COMMON_END (ppbl_l)

      MARK_COMMON_BEG (ppbl_i)
      common /ppbl_i/ P_pbl_nslof  ,P_pbl_dumpbus
      MARK_COMMON_END (ppbl_i)

      MARK_COMMON_BEG (ppbl_r)
      common /ppbl_r/               P_pbl_cst   ,P_pbl_csn,
     $                P_pbl_csg    ,P_pbl_kst   ,P_pbl_ksn,     
     $                P_pbl_ksg    ,P_pbl_prsol ,P_pbl_spng,
     $                p_pbl_as     ,P_pbl_beta  ,P_pbl_z0tlat,
     $                P_pbl_zua    ,P_pbl_zta
      MARK_COMMON_END (ppbl_r)
*
      MARK_COMMON_BEG (ppbl_r8)
      common /ppbl_r8/ P_pbl_valml_8  ,P_pbl_mllat_8  ,
     $                 P_pbl_valeq_8  ,P_pbl_eqlat_8  
      MARK_COMMON_END (ppbl_r8)
*
      DCL_DYNVAR(P_pbl, vlsp ,  real, (l_ni,l_nj))