From 03dd7400691f5ab94e47dc6fc4cbb26382ffd1e0 Mon Sep 17 00:00:00 2001
From: Juan Escobar <escj@aero.obs-mip.fr>
Date: Tue, 7 Jul 2020 12:36:27 +0200
Subject: [PATCH] Juan 07/07/2020: more PGI BUG correction -> use MNH_ALLOCATE

---
 src/MNH/turb.f90 | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/MNH/turb.f90 b/src/MNH/turb.f90
index 4e9ca2df0..dbe932a9a 100644
--- a/src/MNH/turb.f90
+++ b/src/MNH/turb.f90
@@ -1687,6 +1687,7 @@ REAL, DIMENSION(:,:,:), INTENT(OUT)   :: PAMOIST,PATHETA
 REAL                :: ZEPS         ! XMV / XMD
 real, dimension(:,:,:), pointer , contiguous :: zrvsat
 real, dimension(:,:,:), pointer , contiguous :: zdrvsatdt
+INTEGER :: izrvsat, izdrvsatdt
 !
 !-------------------------------------------------------------------------------
 
@@ -1699,10 +1700,15 @@ real, dimension(:,:,:), pointer , contiguous :: zdrvsatdt
     call Mppdb_check( pcp,  "Compute_function_thermo beg:pcp"  )
   end if
 
+#ifndef MNH_OPENACC  
   allocate( zrvsat   ( size( pexn, 1 ), size( pexn, 2 ), size( pexn, 3 ) ) )
   allocate( zdrvsatdt( size( pexn, 1 ), size( pexn, 2 ), size( pexn, 3 ) ) )
+#else
+izrvsat    = MNH_ALLOCATE_ZT3D( zrvsat   , size( pexn, 1 ), size( pexn, 2 ), size( pexn, 3 ) ) 
+izdrvsatdt = MNH_ALLOCATE_ZT3D( zdrvsatdt, size( pexn, 1 ), size( pexn, 2 ), size( pexn, 3 ) )
+#endif
 
-!$acc data create( zrvsat, zdrvsatdt )
+!$acc data present( zrvsat, zdrvsatdt )
 
   ZEPS = XMV / XMD
 !
@@ -1758,7 +1764,7 @@ real, dimension(:,:,:), pointer , contiguous :: zdrvsatdt
   PLOCPEXN(:,:,:) = PLOCPEXN(:,:,:) / PEXN(:,:,:)
 !$acc end kernels
 
-  deallocate( zrvsat, zdrvsatdt )
+
 
   if ( mppdb_initialized ) then
     !Check all out arrays
@@ -1769,6 +1775,12 @@ real, dimension(:,:,:), pointer , contiguous :: zdrvsatdt
 
 !$acc end data
 
+#ifndef MNH_OPENACC 
+  deallocate( zrvsat, zdrvsatdt )
+#else
+  CALL MNH_REL_ZT3D(izrvsat, izdrvsatdt )
+#endif
+ 
 !$acc end data
 
 END SUBROUTINE COMPUTE_FUNCTION_THERMO
-- 
GitLab