<p><b>laura@ucar.edu</b> 2010-12-21 15:43:17 -0700 (Tue, 21 Dec 2010)</p><p>new drivers for PBL and surface parameterizations<br>
</p><hr noshade><pre><font color="gray">Added: branches/atmos_physics/src/core_physics/module_driver_pbl.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_driver_pbl.F                                (rev 0)
+++ branches/atmos_physics/src/core_physics/module_driver_pbl.F        2010-12-21 22:43:17 UTC (rev 652)
@@ -0,0 +1,206 @@
+!=============================================================================================
+ module module_driver_pbl
+ use grid_types
+ use constants
+
+ use module_physics_constants
+ use module_physics_vars
+
+!from wrf physics:
+ use module_bl_ysu
+
+ implicit none
+ private
+ public:: pbl_allocate,   &amp;
+          pbl_deallocate, &amp;
+          pbl_driver
+
+ logical,parameter,private:: pbl_flag_qi = .true. !
+
+ integer,private:: i,iCell,j,k
+
+ contains
+
+!=============================================================================================
+ subroutine pbl_allocate
+!=============================================================================================
+
+ if(.not.allocated(hpbl_p)    ) allocate(hpbl_p(ims:ime,jms:jme)             )
+ if(.not.allocated(kpbl_p)    ) allocate(kpbl_p(ims:ime,jms:jme)             )
+ if(.not.allocated(exch_p)    ) allocate(exch_p(ims:ime,kms:kme,jms:jme)     )
+
+!tendencies
+ if(.not.allocated(rublten_p) ) allocate(rublten_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(rvblten_p) ) allocate(rvblten_p(ims:ime,kms:kme,jms:jme)  )
+ if(.not.allocated(rthblten_p)) allocate(rthblten_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(rqvblten_p)) allocate(rqvblten_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(rqcblten_p)) allocate(rqcblten_p(ims:ime,kms:kme,jms:jme) )
+ if(.not.allocated(rqiblten_p)) allocate(rqiblten_p(ims:ime,kms:kme,jms:jme) )
+
+ end subroutine pbl_allocate
+
+!=============================================================================================
+ subroutine pbl_deallocate
+!=============================================================================================
+
+ if(allocated(hpbl_p)    ) deallocate(hpbl_p     )
+ if(allocated(kpbl_p)    ) deallocate(kpbl_p     )
+ if(allocated(exch_p)    ) deallocate(exch_p     )
+
+!tendencies
+ if(allocated(rublten_p) ) deallocate(rublten_p  )
+ if(allocated(rvblten_p) ) deallocate(rvblten_p  )
+ if(allocated(rthblten_p)) deallocate(rthblten_p )
+ if(allocated(rqvblten_p)) deallocate(rqvblten_p )
+ if(allocated(rqcblten_p)) deallocate(rqcblten_p )
+ if(allocated(rqiblten_p)) deallocate(rqiblten_p )
+
+ end subroutine pbl_deallocate
+
+!=============================================================================================
+ subroutine pbl_from_MPAS(diag_physics,tend_physics)
+!=============================================================================================
+
+!input arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+ type(tend_physics_type),intent(inout):: tend_physics
+
+!---------------------------------------------------------------------------------------------
+
+ do j = jts,jte
+
+ do i = its,ite
+    br_p(i,j)     = diag_physics % br     % array(i)
+    gz1oz0_p(i,j) = diag_physics % gz1oz0 % array(i)
+    hfx_p(i,j)    = diag_physics % hfx    % array(i)
+    hpbl_p(i,j)   = diag_physics % hpbl   % array(i)
+    psim_p(i,j)   = diag_physics % psim   % array(i)
+    psih_p(i,j)   = diag_physics % psih   % array(i)
+    qfx_p(i,j)    = diag_physics % qfx    % array(i)
+    u10_p(i,j)    = diag_physics % u10    % array(i)
+    ust_p(i,j)    = diag_physics % ust    % array(i)
+    v10_p(i,j)    = diag_physics % v10    % array(i)
+    wspd_p(i,j)   = diag_physics % wspd   % array(i)
+    xland_p(i,j)  = diag_physics % xland  % array(i)       
+    znt_p(i,j)    = diag_physics % znt    % array(i)
+    kpbl_p(i,j)   = int(diag_physics % kpbl % array(i))
+ enddo
+
+ do k = kts,kte
+ do i = its,ite
+    exch_p(i,k,j)     = diag_physics % exch_h   % array(i,k)
+    rublten_p(i,k,j)  = tend_physics % rublten  % array(i,k)
+    rvblten_p(i,k,j)  = tend_physics % rvblten  % array(i,k)
+    rthblten_p(i,k,j) = tend_physics % rthblten % array(i,k)
+    rqvblten_p(i,k,j) = tend_physics % rqvblten % array(i,k)
+    rqcblten_p(i,k,j) = tend_physics % rqcblten % array(i,k)
+    rqiblten_p(i,k,j) = tend_physics % rqiblten % array(i,k)
+ enddo
+ enddo
+
+ enddo
+
+ end subroutine pbl_from_MPAS

