From 61f1b3357ea297287044e71ada01a8b94cc67f64 Mon Sep 17 00:00:00 2001
From: Philippe WAUTELET <philippe.wautelet@aero.obs-mip.fr>
Date: Mon, 15 Jan 2024 13:32:29 +0100
Subject: [PATCH] Philippe 15/01/2024: FFT: simplify some array bounds (some
 missing data problems with OpenACC disappear maybe because less array copies)

---
 src/MNH/compute_spectre.f90 |  8 ++++----
 src/MNH/flat_inv.f90        | 16 ++++++++--------
 src/MNH/flat_invz.f90       | 16 ++++++++--------
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/MNH/compute_spectre.f90 b/src/MNH/compute_spectre.f90
index f40f291a5..f43ffc7b4 100644
--- a/src/MNH/compute_spectre.f90
+++ b/src/MNH/compute_spectre.f90
@@ -259,7 +259,7 @@ CALL REMAP_2WAY_X_ll(ZY,ZBAND_X,IINFO_ll)
 !             ---------------------------
 !
 !
-CALL FFT55( ZBAND_X(1:,1:,IKB-1:), ZWORKX, ZTRIGSX, IIFAXX, -1 )
+CALL FFT55( ZBAND_X(:,:,:), ZWORKX, ZTRIGSX, IIFAXX, -1 )
 !
 !
 ZBAND_Y=0.
@@ -271,7 +271,7 @@ IF (.NOT. L2D) THEN
 !
 CALL FAST_TRANSPOSE(ZBAND_Y,ZBAND_YT,IIY,IJY,IKU)
 !
-CALL FFT55( ZBAND_YT(1:,1:,IKB-1:), ZWORKY, ZTRIGSY, IIFAXY, -1 )
+CALL FFT55( ZBAND_YT(:,:,:), ZWORKY, ZTRIGSY, IIFAXY, -1 )
 !
 END IF    
 !
@@ -390,7 +390,7 @@ IF(LSTAT) THEN
   !*	7.1 Second statistics
   !APPLY A COMPLEX TO REAL FFT
   IF (.NOT. L2D) THEN
-    CALL FFT55( ZBAND_YT(1:,1:,IKB-1:), ZWORKY, ZTRIGSY, IIFAXY, +1 )
+    CALL FFT55( ZBAND_YT(:,:,:), ZWORKY, ZTRIGSY, IIFAXY, +1 )
     ! array transposition J --> I
     CALL FAST_TRANSPOSE(ZBAND_YT,ZBAND_Y,IJY,IIY,IKU)
   ENDIF
@@ -401,7 +401,7 @@ IF(LSTAT) THEN
   CALL REMAP_Y_X_ll(ZBAND_Y,ZBAND_X,IINFO_ll)
   !
   !
-  CALL FFT55( ZBAND_X(1:,1:,IKB-1:), ZWORKX, ZTRIGSX, IIFAXX, +1 )
+  CALL FFT55( ZBAND_X(:,:,:), ZWORKX, ZTRIGSX, IIFAXX, +1 )
   !
   !RETURN TO A NON HOMOGENEOUS NEUMAN CONDITION FOR NON-CYCLIC CASES
   ! Transposition + shift X -> 2way
diff --git a/src/MNH/flat_inv.f90 b/src/MNH/flat_inv.f90
index 93b36d357..b0af64202 100644
--- a/src/MNH/flat_inv.f90
+++ b/src/MNH/flat_inv.f90
@@ -416,10 +416,10 @@ CALL REMAP_2WAY_X_ll(ZY,ZBAND_X,IINFO_ll)
 !
 !
 IF (HLBCX(1) == 'CYCL') THEN
-    ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X(:,:,IKB-1:),3) ) => ZBAND_X(:,:,IKB-1:)
+    ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X,3) ) => ZBAND_X(:,:,:)
     CALL FFT991( ZBAND1D, ZWORKX, PTRIGSX, KIFAXX, INC2X, IIMAX, ILOTX, -1 )
 ELSE
-    CALL FFT55( ZBAND_X(1:,1:,IKB-1:), ZWORKX, PTRIGSX, KIFAXX, -1 )
+    CALL FFT55( ZBAND_X(:,:,:), ZWORKX, PTRIGSX, KIFAXX, -1 )
 END IF
 !
 !
