diff --git a/MNH/get_halo.f90 b/MNH/get_halo.f90 index 00d39a5169bd4417681813c9df2d35f7c83ee3d9..a4291225856408de080ee63e078db14b0987f6c7 100644 --- a/MNH/get_halo.f90 +++ b/MNH/get_halo.f90 @@ -123,20 +123,38 @@ CHARACTER(len=4), OPTIONAL :: HDIR ! to send only halo on X or Y direction ! TYPE(LIST_ll) , POINTER :: TZ_PSRC_ll ! halo INTEGER :: IERROR ! error return code -INTEGER:: IIB,IJB ! Begining useful area in x,y,z directions -INTEGER:: IIE,IJE ! End useful area in x,y,z directions +INTEGER, SAVE :: IIB,IJB ! Begining useful area in x,y,z directions +INTEGER, SAVE :: IIE,IJE ! End useful area in x,y,z directions -INTEGER :: IIU,IJU,IKU +INTEGER,SAVE :: IIU,IJU,IKU ! -REAL, ALLOCATABLE, DIMENSION(:,:,:) :: ZNORTH, ZSOUTH, ZWEST, ZEAST +REAL, SAVE , ALLOCATABLE, DIMENSION(:,:,:) :: ZNORTH_IN, ZSOUTH_IN, ZWEST_IN, ZEAST_IN +REAL, SAVE , ALLOCATABLE, DIMENSION(:,:,:) :: ZNORTH_OUT, ZSOUTH_OUT, ZWEST_OUT, ZEAST_OUT ! -NULLIFY( TZ_PSRC_ll) -CALL GET_INDICE_ll(IIB,IJB,IIE,IJE) -! -IIU=size(psrc,1) -IJU=size(psrc,2) -IKU=size(psrc,3) +LOGICAL, SAVE :: GFIRST_GET_HALO_D = .TRUE. ! +NULLIFY( TZ_PSRC_ll) + +IF (GFIRST_GET_HALO_D ) THEN + CALL GET_INDICE_ll(IIB,IJB,IIE,IJE) + ! + IIU=size(psrc,1) + IJU=size(psrc,2) + IKU=size(psrc,3) + ! + ALLOCATE ( ZSOUTH_IN ( IIU , 1 :IJB-1 , IKU ) ) + ALLOCATE ( ZNORTH_IN ( IIU , IJE+1:IJU , IKU ) ) + ALLOCATE ( ZWEST_IN ( 1 :IIB-1 , IJU , IKU ) ) + ALLOCATE ( ZEAST_IN ( IIE+1:IIU , IJU , IKU ) ) + ! + ALLOCATE ( ZSOUTH_OUT ( IIU , 1 :IJB-1 , IKU ) ) + ALLOCATE ( ZNORTH_OUT ( IIU , IJE+1:IJU , IKU ) ) + ALLOCATE ( ZWEST_OUT ( 1 :IIB-1 , IJU , IKU ) ) + ALLOCATE ( ZEAST_OUT ( IIE+1:IIU , IJU , IKU ) ) + + + GFIRST_GET_HALO_D = .FALSE. +END IF !$acc update host (PSRC) ! acc update host (PSRC( : , :IJB , : )) @@ -144,22 +162,18 @@ IKU=size(psrc,3) ! acc update host (PSRC( :IIB , IJB:IJE , : )) ! acc update host (PSRC( IIE: , IJB:IJE , : )) -!!$ALLOCATE ( ZNORTH ( IIU , IJE:IJU , IKU ) ) -!!$ALLOCATE ( ZSOUTH ( IIU , 1:IJB , IKU ) ) -!!$ALLOCATE ( ZWEST ( 1 :IIB , IJU , IKU ) ) -!!$ALLOCATE ( ZEAST ( IIE:IIU , IJU , IKU ) ) !!$ -!!$!$acc kernels copyout (ZNORTH,ZSOUTH,ZWEST,ZEAST) -!!$ZNORTH = PSRC( : , IJE: , : ) -!!$ZSOUTH = PSRC( : , :IJB , : ) -!!$ZWEST = PSRC( :IIB , : , : ) -!!$ZEAST = PSRC( IIE: , : , : ) +!!$!$acc kernels copyout (ZNORTH_IN,ZSOUTH_IN,ZWEST_IN,ZEAST_IN) +!!$ZNORTH_IN = PSRC( : , IJE: , : ) +!!$ZSOUTH_IN = PSRC( : , :IJB , : ) +!!$ZWEST_IN = PSRC( :IIB , : , : ) +!!$ZEAST_IN = PSRC( IIE: , : , : ) !!$!$acc end kernels !!$ -!!$PSRC( : , IJE: , : ) = ZNORTH -!!$PSRC( : , :IJB , : ) = ZSOUTH -!!$PSRC( :IIB , : , : ) = ZWEST -!!$PSRC( IIE: , : , : ) = ZEAST +!!$PSRC( : , IJE: , : ) = ZNORTH_OUT +!!$PSRC( : , :IJB , : ) = ZSOUTH_OUT +!!$PSRC( :IIB , : , : ) = ZWEST_OUT +!!$PSRC( IIE: , : , : ) = ZEAST_OUT CALL ADD3DFIELD_ll(TZ_PSRC_ll,PSRC) CALL UPDATE_HALO_ll(TZ_PSRC_ll,IERROR, HDIR=HDIR ) @@ -171,37 +185,33 @@ CALL CLEANLIST_ll(TZ_PSRC_ll) !!$! acc update device (PSRC( :IIB-1 , : , : )) !!$! acc update device (PSRC( IIE+1: , : , : )) !!$ -ALLOCATE ( ZSOUTH ( IIU , 1 :IJB-1 , IKU ) ) -ALLOCATE ( ZNORTH ( IIU , IJE+1:IJU , IKU ) ) -ALLOCATE ( ZWEST ( 1 :IIB-1 , IJU , IKU ) ) -ALLOCATE ( ZEAST ( IIE+1:IIU , IJU , IKU ) ) -ZSOUTH = PSRC( : , :IJB-1 , : ) -ZNORTH = PSRC( : , IJE+1: , : ) -ZWEST = PSRC( :IIB-1 , : , : ) -ZEAST = PSRC( IIE+1: , : , : ) +ZSOUTH_OUT = PSRC( : , :IJB-1 , : ) +ZNORTH_OUT = PSRC( : , IJE+1: , : ) +ZWEST_OUT = PSRC( :IIB-1 , : , : ) +ZEAST_OUT = PSRC( IIE+1: , : , : ) -!!$!$acc kernels copyin (ZNORTH,ZSOUTH,ZWEST,ZEAST) -!!$PSRC( : , :IJB-1 , : ) = ZSOUTH -!!$PSRC( : , IJE+1: , : ) = ZNORTH -!!$PSRC( :IIB-1 , : , : ) = ZWEST -!!$PSRC( IIE+1: , : , : ) = ZEAST +!!$!$acc kernels copyin (ZNORTH_OUT,ZSOUTH_OUT,ZWEST_OUT,ZEAST_OUT) +!!$PSRC( : , :IJB-1 , : ) = ZSOUTH_OUT +!!$PSRC( : , IJE+1: , : ) = ZNORTH_OUT +!!$PSRC( :IIB-1 , : , : ) = ZWEST_OUT +!!$PSRC( IIE+1: , : , : ) = ZEAST_OUT !!$!$acc end kernels -!$acc kernels copyin (ZSOUTH) async(1) -PSRC( : , :IJB-1 , : ) = ZSOUTH +!$acc kernels copyin (ZSOUTH_OUT) async(1) +PSRC( : , :IJB-1 , : ) = ZSOUTH_OUT !$acc end kernels -!$acc kernels copyin (ZNORTH) async(2) -PSRC( : , IJE+1: , : ) = ZNORTH +!$acc kernels copyin (ZNORTH_OUT) async(2) +PSRC( : , IJE+1: , : ) = ZNORTH_OUT !$acc end kernels -!$acc kernels copyin (ZWEST) async(3) -PSRC( :IIB-1 , : , : ) = ZWEST +!$acc kernels copyin (ZWEST_OUT) async(3) +PSRC( :IIB-1 , : , : ) = ZWEST_OUT !$acc end kernels -!$acc kernels copyin (ZEAST) async(4) -PSRC( IIE+1: , : , : ) = ZEAST +!$acc kernels copyin (ZEAST_OUT) async(4) +PSRC( IIE+1: , : , : ) = ZEAST_OUT !$acc end kernels !$acc wait