Index: palm/trunk/SOURCE/data_output_2d.f90
===================================================================
--- palm/trunk/SOURCE/data_output_2d.f90	(revision 1852)
+++ palm/trunk/SOURCE/data_output_2d.f90	(revision 1960)
@@ -19,5 +19,6 @@
 ! Current revisions:
 ! -----------------
-!
+! Scalar surface flux added
+! Rename INTEGER variable s into s_ind, as s is already assigned to scalar
 !
 ! Former revisions:
@@ -138,6 +139,6 @@
     USE arrays_3d,                                                             &
         ONLY:  dzw, e, nr, ol, p, pt, precipitation_amount, precipitation_rate,&
-               prr,q, qc, ql, ql_c, ql_v, ql_vp, qr, qsws, rho, sa, shf, tend, &
-               ts, u, us, v, vpt, w, z0, z0h, z0q, zu, zw
+               prr,q, qc, ql, ql_c, ql_v, ql_vp, qr, qsws, rho, s, sa, shf,    &
+               ssws, tend, ts, u, us, v, vpt, w, z0, z0h, z0q, zu, zw
         
     USE averaging
@@ -224,5 +225,5 @@
     INTEGER(iwp) ::  nzt_do    !< upper limit of the data field (usually nzt+1)
     INTEGER(iwp) ::  psi       !< 
-    INTEGER(iwp) ::  s         !< 
+    INTEGER(iwp) ::  s_ind     !< 
     INTEGER(iwp) ::  sender    !< 
     INTEGER(iwp) ::  ind(4)    !< 
@@ -268,10 +269,10 @@
 
        CASE ( 'xy' )
-          s = 1
+          s_ind = 1
           ALLOCATE( level_z(nzb:nzt+1), local_2d(nxlg:nxrg,nysg:nyng) )
 
           IF ( netcdf_data_format > 4 )  THEN
              ns = 1
-             DO WHILE ( section(ns,s) /= -9999  .AND.  ns <= 100 )
+             DO WHILE ( section(ns,s_ind) /= -9999  .AND.  ns <= 100 )
                 ns = ns + 1
              ENDDO
@@ -298,10 +299,10 @@
 
        CASE ( 'xz' )
-          s = 2
+          s_ind = 2
           ALLOCATE( local_2d(nxlg:nxrg,nzb:nzt+1) )
 
           IF ( netcdf_data_format > 4 )  THEN
              ns = 1
-             DO WHILE ( section(ns,s) /= -9999  .AND.  ns <= 100 )
+             DO WHILE ( section(ns,s_ind) /= -9999  .AND.  ns <= 100 )
                 ns = ns + 1
              ENDDO
@@ -329,10 +330,10 @@
 
        CASE ( 'yz' )
-          s = 3
+          s_ind = 3
           ALLOCATE( local_2d(nysg:nyng,nzb:nzt+1) )
 
           IF ( netcdf_data_format > 4 )  THEN
              ns = 1
-             DO WHILE ( section(ns,s) /= -9999  .AND.  ns <= 100 )
+             DO WHILE ( section(ns,s_ind) /= -9999  .AND.  ns <= 100 )
                 ns = ns + 1
              ENDDO
@@ -1070,5 +1071,5 @@
              CASE ( 's_xy', 's_xz', 's_yz' )
                 IF ( av == 0 )  THEN
-                   to_be_resorted => q
+                   to_be_resorted => s
                 ELSE
                    to_be_resorted => s_av
@@ -1117,4 +1118,22 @@
                 two_d = .TRUE.
                 level_z(nzb+1) = zu(nzb+1)
+                
+             CASE ( 'ssws*_xy' )        ! 2d-array
+                IF ( av == 0 ) THEN
+                   DO  i = nxlg, nxrg
+                      DO  j = nysg, nyng
+                         local_pf(i,j,nzb+1) =  ssws(j,i)
+                      ENDDO
+                   ENDDO
+                ELSE
+                   DO  i = nxlg, nxrg
+                      DO  j = nysg, nyng 
+                         local_pf(i,j,nzb+1) =  ssws_av(j,i)
+                      ENDDO
+                   ENDDO
+                ENDIF
+                resorted = .TRUE.
+                two_d = .TRUE.
+                level_z(nzb+1) = zu(nzb+1)                
 
              CASE ( 't*_xy' )        ! 2d-array