@@ -435,10 +435,10 @@ IF (.NOT. L2D) THEN
   CALL FAST_TRANSPOSE(ZBAND_Y,ZBAND_YT,IIY,IJY,IKU)
 !
   IF (HLBCY(1) == 'CYCL') THEN
-       ZBAND1D( 1 : SIZE(ZBAND_YT,1)*SIZE(ZBAND_YT,2)*SIZE(ZBAND_YT(:,:,IKB-1:),3) ) => ZBAND_YT(:,:,IKB-1:)
+       ZBAND1D( 1 : SIZE(ZBAND_YT,1)*SIZE(ZBAND_YT,2)*SIZE(ZBAND_YT,3) ) => ZBAND_YT(:,:,:)
        CALL FFT991( ZBAND1D, ZWORKY, PTRIGSY, KIFAXY, INC2Y, IJMAX, ILOTY, -1 )
   ELSE
-       CALL FFT55( ZBAND_YT(1:,1:,IKB-1:), ZWORKY, PTRIGSY, KIFAXY, -1 )
+       CALL FFT55( ZBAND_YT(:,:,:), ZWORKY, PTRIGSY, KIFAXY, -1 )
   END IF
 !
 END IF                                        
@@ -488,10 +488,10 @@ END IF
 !  
 IF (.NOT. L2D) THEN
   IF (HLBCY(1) == 'CYCL') THEN
-    ZBAND1D( 1 : SIZE(ZBAND_YRT,1)*SIZE(ZBAND_YRT,2)*SIZE(ZBAND_YRT(:,:,IKB-1:),3) ) => ZBAND_YRT(:,:,IKB-1:)
+    ZBAND1D( 1 : SIZE(ZBAND_YRT,1)*SIZE(ZBAND_YRT,2)*SIZE(ZBAND_YRT,3) ) => ZBAND_YRT(:,:,:)
     CALL FFT991( ZBAND1D, ZWORKY, PTRIGSY, KIFAXY, INC2Y, IJMAX, ILOTY, +1 )
   ELSE
-    CALL FFT55( ZBAND_YRT(1:,1:,IKB-1:), ZWORKY, PTRIGSY, KIFAXY, +1 )
+    CALL FFT55( ZBAND_YRT(:,:,:), ZWORKY, PTRIGSY, KIFAXY, +1 )
   END IF
   ! array transposition J --> I
   CALL FAST_TRANSPOSE(ZBAND_YRT,ZBAND_YR,IJY,IIY,IKU)
@@ -506,10 +506,10 @@ CALL REMAP_Y_X_ll(ZBAND_YR,ZBAND_X,IINFO_ll)
 !
 !
 IF (HLBCX(1) == 'CYCL') THEN
-  ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X(:,:,IKB-1:),3) ) => ZBAND_X(:,:,IKB-1:)
+  ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X,3) ) => ZBAND_X(:,:,:)
   CALL FFT991( ZBAND1D, ZWORKX, PTRIGSX, KIFAXX, INC2X, IIMAX, ILOTX, +1 )
 ELSE
-  CALL FFT55( ZBAND_X(1:,1:,IKB-1:), ZWORKX, PTRIGSX, KIFAXX, +1 )
+  CALL FFT55( ZBAND_X(:,:,:), ZWORKX, PTRIGSX, KIFAXX, +1 )
 END IF
 !
 !-------------------------------------------------------------------------------
diff --git a/src/MNH/flat_invz.f90 b/src/MNH/flat_invz.f90
index 1790b4c23..7eee5ed13 100644
--- a/src/MNH/flat_invz.f90
+++ b/src/MNH/flat_invz.f90
@@ -670,10 +670,10 @@ CALL PRINT_MSG( NVERB_WARNING, 'GEN', 'FLAT_INVZ', 'OpenACC: IAND(NZ_SPLITTING,1
   !
   IF (  IAND(NZ_SPLITTING,1) > 0 ) THEN 
      IF (HLBCX(1) == 'CYCL') THEN
-      ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X(:,:,IKB-1:),3) ) => ZBAND_X(:,:,IKB-1:)
+      ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X,3) ) => ZBAND_X(:,:,:)
       CALL FFT991( ZBAND1D, ZWORKX(:,:,:), PTRIGSX, KIFAXX, INC2X, IIMAX, ILOTX, -1 )
      ELSE
