Index: /palm/trunk/SOURCE/transpose.f90
===================================================================
--- /palm/trunk/SOURCE/transpose.f90	(revision 4170)
+++ /palm/trunk/SOURCE/transpose.f90	(revision 4171)
@@ -26,14 +26,17 @@
 ! $Id$
 ! loop reordering for performance optimization
-! 
+!
+! 3832 2019-03-28 13:16:58Z raasch
+! loop reordering for performance optimization
+!
 ! 3694 2019-01-23 17:01:49Z knoop
 ! OpenACC port for SPEC
-! 
+!
 ! 3241 2018-09-12 15:02:00Z raasch
 ! unused variables removed
-! 
+!
 ! 2718 2018-01-02 08:49:38Z maronga
 ! Corrected "Former revisions" section
-! 
+!
 ! 2696 2017-12-14 17:12:51Z kanani
 ! Change in file header (GPL part)
@@ -43,13 +46,13 @@
 ! 2118 2017-01-17 16:38:49Z raasch
 ! OpenACC directives removed
-! 
+!
 ! 2000 2016-08-20 18:09:15Z knoop
 ! Forced header and separation lines into 80 columns
-! 
+!
 ! 1682 2015-10-07 23:56:08Z knoop
-! Code annotations made doxygen readable 
-! 
+! Code annotations made doxygen readable
+!
 ! 1324 2014-03-21 09:13:16Z suehring
-! Bugfix: ONLY statement for module pegrid removed 
+! Bugfix: ONLY statement for module pegrid removed
 !
 ! 1320 2014-03-20 08:40:49Z raasch
@@ -60,5 +63,5 @@
 ! revision history before 2012 removed,
 ! comment fields (!:) to be used for variable explanations added to
-! all variable declaration statements 
+! all variable declaration statements
 !
 ! 1318 2014-03-17 13:35:16Z raasch
@@ -104,5 +107,5 @@
 !------------------------------------------------------------------------------!
  SUBROUTINE resort_for_xy( f_in, f_inv )
- 
+
 
      USE indices,                                                              &
@@ -116,11 +119,11 @@
      IMPLICIT NONE
 
-     REAL(wp) ::  f_in(0:nx,nys_x:nyn_x,nzb_x:nzt_x)  !< 
-     REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !< 
-
-
-     INTEGER(iwp) ::  i !< 
-     INTEGER(iwp) ::  j !< 
-     INTEGER(iwp) ::  k !< 
+     REAL(wp) ::  f_in(0:nx,nys_x:nyn_x,nzb_x:nzt_x)  !<
+     REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !<
+
+
+     INTEGER(iwp) ::  i !<
+     INTEGER(iwp) ::  j !<
+     INTEGER(iwp) ::  k !<
 !
 !-- Rearrange indices of input array in order to make data to be send
@@ -133,6 +136,6 @@
 #endif
      DO  k = nzb_x, nzt_x
-         DO  i = 0, nx
-             DO  j = nys_x, nyn_x
+         DO  j = nys_x, nyn_x
+             DO  i = 0, nx
                  f_inv(j,k,i) = f_in(i,j,k)
              ENDDO
@@ -159,5 +162,5 @@
     USE indices,                                                               &
         ONLY:  nx, ny
-        
+
     USE kinds
 
