Index: /palm/trunk/DOC/app/chapter_3.5.3.html
===================================================================
--- /palm/trunk/DOC/app/chapter_3.5.3.html	(revision 131)
+++ /palm/trunk/DOC/app/chapter_3.5.3.html	(revision 132)
@@ -1,6 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <html><head>
-<meta http-equiv="CONTENT-TYPE" content="text/html; charset=windows-1252"><title>PALM
-chapter 3.5.3</title> <meta name="GENERATOR" content="StarOffice 7 (Win32)"> <meta name="AUTHOR" content="Siegfried Raasch"> <meta name="CREATED" content="20040802;14001660"> <meta name="CHANGED" content="20041112;14483720"> <meta name="KEYWORDS" content="parallel LES model"> <style>
+<meta http-equiv="CONTENT-TYPE" content="text/html; charset=windows-1252"><title>PALM chapter 3.5.3</title> <meta name="GENERATOR" content="StarOffice 7 (Win32)"> <meta name="AUTHOR" content="Siegfried Raasch"> <meta name="CREATED" content="20040802;14001660"> <meta name="CHANGED" content="20041112;14483720"> <meta name="KEYWORDS" content="parallel LES model"> <style>
 <!--
 @page { size: 21cm 29.7cm }
@@ -33,5 +32,5 @@
 declared as: </p>
 <ul> <p style="line-height: 100%;"><tt><font style="font-size: 10pt;" size="2">REAL :: rmask
-(nys-1:nyn+1,nxl-1,nxr+1,0:9) .</font></tt></p>
+(nys-1:nyn+1,nxl-1:nxr+1,0:9) .</font></tt></p>
 </ul><p style="line-height: 100%;">The first two
 indices are the grid point
Index: /palm/trunk/DOC/app/chapter_4.1.html
===================================================================
--- /palm/trunk/DOC/app/chapter_4.1.html	(revision 131)
+++ /palm/trunk/DOC/app/chapter_4.1.html	(revision 132)
@@ -20,5 +20,4 @@
   
   <title>PALM chapter 4.1</title></head>
-
 <body>
 
@@ -1736,5 +1735,5 @@
       
       <p>Allowed
-values are <span style="font-style: italic;">'dirichlet'</span>
+values are <span style="font-style: italic;">'dirichlet'</span>, <span style="font-style: italic;">'dirichlet_0'</span>
 and <span style="font-style: italic;">'neumann'</span>.
 The
@@ -1743,5 +1742,6 @@
 Neumann condition yields the free-slip condition with u(k=nz+1) =
 u(k=nz) and v(k=nz+1) = v(k=nz) (up to k=nz the prognostic equations
-for the velocities are solved).</p>
+for the velocities are solved). The special condition&nbsp;<span style="font-style: italic;">'dirichlet_0'</span> can be used for channel flow, it yields the no-slip condition u(k=nz+1) = ug(nz+1) = 0 and v(k=nz+1) =
+vg(nz+1) = 0.</p>
 
 
Index: /palm/trunk/DOC/misc/Tsubame.html
===================================================================
--- /palm/trunk/DOC/misc/Tsubame.html	(revision 131)
+++ /palm/trunk/DOC/misc/Tsubame.html	(revision 132)
@@ -21,5 +21,5 @@
 Tsubame is located behind a firewall, the usual&nbsp;address  <a class="fixed" href="svn://130.75.105.45" target="_blank">svn://130.75.105.45</a>&nbsp;is unreachable from Tsubame. Instead, please login to media-o
 and use&nbsp;<a class="fixed" href="svn://p9c.cc.titech.ac.jp:36900" target="_blank">svn://p9c.cc.titech.ac.jp:36900</a>.
-This port works in both directions, i.e. for <code>svn update</code> as well as <code>svn commit</code> commands.</p><h4>Combine plot fields</h4><p>Please add the following line to the output command (<code>OC:</code>) section of your <code>.mrun.config</code> to ensure correct output of 2D and 3D data for PALM runs on more than one CPU&nbsp;:</p><code>OC:[[ \$( echo \$localhost | cut -c1-3 ) = lct ]]&nbsp; &amp;&amp;&nbsp; combine_plot_fields.x</code><br><h4>Batch system<br></h4><p>The implementation of the <span style="font-weight: bold;">n1ge</span> command on
+This port works in both directions, i.e. for <code>svn update</code> as well as <code>svn commit</code> commands.</p><h4>Batch system<br></h4><p>The implementation of the <span style="font-weight: bold;">n1ge</span> command on
 Tsubame requires modifications to&nbsp;<span style="font-weight: bold;">mrun</span> and <span style="font-weight: bold;">subjob</span> for PALM to
 run on Tsubame. Since <span style="font-weight: bold;">mrun</span>