-        CALL FFT55( ZBAND_X(1:,1:,IKB-1:), ZWORKX, PTRIGSX, KIFAXX, -1 )
+        CALL FFT55( ZBAND_X(:,:,:), ZWORKX, PTRIGSX, KIFAXX, -1 )
      END IF
      !
 !$acc kernels
@@ -720,10 +720,10 @@ CALL PRINT_MSG( NVERB_FATAL, 'GEN', 'FLAT_INVZ', 'OpenACC: HLBCX(1)==CYCL not po
         CALL FAST_TRANSPOSE(ZBAND_Y,ZBAND_YT,IIY,IJY,IKU)
         !
         IF (HLBCY(1) == 'CYCL') THEN
-          ZBAND1D( 1 : SIZE(ZBAND_YT,1)*SIZE(ZBAND_YT,2)*SIZE(ZBAND_YT(:,:,IKB-1:),3) ) => ZBAND_YT(:,:,IKB-1:)
+          ZBAND1D( 1 : SIZE(ZBAND_YT,1)*SIZE(ZBAND_YT,2)*SIZE(ZBAND_YT,3) ) => ZBAND_YT(:,:,:)
           CALL FFT991( ZBAND1D, ZWORKY(:,:,:), PTRIGSY, KIFAXY, INC2Y, IJMAX, ILOTY, -1 )
         ELSE
-           CALL FFT55( ZBAND_YT(1:,1:,IKB-1:), ZWORKY, PTRIGSY, KIFAXY, -1 )
+           CALL FFT55( ZBAND_YT(:,:,:), ZWORKY, PTRIGSY, KIFAXY, -1 )
         END IF
         !
      END IF
@@ -874,10 +874,10 @@ CALL PRINT_MSG( NVERB_WARNING, 'GEN', 'FLAT_INVZ', 'L2D=T not tested' )
      !  
      IF (.NOT. L2D) THEN
         IF (HLBCY(1) == 'CYCL') THEN
-          ZBAND1D( 1 : SIZE(ZBAND_YRT,1)*SIZE(ZBAND_YRT,2)*SIZE(ZBAND_YRT(:,:,IKB-1:),3) ) => ZBAND_YRT(:,:,IKB-1:)
+          ZBAND1D( 1 : SIZE(ZBAND_YRT,1)*SIZE(ZBAND_YRT,2)*SIZE(ZBAND_YRT,3) ) => ZBAND_YRT(:,:,:)
           CALL FFT991( ZBAND1D, ZWORKY(:,:,:), PTRIGSY, KIFAXY, INC2Y, IJMAX, ILOTY, +1 )
         ELSE
-           CALL FFT55( ZBAND_YRT(1:,1:,IKB-1:), ZWORKY, PTRIGSY, KIFAXY, +1 )
+           CALL FFT55( ZBAND_YRT(:,:,:), ZWORKY, PTRIGSY, KIFAXY, +1 )
         END IF
         ! array transposition J --> I
         CALL FAST_TRANSPOSE(ZBAND_YRT,ZBAND_YR,IJY,IIY,IKU)
@@ -892,10 +892,10 @@ CALL PRINT_MSG( NVERB_WARNING, 'GEN', 'FLAT_INVZ', 'L2D=T not tested' )
      CALL REMAP_Y_X_ll(ZBAND_YR,ZBAND_X,IINFO_ll)
      !
      IF (HLBCX(1) == 'CYCL') THEN
-        ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X(:,:,IKB-1:),3) ) => ZBAND_X(:,:,IKB-1:)
+        ZBAND1D( 1 : SIZE(ZBAND_X,1)*SIZE(ZBAND_X,2)*SIZE(ZBAND_X,3) ) => ZBAND_X(:,:,:)
         CALL FFT991( ZBAND1D, ZWORKX(:,:,:), PTRIGSX, KIFAXX, INC2X, IIMAX, ILOTX, +1 )
      ELSE
-        CALL FFT55( ZBAND_X(1:,1:,IKB-1:), ZWORKX, PTRIGSX, KIFAXX, +1 )
+        CALL FFT55( ZBAND_X(:,:,:), ZWORKX, PTRIGSX, KIFAXX, +1 )
      END IF
   END IF ! NZ_SPLITTING
 
-- 
GitLab