+!=============================================================================================
+ subroutine pbl_to_MPAS(diag_physics,tend_physics)
+!=============================================================================================
+
+!input arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+ type(tend_physics_type),intent(inout):: tend_physics
+
+!---------------------------------------------------------------------------------------------
+
+ do j = jts,jte
+
+ do i = its,ite
+    diag_physics % br     % array(i) = br_p(i,j)
+    diag_physics % gz1oz0 % array(i) = gz1oz0_p(i,j)
+    diag_physics % hfx    % array(i) = hfx_p(i,j)
+    diag_physics % hpbl   % array(i) = hpbl_p(i,j)
+    diag_physics % kpbl   % array(i) = dble(kpbl_p(i,j))
+    diag_physics % psim   % array(i) = psim_p(i,j)
+    diag_physics % psih   % array(i) = psih_p(i,j)
+    diag_physics % qfx    % array(i) = qfx_p(i,j)
+    diag_physics % u10    % array(i) = u10_p(i,j)
+    diag_physics % ust    % array(i) = ust_p(i,j)
+    diag_physics % v10    % array(i) = v10_p(i,j)
+    diag_physics % wspd   % array(i) = wspd_p(i,j)
+    diag_physics % xland  % array(i) = xland_p(i,j)
+    diag_physics % znt    % array(i) = znt_p(i,j)
+    
+ enddo
+
+ do k = kts,kte
+ do i = its,ite
+    diag_physics % exch_h   % array(i,k) = exch_p(i,k,j)
+    tend_physics % rublten  % array(i,k) = rublten_p(i,k,j) 
+    tend_physics % rvblten  % array(i,k) = rvblten_p(i,k,j)
+    tend_physics % rthblten % array(i,k) = rthblten_p(i,k,j)
+    tend_physics % rqvblten % array(i,k) = rqvblten_p(i,k,j)
+    tend_physics % rqcblten % array(i,k) = rqcblten_p(i,k,j)
+    tend_physics % rqiblten % array(i,k) = rqiblten_p(i,k,j)
+ enddo
+ enddo
+
+ enddo
+
+ end subroutine pbl_to_MPAS

