Index: palm/trunk/DOC/app/chapter_3.5.4.html
===================================================================
--- palm/trunk/DOC/app/chapter_3.5.4.html	(revision 128)
+++ palm/trunk/DOC/app/chapter_3.5.4.html	(revision 129)
@@ -1,5 +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.5</title> <meta name="GENERATOR" content="StarOffice 7 (Win32)"> <meta name="AUTHOR" content="Siegfried Raasch"> <meta name="CREATED" content="20040802;14050943"> <meta name="CHANGED" content="20041117;12180008"> <meta name="KEYWORDS" content="parallel LES model"> <style>
+<meta http-equiv="CONTENT-TYPE" content="text/html; charset=windows-1252"><title>PALM chapter 3.5.4</title> <meta name="GENERATOR" content="StarOffice 7 (Win32)"> <meta name="AUTHOR" content="Siegfried Raasch"> <meta name="CREATED" content="20040802;14050943"> <meta name="CHANGED" content="20041117;12180008"> <meta name="KEYWORDS" content="parallel LES model"> <style>
 <!--
 @page { size: 21cm 29.7cm }
@@ -13,10 +13,10 @@
 quantities which are not part of PALM's standard output. The basic user
 interface includes a number of subroutines which allow the calculation
-of user-defined quantities and output of these quantities as time series, (horizontally averaged) vertical profile, 2d cross
-section or 3d volume data. The respective subroutines
+of user-defined quantities and output of these quantities as (horizontally averaged) <a href="#vertical_profiles">vertical profiles</a>, <a href="#time_series">time series</a>, <a href="#2D_and_3D">2d cross
+section</a> or <a href="#2D_and_3D">3d volume data</a>. The respective subroutines
 contain sample code lines (written as comment lines) for defining, calculating and
 output of such quantities.<br><br>Output times, averaging intervals, etc. are steered by the same variables as used for the standard PALM output quantities, e.g. <a href="chapter_4.2.html#dt_data_output">dt_data_output</a>.<br><br>The
 rest of this chapter explains step-by-step how to modify/extend the
-default file user_interface.f90 in order to generate the respective output.<br><br><br><h4>Output of vertical profiles</h4>This example shows the output of the
+default file user_interface.f90 in order to generate the respective output.<br><br><br><h4><a name="vertical_profiles"></a>Output of vertical profiles</h4>This example shows the output of the
 quantity "turbulent resolved-scale horizontal momentum flux" (u*v*). If more than one user-defined
 quantity shall be output, the following steps have to be carried out in the
@@ -49,5 +49,7 @@
 calculation is stored in array <span style="font-family: Courier New,Courier,monospace;">sums_l</span>.
 The second index of this array is the identification number of the