@@ -42,5 +42,5 @@
 not always be the best choice. For code development, debugging or short
 test runs the value "novice" for both options may be suitable.
-Production runs should use the respective production queues (see <a href="http://www.gsic.titech.ac.jp/%7Eccwww/tgc/q_e.html">http://www.gsic.titech.ac.jp/~ccwww/tgc/q_e.html</a> for details).&nbsp;</p><p>The
+Production runs should use the respective production queues (see <a href="http://www.gsic.titech.ac.jp/%7Eccwww/tgc/q_e.html">http://www.gsic.titech.ac.jp/~ccwww/tgc/q_e.html</a> for details). In the past the queueing system on Tsubame has undergone several changes, so this information may change.</p><p>The
 computer center advised us that due to restrictions of the batch system
 the value "novice" should not be mixed with the other queues. Please
@@ -53,4 +53,4 @@
 option <code><span style="font-family: Courier New,Courier,monospace;">-m</span></code>
 contains the memory demand for the main job <span style="font-weight: bold;">in MB</span> which will be
-automatically converted into GB for the <span style="font-weight: bold;">n1ge</span> command.</p><p>Finally, PALM batch jobs on Tsubame require the&nbsp;<span style="font-weight: bold;">mrun</span> option <code>-b</code>.</p><h4>NetCDF</h4><p>In order to use NetCDF commands like <code>ncdump</code>&nbsp;and the graphical NetCDF tools <a href="http://www.ncl.ucar.edu" target="_top">NCL</a> and <a href="http://meteora.ucsd.edu/%7Epierce/ncview_home_page.html" target="_top">Ncview</a>, please add the following lines to  <code><span style="font-family: Courier New,Courier,monospace;">~/.profile</span></code> (for ksh users) or <code>~/.bashrc</code> (for bash users):</p><p><code># NetCDF<br>export PATH=$PATH:~mkanda/netcdf-3.6.2/bin:~mkanda/netcdf-3.6.2/include<br><br></code><code># NCL<br>export NCARG_ROOT=~mkanda/ncl<br>PATH=~mkanda/ncl/bin:$PATH<br><br># Ncview<br>export PATH=$PATH:~mkanda/ncview/bin<br>export XAPPLRESDIR=~mkanda/.app-defaults</code></p><i><br>Last
+automatically converted into GB for the <span style="font-weight: bold;">n1ge</span> command.</p><p>Finally, PALM batch jobs on Tsubame require the&nbsp;<span style="font-weight: bold;">mrun</span> option <code>-b</code>.</p><h4>NetCDF</h4><p>In order to use <a href="http://www.unidata.ucar.edu/software/netcdf" target="_top">NetCDF</a> commands like <code>ncdump</code>&nbsp;and the graphical NetCDF tools <a href="http://www.ncl.ucar.edu" target="_top">NCL</a>,&nbsp;<a href="http://meteora.ucsd.edu/%7Epierce/ncview_home_page.html" target="_top">Ncview</a> and <a href="http://ferret.pmel.noaa.gov/Ferret" target="_top">Ferret</a>, please add the following lines to  <code><span style="font-family: Courier New,Courier,monospace;">~/.profile</span></code> (for ksh users) or <code>~/.bashrc</code> (for bash users):</p><p><code># NetCDF<br>export PATH=$PATH:~mkanda/netcdf-3.6.2/bin:~mkanda/netcdf-3.6.2/include<br><br></code><code># NCL<br>export NCARG_ROOT=~mkanda/ncl<br>PATH=~mkanda/ncl/bin:$PATH<br><br># Ncview<br>export PATH=$PATH:~mkanda/ncview/bin<br>export XAPPLRESDIR=~mkanda/.app-defaults</code></p><p><code># Ferret<br>export FER_DIR=~mkanda/ferret<br>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$FER_DIR/lib<br>export PATH=$PATH:$FER_DIR:$FER_DIR/bin<br>export FER_DSETS=$FER_DIR<br>export FER_WEB_BROWSER=firefox<br>export FER_EXTERNAL_FUNCTIONS="$FER_DIR/lib"<br>export FER_GO=". $FER_DIR/go $FER_DIR/examples $FER_DIR/contrib"<br>export FER_DATA="."<br>export FER_DESCR="."<br>export FER_GRIDS=". $FER_DSETS/grids"<br>export TMAP="$FER_DIR/fmt"<br>export PLOTFONTS="$FER_DIR/ppl/fonts"<br>export SPECTRA="$FER_DIR/ppl"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # for old ferret versions<br>export FER_PALETTE=". $FER_DIR/ppl"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # palette search list<br></code></p><i><br>Last
 change:</i>&nbsp; $Id$</body></html>
Index: /palm/trunk/SOURCE/CURRENT_MODIFICATIONS
===================================================================
--- /palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 131)
+++ /palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 132)
@@ -1,4 +1,6 @@
 New:
 ---
