Index: /palm/trunk/SCRIPTS/mrun
===================================================================
--- /palm/trunk/SCRIPTS/mrun	(revision 695)
+++ /palm/trunk/SCRIPTS/mrun	(revision 696)
@@ -219,6 +219,7 @@
      # 02/02/10 - Siggi  - further adjustments on Tsubame and concerning openMP
      #                     usage
-     # 09/02/10 - Siggi  - adjustments for ibmkisti, mpt bugfix for netCDF4
+     # 09/03/10 - Siggi  - adjustments for ibmkisti, mpt bugfix for netCDF4
      #                     usage, totalview usage extended
+     # 17/03/11 - Siggi -  adjustments for openmp usage on ibmkisti
 
 
@@ -3131,6 +3132,11 @@
                 export LANG=en_US
                 export MP_SHARED_MEMORY=yes
-                export MP_SINGLE_THREAD=yes
-                export MEMORY_AFFINITY=MCM
+                if [[ $threads_per_task = 1 ]]
+                then
+                   export MP_SINGLE_THREAD=yes
+                   export MEMORY_AFFINITY=MCM
+                else
+                   export OMP_NUM_THREADS=$threads_per_task
+                fi
              fi
 
@@ -3291,5 +3297,5 @@
              (( ii = $numprocs / $threads_per_task ))
              export OMP_NUM_THREADS=$threads_per_task
-#             echo "OMP_NUM_THREADS=$OMP_NUM_THREADS"
+             # echo "*** OMP_NUM_THREADS=$OMP_NUM_THREADS"
              if [[ $threads_per_task != 1 ]]
              then
Index: /palm/trunk/SCRIPTS/subjob
===================================================================
--- /palm/trunk/SCRIPTS/subjob	(revision 695)
+++ /palm/trunk/SCRIPTS/subjob	(revision 696)
@@ -128,4 +128,5 @@
      # 02/02/11 - Siggi - further asjustments for Tsubame concerning openMP
      # 06/03/11 - Siggi - adjustments for ibmkisti
+     # 17/03/11 - Siggi - adjustments for openmp usage on ibmkisti
 
 
@@ -152,5 +153,5 @@
 
  typeset  -i   cputime=0  memory=0  Memory=0  minuten  resttime  sekunden  stunden
- typeset  -i   inumprocs  nodes=0  processes_per_node=0 tasks_per_node=0  threads_per_task=1
+ typeset  -i   inumprocs  mpi_tasks=0  nodes=0  processes_per_node=0 tasks_per_node=0  threads_per_task=1
  typeset  -L20 spalte1
  typeset  -R40 spalte2
@@ -548,4 +549,7 @@
  (( processes_per_node = tasks_per_node * threads_per_task ))
 
+    # Calculate number of MPI tasks
+ (( mpi_tasks = numprocs / threads_per_task ))
+
 
     # HEADER-AUSGABE
@@ -638,6 +642,9 @@
        network_to_use="# @ network.MPI = sn_all,shared,US"
        wall_clock_limit="# @ wall_clock_limit = $timestring"
-       rset="# @ rset = RSET_MCM_AFFINITY"
-       mcm_affinity_options="# @ mcm_affinity_options = mcm_mem_pref mcm_sni_none mcm_distribute"
+       if [[ $threads_per_task = 1 ]]
+       then
+          rset="# @ rset = RSET_MCM_AFFINITY"
+          mcm_affinity_options="# @ mcm_affinity_options = mcm_mem_pref mcm_sni_none mcm_distribute"
+       fi
        environment=""
        use_shell=""
@@ -701,5 +708,5 @@
 
           cat >> $job_to_send << %%END%%
-# @ total_tasks = $numprocs
+# @ total_tasks = $mpi_tasks
 # @ blocking = unlimited
 # @ queue
@@ -733,4 +740,10 @@
        fi
 
+    fi
+
+       # workaround because of silly job filter on ibmkisti
+    if [[ $remote_host = ibmkisti  &&  $threads_per_task != 1 ]]
+    then
+       echo  "export OMP_NUM_THREADS=$threads_per_task"  >>  $job_to_send
     fi
 
Index: /palm/trunk/SOURCE/flow_statistics.f90
===================================================================
--- /palm/trunk/SOURCE/flow_statistics.f90	(revision 695)
+++ /palm/trunk/SOURCE/flow_statistics.f90	(revision 696)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-! 
+! Bugfix: Summation of Wicker-Skamarock scheme fluxes and variances for all
+! threads
 !
 ! Former revisions:
@@ -155,4 +156,5 @@
 !--    the local array sums_l() for further computations
        IF ( ws_scheme_mom )  THEN
+
 !       
 !--       According to the Neumann bc for the horizontal velocity components,
@@ -162,25 +164,35 @@
              sums_vs2_ws_l(nzt+1,sr) = sums_vs2_ws_l(nzt,sr)    
           ENDIF
+
+          DO  i = 0, threads_per_task-1
 !          