-profile which must match the one given in the previous step 2.</li></ol><br><h4>Output of timeseries</h4>still to be added<br>&nbsp;<br><h4><span style="font-weight: bold;">Output of 2d cross sections or 3d volume data</span></h4><br>This example shows the output of the
+profile which must match the one given in the previous step 2.</li></ol><br><h4><a name="time_series"></a>Output of timeseries</h4>This example shows the output of  two time series for the absolut extremal values of the horizontal velocities <span style="font-style: italic;">u</span> and <span style="font-style: italic;">v</span>. If more than one user-defined
+quantity shall be output, the following steps have to be carried out in the
+same way for each of the quantities.<br><br><ol><li>For each time series quantity you have to give a label and a unit  (subroutine <a href="chapter_3.5.1.html#user_init">user_init</a>), which will be used for the NetCDF file. They must not contain more than seven characters. The value of <code>dots_num</code> has to be increased by the number of new time series quantities. Its old value has to be stored in <code>dots_num_palm</code>.<br><br><code>&nbsp;&nbsp;&nbsp; dots_label(dots_num<span style="color: rgb(255, 0, 0);">+1</span>) = '<span style="color: rgb(255, 0, 0);">abs_umx</span>'<br>&nbsp;&nbsp;&nbsp; dots_unit(dots_num<span style="color: rgb(255, 0, 0);">+1</span>)&nbsp; = '<span style="color: rgb(255, 0, 0);">m/s</span>'<br>&nbsp;&nbsp;&nbsp; dots_label(dots_num<span style="color: rgb(255, 0, 0);">+2</span>) = '<span style="color: rgb(255, 0, 0);">abs_vmx</span>'<br>&nbsp;&nbsp;&nbsp; dots_unit(dots_num<span style="color: rgb(255, 0, 0);">+2</span>)&nbsp; = '<span style="color: rgb(255, 0, 0);">m/s</span>'<br><br>&nbsp;&nbsp;&nbsp; dots_num_palm = dots_num<br>&nbsp;&nbsp;&nbsp; dots_num = dots_num <span style="color: rgb(255, 0, 0);">+ 2</span><br><br></code>Only those parts in <span style="color: rgb(255, 0, 0);">red</span> have to be adjusted by the user.<br><br></li><li>These quantities are&nbsp;calculated and output in subroutine <a href="chapter_3.5.1.html#user_statistics">user_statistics</a> for every statistic region <code>sr</code> defined by the user,&nbsp;but at least for the region <span style="font-style: italic;">"total domain"</span>:<br>&nbsp;<br><code>&nbsp;&nbsp;&nbsp; ts_value(dots_num_palm+1,sr) = ABS( u_max )<br>&nbsp;&nbsp;&nbsp; ts_value(dots_num_palm+2,sr) = ABS( v_max )<br></code>&nbsp;<br></li></ol><h4><span style="font-weight: bold;"><a name="2D_and_3D"></a>Output of 2d cross sections or 3d volume data</span></h4><br>This example shows the output of the
 quantity "square of the u-component" (<span style="font-weight: bold;">Note:</span> this quantity
 could of course easily be calculated from the u-component by
Index: palm/trunk/DOC/app/chapter_4.2.html
===================================================================
--- palm/trunk/DOC/app/chapter_4.2.html	(revision 128)
+++ palm/trunk/DOC/app/chapter_4.2.html	(revision 129)
@@ -10682,6 +10682,6 @@
 (cross sections), and <span style="font-style: italic;">'particles'</span>.
 Within the strings the hash character ("#") has to be replaced by a
-digit &le;9. Up to 10 objects
-can be assigned at the same time, e.g. :&nbsp; </p>
+digit 1&le;#&le;9. Up to 10 objects
+can be assigned at the same time, e.g.:&nbsp; </p>
 
 
@@ -10700,26 +10700,22 @@
       <p>In this
 case one isosurface, two cross sections, and particles
-will be created. The quantities for which an isosurface are to be
+will be created. The quantities for which isosurfaces or cross sections are to be
 created have to be selected with
-the parameter <a href="#data_output">data_output</a>,
-those for cross sections with <a href="#data_output">data_output</a>
-(<span style="font-weight: bold;">data_output</span>
+the parameter <a href="#data_output">data_output</a> (<span style="font-weight: bold;">data_output</span>
 also determines the
-orientation of the cross section, thus xy, xz, or yz). Since for <span style="font-weight: bold;">data_output</span> and <span style="font-weight: bold;">data_output</span> lists of
+orientation of the cross section, thus xy, xz, or yz). Since for <span style="font-weight: bold;">data_output</span> <span style="font-weight: bold;"></span>lists of
 variables may be
 assigned, the digit at the end of the <span style="font-weight: bold;">mode_dvrp</span>-string
 selects the quantity, which is given
 at the respective position in the respective list (e.g. <span style="font-style: italic;">'isosurface2'</span>
-selects the quantity
-given in the second position of <span style="font-weight: bold;">data_output</span>).
-If e.g. <span style="font-weight: bold;">data_output</span>
-and <span style="font-weight: bold;">data_output</span>
-are assigned as <b>data_output</b> = <span style="font-style: italic;">'u_xy'</span><i>,
-'w_xz', 'v_yz'</i> and <b>data_output</b> = <span style="font-style: italic;">'pt'</span><i>,
-'u', 'w' </i>are
-indicated, then - assuming the above assignment of <span style="font-weight: bold;">mode_dvrp</span> - an
+selects the second 3D quantity
+of <span style="font-weight: bold;">data_output</span>,  <span style="font-style: italic;">'slicer1'</span> selects the first 2D quantity
+of <span style="font-weight: bold;">data_output</span>).
+If e.g. <span style="font-weight: bold;">data_output</span> is assigned as <b>data_output</b> = <span style="font-style: italic;">'u_xy'</span><i>,
+'w_xz', 'v_yz'</i>, <span style="font-style: italic;">'pt'</span><i>,
+'u', 'w'</i>, then - assuming the above assignment of <span style="font-weight: bold;">mode_dvrp</span> - an
 isosurface of u, a
 horizontal cross section of u and
