From 527efb7edd76893da64b569021deaa24d7c13155 Mon Sep 17 00:00:00 2001
From: Juan ESCOBAR <juan.escobar@aero.obs-mip.fr>
Date: Wed, 22 Nov 2023 14:45:18 +0100
Subject: [PATCH] Juan 22/11/2023:turb.f90, GPU opt -> MNH_MEM_GET( zcoef_ampl
 + zlm_cloud )

---
 src/MNH/turb.f90 | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/MNH/turb.f90 b/src/MNH/turb.f90
index 428ddf668..a7658c488 100644
--- a/src/MNH/turb.f90
+++ b/src/MNH/turb.f90
@@ -2024,8 +2024,16 @@ real, dimension(:,:,:), pointer , contiguous :: zlm_cloud
 call Print_msg( NVERB_FATAL, 'GEN', 'TURB', 'OpenACC: CLOUD_MODIF_LM not yet implemented' )
 #endif
 
+#ifndef MNH_OPENACC
 allocate( zcoef_ampl(size( put, 1 ), size( put, 2 ), size( put, 3) ) )
 allocate( zlm_cloud (size( put, 1 ), size( put, 2 ), size( put, 3) ) )
+#else
+!Pin positions in the pools of MNH memory
+CALL MNH_MEM_POSITION_PIN()
+
+CALL MNH_MEM_GET( zcoef_ampl, size( put, 1 ), size( put, 2 ), size( put, 3) )
+CALL MNH_MEM_GET( zlm_cloud , size( put, 1 ), size( put, 2 ), size( put, 3) )
+#endif
 !
 !*       1.    INITIALISATION
 !              --------------
@@ -2139,7 +2147,12 @@ IF ( OTURB_DIAG .AND. tpfile%lopened ) THEN
   !
 ENDIF
 
+#ifndef MNH_OPENACC
 deallocate( zcoef_ampl, zlm_cloud )
+#else
+!Release all memory allocated with MNH_MEM_GET calls since last call to MNH_MEM_POSITION_PIN
+CALL MNH_MEM_RELEASE()
+#endif
 
 END SUBROUTINE CLOUD_MODIF_LM
 !
-- 
GitLab