+
+Allow new case bc_uv_t = 'dirichlet_0' for channel flow.
 
 For unknown variables (CASE DEFAULT) call new subroutine user_data_output_dvrp
@@ -13,9 +15,13 @@
 advec_particles after the end of this loop.
 
-advec_particles, check_parameters, data_output_dvrp, header, init_grid, init_particles, init_pegrid, modules, package_parin, read_var_list, user_interface, write_var_list
+advec_particles, check_parameters, data_output_dvrp, header, init_3d_model, init_grid, init_particles, init_pegrid, modules, package_parin, read_var_list, user_interface, write_var_list
 
 
 Changed:
 -------
+
+Vertical profiles now based on nzb_s_inner; they are divided by
+ngp_2dh_s_inner (scalars, procucts of scalars and velocity components) and
+ngp_2dh (staggered velocity components and their products), respectively.
 
 Allow two instead of one digit to specify isosurface and slicer variables.
@@ -33,5 +39,5 @@
 humidity/scalar/salinity in a future release.
 
-check_open, data_output_dvrp, diffusion_s, header, init_dvrp, modules, prognostic_equations
+buoyancy, check_open, data_output_dvrp, diffusion_s, diffusivities, flow_statistics, header, init_3d_model, init_dvrp, modules, prognostic_equations
 
 
Index: /palm/trunk/SOURCE/buoyancy.f90
===================================================================
--- /palm/trunk/SOURCE/buoyancy.f90	(revision 131)
+++ /palm/trunk/SOURCE/buoyancy.f90	(revision 132)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! 
+! Vertical scalar profiles now based on nzb_s_inner and ngp_2dh_s_inner.
 !
 ! Former revisions:
@@ -258,5 +258,5 @@
           DO  i = nxl, nxr
              DO  j =  nys, nyn
-                DO  k = nzb_s_outer(j,i), nzt+1
+                DO  k = nzb_s_inner(j,i), nzt+1
                    sums_l(k,pr,tn) = sums_l(k,pr,tn) + var(k,j,i)
                 ENDDO
@@ -280,5 +280,5 @@
 #endif
 
-          hom(:,1,pr,0) = sums(:,pr) / ngp_2dh_outer(:,0)
+          hom(:,1,pr,0) = sums(:,pr) / ngp_2dh_s_inner(:,0)
 
        ENDIF
Index: /palm/trunk/SOURCE/check_parameters.f90
===================================================================
--- /palm/trunk/SOURCE/check_parameters.f90	(revision 131)
+++ /palm/trunk/SOURCE/check_parameters.f90	(revision 132)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! Allow new case bc_uv_t = 'dirichlet_0' for channel flow.
 ! Multigrid solver allows topography, checking of dt_sort_particles
 ! Bugfix: initializing u_init and v_init in case of ocean runs
@@ -1397,5 +1398,5 @@
        ibc_uv_t = 1
     ELSE
-       IF ( bc_uv_t == 'dirichlet' )  THEN
+       IF ( bc_uv_t == 'dirichlet' .OR. bc_uv_t == 'dirichlet_0' )  THEN
           ibc_uv_t = 0
        ELSEIF ( bc_uv_t == 'neumann' )  THEN
Index: /palm/trunk/SOURCE/diffusivities.f90
===================================================================
--- /palm/trunk/SOURCE/diffusivities.f90	(revision 131)
+++ /palm/trunk/SOURCE/diffusivities.f90	(revision 132)
@@ -4,4 +4,5 @@
 ! Actual revisions:
 ! -----------------
+! Vertical scalar profiles now based on nzb_s_inner and ngp_2dh_s_inner.
 ! 
 ! 
@@ -141,5 +142,5 @@
           DO  sr = 0, statistic_regions
              IF ( rmask(j,i,sr) /= 0.0 )  THEN
-                DO  k = nzb_s_outer(j,i)+1, nzt
+                DO  k = nzb_s_inner(j,i)+1, nzt
                    sums_l_l(k,sr,tn) = sums_l_l(k,sr,tn) + l(k)
                 ENDDO