-a vertical cross section (xz) of w is created. For locations of the
+a vertical cross section (xz) of w are created. For locations of the
 cross sections see <a href="#data_output">data_output</a>.
 The theshold value for which the isosurface is
@@ -10738,25 +10734,11 @@
 
 
- </p>
-
-
-
-      
-      
-      <p>The vertical extension of the displayed domain is given by <a href="#nz_do3d">nz_do3d</a>. </p>
-
-
- 
-      
-      
-      <p><b>Assignments
+ </p><p><b>Assignments
 of mode_dvrp must correspond to those of data_output
 and
-data_output! </b>If e.g. <b>data_output</b> = <span style="font-style: italic;">'pt_xy'</span>
-and <b>data_output</b>
-= 'w'<i> </i>was set, then only the digit "1" is allowed
+data_output! </b>If e.g. <b>data_output</b> = <span style="font-style: italic;">'pt_xy'</span>,<span style="font-style: italic;"> 'w'</span><i> </i>was set, then only the digit "1" is allowed
 for <b>mode_dvrp</b>,
 thus <span style="font-style: italic;">'isosurface1'</span>
-and/or <span style="font-style: italic;">'slicer1'</span><i>.</i>&nbsp;
+and/or <span style="font-style: italic;">'slicer1'</span><i>.</i>
       </p>
 
Index: palm/trunk/DOC/misc/Tsubame.html
===================================================================
--- palm/trunk/DOC/misc/Tsubame.html	(revision 128)
+++ palm/trunk/DOC/misc/Tsubame.html	(revision 129)
@@ -42,11 +42,12 @@
 options are available:</p><table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td><span style="font-weight: bold;">mrun</span> option</td><td>explanation</td><td>possible
 values</td><td>default value</td></tr><tr><td><code>-q</code></td><td>queue
-name for main job</td><td>novice, bes1, bes2, sla1, sla2,
-sla3, RAM64GB, RAM128GB</td><td>novice</td></tr><tr><td><code>-n</code></td><td>queue
+name for main job</td><td>novice,&nbsp;sla1, sla2,
+sla3, RAM64GB, RAM128GB</td><td>sla3</td></tr><tr><td><code>-n</code></td><td>queue
 name for "submitting job" (always runs on 1 PE only)</td><td>novice,
-sla1, sla2, sla3</td><td>novice</td></tr><tr><td><code>-g</code></td><td>group number</td><td>name of the N1GE_GROUP that is required to utilize the bes or sla queues</td><td>none</td></tr></tbody></table><p>Note that the default value "novice" of the
+sla1, sla2, sla3</td><td>sla3</td></tr><tr><td><code>-g</code></td><td>group number</td><td>name of the N1GE_GROUP that is required to utilize the bes or sla queues</td><td>none</td></tr></tbody></table><p>Note that the default value "sla3" of the
 <span style="font-weight: bold;">mrun</span> option <code>-q</code> may
-only be suitable for code development, debugging or short test runs.
-Production runs should use the respective production queues(see&nbsp; <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).</p><p>The <span style="font-weight: bold;">mrun</span> option <code><span style="font-family: Courier New,Courier,monospace;">-t</span></code>
+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 computer center advised us that due to restrictions of the batch system the value "novice" should not be mixed with the other queues. Please specify either a combination of sla<span style="font-style: italic;">n</span> for <code>-n</code> and sla<span style="font-style: italic;">n</span> or RAM<span style="font-style: italic;">*</span> for <code>-q</code>, or specify the combination "novice" + "novice".<span style="font-style: italic;"></span></p><p>The <span style="font-weight: bold;">mrun</span> option <code><span style="font-family: Courier New,Courier,monospace;">-t</span></code>
 contains the CPU time demand for the main job in s which will be
 automatically converted into min for the <span style="font-weight: bold;">n1ge</span> command. The
Index: palm/trunk/SCRIPTS/.mrun.config.default
===================================================================
--- palm/trunk/SCRIPTS/.mrun.config.default	(revision 128)
+++ palm/trunk/SCRIPTS/.mrun.config.default	(revision 129)
@@ -47,6 +47,6 @@
 #
 #%remote_username   <replace by your tsubame username>              lctit parallel 