@@ -1303,5 +1322,5 @@
 !--       section mode chosen.
           is = 1
-   loop1: DO WHILE ( section(is,s) /= -9999  .OR.  two_d )
+   loop1: DO WHILE ( section(is,s_ind) /= -9999  .OR.  two_d )
 
              SELECT CASE ( mode )
@@ -1313,5 +1332,5 @@
                       layer_xy = nzb+1
                    ELSE
-                      layer_xy = section(is,s)
+                      layer_xy = section(is,s_ind)
                    ENDIF
 
@@ -1347,5 +1366,5 @@
 !
 !--                If required, carry out averaging along z
-                   IF ( section(is,s) == -1  .AND.  .NOT. two_d )  THEN
+                   IF ( section(is,s_ind) == -1  .AND.  .NOT. two_d )  THEN
 
                       local_2d = 0.0_wp
@@ -1537,5 +1556,5 @@
 !
 !--                If required, carry out averaging along y
-                   IF ( section(is,s) == -1 )  THEN
+                   IF ( section(is,s_ind) == -1 )  THEN
 
                       ALLOCATE( local_2d_l(nxlg:nxrg,nzb_do:nzt_do) )
@@ -1570,7 +1589,7 @@
 !--                   Just store the respective section on the local array
 !--                   (but only if it is available on this PE!)
-                      IF ( section(is,s) >= nys  .AND.  section(is,s) <= nyn ) &
+                      IF ( section(is,s_ind) >= nys  .AND.  section(is,s_ind) <= nyn ) &
                       THEN
-                         local_2d = local_pf(:,section(is,s),nzb_do:nzt_do)
+                         local_2d = local_pf(:,section(is,s_ind),nzb_do:nzt_do)
                       ENDIF
 
@@ -1584,7 +1603,7 @@
 !--                   sections reside. Cross sections averaged along y are
 !--                   output on the respective first PE along y (myidy=0).
-                      IF ( ( section(is,s) >= nys  .AND.                       &
-                             section(is,s) <= nyn )  .OR.                      &
-                           ( section(is,s) == -1  .AND.  myidy == 0 ) )  THEN
+                      IF ( ( section(is,s_ind) >= nys  .AND.                   &
+                             section(is,s_ind) <= nyn )  .OR.                  &
+                           ( section(is,s_ind) == -1  .AND.  myidy == 0 ) )  THEN
 #if defined( __netcdf )
 !
@@ -1615,7 +1634,7 @@
                          DO  i = 0, io_blocks-1
                             IF ( i == io_group )  THEN
