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