-!--       Swap the turbulent quantities evaluated in advec_ws.
-          sums_l(:,13,0) = sums_wsus_ws_l(:,sr)       ! w*u* 
-          sums_l(:,15,0) = sums_wsvs_ws_l(:,sr)       ! w*v* 
-          sums_l(:,30,0) = sums_us2_ws_l(:,sr)        ! u*2 
-          sums_l(:,31,0) = sums_vs2_ws_l(:,sr)        ! v*2 
-          sums_l(:,32,0) = sums_ws2_ws_l(:,sr)        ! w*2 
-          sums_l(:,34,0) = sums_l(:,34,0) + 0.5 *                             & 
-                (sums_us2_ws_l(:,sr) + sums_vs2_ws_l(:,sr)                    &
-                + sums_ws2_ws_l(:,sr))                      ! e*
-          DO  k = nzb, nzt
-             sums_l(nzb+5,pr_palm,0) = sums_l(nzb+5,pr_palm,0) + 0.5 * (      &
-                sums_us2_ws_l(k,sr) + sums_vs2_ws_l(k,sr) +                   &
-                sums_ws2_ws_l(k,sr))
-          ENDDO
-       ENDIF
+!--          Swap the turbulent quantities evaluated in advec_ws.
+             sums_l(:,13,i) = sums_wsus_ws_l(:,sr)       ! w*u* 
+             sums_l(:,15,i) = sums_wsvs_ws_l(:,sr)       ! w*v* 
+             sums_l(:,30,i) = sums_us2_ws_l(:,sr)        ! u*2 
+             sums_l(:,31,i) = sums_vs2_ws_l(:,sr)        ! v*2 
+             sums_l(:,32,i) = sums_ws2_ws_l(:,sr)        ! w*2 
+             sums_l(:,34,i) = sums_l(:,34,i) + 0.5 *                        & 
+                              ( sums_us2_ws_l(:,sr) + sums_vs2_ws_l(:,sr) + &
+                                sums_ws2_ws_l(:,sr) )    ! e*
+             DO  k = nzb, nzt
+                sums_l(nzb+5,pr_palm,i) = sums_l(nzb+5,pr_palm,i) + 0.5 * (  &
+                                                      sums_us2_ws_l(k,sr) +  &
+                                                      sums_vs2_ws_l(k,sr) +  &
+                                                      sums_ws2_ws_l(k,sr) )
+             ENDDO
+          ENDDO
+
+       ENDIF
+
        IF ( ws_scheme_sca )  THEN
-          sums_l(:,17,0) = sums_wspts_ws_l(:,sr)      ! w*pt* from advec_s_ws
-          IF ( ocean ) sums_l(:,66,0) = sums_wssas_ws_l(:,sr) ! w*sa*
-          IF ( humidity  .OR.  passive_scalar ) sums_l(:,49,0) =              &
-                                                   sums_wsqs_ws_l(:,sr) !w*q* 
+
+          DO  i = 0, threads_per_task-1
+             sums_l(:,17,i) = sums_wspts_ws_l(:,sr)      ! w*pt* from advec_s_ws
+             IF ( ocean ) sums_l(:,66,i) = sums_wssas_ws_l(:,sr) ! w*sa*
+             IF ( humidity .OR. passive_scalar ) sums_l(:,49,i) =              &
+                                                   sums_wsqs_ws_l(:,sr) !w*q*
+          ENDDO
+
        ENDIF
 ! 
Index: /palm/trunk/SOURCE/poisfft.f90
===================================================================
--- /palm/trunk/SOURCE/poisfft.f90	(revision 695)
+++ /palm/trunk/SOURCE/poisfft.f90	(revision 696)
@@ -4,5 +4,5 @@
 ! Current revisions:
 ! -----------------
-! 
+! work_fftx removed from PRIVATE clauses in fftx_tr_xy and tr_yx_fftx
 !
 ! Former revisions:
@@ -1070,5 +1070,5 @@
 !--       Cache optimized code (there might be still a potential for better
 !--       optimization).
-!$OMP     PARALLEL PRIVATE (i,j,k,work_fftx)
+!$OMP     PARALLEL PRIVATE (i,j,k)
 !$OMP     DO
           DO  i = 0, nx
@@ -1181,5 +1181,5 @@
 !--       Cache optimized code (there might be still a potential for better
 !--       optimization).
-!$OMP     PARALLEL PRIVATE (i,j,k,work_fftx)
+!$OMP     PARALLEL PRIVATE (i,j,k)
 !$OMP     DO
           DO  j = nys, nyn
@@ -1245,6 +1245,5 @@
 
        tn = 0           ! Default thread number in case of one thread
-!$OMP  PARALLEL PRIVATE ( i, j, k, m, n, tn, work_ffty, work_triy )
-!$OMP  DO
+!$OMP  PARALLEL DO PRIVATE ( i, j, k, m, n, tn, work_ffty, work_triy )
        DO  i = nxl_y, nxr_y
 
@@ -1336,5 +1335,4 @@
 
        ENDDO
-!$OMP  END PARALLEL
 
        DEALLOCATE( tri )
