Index: palm/trunk/SOURCE/pres.f90
===================================================================
--- palm/trunk/SOURCE/pres.f90	(revision 668)
+++ palm/trunk/SOURCE/pres.f90	(revision 673)
@@ -4,5 +4,6 @@
 ! Current revisions:
 ! -----------------
-!
+! Weighting coefficients added for right computation of the pressure during
+! Runge-Kutta substeps. 
 ! Former revisions:
 ! -----------------
@@ -72,5 +73,5 @@
     INTEGER ::  i, j, k, sr
 
-    REAL    ::  ddt_3d, localsum, threadsum
+    REAL    ::  ddt_3d, localsum, threadsum, d_weight_pres
 
     REAL, DIMENSION(1:2) ::  volume_flow_l, volume_flow_offset
@@ -82,4 +83,5 @@
 
     ddt_3d = 1.0 / dt_3d
+    d_weight_pres = 1. / weight_pres(intermediate_timestep_count)
 
 !
@@ -253,5 +255,6 @@
              d(k,j,i) = ( ( u(k,j,i+1) - u(k,j,i) ) * ddx + &
                           ( v(k,j+1,i) - v(k,j,i) ) * ddy + &
-                          ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) ) * ddt_3d
+                          ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) ) * ddt_3d      &
+                                                                * d_weight_pres 
           ENDDO
 !
@@ -268,5 +271,5 @@
                                        - g * ( pt(k+1,j,i) - sums(k+1,4) ) / &
                                          sums(k+1,4)                         &
-                                       ) * ddzw(k+1) * ddt_3d
+                                       ) * ddzw(k+1) * ddt_3d * d_weight_pres 
           ENDIF
 
@@ -291,5 +294,6 @@
              d(k,j,i) = ( ( u(k,j,i+1) - u(k,j,i) ) * ddx + &
                           ( v(k,j+1,i) - v(k,j,i) ) * ddy + &
-                          ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) ) * ddt_3d
+                          ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) ) * ddt_3d      &
+                                                                * d_weight_pres 
              ENDDO
           ENDDO
@@ -307,5 +311,6 @@
                            - g * ( pt(k+1,j,i) - sums(k+1,4) ) / &
                              sums(k+1,4)                         &
-                                        ) * ddzw(k+1) * ddt_3d
+                                        ) * ddzw(k+1) * ddt_3d   &
+                                          * d_weight_pres 
           ENDDO
        ENDDO
@@ -321,5 +326,6 @@
                 d(k,j,i) = ( ( u(k,j,i+1) - u(k,j,i) ) * ddx + &
                           ( v(k,j+1,i) - v(k,j,i) ) * ddy + &
-                          ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) ) * ddt_3d
+                          ( w(k,j,i) - w(k-1,j,i) ) * ddzw(k) ) * ddt_3d      &
+                                                                * d_weight_pres 
              ENDDO
           ENDDO
@@ -340,5 +346,6 @@
        ENDDO
     ENDDO
-    localsum = ( localsum + threadsum ) * dt_3d
+    localsum = ( localsum + threadsum ) * dt_3d                               &
+               * weight_pres(intermediate_timestep_count)
     !$OMP END PARALLEL
 #endif
@@ -496,11 +503,5 @@
           DEALLOCATE( p )
           ALLOCATE( p(nzb:nzt+1,nysg:nyng,nxlg:nxrg) )
-          DO  i = nxl, nxr
-             DO  j = nys, nyn
-                DO  k = nzb_s_inner(j,i), nzt
-                   p(k,j,i) = tend(k,j,i)
-                ENDDO
-             ENDDO
-          ENDDO
+          
        ENDIF
 
@@ -510,15 +511,37 @@
 !-- Store perturbation pressure on array p, used in the momentum equations
     IF ( psolver(1:7) == 'poisfft' )  THEN