-#%tmp_user_catalog  <replace by your user_catalog>                  lctit parallel
-#%tmp_data_catalog  <replace by your data_catalog>                  lctit parallel
+#%tmp_user_catalog  /work/<replace by your tsubame username>                    lctit parallel
+#%tmp_data_catalog  /work/<replace by your tsubame username>/palm_restart_data  lctit parallel
 %cpp_options       -Mpreprocess:-DMPI_REAL=MPI_DOUBLE_PRECISION:-DMPI_2REAL=MPI_2DOUBLE_PRECISION:-D__netcdf  lctit parallel
 %netcdf_inc        -I:/home2/usr5/mkanda/netcdf-3.6.2/include      lctit parallel
Index: palm/trunk/SCRIPTS/mrun
===================================================================
--- palm/trunk/SCRIPTS/mrun	(revision 128)
+++ palm/trunk/SCRIPTS/mrun	(revision 129)
@@ -135,5 +135,5 @@
      #                     argument -g group_number, admit all sla* node_usage 
      #                     queues
-     # 23/10/07 - Marcus - further adjustments for queues on lctit
+     # 30/10/07 - Marcus - further adjustments for queues on lctit
 
  
@@ -1026,5 +1026,5 @@
        elif [[ $host = lctit ]]
        then
-          node_usage=novice
+          node_usage=sla3
        else
           node_usage=not_shared
@@ -1090,5 +1090,5 @@
                      fi;;
         (ibmy)       queue=parallel;;
-        (lctit)      queue=novice;;
+        (lctit)      queue=sla3;;
         (nech)       queue=none;;
         (neck)       queue=P;;
Index: palm/trunk/SCRIPTS/subjob
===================================================================
--- palm/trunk/SCRIPTS/subjob	(revision 128)
+++ palm/trunk/SCRIPTS/subjob	(revision 129)
@@ -89,5 +89,5 @@
      # 19/10/07 - Marcus- add new optional argument -g group_number
      # 19/10/07 - Siggi - a ";" was missing in the last change done by Marcus
-     # 23/10/07 - Marcus- further adjustments for queues on lctit
+     # 30/10/07 - Marcus- further adjustments for queues on lctit
 
 
@@ -340,5 +340,5 @@
                  esac;;
         (lctit)  case  $ndq  in
-                     (novice|bes1|bes2|sla1|sla2|sla3|RAM64GB|RAM128GB)    error=false;;
+                     (novice|sla1|sla2|sla3|RAM64GB|RAM128GB)    error=false;;
                      (*)                                     error=true;;
                  esac;;
Index: palm/trunk/SOURCE/CURRENT_MODIFICATIONS
===================================================================
--- palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 128)
+++ palm/trunk/SOURCE/CURRENT_MODIFICATIONS	(revision 129)
@@ -19,5 +19,15 @@
 Status of 3D-volume NetCDF data file only depends on switch netcdf_64bit_3d (check_open)
 
-check_open
+prognostic_equations include the respective wall_*flux in the parameter list of 
+calls of diffusion_s. Same as before, only the values of wall_heatflux(0:4) 
+can be assigned. At present, wall_humidityflux, wall_qflux, wall_salinityflux, 
+and wall_scalarflux are kept zero. diffusion_s uses the respective wall_*flux 
+instead of wall_heatflux. This update serves two purposes:
+- it avoids errors in calculations with humidity/scalar/salinity and prescribed 
+non-zero wall_heatflux,
+- it prepares PALM for a possible assignment of wall fluxes of 
+humidity/scalar/salinity in a future release.
+
+check_open, diffusion_s, modules, prognostic_equations
 
 
@@ -37,3 +47,5 @@
 Bugfix: wavenumber calculation for even nx in routines maketri (poisfft)
 
-advec_particles, check_parameters, combine_plot_fields, init_ocean, poisfft, production_e
+Bugfix: assignment of fluxes at walls
+
+advec_particles, check_parameters, combine_plot_fields, diffusion_s, init_ocean, poisfft, production_e
Index: palm/trunk/SOURCE/diffusion_s.f90
===================================================================
--- palm/trunk/SOURCE/diffusion_s.f90	(revision 128)
+++ palm/trunk/SOURCE/diffusion_s.f90	(revision 129)
@@ -4,5 +4,6 @@
 ! Actual revisions:
 ! -----------------