+!=============================================================================================
+ subroutine pbl_driver(diag_physics,tend_physics)
+!=============================================================================================
+
+!input and output arguments:
+!---------------------------
+ type(diag_physics_type),intent(inout):: diag_physics
+ type(tend_physics_type),intent(inout):: tend_physics
+
+!--------------------------------------------------------------------------------------------- 
+ write(0,*)
+ write(0,*) '--- enter pbl driver:'
+
+!copy all MPAS arrays to rectanguler grid arrays:
+ call pbl_from_MPAS(diag_physics,tend_physics)
+ write(0,*) '--- end pbl_from_MPAS:'
+
+ pbl_select: select case (trim(pbl_scheme))
+
+    case(&quot;ysu&quot;)
+       write(0,*) '--- begin subroutine ysu:'
+       call ysu ( &amp;
+                 u3d      = u_p        , v3d      = v_p         , th3d     = th_p       , &amp;
+                 t3d      = t_p        , qv3d     = qv_p        , qc3d     = qc_p       , &amp;
+                 qi3d     = qi_p       , p3d      = pres_p      , p3di     = pres2_p    , &amp;
+                 pi3d     = pi_p       , rublten  = rublten_p   , rvblten  = rvblten_p  , &amp;
+                 rthblten = rthblten_p , rqvblten = rqvblten_p  , rqcblten = rqcblten_p , &amp;
+                 rqiblten = rqiblten_p , flag_qi  = pbl_flag_qi , cp       = cp         , &amp;
+                 g        = g          , rovcp    = rcp         , rd       = R_d        , &amp;
+                 rovg     = rdg        , ep1      = ep_1        , ep2      = ep_2       , &amp;
+                 karman   = karman     , xlv      = xlv         , rv       = R_v        , &amp;
+                 dz8w     = dz_p       , psfc     = psfc_p      , znt      = znt_p      , &amp;
+                 ust      = ust_p      , hpbl     = hpbl_p      , psim     = psim_p     , &amp;
+                 psih     = psih_p     , xland    = xland_p     , hfx      = hfx_p      , &amp;
+                 qfx      = qfx_p      , gz1oz0   = gz1oz0_p    , wspd     = wspd_p     , &amp;
+                 br       = br_p       , dt       = dt_pbl      , kpbl2d   = kpbl_p     , &amp;
+                 exch_h   = exch_p     , u10      = u10_p       , v10      = v10_p      , &amp;
+                 ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde  , &amp;
+                 ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme  , &amp;
+                 its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte    &amp;
+                )
+       write(0,*) '--- begin subroutine ysu:'
+
+     case default
+
+ end select pbl_select
+
+!copy all arrays back to the MPAS grid:
+ call pbl_to_MPAS(diag_physics,tend_physics)
+ write(0,*) '--- end pbl_to_MPAS:'
+
+ end subroutine pbl_driver
+
+!=============================================================================================
+ end module module_driver_pbl
+!=============================================================================================