Index: /palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/flow_statistics.f90	(revision 131)
+++ /palm/trunk/SOURCE/flow_statistics.f90	(revision 132)
@@ -4,4 +4,7 @@
 ! Actual revisions:
 ! -----------------
+! Vertical profiles now based on nzb_s_inner; they are divided by 
+! ngp_2dh_s_inner (scalars, procucts of scalars and velocity components) and 
+! ngp_2dh (staggered velocity components and their products), respectively.
 ! 
 !
@@ -49,10 +52,9 @@
 ! user-defined (sub-)regions. The region indexed 0 is the total model domain.
 !
-! NOTE: For simplicity, nzb_s_outer and nzb_diff_s_outer are being used as a
-! ----  lower vertical index for k-loops for all variables so that regardless
-! of the variable and its respective staggered grid always the same number of
-! grid points is used for 2D averages. The disadvantage: depending on the
-! variable, up to one grid layer adjacent to the (vertical walls of the)
-! topography is missed out by this simplification.
+! NOTE: For simplicity, nzb_s_inner and nzb_diff_s_inner are being used as a
+! ----  lower vertical index for k-loops for all variables, although strictly 
+! speaking the k-loops would have to be split up according to the staggered 
+! grid. However, this implies no error since staggered velocity components are 
+! zero at the walls and inside buildings.
 !------------------------------------------------------------------------------!
 
@@ -124,5 +126,5 @@
        DO  i = nxl, nxr
           DO  j =  nys, nyn
-             DO  k = nzb_s_outer(j,i), nzt+1
+             DO  k = nzb_s_inner(j,i), nzt+1
                 sums_l(k,1,tn)  = sums_l(k,1,tn)  + u(k,j,i)  * rmask(j,i,sr)
                 sums_l(k,2,tn)  = sums_l(k,2,tn)  + v(k,j,i)  * rmask(j,i,sr)
@@ -138,5 +140,5 @@
           DO  i = nxl, nxr
              DO  j =  nys, nyn
-                DO  k = nzb_s_outer(j,i), nzt+1
+                DO  k = nzb_s_inner(j,i), nzt+1
                    sums_l(k,23,tn)  = sums_l(k,23,tn) + &
                                       sa(k,j,i) * rmask(j,i,sr)
@@ -154,5 +156,5 @@
           DO  i = nxl, nxr
              DO  j =  nys, nyn
-                DO  k = nzb_s_outer(j,i), nzt+1
+                DO  k = nzb_s_inner(j,i), nzt+1
                    sums_l(k,44,tn)  = sums_l(k,44,tn) + &
                                       vpt(k,j,i) * rmask(j,i,sr)
@@ -166,5 +168,5 @@
              DO  i = nxl, nxr
                 DO  j =  nys, nyn
-                   DO  k = nzb_s_outer(j,i), nzt+1
+                   DO  k = nzb_s_inner(j,i), nzt+1
                       sums_l(k,42,tn) = sums_l(k,42,tn) + &
                                       ( q(k,j,i) - ql(k,j,i) ) * rmask(j,i,sr)
@@ -184,5 +186,5 @@
           DO  i = nxl, nxr
              DO  j =  nys, nyn
-                DO  k = nzb_s_outer(j,i), nzt+1
+                DO  k = nzb_s_inner(j,i), nzt+1
                    sums_l(k,41,tn)  = sums_l(k,41,tn) + q(k,j,i) * rmask(j,i,sr)
                 ENDDO
@@ -265,7 +267,7 @@
 !--    Final values are obtained by division by the total number of grid points 
 !--    used for summation. After that store profiles.
-       sums(:,1) = sums(:,1) / ngp_2dh_outer(:,sr)
-       sums(:,2) = sums(:,2) / ngp_2dh_outer(:,sr)
-       sums(:,4) = sums(:,4) / ngp_2dh_outer(:,sr)
+       sums(:,1) = sums(:,1) / ngp_2dh(sr)
+       sums(:,2) = sums(:,2) / ngp_2dh(sr)
+       sums(:,4) = sums(:,4) / ngp_2dh_s_inner(:,sr)
        hom(:,1,1,sr) = sums(:,1)             ! u
        hom(:,1,2,sr) = sums(:,2)             ! v
@@ -275,5 +277,5 @@
 !--    Salinity
        IF ( ocean )  THEN