-! 
+! replace wall_heatflux by wall_s_flux that is now included in the parameter 
+! list, bugfix for assignment of fluxes at walls
 !
 ! Former revisions:
@@ -45,5 +46,6 @@
 ! Call for all grid points
 !------------------------------------------------------------------------------!
-    SUBROUTINE diffusion_s( ddzu, ddzw, kh, s, s_flux_b, s_flux_t, tend )
+    SUBROUTINE diffusion_s( ddzu, ddzw, kh, s, s_flux_b, s_flux_t, &
+                            wall_s_flux, tend )
 
        USE control_parameters
@@ -57,4 +59,5 @@
        REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
+       REAL    ::  wall_s_flux(0:4)
        REAL, DIMENSION(:,:),   POINTER ::  s_flux_b, s_flux_t
        REAL, DIMENSION(:,:,:), POINTER ::  kh, s
@@ -86,15 +89,15 @@
                                           + 0.5 * ( fwxp(j,i) *               &
                         ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) &
-                        - ( 1.0 - fwxp(j,i) ) * wall_heatflux(1)              &
+                        + ( 1.0 - fwxp(j,i) ) * wall_s_flux(1)                &
                                                    -fwxm(j,i) *               &
                         ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) &
-                        + ( 1.0 - fwxm(j,i) ) * wall_heatflux(3)              &
+                        + ( 1.0 - fwxm(j,i) ) * wall_s_flux(2)                &
                                                   ) * ddx2                    &
                                           + 0.5 * ( fwyp(j,i) *               &
                         ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) &
-                        - ( 1.0 - fwyp(j,i) ) * wall_heatflux(2)              &
+                        + ( 1.0 - fwyp(j,i) ) * wall_s_flux(3)                &
                                                    -fwym(j,i) *               &
                         ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) &
-                        + ( 1.0 - fwym(j,i) ) * wall_heatflux(4)              &
+                        + ( 1.0 - fwym(j,i) ) * wall_s_flux(4)                &
                                                   ) * ddy2
                 ENDDO
@@ -156,5 +159,5 @@
 !------------------------------------------------------------------------------!
     SUBROUTINE diffusion_s_ij( i, j, ddzu, ddzw, kh, s, s_flux_b, s_flux_t, &
-                               tend )
+                               wall_s_flux, tend )
 
        USE control_parameters
@@ -168,4 +171,5 @@
        REAL    ::  ddzu(1:nzt+1), ddzw(1:nzt+1)
        REAL    ::  tend(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1)
+       REAL    ::  wall_s_flux(0:4)
        REAL, DIMENSION(:,:),   POINTER ::  s_flux_b, s_flux_t
        REAL, DIMENSION(:,:,:), POINTER ::  kh, s
@@ -195,15 +199,15 @@
                                           + 0.5 * ( fwxp(j,i) *               &
                         ( kh(k,j,i) + kh(k,j,i+1) ) * ( s(k,j,i+1)-s(k,j,i) ) &
-                        - ( 1.0 - fwxp(j,i) ) * wall_heatflux(1)              &
+                        + ( 1.0 - fwxp(j,i) ) * wall_s_flux(1)                &
                                                    -fwxm(j,i) *               &
                         ( kh(k,j,i) + kh(k,j,i-1) ) * ( s(k,j,i)-s(k,j,i-1) ) &
-                        + ( 1.0 - fwxm(j,i) ) * wall_heatflux(3)              &
+                        + ( 1.0 - fwxm(j,i) ) * wall_s_flux(2)                &
                                                   ) * ddx2                    &
                                           + 0.5 * ( fwyp(j,i) *               &
                         ( kh(k,j,i) + kh(k,j+1,i) ) * ( s(k,j+1,i)-s(k,j,i) ) &
-                        - ( 1.0 - fwyp(j,i) ) * wall_heatflux(2)              &
+                        + ( 1.0 - fwyp(j,i) ) * wall_s_flux(3)                &
                                                    -fwym(j,i) *               &
                         ( kh(k,j,i) + kh(k,j-1,i) ) * ( s(k,j,i)-s(k,j-1,i) ) &
-                        + ( 1.0 - fwym(j,i) ) * wall_heatflux(4)              &
+                        + ( 1.0 - fwym(j,i) ) * wall_s_flux(4)                &
                                                   ) * ddy2
           ENDDO