-!
-!--    Here, only the values from the left and right boundaries are copied
-!--    The remaining values are copied in the following loop due to speed
-!--    optimization
-       !$OMP PARALLEL DO
-       DO  j = nysg, nyng
-          DO  k = nzb, nzt+1
-             p(k,j,nxlg:nxl-1) = tend(k,j,nxlg:nxl-1)
-             p(k,j,nxr+1:nxrg) = tend(k,j,nxr+1:nxrg)
-          ENDDO
-       ENDDO
+
+       IF ( intermediate_timestep_count == 1 )  THEN
+          !$OMP PARALLEL PRIVATE (i,j,k)
+          !$OMP DO
+          DO  i = nxlg, nxrg
+             DO  j = nysg, nyng
+                DO  k = nzb, nzt+1
+                   p(k,j,i) = tend(k,j,i)                                     &
+                            * weight_substep(intermediate_timestep_count)
+                   p(k,j,i) = tend(k,j,i)                                     &
+                            * weight_substep(intermediate_timestep_count)
+                ENDDO
+             ENDDO
+          ENDDO
+          !$OMP END PARALLEL
+          
+       ELSE 
+          !$OMP PARALLEL PRIVATE (i,j,k)
+          !$OMP DO
+          DO  i = nxlg, nxrg
+             DO  j = nysg, nyng
+                DO  k = nzb, nzt+1
+                   p(k,j,i) = p(k,j,i) + tend(k,j,i)                          &
+                            * weight_substep(intermediate_timestep_count)
+                   p(k,j,i) = p(k,j,i) + tend(k,j,i)                          &
+                            * weight_substep(intermediate_timestep_count)
+                ENDDO
+             ENDDO
+          ENDDO
+          !$OMP END PARALLEL
+          
+       ENDIF
+       
     ENDIF
 
@@ -533,24 +556,21 @@
     !$OMP PARALLEL PRIVATE (i,j,k)
     !$OMP DO
-    DO  i = nxl, nxr
-       IF ( psolver(1:7) == 'poisfft' )  THEN
-          DO  j = nysg, nyng
-             DO  k = nzb, nzt+1
-                p(k,j,i) = tend(k,j,i)
-             ENDDO
-          ENDDO
-       ENDIF
+    DO  i = nxl, nxr   
        DO  j = nys, nyn
           DO  k = nzb_w_inner(j,i)+1, nzt
-             w(k,j,i) = w(k,j,i) - dt_3d * &
-                                   ( tend(k+1,j,i) - tend(k,j,i) ) * ddzu(k+1)
+             w(k,j,i) = w(k,j,i) - dt_3d *                                    &
+                        ( tend(k+1,j,i) - tend(k,j,i) ) * ddzu(k+1)           &
+                        * weight_pres(intermediate_timestep_count)
           ENDDO
           DO  k = nzb_u_inner(j,i)+1, nzt
-             u(k,j,i) = u(k,j,i) - dt_3d * ( tend(k,j,i) - tend(k,j,i-1) ) * ddx
+             u(k,j,i) = u(k,j,i) - dt_3d *                                 &
+                        ( tend(k,j,i) - tend(k,j,i-1) ) * ddx              &
+                        * weight_pres(intermediate_timestep_count)
           ENDDO
           DO  k = nzb_v_inner(j,i)+1, nzt
-             v(k,j,i) = v(k,j,i) - dt_3d * ( tend(k,j,i) - tend(k,j-1,i) ) * ddy
-          ENDDO
-
+             v(k,j,i) = v(k,j,i) - dt_3d *                                 &
+                        ( tend(k,j,i) - tend(k,j-1,i) ) * ddy              &
+                        * weight_pres(intermediate_timestep_count)
+          ENDDO                                                         
 !
 !--       Sum up the volume flow through the right and north boundary
@@ -575,5 +595,47 @@
     ENDDO
     !$OMP END PARALLEL
-
+    
+    IF ( psolver == 'multigrid' .OR. psolver == 'sor' )  THEN       
+       IF ( intermediate_timestep_count == 1 .OR. simulated_time == 0)  THEN 
+          !$OMP PARALLEL PRIVATE (i,j,k)
+          !$OMP DO
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                DO  k = nzb, nzt+1
+                   p_sub(k,j,i) = tend(k,j,i)                                 &
+                                * weight_substep(intermediate_timestep_count)
+                ENDDO
+             ENDDO
+          ENDDO
+          !$OMP END PARALLEL
+       ELSE
+          !$OMP PARALLEL PRIVATE (i,j,k)
+          !$OMP DO
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                DO  k = nzb, nzt+1
+                   p_sub(k,j,i) = p_sub(k,j,i) + tend(k,j,i)                  &
+                                * weight_substep(intermediate_timestep_count)
+                ENDDO
+             ENDDO
+          ENDDO
+          !$OMP END PARALLEL
+       ENDIF
+          
+       IF ( intermediate_timestep_count == intermediate_timestep_count_max )  &
+          THEN
+          !$OMP PARALLEL PRIVATE (i,j,k)
+          !$OMP DO
+          DO  i = nxl, nxr
+             DO  j = nys, nyn
+                DO  k = nzb, nzt+1
+                   p(k,j,i) = p_sub(k,j,i) 
+                ENDDO
+             ENDDO
+          ENDDO
+          !$OMP END PARALLEL
+       ENDIF
+    ENDIF
+ 
 !
 !-- Resize tend to its normal size in case of multigrid and ws-scheme.