-          sums(:,23) = sums(:,23) / ngp_2dh_outer(:,sr)
+          sums(:,23) = sums(:,23) / ngp_2dh_s_inner(:,sr)
           hom(:,1,23,sr) = sums(:,23)             ! sa
        ENDIF
@@ -282,11 +284,11 @@
 !--    Humidity and cloud parameters
        IF ( humidity ) THEN
-          sums(:,44) = sums(:,44) / ngp_2dh_outer(:,sr)
-          sums(:,41) = sums(:,41) / ngp_2dh_outer(:,sr)
+          sums(:,44) = sums(:,44) / ngp_2dh_s_inner(:,sr)
+          sums(:,41) = sums(:,41) / ngp_2dh_s_inner(:,sr)
           hom(:,1,44,sr) = sums(:,44)             ! vpt
           hom(:,1,41,sr) = sums(:,41)             ! qv (q)
           IF ( cloud_physics ) THEN
-             sums(:,42) = sums(:,42) / ngp_2dh_outer(:,sr)
-             sums(:,43) = sums(:,43) / ngp_2dh_outer(:,sr)
+             sums(:,42) = sums(:,42) / ngp_2dh_s_inner(:,sr)
+             sums(:,43) = sums(:,43) / ngp_2dh_s_inner(:,sr)
              hom(:,1,42,sr) = sums(:,42)             ! qv
              hom(:,1,43,sr) = sums(:,43)             ! pt
@@ -296,5 +298,6 @@
 !
 !--    Passive scalar
-       IF ( passive_scalar )  hom(:,1,41,sr) = sums(:,41) / ngp_2dh_outer(:,sr)
+       IF ( passive_scalar )  hom(:,1,41,sr) = sums(:,41) /  &
+            ngp_2dh_s_inner(:,sr)                    ! s (q)
 
 !
@@ -302,7 +305,9 @@
 !--    variances, the total and the perturbation energy (single values in last
 !--    column of sums_l) and some diagnostic quantities.
-!--    NOTE: for simplicity, nzb_s_outer is used below, although strictly 
+!--    NOTE: for simplicity, nzb_s_inner is used below, although strictly 
 !--    ----  speaking the following k-loop would have to be split up and 
 !--          rearranged according to the staggered grid.
+!--          However, this implies no error since staggered velocity components
+!--          are zero at the walls and inside buildings.
        tn = 0
 #if defined( __intel_openmp_bug )
@@ -319,5 +324,5 @@
              sums_l_etot = 0.0
              sums_l_eper = 0.0
-             DO  k = nzb_s_outer(j,i), nzt+1
+             DO  k = nzb_s_inner(j,i), nzt+1
                 u2   = u(k,j,i)**2
                 v2   = v(k,j,i)**2
@@ -382,8 +387,11 @@
 !--          Subgridscale fluxes (without Prandtl layer from k=nzb, 
 !--          oterwise from k=nzb+1)
-!--          NOTE: for simplicity, nzb_diff_s_outer is used below, although
+!--          NOTE: for simplicity, nzb_diff_s_inner is used below, although
 !--          ----  strictly speaking the following k-loop would have to be
 !--                split up according to the staggered grid.
-             DO  k = nzb_diff_s_outer(j,i)-1, nzt_diff
+!--                However, this implies no error since staggered velocity 
+!--                components are zero at the walls and inside buildings.
+
+             DO  k = nzb_diff_s_inner(j,i)-1, nzt_diff
 !
 !--             Momentum flux w"u"
@@ -528,8 +536,8 @@
 !
 !--          Resolved fluxes (can be computed for all horizontal points)
-!--          NOTE: for simplicity, nzb_s_outer is used below, although strictly 
+!--          NOTE: for simplicity, nzb_s_inner is used below, although strictly 
 !--          ----  speaking the following k-loop would have to be split up and 
 !--                rearranged according to the staggered grid.
-             DO  k = nzb_s_outer(j,i), nzt
+             DO  k = nzb_s_inner(j,i), nzt
                 ust = 0.5 * ( u(k,j,i)   - hom(k,1,1,sr) + &
                               u(k+1,j,i) - hom(k+1,1,1,sr) )
@@ -634,5 +642,5 @@
           DO  i = nxl, nxr
              DO  j = nys, nyn