Index: palm/trunk/SOURCE/modules.f90
===================================================================
--- palm/trunk/SOURCE/modules.f90	(revision 128)
+++ palm/trunk/SOURCE/modules.f90	(revision 129)
@@ -6,4 +6,6 @@
 ! -----------------
 ! +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)
 !
 ! Former revisions:
@@ -431,5 +433,7 @@
              vg_vertical_gradient_level(10) = -9999999.9, &
              volume_flow(1:2) = 0.0, volume_flow_area(1:2) = 0.0, &
-             volume_flow_initial(1:2) = 0.0, wall_heatflux(0:4) = 0.0
+             volume_flow_initial(1:2) = 0.0, wall_heatflux(0:4) = 0.0, &
+             wall_humidityflux(0:4) = 0.0, wall_qflux(0:4) = 0.0, &
+             wall_salinityflux(0:4) = 0.0, wall_scalarflux(0:4) = 0.0
 
 
Index: palm/trunk/SOURCE/prognostic_equations.f90
===================================================================
--- palm/trunk/SOURCE/prognostic_equations.f90	(revision 128)
+++ palm/trunk/SOURCE/prognostic_equations.f90	(revision 129)
@@ -4,5 +4,5 @@
 ! Actual revisions:
 ! -----------------
-! 
+! add wall_*flux to parameter list of calls of diffusion_s
 !
 ! Former revisions:
@@ -369,5 +369,6 @@
 !--       Tendency terms
           IF ( scalar_advec == 'bc-scheme' )  THEN
-             CALL diffusion_s( i, j, ddzu, ddzw, kh, pt, shf, tswst, tend )
+             CALL diffusion_s( i, j, ddzu, ddzw, kh, pt, shf, tswst, &
+                               wall_heatflux, tend )
           ELSE
              IF ( tsc(2) == 2.0  .OR.  timestep_scheme(1:5) == 'runge' )  THEN
@@ -383,7 +384,8 @@
              THEN
                 CALL diffusion_s( i, j, ddzu, ddzw, kh_m, pt_m, shf_m, &
-                                  tswst_m, tend )
+                                  tswst_m, wall_heatflux, tend )
              ELSE
-                CALL diffusion_s( i, j, ddzu, ddzw, kh, pt, shf, tswst, tend )
+                CALL diffusion_s( i, j, ddzu, ddzw, kh, pt, shf, tswst, &
+                                  wall_heatflux, tend )
              ENDIF
           ENDIF
@@ -471,5 +473,5 @@
              IF ( scalar_advec == 'bc-scheme' )  THEN
                 CALL diffusion_s( i, j, ddzu, ddzw, kh, sa, saswsb, saswst, &
-                                  tend )
+                                  wall_salinityflux, tend )
              ELSE
                 IF ( tsc(2) == 2.0  .OR.  timestep_scheme(1:5) == 'runge' ) THEN
@@ -483,5 +485,5 @@
                 ENDIF
                 CALL diffusion_s( i, j, ddzu, ddzw, kh, sa, saswsb, saswst, &
-                                  tend )
+                                  wall_salinityflux, tend )
              ENDIF
        
@@ -563,5 +565,6 @@
 !--          Tendency-terms
              IF ( scalar_advec == 'bc-scheme' )  THEN
-                CALL diffusion_s( i, j, ddzu, ddzw, kh, q, qsws, qswst, tend )
+                CALL diffusion_s( i, j, ddzu, ddzw, kh, q, qsws, qswst, &
+                                  wall_qflux, tend )
              ELSE
                 IF ( tsc(2) == 2.0  .OR.  timestep_scheme(1:5) == 'runge' ) THEN
@@ -577,8 +580,8 @@
                 THEN
                    CALL diffusion_s( i, j, ddzu, ddzw, kh_m, q_m, qsws_m, &
-                                     qswst_m, tend )
+                                     qswst_m, wall_qflux, tend )
                 ELSE
                    CALL diffusion_s( i, j, ddzu, ddzw, kh, q, qsws, qswst, &
-                                     tend )
+                                     wall_qflux, tend )
                 ENDIF
              ENDIF
@@ -974,7 +977,8 @@
           THEN
              CALL diffusion_s( i, j, ddzu, ddzw, kh_m, pt_m, shf_m, &
-                               tswst_m, tend )
-          ELSE
-             CALL diffusion_s( i, j, ddzu, ddzw, kh, pt, shf, tswst, tend )
+                               tswst_m, wall_heatflux, tend )
+          ELSE
+             CALL diffusion_s( i, j, ddzu, ddzw, kh, pt, shf, tswst, &
+                               wall_heatflux, tend )
           ENDIF
 