Added: branches/atmos_physics/src/core_physics/module_driver_sfclayer.F
===================================================================
--- branches/atmos_physics/src/core_physics/module_driver_sfclayer.F                                (rev 0)
+++ branches/atmos_physics/src/core_physics/module_driver_sfclayer.F        2010-12-21 22:43:17 UTC (rev 652)
@@ -0,0 +1,334 @@
+!=============================================================================================
+ module module_driver_sfclayer
+ use grid_types
+ use configure
+
+ use module_physics_constants
+ use module_physics_vars
+ use module_physics_aquaplanet
+
+!from wrf physics:
+ use module_sf_sfclay
+
+ implicit none
+ private
+ public:: sfclayer_allocate,      &amp;
+          sfclayer_deallocate,    &amp;
+          sfclayer_driver,        &amp;
+          sfclayer_init
+
+ integer,parameter,private:: isfflx   = 1        !=1 for surface heat and moisture fluxes.
+ integer,parameter,private:: isftcflx = 0        !=0,(Charnock and Carlson-Boland).
+ integer,parameter,private:: iz0tlnd  = 0        !=0,(Carlson-Boland)
+
+ real,parameter,private:: xmava   = 0.3          !max. surface moisture availability (0 to 1).
+ real,parameter,private:: ust_min = 0.0001       !min. u* in similarity theory.
+ real,parameter,private:: zzlnd   = 0.1          !roughness length over land.
+ real,parameter,private:: zzwtr   = 0.0001       !roughness lenght over water.
+
+ integer,private:: i,iCell,j
+
+ contains
+
+!=============================================================================================
+ subroutine sfclayer_allocate
+!=============================================================================================
+
+ if(.not.allocated(br_p)     ) allocate(br_p(ims:ime,jms:jme)     )
+ if(.not.allocated(cd_p)     ) allocate(cd_p(ims:ime,jms:jme)     )
+ if(.not.allocated(cda_p)    ) allocate(cda_p(ims:ime,jms:jme)    )
+ if(.not.allocated(chs_p)    ) allocate(chs_p(ims:ime,jms:jme)    )
+ if(.not.allocated(chs2_p)   ) allocate(chs2_p(ims:ime,jms:jme)   )
+ if(.not.allocated(cpm_p)    ) allocate(cpm_p(ims:ime,jms:jme)    )
+ if(.not.allocated(cqs2_p)   ) allocate(cqs2_p(ims:ime,jms:jme)   )
+ if(.not.allocated(ck_p)     ) allocate(ck_p(ims:ime,jms:jme)     )
+ if(.not.allocated(cka_p)    ) allocate(cka_p(ims:ime,jms:jme)    )
+ if(.not.allocated(gz1oz0_p) ) allocate(gz1oz0_p(ims:ime,jms:jme) )
+ if(.not.allocated(flhc_p)   ) allocate(flhc_p(ims:ime,jms:jme)   )
+ if(.not.allocated(flqc_p)   ) allocate(flqc_p(ims:ime,jms:jme)   )
+ if(.not.allocated(hfx_p)    ) allocate(hfx_p(ims:ime,jms:jme)    )
+ if(.not.allocated(lh_p)     ) allocate(lh_p(ims:ime,jms:jme)     )
+ if(.not.allocated(mavail_p) ) allocate(mavail_p(ims:ime,jms:jme) )
+ if(.not.allocated(mol_p)    ) allocate(mol_p(ims:ime,jms:jme)    )
+ if(.not.allocated(pblh_p)   ) allocate(pblh_p(ims:ime,jms:jme)   )
+ if(.not.allocated(psih_p)   ) allocate(psih_p(ims:ime,jms:jme)   )
+ if(.not.allocated(psim_p)   ) allocate(psim_p(ims:ime,jms:jme)   )
+ if(.not.allocated(q2_p)     ) allocate(q2_p(ims:ime,jms:jme)     )
+ if(.not.allocated(qfx_p)    ) allocate(qfx_p(ims:ime,jms:jme)    )
+ if(.not.allocated(qgh_p)    ) allocate(qgh_p(ims:ime,jms:jme)    )
+ if(.not.allocated(qsfc_p)   ) allocate(qsfc_p(ims:ime,jms:jme)   )
+ if(.not.allocated(regime_p) ) allocate(regime_p(ims:ime,jms:jme) )
+ if(.not.allocated(rmol_p)   ) allocate(rmol_p(ims:ime,jms:jme)   )
+ if(.not.allocated(t2m_p)    ) allocate(t2m_p(ims:ime,jms:jme)    )
+ if(.not.allocated(tsk_p)    ) allocate(tsk_p(ims:ime,jms:jme)    )
+ if(.not.allocated(th2m_p)   ) allocate(th2m_p(ims:ime,jms:jme)   )
+ if(.not.allocated(u10_p)    ) allocate(u10_p(ims:ime,jms:jme)    )
+ if(.not.allocated(ust_p)    ) allocate(ust_p(ims:ime,jms:jme)    )
+ if(.not.allocated(ustm_p)   ) allocate(ustm_p(ims:ime,jms:jme)   )
+ if(.not.allocated(v10_p)    ) allocate(v10_p(ims:ime,jms:jme)    )
+ if(.not.allocated(wspd_p)   ) allocate(wspd_p(ims:ime,jms:jme)   )
+ if(.not.allocated(xland_p)  ) allocate(xland_p(ims:ime,jms:jme)  )
+ if(.not.allocated(zol_p)    ) allocate(zol_p(ims:ime,jms:jme)    )
+ if(.not.allocated(znt_p)    ) allocate(znt_p(ims:ime,jms:jme)    )
+
+ end subroutine sfclayer_allocate
+
+!=============================================================================================
+ subroutine sfclayer_deallocate
+!=============================================================================================
+
+ if(allocated(br_p)     ) deallocate(br_p     )
+ if(allocated(cd_p)     ) deallocate(cd_p     )
+ if(allocated(cda_p)    ) deallocate(cda_p    )
+ if(allocated(chs_p)    ) deallocate(chs_p    )
+ if(allocated(chs2_p)   ) deallocate(chs2_p   )
+ if(allocated(cpm_p)    ) deallocate(cpm_p    )
+ if(allocated(cqs2_p)   ) deallocate(cqs2_p   )
+ if(allocated(ck_p)     ) deallocate(ck_p     )
+ if(allocated(cka_p)    ) deallocate(cka_p    )
+ if(allocated(gz1oz0_p) ) deallocate(gz1oz0_p )
+ if(allocated(flhc_p)   ) deallocate(flhc_p   )
+ if(allocated(flqc_p)   ) deallocate(flqc_p   )
+ if(allocated(hfx_p)    ) deallocate(hfx_p    )
+ if(allocated(lh_p)     ) deallocate(lh_p     )
+ if(allocated(mavail_p) ) deallocate(mavail_p )
+ if(allocated(mol_p)    ) deallocate(mol_p    )
+ if(allocated(pblh_p)   ) deallocate(pblh_p   )
+ if(allocated(psih_p)   ) deallocate(psih_p   )
+ if(allocated(psim_p)   ) deallocate(psim_p   )
+ if(allocated(q2_p)     ) deallocate(q2_p     )
+ if(allocated(qfx_p)    ) deallocate(qfx_p    )
+ if(allocated(qgh_p)    ) deallocate(qgh_p    )
+ if(allocated(qsfc_p)   ) deallocate(qsfc_p   )
+ if(allocated(regime_p) ) deallocate(regime_p )
+ if(allocated(rmol_p)   ) deallocate(rmol_p   )
+ if(allocated(t2m_p)    ) deallocate(t2m_p    )
+ if(allocated(tsk_p)    ) deallocate(tsk_p    )
+ if(allocated(th2m_p)   ) deallocate(th2m_p   )
+ if(allocated(u10_p)    ) deallocate(u10_p    )
+ if(allocated(ust_p)    ) deallocate(ust_p    )
+ if(allocated(ustm_p)   ) deallocate(ustm_p   )
+ if(allocated(v10_p)    ) deallocate(v10_p    )
+ if(allocated(wspd_p)   ) deallocate(wspd_p   )
+ if(allocated(xland_p)  ) deallocate(xland_p  )
+ if(allocated(zol_p)    ) deallocate(zol_p    )
+ if(allocated(znt_p)    ) deallocate(znt_p    )
+
+ end subroutine sfclayer_deallocate
+
+!=============================================================================================
+ subroutine sfclayer_from_MPAS(diag_physics)
+!=============================================================================================
+
+!input arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+
+!---------------------------------------------------------------------------------------------
+
+ do j = jts,jte
+ do i = its,ite
+
+    br_p(i,j)     = diag_physics % br     % array(i)
+    cd_p(i,j)     = diag_physics % cd     % array(i)
+    cda_p(i,j)    = diag_physics % cda    % array(i)
+    chs_p(i,j)    = diag_physics % chs    % array(i)
+    chs2_p(i,j)   = diag_physics % chs2   % array(i)
+    cpm_p(i,j)    = diag_physics % cpm    % array(i)
+    cqs2_p(i,j)   = diag_physics % cqs2   % array(i)
+    ck_p(i,j)     = diag_physics % ck     % array(i)
+    cka_p(i,j)    = diag_physics % cka    % array(i)
+    gz1oz0_p(i,j) = diag_physics % gz1oz0 % array(i)
+    flhc_p(i,j)   = diag_physics % flhc   % array(i)
+    flqc_p(i,j)   = diag_physics % flqc   % array(i)
+    hfx_p(i,j)    = diag_physics % hfx    % array(i)
+    lh_p(i,j)     = diag_physics % lh     % array(i)
+    mavail_p(i,j) = diag_physics % mavail % array(i)
+    mol_p(i,j)    = diag_physics % mol    % array(i)
+    pblh_p(i,j)   = diag_physics % pblh   % array(i)
+    psim_p(i,j)   = diag_physics % psim   % array(i)
+    psih_p(i,j)   = diag_physics % psih   % array(i)
+    q2_p(i,j)     = diag_physics % q2     % array(i)
+    qfx_p(i,j)    = diag_physics % qfx    % array(i)
+    qgh_p(i,j)    = diag_physics % qgh    % array(i)
+    qsfc_p(i,j)   = diag_physics % qsfc   % array(i)
+    regime_p(i,j) = diag_physics % regime % array(i)
+    rmol_p(i,j)   = diag_physics % rmol   % array(i)
+    t2m_p(i,j)    = diag_physics % t2m    % array(i)
+    tsk_p(i,j)    = diag_physics % tsk    % array(i)
+    th2m_p(i,j)   = diag_physics % th2m   % array(i)
+    u10_p(i,j)    = diag_physics % u10    % array(i)
+    ust_p(i,j)    = diag_physics % ust    % array(i)
+    ustm_p(i,j)   = diag_physics % ustm   % array(i)
+    v10_p(i,j)    = diag_physics % v10    % array(i)
+    wspd_p(i,j)   = diag_physics % wspd   % array(i)
+    xland_p(i,j)  = diag_physics % xland  % array(i)       
+    zol_p(i,j)    = diag_physics % zol    % array(i)
+    znt_p(i,j)    = diag_physics % znt    % array(i)
+
+ enddo
+ enddo