-                DO  k = nzb_s_outer(j,i)+1, nzt
+                DO  k = nzb_s_inner(j,i)+1, nzt
 
                    sums_ll(k,1) = sums_ll(k,1) + 0.5 * w(k,j,i) * (        &
@@ -656,5 +664,5 @@
           sums_ll(nzt+1,2) = 0.0
 
-          DO  k = nzb_s_outer(j,i)+1, nzt
+          DO  k = nzb_s_inner(j,i)+1, nzt
              sums_l(k,55,tn) = ( sums_ll(k,1) - sums_ll(k-1,1) ) * ddzw(k)
              sums_l(k,56,tn) = ( sums_ll(k,2) - sums_ll(k-1,2) ) * ddzw(k)
@@ -674,5 +682,5 @@
           DO  i = nxl, nxr
              DO  j = nys, nyn
-                DO  k = nzb_s_outer(j,i)+1, nzt
+                DO  k = nzb_s_inner(j,i)+1, nzt
 
                    sums_l(k,57,tn) = sums_l(k,57,tn) - 0.5 * (                 &
@@ -701,5 +709,5 @@
           DO  i = nxl, nxr
              DO  j = nys, nyn
-                DO  k = nzb_s_outer(j,i)+1, nzt
+                DO  k = nzb_s_inner(j,i)+1, nzt
 !
 !--                Subgrid horizontal heat fluxes u"pt", v"pt"
@@ -773,5 +781,18 @@
 !--    Profiles:
        DO  k = nzb, nzt+1
-          sums(k,:pr_palm-2)      = sums(k,:pr_palm-2) / ngp_2dh_outer(k,sr)
+          sums(k,3)               = sums(k,3)           / ngp_2dh(sr)
+          sums(k,9:11)            = sums(k,9:11)        / ngp_2dh_s_inner(k,sr)
+          sums(k,12:22)           = sums(k,12:22)       / ngp_2dh(sr)
+          sums(k,23:29)           = sums(k,23:29)       / ngp_2dh_s_inner(k,sr)
+          sums(k,30:32)           = sums(k,30:32)       / ngp_2dh(sr)
+          sums(k,33)              = sums(k,33)          / ngp_2dh_s_inner(k,sr)
+          sums(k,34:39)           = sums(k,34:39)       / ngp_2dh(sr)
+          sums(k,40)              = sums(k,40)          / ngp_2dh_s_inner(k,sr)
+          sums(k,45:53)           = sums(k,45:53)       / ngp_2dh(sr)
+          sums(k,54)              = sums(k,54)          / ngp_2dh_s_inner(k,sr)
+          sums(k,55:63)           = sums(k,55:63)       / ngp_2dh(sr)
+          sums(k,64)              = sums(k,64)          / ngp_2dh_s_inner(k,sr)
+          sums(k,65:69)           = sums(k,65:69)       / ngp_2dh(sr)
+          sums(k,70:pr_palm-2)    = sums(k,70:pr_palm-2)/ ngp_2dh_s_inner(k,sr)
        ENDDO
 !--    Upstream-parts
@@ -785,5 +806,5 @@
 !--    eges, e*
        sums(nzb+4:nzb+5,pr_palm)  = sums(nzb+4:nzb+5,pr_palm)  / &
-                                    ngp_3d_inner(sr)
+                                    ngp_3d(sr)
 !--    Old and new divergence
        sums(nzb+9:nzb+10,pr_palm) = sums(nzb+9:nzb+10,pr_palm) / &
@@ -795,5 +816,5 @@
              sums(k,pr_palm+1:pr_palm+max_pr_user) = &
                                     sums(k,pr_palm+1:pr_palm+max_pr_user) / &
-                                    ngp_2dh_outer(k,sr)
+                                    ngp_2dh_s_inner(k,sr)
           ENDDO
        ENDIF
Index: /palm/trunk/SOURCE/header.f90
===================================================================
--- /palm/trunk/SOURCE/header.f90	(revision 131)
+++ /palm/trunk/SOURCE/header.f90	(revision 132)
@@ -4,5 +4,6 @@
 ! Actual revisions:
 ! -----------------
-! allow two instead of one digit to specify isosurface and slicer variables
+! Allow new case bc_uv_t = 'dirichlet_0' for channel flow.
+! Allow two instead of one digit to specify isosurface and slicer variables.
 ! Output of sorting frequency of particles
 !
@@ -384,5 +385,7 @@
        runten = TRIM( runten ) // ' uv(0)     = uv(1)                 |'
     ENDIF
-    IF ( ibc_uv_t == 0 )  THEN
+    IF ( TRIM( bc_uv_t ) == 'dirichlet_0' )  THEN
+       roben  = TRIM( roben  ) // ' uv(nzt+1) = 0                     |'
+    ELSEIF ( ibc_uv_t == 0 )  THEN
        roben  = TRIM( roben  ) // ' uv(nzt+1) = ug(nzt+1), vg(nzt+1)  |'
     ELSE
Index: /palm/trunk/SOURCE/init_3d_model.f90
===================================================================
--- /palm/trunk/SOURCE/init_3d_model.f90	(revision 131)
+++ /palm/trunk/SOURCE/init_3d_model.f90	(revision 132)
@@ -7,5 +7,8 @@
 ! Actual revisions:
 ! -----------------
-! 
+! New counter ngp_2dh_s_inner.
+! Allow new case bc_uv_t = 'dirichlet_0' for channel flow.
+! Corrected calculation of initial volume flow for 'set_1d-model_profiles' and
+! 'set_constant_profiles' in case of buildings in the reference cross-sections.
 !
 ! Former revisions:
@@ -80,5 +83,6 @@
     INTEGER, DIMENSION(:), ALLOCATABLE ::  ngp_2dh_l, ngp_3d_inner_l
 
-    INTEGER, DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_outer_l
+    INTEGER, DIMENSION(:,:), ALLOCATABLE ::  ngp_2dh_outer_l,  &
+         ngp_2dh_s_inner_l
 
     REAL, DIMENSION(1:2) ::  volume_flow_area_l, volume_flow_initial_l
@@ -97,4 +101,6 @@
               ngp_2dh_outer(nzb:nzt+1,0:statistic_regions),                 &
               ngp_2dh_outer_l(nzb:nzt+1,0:statistic_regions),               &
+              ngp_2dh_s_inner(nzb:nzt+1,0:statistic_regions),               &
+              ngp_2dh_s_inner_l(nzb:nzt+1,0:statistic_regions),             &
               rmask(nys-1:nyn+1,nxl-1:nxr+1,0:statistic_regions),           &
               sums(nzb:nzt+1,pr_palm+max_pr_user),                          &
@@ -426,4 +432,20 @@
                 ENDDO
              ENDDO
+             IF ( conserve_volume_flow )  THEN
+                IF ( nxr == nx )  THEN
+                   DO  j = nys, nyn
+                      DO  k = nzb + 1, nzb_u_inner(j,nx)
+                         u_nzb_p1_for_vfc(j) = u1d(k) * dzu(k)
+                      ENDDO
+                   ENDDO
+                ENDIF
+                IF ( nyn == ny )  THEN
+                   DO  i = nxl, nxr
+                      DO  k = nzb + 1, nzb_v_inner(ny,i)
+                         v_nzb_p1_for_vfc(i) = v1d(k) * dzu(k)
+                      ENDDO
+                   ENDDO
+                ENDIF
+             ENDIF
 !
 !--          WARNING: The extra boundary conditions set after running the
@@ -486,12 +508,14 @@
              IF ( nxr == nx )  THEN
                 DO  j = nys, nyn
-                   k = nzb_u_inner(j,nx) + 1
-                   u_nzb_p1_for_vfc(j) = u_init(k) * dzu(k)
+                   DO  k = nzb + 1, nzb_u_inner(j,nx) + 1
+                      u_nzb_p1_for_vfc(j) = u_init(k) * dzu(k)
+                   ENDDO
                 ENDDO
              ENDIF
              IF ( nyn == ny )  THEN
                 DO  i = nxl, nxr
-                   k = nzb_v_inner(ny,i) + 1
-                   v_nzb_p1_for_vfc(i) = v_init(k) * dzu(k)
+                   DO  k = nzb + 1, nzb_v_inner(ny,i) + 1
+                      v_nzb_p1_for_vfc(i) = v_init(k) * dzu(k)
+                   ENDDO
                 ENDDO
              ENDIF
@@ -561,4 +585,18 @@
 
 !
+!--    apply channel flow boundary condition
+       IF ( TRIM( bc_uv_t ) == 'dirichlet_0' )  THEN
+
+          u(nzt+1,:,:) = 0.0
+          v(nzt+1,:,:) = 0.0
+
+!--       for the Dirichlet condition to be correctly applied at the top, set
+!--       ug and vg to zero there
+          ug(nzt+1)    = 0.0
+          vg(nzt+1)    = 0.0
+
+       ENDIF
+
+!
 !--    Calculate virtual potential temperature
        IF ( humidity ) vpt = pt * ( 1.0 + 0.61 * q )
@@ -1036,15 +1074,14 @@
 !--          total domain
 !-- ngp_3d:  number of grid points of the total domain
-!-- Note: The lower vertical index nzb_s_outer imposes a small error on the 2D 
-!-- ----  averages of staggered variables such as u and v due to the topography
-!--       arrangement on the staggered grid. Maybe revise later.
-    ngp_2dh_outer_l = 0
-    ngp_2dh_outer   = 0
-    ngp_2dh_l       = 0
-    ngp_2dh         = 0
-    ngp_3d_inner_l  = 0
-    ngp_3d_inner    = 0
-    ngp_3d          = 0
-    ngp_sums        = ( nz + 2 ) * ( pr_palm + max_pr_user )
+    ngp_2dh_outer_l   = 0
+    ngp_2dh_outer     = 0
+    ngp_2dh_s_inner_l = 0
+    ngp_2dh_s_inner   = 0
+    ngp_2dh_l         = 0
+    ngp_2dh           = 0
+    ngp_3d_inner_l    = 0
+    ngp_3d_inner      = 0
+    ngp_3d            = 0
+    ngp_sums          = ( nz + 2 ) * ( pr_palm + max_pr_user )
 
     DO  sr = 0, statistic_regions
@@ -1059,4 +1096,7 @@
                 DO  k = nzb_s_outer(j,i), nz + 1
                    ngp_2dh_outer_l(k,sr) = ngp_2dh_outer_l(k,sr) + 1
+                ENDDO
+                DO  k = nzb_s_inner(j,i), nz + 1
+                   ngp_2dh_s_inner_l(k,sr) = ngp_2dh_s_inner_l(k,sr) + 1
                 ENDDO
 !
@@ -1075,10 +1115,13 @@
     CALL MPI_ALLREDUCE( ngp_2dh_outer_l(0,0), ngp_2dh_outer(0,0), (nz+2)*sr, &
                         MPI_INTEGER, MPI_SUM, comm2d, ierr )
+    CALL MPI_ALLREDUCE( ngp_2dh_s_inner_l(0,0), ngp_2dh_s_inner(0,0),        &
+                        (nz+2)*sr, MPI_INTEGER, MPI_SUM, comm2d, ierr )
     CALL MPI_ALLREDUCE( ngp_3d_inner_l(0), ngp_3d_inner(0), sr, MPI_INTEGER, &
                         MPI_SUM, comm2d, ierr )
 #else
-    ngp_2dh       = ngp_2dh_l
-    ngp_2dh_outer = ngp_2dh_outer_l
-    ngp_3d_inner  = ngp_3d_inner_l
+    ngp_2dh         = ngp_2dh_l
+    ngp_2dh_outer   = ngp_2dh_outer_l
+    ngp_2dh_s_inner = ngp_2dh_s_inner_l
+    ngp_3d_inner    = ngp_3d_inner_l
 #endif
 
Index: /palm/trunk/SOURCE/modules.f90
===================================================================
--- /palm/trunk/SOURCE/modules.f90	(revision 131)
+++ /palm/trunk/SOURCE/modules.f90	(revision 132)
@@ -5,7 +5,7 @@
 ! Actual revisions:
 ! -----------------
-! +dt_sort_particles, time_sort_particles, flags, wall_flags_1..10
-! wall_humidityflux(0:4), wall_qflux(0:4), wall_salinityflux(0:4), 
-! wall_scalarflux(0:4)
+! +dt_sort_particles, ngp_2dh_s_inner, time_sort_particles, flags, 
+! wall_flags_1..10, wall_humidityflux(0:4), wall_qflux(0:4), 
+! wall_salinityflux(0:4), wall_scalarflux(0:4)
 !
 ! Former revisions:
@@ -588,8 +588,8 @@
 
     INTEGER, DIMENSION(:,:), ALLOCATABLE ::                                    &
-                ngp_2dh_outer, mg_loc_ind, nzb_diff_s_inner, nzb_diff_s_outer, &
-                nzb_diff_u, nzb_diff_v, nzb_inner, nzb_outer, nzb_s_inner,     &
-                nzb_s_outer, nzb_u_inner, nzb_u_outer, nzb_v_inner,            &
-                nzb_v_outer, nzb_w_inner, nzb_w_outer, nzb_2d
+                ngp_2dh_outer, ngp_2dh_s_inner, mg_loc_ind, nzb_diff_s_inner,  &
+                nzb_diff_s_outer, nzb_diff_u, nzb_diff_v, nzb_inner, nzb_outer,&
+                nzb_s_inner, nzb_s_outer, nzb_u_inner, nzb_u_outer,            &
+                nzb_v_inner, nzb_v_outer, nzb_w_inner, nzb_w_outer, nzb_2d
 
     INTEGER, DIMENSION(:,:,:), POINTER ::  flags