@@ -1033,5 +1037,5 @@
              ENDIF
              CALL diffusion_s( i, j, ddzu, ddzw, kh, sa, saswsb, saswst, &
-                               tend )
+                               wall_salinityflux, tend )
 
              CALL user_actions( i, j, 'sa-tendency' )
@@ -1087,8 +1091,8 @@
              THEN
                 CALL diffusion_s( i, j, ddzu, ddzw, kh_m, q_m, qsws_m, &
-                                  qswst_m, tend )
+                                  qswst_m, wall_qflux, tend )
              ELSE
                 CALL diffusion_s( i, j, ddzu, ddzw, kh, q, qsws, qswst, &
-                                  tend )
+                                  wall_qflux, tend )
              ENDIF
        
@@ -1487,5 +1491,6 @@
 !-- pt-tendency terms with no communication
     IF ( scalar_advec == 'bc-scheme' )  THEN
-       CALL diffusion_s( ddzu, ddzw, kh, pt, shf, tswst, tend )
+       CALL diffusion_s( ddzu, ddzw, kh, pt, shf, tswst, wall_heatflux, &
+                         tend )
     ELSE
        IF ( tsc(2) == 2.0  .OR.  timestep_scheme(1:5) == 'runge' )  THEN
@@ -1499,7 +1504,9 @@
        ENDIF
        IF ( tsc(2) == 2.0  .AND.  timestep_scheme(1:8) == 'leapfrog' )  THEN
-          CALL diffusion_s( ddzu, ddzw, kh_m, pt_m, shf_m, tswst_m, tend )
+          CALL diffusion_s( ddzu, ddzw, kh_m, pt_m, shf_m, tswst_m, &
+                            wall_heatflux, tend )
        ELSE
-          CALL diffusion_s( ddzu, ddzw, kh, pt, shf, tswst, tend )
+          CALL diffusion_s( ddzu, ddzw, kh, pt, shf, tswst, wall_heatflux, &
+                            tend )
        ENDIF
     ENDIF
@@ -1589,7 +1596,8 @@
 
 !
-!--    Scalar/q-tendency terms with no communication
+!--    sa-tendency terms with no communication
        IF ( scalar_advec == 'bc-scheme' )  THEN
-          CALL diffusion_s( ddzu, ddzw, kh, sa, saswsb, saswst, tend )
+          CALL diffusion_s( ddzu, ddzw, kh, sa, saswsb, saswst, &
+                            wall_salinityflux, tend )
        ELSE
           IF ( tsc(2) == 2.0  .OR.  timestep_scheme(1:5) == 'runge' )  THEN
@@ -1602,5 +1610,6 @@
              ENDIF
           ENDIF
-          CALL diffusion_s( ddzu, ddzw, kh, sa, saswsb, saswst, tend )
+          CALL diffusion_s( ddzu, ddzw, kh, sa, saswsb, saswst, &
+                            wall_salinityflux, tend )
        ENDIF
        
@@ -1689,5 +1698,5 @@
 !--    Scalar/q-tendency terms with no communication
        IF ( scalar_advec == 'bc-scheme' )  THEN
-          CALL diffusion_s( ddzu, ddzw, kh, q, qsws, qswst, tend )
+          CALL diffusion_s( ddzu, ddzw, kh, q, qsws, qswst, wall_qflux, tend )
        ELSE
           IF ( tsc(2) == 2.0  .OR.  timestep_scheme(1:5) == 'runge' )  THEN
@@ -1701,7 +1710,9 @@
           ENDIF
           IF ( tsc(2) == 2.0  .AND.  timestep_scheme(1:8) == 'leapfrog' )  THEN
-             CALL diffusion_s( ddzu, ddzw, kh_m, q_m, qsws_m, qswst_m, tend )
-          ELSE
-             CALL diffusion_s( ddzu, ddzw, kh, q, qsws, qswst, tend )
+             CALL diffusion_s( ddzu, ddzw, kh_m, q_m, qsws_m, qswst_m, &
+                               wall_qflux, tend )
+          ELSE
+             CALL diffusion_s( ddzu, ddzw, kh, q, qsws, qswst, &
+                               wall_qflux, tend )
           ENDIF
        ENDIF