-                               IF ( ( section(is,s) >= nys  .AND.              &
-                                      section(is,s) <= nyn )  .OR.             &
-                                    ( section(is,s) == -1  .AND.               &
+                               IF ( ( section(is,s_ind) >= nys  .AND.          &
+                                      section(is,s_ind) <= nyn )  .OR.         &
+                                    ( section(is,s_ind) == -1  .AND.           &
                                       nys-1 == -1 ) )                          &
                                THEN
@@ -1643,8 +1662,8 @@
 !
 !--                         Local array can be relocated directly.
-                            IF ( ( section(is,s) >= nys  .AND.                 &
-                                   section(is,s) <= nyn )  .OR.                &
-                                 ( section(is,s) == -1  .AND.  nys-1 == -1 ) ) &
-                            THEN
+                            IF ( ( section(is,s_ind) >= nys  .AND.              &
+                                   section(is,s_ind) <= nyn )  .OR.             &
+                                 ( section(is,s_ind) == -1  .AND.               &
+                                   nys-1 == -1 ) )  THEN
                                total_2d(nxlg:nxrg,nzb_do:nzt_do) = local_2d
                             ENDIF
@@ -1691,7 +1710,7 @@
 !--                         If the cross section resides on the PE, send the
 !--                         local index limits, otherwise send -9999 to PE0.
-                            IF ( ( section(is,s) >= nys  .AND.                 &
-                                   section(is,s) <= nyn )  .OR.                &
-                                 ( section(is,s) == -1  .AND.  nys-1 == -1 ) ) &
+                            IF ( ( section(is,s_ind) >= nys  .AND.              &
+                                   section(is,s_ind) <= nyn )  .OR.             &
+                                 ( section(is,s_ind) == -1  .AND.  nys-1 == -1 ) ) &
                             THEN
                                ind(1) = nxlg; ind(2) = nxrg
@@ -1756,5 +1775,5 @@
 !
 !--                If required, carry out averaging along x
-                   IF ( section(is,s) == -1 )  THEN
+                   IF ( section(is,s_ind) == -1 )  THEN
 
                       ALLOCATE( local_2d_l(nysg:nyng,nzb_do:nzt_do) )
@@ -1789,7 +1808,7 @@
 !--                   Just store the respective section on the local array
 !--                   (but only if it is available on this PE!)
-                      IF ( section(is,s) >= nxl  .AND.  section(is,s) <= nxr ) &
+                      IF ( section(is,s_ind) >= nxl  .AND.  section(is,s_ind) <= nxr ) &
                       THEN
-                         local_2d = local_pf(section(is,s),:,nzb_do:nzt_do)
+                         local_2d = local_pf(section(is,s_ind),:,nzb_do:nzt_do)
                       ENDIF
 
@@ -1803,7 +1822,7 @@
 !--                   sections reside. Cross sections averaged along x are
 !--                   output on the respective first PE along x (myidx=0).
-                      IF ( ( section(is,s) >= nxl  .AND.                       &
-                             section(is,s) <= nxr )  .OR.                      &
-                           ( section(is,s) == -1  .AND.  myidx == 0 ) )  THEN
+                      IF ( ( section(is,s_ind) >= nxl  .AND.                       &
+                             section(is,s_ind) <= nxr )  .OR.                      &
+                           ( section(is,s_ind) == -1  .AND.  myidx == 0 ) )  THEN
 #if defined( __netcdf )
 !
@@ -1834,7 +1853,7 @@
                          DO  i = 0, io_blocks-1
                             IF ( i == io_group )  THEN
-                               IF ( ( section(is,s) >= nxl  .AND.              &
-                                      section(is,s) <= nxr )  .OR.             &
-                                    ( section(is,s) == -1  .AND.               &
+                               IF ( ( section(is,s_ind) >= nxl  .AND.          &
+                                      section(is,s_ind) <= nxr )  .OR.         &
+                                    ( section(is,s_ind) == -1  .AND.           &
                                       nxl-1 == -1 ) )                          &
                                THEN
@@ -1862,7 +1881,7 @@
 !
 !--                         Local array can be relocated directly.
-                            IF ( ( section(is,s) >= nxl  .AND.                 &
-                                   section(is,s) <= nxr )   .OR.               &
-                                 ( section(is,s) == -1  .AND.  nxl-1 == -1 ) ) &
+                            IF ( ( section(is,s_ind) >= nxl  .AND.             &
+                                   section(is,s_ind) <= nxr )   .OR.           &
+                                 ( section(is,s_ind) == -1  .AND.  nxl-1 == -1 ) ) &
                             THEN
                                total_2d(nysg:nyng,nzb_do:nzt_do) = local_2d
@@ -1910,7 +1929,7 @@
 !--                         If the cross section resides on the PE, send the
 !--                         local index limits, otherwise send -9999 to PE0.
-                            IF ( ( section(is,s) >= nxl  .AND.                 &
-                                   section(is,s) <= nxr )  .OR.                &
-                                 ( section(is,s) == -1  .AND.  nxl-1 == -1 ) ) &
+                            IF ( ( section(is,s_ind) >= nxl  .AND.              &
+                                   section(is,s_ind) <= nxr )  .OR.             &
+                                 ( section(is,s_ind) == -1  .AND.  nxl-1 == -1 ) ) &
                             THEN
                                ind(1) = nysg; ind(2) = nyng
@@ -2148,5 +2167,5 @@
 !
 !-- Close plot output file.
-    file_id = 20 + s
+    file_id = 20 + s_ind
 
     IF ( data_output_2d_on_each_pe )  THEN