+ end subroutine sfclayer_from_MPAS
+
+!=============================================================================================
+ subroutine sfclayer_to_MPAS(diag_physics)
+!=============================================================================================
+
+!input arguments:
+ type(diag_physics_type),intent(inout):: diag_physics
+
+!---------------------------------------------------------------------------------------------
+
+ do j = jts,jte 
+ do i = its,ite
+
+    diag_physics % br     % array(i) = br_p(i,j)
+    diag_physics % cd     % array(i) = cd_p(i,j)
+    diag_physics % cda    % array(i) = cda_p(i,j)
+    diag_physics % chs    % array(i) = chs_p(i,j)
+    diag_physics % chs2   % array(i) = chs2_p(i,j)
+    diag_physics % cpm    % array(i) = cpm_p(i,j)
+    diag_physics % cqs2   % array(i) = cqs2_p(i,j)
+    diag_physics % ck     % array(i) = ck_p(i,j)
+    diag_physics % cka    % array(i) = cka_p(i,j)
+    diag_physics % gz1oz0 % array(i) = gz1oz0_p(i,j)
+    diag_physics % flhc   % array(i) = flhc_p(i,j)
+    diag_physics % flqc   % array(i) = flqc_p(i,j)
+    diag_physics % hfx    % array(i) = hfx_p(i,j)
+    diag_physics % lh     % array(i) = lh_p(i,j)
+    diag_physics % mavail % array(i) = mavail_p(i,j)
+    diag_physics % mol    % array(i) = mol_p(i,j)
+    diag_physics % pblh   % array(i) = pblh_p(i,j)
+    diag_physics % psim   % array(i) = psim_p(i,j)
+    diag_physics % psih   % array(i) = psih_p(i,j)
+    diag_physics % q2     % array(i) = q2_p(i,j)
+    diag_physics % qfx    % array(i) = qfx_p(i,j)
+    diag_physics % qgh    % array(i) = qgh_p(i,j)
+    diag_physics % qsfc   % array(i) = qsfc_p(i,j)
+    diag_physics % regime % array(i) = regime_p(i,j)
+    diag_physics % rmol   % array(i) = rmol_p(i,j)
+    diag_physics % t2m    % array(i) = t2m_p(i,j)
+    diag_physics % tsk    % array(i) = tsk_p(i,j)
+    diag_physics % th2m   % array(i) = th2m_p(i,j)
+    diag_physics % u10    % array(i) = u10_p(i,j)
+    diag_physics % ust    % array(i) = ust_p(i,j)
+    diag_physics % ustm   % array(i) = ustm_p(i,j)
+    diag_physics % v10    % array(i) = v10_p(i,j)
+    diag_physics % wspd   % array(i) = wspd_p(i,j)
+    diag_physics % xland  % array(i) = xland_p(i,j)       
+    diag_physics % zol    % array(i) = zol_p(i,j)
+    diag_physics % znt    % array(i) = znt_p(i,j)
+
+ enddo
+ enddo