@@ -169,14 +172,14 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  ys !< 
- 
-    REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !< 
-    REAL(wp) ::  f_out(0:ny,nxl_y:nxr_y,nzb_y:nzt_y) !< 
-
-    REAL(wp), DIMENSION(nyn_x-nys_x+1,nzb_y:nzt_y,nxl_y:nxr_y,0:pdims(2)-1) ::  work !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  ys !<
+
+    REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !<
+    REAL(wp) ::  f_out(0:ny,nxl_y:nxr_y,nzb_y:nzt_y) !<
+
+    REAL(wp), DIMENSION(nyn_x-nys_x+1,nzb_y:nzt_y,nxl_y:nxr_y,0:pdims(2)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
@@ -275,10 +278,10 @@
      IMPLICIT NONE
 
-     REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !< 
-     REAL(wp) ::  f_out(1:nz,nys:nyn,nxl:nxr) !< 
-
-     INTEGER(iwp) ::  i !< 
-     INTEGER(iwp) ::  j !< 
-     INTEGER(iwp) ::  k !< 
+     REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !<
+     REAL(wp) ::  f_out(1:nz,nys:nyn,nxl:nxr) !<
+
+     INTEGER(iwp) ::  i !<
+     INTEGER(iwp) ::  j !<
+     INTEGER(iwp) ::  k !<
 !
 !-- Rearrange indices of input array in order to make data to be send
@@ -292,7 +295,7 @@
      !$ACC PRESENT(f_out, f_inv)
 #endif
-     DO  k = 1, nz
-         DO  i = nxl, nxr
-             DO  j = nys, nyn
+     DO  i = nxl, nxr
+         DO  j = nys, nyn
+             DO  k = 1, nz
                  f_out(k,j,i) = f_inv(j,i,k)
              ENDDO
@@ -329,14 +332,14 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  xs !< 
-
-    REAL(wp) ::  f_in(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !< 
-    REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !< 
-
-    REAL(wp), DIMENSION(nys_x:nyn_x,nnx,nzb_x:nzt_x,0:pdims(1)-1) ::  work !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  xs !<
+
+    REAL(wp) ::  f_in(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
+    REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !<
+
+    REAL(wp), DIMENSION(nys_x:nyn_x,nnx,nzb_x:nzt_x,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
@@ -441,11 +444,11 @@
      IMPLICIT NONE
 
-     REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !< 
-     REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !< 
-
-
-     INTEGER(iwp) ::  i !< 
-     INTEGER(iwp) ::  j !< 
-     INTEGER(iwp) ::  k !< 
+     REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !<
+     REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
+
+
+     INTEGER(iwp) ::  i !<
+     INTEGER(iwp) ::  j !<
+     INTEGER(iwp) ::  k !<
 !
 !-- Rearrange indices of input array in order to make data to be send
@@ -457,7 +460,7 @@
      !$ACC PRESENT(f_out, f_inv)
 #endif
-     DO  i = 0, nx
-         DO  k = nzb_x, nzt_x
-             DO  j = nys_x, nyn_x
+     DO  k = nzb_x, nzt_x
+         DO  j = nys_x, nyn_x
+             DO  i = 0, nx
                  f_out(i,j,k) = f_inv(j,k,i)
              ENDDO
@@ -494,14 +497,14 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  ys !< 
-
-    REAL(wp) ::  f_in(0:ny,nxl_y:nxr_y,nzb_y:nzt_y)  !< 
-    REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !< 
-
-    REAL(wp), DIMENSION(nyn_x-nys_x+1,nzb_y:nzt_y,nxl_y:nxr_y,0:pdims(2)-1) ::  work !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  ys !<
+
+    REAL(wp) ::  f_in(0:ny,nxl_y:nxr_y,nzb_y:nzt_y)  !<
+    REAL(wp) ::  f_inv(nys_x:nyn_x,nzb_x:nzt_x,0:nx) !<
+
+    REAL(wp), DIMENSION(nyn_x-nys_x+1,nzb_y:nzt_y,nxl_y:nxr_y,0:pdims(2)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
@@ -611,15 +614,15 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  m  !< 
-    INTEGER(iwp) ::  xs !< 
-
-    REAL(wp) ::  f_in(1:nz,nys:nyn,nxl:nxr)          !< 
-    REAL(wp) ::  f_inv(nxl:nxr,1:nz,nys:nyn)         !< 
-    REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !< 
-    REAL(wp) ::  work(nnx*nny*nnz)                   !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  m  !<
+    INTEGER(iwp) ::  xs !<
+
+    REAL(wp) ::  f_in(1:nz,nys:nyn,nxl:nxr)          !<
+    REAL(wp) ::  f_inv(nxl:nxr,1:nz,nys:nyn)         !<
+    REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
+    REAL(wp) ::  work(nnx*nny*nnz)                   !<
 #if defined( __parallel )
 
@@ -683,10 +686,10 @@
      IMPLICIT NONE
 
-     REAL(wp) ::  f_in(0:ny,nxl_y:nxr_y,nzb_y:nzt_y)  !< 
-     REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !< 
-
-     INTEGER(iwp) ::  i !< 
-     INTEGER(iwp) ::  j !< 
-     INTEGER(iwp) ::  k !< 
+     REAL(wp) ::  f_in(0:ny,nxl_y:nxr_y,nzb_y:nzt_y)  !<
+     REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !<
+
+     INTEGER(iwp) ::  i !<
+     INTEGER(iwp) ::  j !<
+     INTEGER(iwp) ::  k !<
 
 !
@@ -699,7 +702,7 @@
      !$ACC PRESENT(f_inv, f_in)
 #endif
-     DO  j = 0, ny
-         DO  k = nzb_y, nzt_y
-             DO  i = nxl_y, nxr_y
+     DO  k = nzb_y, nzt_y
+         DO  i = nxl_y, nxr_y
+             DO  j = 0, ny
                  f_inv(i,k,j) = f_in(j,i,k)
              ENDDO
@@ -736,14 +739,14 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  zs !< 
-
-    REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !< 
-    REAL(wp) ::  f_out(nxl_z:nxr_z,nys_z:nyn_z,1:nz) !< 
-
-    REAL(wp), DIMENSION(nxl_z:nxr_z,nzt_y-nzb_y+1,nys_z:nyn_z,0:pdims(1)-1) ::  work !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  zs !<
+
+    REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !<
+    REAL(wp) ::  f_out(nxl_z:nxr_z,nys_z:nyn_z,1:nz) !<
+
+    REAL(wp), DIMENSION(nxl_z:nxr_z,nzt_y-nzb_y+1,nys_z:nyn_z,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
@@ -843,10 +846,10 @@
      IMPLICIT NONE
 
-     REAL(wp) ::  f_in(1:nz,nys:nyn,nxl:nxr)  !< 
-     REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !< 
-
-     INTEGER(iwp) ::  i !< 
-     INTEGER(iwp) ::  j !< 
-     INTEGER(iwp) ::  k !< 
+     REAL(wp) ::  f_in(1:nz,nys:nyn,nxl:nxr)  !<
+     REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz) !<
+
+     INTEGER(iwp) ::  i !<
+     INTEGER(iwp) ::  j !<
+     INTEGER(iwp) ::  k !<
 
 !
@@ -860,6 +863,6 @@
 #endif
      DO  i = nxl, nxr
-         DO  k = 1,nz
-             DO  j = nys, nyn
+         DO  j = nys, nyn
+             DO  k = 1,nz
                  f_inv(j,i,k) = f_in(k,j,i)
              ENDDO
@@ -896,14 +899,14 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  xs !< 
-
-    REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz)         !< 
-    REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !< 
-
-    REAL(wp), DIMENSION(nys_x:nyn_x,nnx,nzb_x:nzt_x,0:pdims(1)-1) ::  work !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  xs !<
+
+    REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz)         !<
+    REAL(wp) ::  f_out(0:nx,nys_x:nyn_x,nzb_x:nzt_x) !<
+
+    REAL(wp), DIMENSION(nys_x:nyn_x,nnx,nzb_x:nzt_x,0:pdims(1)-1) ::  work !<
 #if __acc_fft_device
     !$ACC DECLARE CREATE(work)
@@ -1006,11 +1009,11 @@
      IMPLICIT NONE
 
-     REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !< 
-     REAL(wp) ::  f_out(0:ny,nxl_y:nxr_y,nzb_y:nzt_y) !< 
-
-
-     INTEGER(iwp) ::  i !< 
-     INTEGER(iwp) ::  j !< 
-     INTEGER(iwp) ::  k !< 
+     REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !<
+     REAL(wp) ::  f_out(0:ny,nxl_y:nxr_y,nzb_y:nzt_y) !<
+
+
+     INTEGER(iwp) ::  i !<
+     INTEGER(iwp) ::  j !<
+     INTEGER(iwp) ::  k !<
 
 !
@@ -1023,7 +1026,7 @@
     !$ACC PRESENT(f_out, f_inv)
 #endif
-     DO  j = 0, ny
-         DO  k = nzb_y, nzt_y
-             DO  i = nxl_y, nxr_y
+     DO  k = nzb_y, nzt_y
+         DO  i = nxl_y, nxr_y
+             DO  j = 0, ny
                  f_out(j,i,k) = f_inv(i,k,j)
              ENDDO
@@ -1060,12 +1063,12 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  zs !< 
-
-    REAL(wp) ::  f_in(nxl_z:nxr_z,nys_z:nyn_z,1:nz)  !< 
-    REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  zs !<
+
+    REAL(wp) ::  f_in(nxl_z:nxr_z,nys_z:nyn_z,1:nz)  !<
+    REAL(wp) ::  f_inv(nxl_y:nxr_y,nzb_y:nzt_y,0:ny) !<
 
     REAL(wp), DIMENSION(nxl_z:nxr_z,nzt_y-nzb_y+1,nys_z:nyn_z,0:pdims(1)-1) ::  work !<
@@ -1178,15 +1181,15 @@
     IMPLICIT NONE
 
-    INTEGER(iwp) ::  i  !< 
-    INTEGER(iwp) ::  j  !< 
-    INTEGER(iwp) ::  k  !< 
-    INTEGER(iwp) ::  l  !< 
-    INTEGER(iwp) ::  m  !< 
-    INTEGER(iwp) ::  ys !< 
-
-    REAL(wp) ::  f_in(1:nz,nys:nyn,nxl:nxr)              !< 
-    REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz)             !< 
-    REAL(wp) ::  f_out(0:ny,nxl_yd:nxr_yd,nzb_yd:nzt_yd) !< 
-    REAL(wp) ::  work(nnx*nny*nnz)                       !< 
+    INTEGER(iwp) ::  i  !<
+    INTEGER(iwp) ::  j  !<
+    INTEGER(iwp) ::  k  !<
+    INTEGER(iwp) ::  l  !<
+    INTEGER(iwp) ::  m  !<
+    INTEGER(iwp) ::  ys !<
+
+    REAL(wp) ::  f_in(1:nz,nys:nyn,nxl:nxr)              !<
+    REAL(wp) ::  f_inv(nys:nyn,nxl:nxr,1:nz)             !<
+    REAL(wp) ::  f_out(0:ny,nxl_yd:nxr_yd,nzb_yd:nzt_yd) !<
+    REAL(wp) ::  work(nnx*nny*nnz)                       !<
 
 #if defined( __parallel )