+ end subroutine sfclayer_to_MPAS
+
+!=============================================================================================
+ subroutine sfclayer_init(mesh,diag_physics)
+!=============================================================================================
+
+!input and output arguments:
+!---------------------------
+ type(mesh_type),intent(in):: mesh
+ type(diag_physics_type),intent(inout):: diag_physics
+
+!---------------------------------------------------------------------------------------------
+
+ write(0,*) '    begin sfclayer_initialization:'
+ do iCell = 1, mesh % nCells
+    diag_physics % ust % array(iCell) = ust_min
+    
+    if(diag_physics % xland % array(iCell) .lt. 1.5) then
+       diag_physics % znt % array(iCell)    = zzlnd
+       diag_physics % mavail % array(iCell) = xmava
+    else
+       diag_physics % znt % array(iCell)    = zzwtr
+       diag_physics % mavail % array(iCell) = 1.0
+    endif
+
+ enddo
+ write(0,*) '    end sfclayer_initialization:'
+
+ end subroutine sfclayer_init
+
+!=============================================================================================
+ subroutine sfclayer_driver(itimestep,mesh,diag_physics)
+!=============================================================================================
+
+!input and inout arguments:
+!--------------------------
+ integer,intent(in):: itimestep
+ type(mesh_type),intent(in):: mesh
+ type(diag_physics_type),intent(inout):: diag_physics
+
+!local variables:
+!----------------
+ real(kind=RKIND):: dx
+
+!---------------------------------------------------------------------------------------------
+ write(0,*)
+ write(0,*) '--- enter sfclayer_driver:'
+
+!copy all MPAS arrays to rectanguler grid arrays:
+ call sfclayer_from_MPAS(diag_physics)
+ write(0,*) '--- end sfclayer_from_MPAS:'
+
+ sfclayer_select: select case (trim(sfclayer_scheme))
+
+    case(&quot;monin_obukhov&quot;)
+       !initialization (this could be moved outside of the monin_obukhov surface scheme if an
+       !other scheme needing the same arrays was used):
+       dx = sqrt(maxval(mesh % areaCell % array))
+
+       do j = jts, jte
+       do i = its, ite
+          chs_p(i,j)  = 0.0
+          chs2_p(i,j) = 0.0
+          cqs2_p(i,j) = 0.0
+          cpm_p(i,j)  = 0.0
+       enddo
+       enddo
+
+       write(0,*) '--- begin subroutine sfclay:'
+       call sfclay( &amp;
+                   u3d      = u_p      , v3d     = v_p      , t3d    = t_p     , &amp;
+                   qv3d     = qv_p     , p3d     = pres_p   , dz8w   = dz_p    , &amp;
+                   cp       = cp       , g       = g        , rovcp  = rcp     , &amp;
+                   R        = R_d      , xlv     = xlv      , psfc   = psfc_p  , &amp;
+                   chs      = chs_p    , chs2    = chs2_p   , cqs2   = cqs2_p  , &amp;
+                   cpm      = cpm_p    , znt     = znt_p    , ust    = ust_p   , &amp;
+                   pblh     = pblh_p   , mavail  = mavail_p , zol    = zol_p   , &amp;
+                   mol      = mol_p    , regime  = regime_p , psim   = psim_p  , &amp;
+                   psih     = psih_p   , xland   = xland_p  , hfx    = hfx_p   , &amp;
+                   qfx      = qfx_p    , lh      = lh_p     , tsk    = tsk_p   , &amp;
+                   flhc     = flhc_p   , flqc    = flqc_p   , qgh    = qgh_p   , &amp;
+                   qsfc     = qsfc_p   , rmol    = rmol_p   , u10    = u10_p   , &amp;
+                   v10      = v10_p    , th2     = th2m_p   , t2     = t2m_p   , &amp;
+                   q2       = q2_p     , gz1oz0  = gz1oz0_p , wspd   = wspd_p  , &amp;
+                   br       = br_p     , isfflx  = isfflx   , dx     = dx      , &amp;
+                   svp1     = svp1     , svp2    = svp2     , svp3   = svp3    , &amp;
+                   svpt0    = svpt0    , ep1     = ep_1     , ep2    = ep_2    , &amp;
+                   karman   = karman   , eomeg   = eomeg    , stbolt = stbolt  , &amp;
+                   P1000mb  = P0       , ustm    = ustm_p   , ck     = ck_p    , &amp;
+                   cka      = cka_p    , cd      = cd_p     , cda    = cda_p   , &amp;
+                   isftcflx = isftcflx , iz0tlnd = iz0tlnd  ,                    &amp; 
+                   ids = ids , ide = ide , jds = jds , jde = jde , kds = kds , kde = kde , &amp;
+                   ims = ims , ime = ime , jms = jms , jme = jme , kms = kms , kme = kme , &amp;
+                   its = its , ite = ite , jts = jts , jte = jte , kts = kts , kte = kte   &amp;
+                 )
+       write(0,*) '--- end subroutine sfclay:'
+       
+    case default
+
+ end select sfclayer_select
+
+!copy all arrays back to the MPAS grid:
+ call sfclayer_to_MPAS(diag_physics)
+ write(0,*) '--- end sfclayer_to_MPAS:'
+
+ end subroutine sfclayer_driver
+
+!=============================================================================================
+ end module module_driver_sfclayer
+!=============================================================================================

</font>
</pre>