diff --git a/src/MNH/advec_ppm_algo.f90 b/src/MNH/advec_ppm_algo.f90 index 1717dd884490b6adb211701f4d8433daa241f833..7b1388e7e4affa4c8b1adb9725020282e9fc1d1e 100644 --- a/src/MNH/advec_ppm_algo.f90 +++ b/src/MNH/advec_ppm_algo.f90 @@ -210,10 +210,6 @@ END IF !* 0. INITIAL STEP ! ------------ ! -#ifdef _OPENACC -CALL INIT_ON_HOST_AND_DEVICE(ZPPM,PVALUE=-1e99,HNAME='ADVEC_PPM_ALGO::ZPPM') -#endif -! !$acc kernels present(PSRC,PFIELDT) PSRC = PFIELDT !$acc end kernels @@ -312,7 +308,10 @@ PRINT *,'OPENACC: advec_ppm_algo::PPM_00 not yet tested' ! CASE('PPM_01') ! - IF (GFLAG ) THEN +#ifdef _OPENACC + CALL INIT_ON_HOST_AND_DEVICE(ZPPM,PVALUE=-1e99,HNAME='ADVEC_PPM_ALGO::ZPPM') +#endif + IF (GFLAG ) THEN ! !* 1. ADVECTION IN X DIRECTION ! ------------------------ diff --git a/src/MNH/advection_metsv.f90 b/src/MNH/advection_metsv.f90 index 32eecccc25d8ce35b29bda7e1cb951599dc4d766..08087ac3197bceb54ac3fbd02d688d0ced79377b 100644 --- a/src/MNH/advection_metsv.f90 +++ b/src/MNH/advection_metsv.f90 @@ -43,29 +43,20 @@ TYPE (DATE_TIME), INTENT(IN) :: TPDTCUR ! current date and time REAL, INTENT(IN) :: PTSTEP ! REAL, DIMENSION(:,:,:), INTENT(IN) :: PUT , PVT , PWT -!$acc declare copyin(PUT,PVT,PWT) REAL, DIMENSION(:,:,:), INTENT(IN) :: PTHT, PTKET, PRHODJ -!$acc declare copyin(PTHT,PTKET) -!$acc declare present(PRHODJ) REAL, DIMENSION(:,:,:), INTENT(IN) :: PPABST REAL, DIMENSION(:,:,:,:), INTENT(IN) :: PRT , PSVT -!$acc declare copyin(PRT,PSVT) ! Variables at t REAL, DIMENSION(:,:,:), INTENT(IN) :: PTHVREF ! Virtual Temperature ! of the reference state -!$acc declare create(PTHVREF) REAL, DIMENSION(:,:,:), INTENT(IN) :: PDXX,PDYY,PDZZ,PDZX,PDZY -!$acc declare present(PDXX,PDYY,PDZZ,PDZX,PDZY) ! metric coefficients REAL, DIMENSION(:,:,:), INTENT(INOUT) :: PRTHS, PRTKES -!$acc declare create(PRTHS,PRTKES) REAL, DIMENSION(:,:,:,:), INTENT(INOUT) :: PRRS , PRSVS -!$acc declare create(PRRS,PRSVS) ! Sources terms REAL, DIMENSION(:,:,:), INTENT(IN) :: PRTHS_CLD REAL, DIMENSION(:,:,:,:), INTENT(IN) :: PRRS_CLD,PRSVS_CLD REAL, DIMENSION(:,:,:), INTENT(OUT) :: PRTKES_ADV ! Advection TKE source term -!$acc declare create(PRTKES_ADV) ! END SUBROUTINE ADVECTION_METSV ! @@ -169,6 +160,7 @@ USE MODD_BLOWSNOW USE MODD_BLOWSNOW_n USE MODD_PARAMETERS ! +use mode_argslist_ll, only: ADD3DFIELD_ll, ADD4DFIELD_ll, CLEANLIST_ll USE MODE_FIELD, ONLY: TFIELDDATA, TYPEREAL USE MODE_IO_FIELD_WRITE, only: IO_Field_write USE MODE_ll @@ -224,7 +216,8 @@ REAL, DIMENSION(:,:,:), INTENT(IN) :: PUT , PVT , PWT REAL, DIMENSION(:,:,:), INTENT(IN) :: PTHT, PTKET, PRHODJ !$acc declare copyin(PTHT,PTKET) !$acc declare present(PRHODJ) -REAL, DIMENSION(:,:,:), INTENT(IN) :: PPABST +REAL, DIMENSION(:,:,:), INTENT(IN) :: PPABST +!$acc declare copyin(PPABST) REAL, DIMENSION(:,:,:,:), INTENT(IN) :: PRT , PSVT !$acc declare copyin(PRT,PSVT) ! Variables at t @@ -242,63 +235,67 @@ REAL, DIMENSION(:,:,:,:), INTENT(INOUT) :: PRRS , PRSVS REAL, DIMENSION(:,:,:), INTENT(IN) :: PRTHS_CLD REAL, DIMENSION(:,:,:,:), INTENT(IN) :: PRRS_CLD, PRSVS_CLD !PW: not interesting to declare PR*_CLD on device (except if async transfers?) -REAL, DIMENSION(:,:,:), INTENT(OUT) :: PRTKES_ADV ! Advection TKE source term +!$acc declare copyin(PRTHS_CLD,PRRS_CLD,PRSVS_CLD) +REAL, DIMENSION(:,:,:), INTENT(OUT) :: PRTKES_ADV ! Advection TKE source term !$acc declare create(PRTKES_ADV) ! ! !* 0.2 declarations of local variables ! ! -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRUCPPM -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRVCPPM -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRWCPPM +REAL, DIMENSION(:,:,:),allocatable :: ZRUCPPM +REAL, DIMENSION(:,:,:),allocatable :: ZRVCPPM +REAL, DIMENSION(:,:,:),allocatable :: ZRWCPPM !$acc declare create(ZRUCPPM,ZRVCPPM,ZRWCPPM) ! contravariant ! components ! of momentum -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZCFLU -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZCFLV -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZCFLW +REAL, DIMENSION(:,:,:),allocatable :: ZCFLU +REAL, DIMENSION(:,:,:),allocatable :: ZCFLV +REAL, DIMENSION(:,:,:),allocatable :: ZCFLW !$acc declare create(ZCFLU,ZCFLV,ZCFLW) ! ! CFL numbers on each direction -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZCFL +REAL, DIMENSION(:,:,:),allocatable :: ZCFL !$acc declare create(ZCFL) ! ! CFL number ! REAL :: ZCFLU_MAX, ZCFLV_MAX, ZCFLW_MAX, ZCFL_MAX ! maximum CFL numbers ! -REAL, DIMENSION(SIZE(PTHT,1), SIZE(PTHT,2), SIZE(PTHT,3) ) :: ZTH -REAL, DIMENSION(SIZE(PTKET,1),SIZE(PTKET,2),SIZE(PTKET,3)) :: ZTKE +REAL, DIMENSION(:,:,:),allocatable :: ZTH +REAL, DIMENSION(:,:,:),allocatable :: ZTKE !$acc declare create(ZTH,ZTKE) -REAL, DIMENSION(SIZE(PTHT,1), SIZE(PTHT,2), SIZE(PTHT,3) ) :: ZRTHS_OTHER -REAL, DIMENSION(SIZE(PTKET,1),SIZE(PTKET,2),SIZE(PTKET,3)) :: ZRTKES_OTHER +REAL, DIMENSION(:,:,:),allocatable :: ZRTHS_OTHER +REAL, DIMENSION(:,:,:),allocatable :: ZRTKES_OTHER !$acc declare create(ZRTHS_OTHER,ZRTKES_OTHER) -REAL, DIMENSION(SIZE(PTHT,1), SIZE(PTHT,2), SIZE(PTHT,3) ) :: ZRTHS_PPM +REAL, DIMENSION(:,:,:),allocatable :: ZRTHS_PPM !$acc declare create(ZRTHS_PPM) -REAL, DIMENSION(SIZE(PTKET,1),SIZE(PTKET,2),SIZE(PTKET,3)) :: ZRTKES_PPM +REAL, DIMENSION(:,:,:),allocatable :: ZRTKES_PPM !$acc declare create(ZRTKES_PPM) -REAL, DIMENSION(SIZE(PRT,1), SIZE(PRT,2), SIZE(PRT,3), SIZE(PRT,4) ) :: ZR -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3),SIZE(PSVT,4)) :: ZSV +REAL, DIMENSION(:,:,:,:),allocatable :: ZR +REAL, DIMENSION(:,:,:,:),allocatable :: ZSV !$acc declare create(ZR,ZSV) -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3), NBLOWSNOW_2D) :: ZSNWC -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3), NBLOWSNOW_2D) :: ZSNWC_INIT -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3), NBLOWSNOW_2D) :: ZRSNWCS +REAL, DIMENSION(:,:,:,:),allocatable :: ZSNWC +REAL, DIMENSION(:,:,:,:),allocatable :: ZSNWC_INIT +REAL, DIMENSION(:,:,:,:),allocatable :: ZRSNWCS +!$acc declare create(ZSNWC,ZSNWC_INIT,ZRSNWCS) ! Guess at the sub time step -REAL, DIMENSION(SIZE(PRT,1), SIZE(PRT,2), SIZE(PRT,3), SIZE(PRT,4) ) :: ZRRS_OTHER -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3),SIZE(PSVT,4)) :: ZRSVS_OTHER -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3),NBLOWSNOW_2D) :: ZRSNWCS_OTHER -!$acc declare create(ZRRS_OTHER,ZRSVS_OTHER) +REAL, DIMENSION(:,:,:,:),allocatable :: ZRRS_OTHER +REAL, DIMENSION(:,:,:,:),allocatable :: ZRSVS_OTHER +REAL, DIMENSION(:,:,:,:),allocatable :: ZRSNWCS_OTHER +!$acc declare create(ZRRS_OTHER,ZRSVS_OTHER,ZRSNWCS_OTHER) ! Tendencies since the beginning of the time step -REAL, DIMENSION(SIZE(PRT,1), SIZE(PRT,2), SIZE(PRT,3), SIZE(PRT,4) ) :: ZRRS_PPM -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3),SIZE(PSVT,4)) :: ZRSVS_PPM -REAL, DIMENSION(SIZE(PSVT,1),SIZE(PSVT,2),SIZE(PSVT,3),NBLOWSNOW_2D) :: ZRSNWCS_PPM -!$acc declare create(ZRRS_PPM,ZRSVS_PPM) +REAL, DIMENSION(:,:,:,:),allocatable :: ZRRS_PPM +REAL, DIMENSION(:,:,:,:),allocatable :: ZRSVS_PPM +REAL, DIMENSION(:,:,:,:),allocatable :: ZRSNWCS_PPM +!$acc declare create(ZRRS_PPM,ZRSVS_PPM,ZRSNWCS_PPM) ! Guess at the end of the sub time step -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRHOX1,ZRHOX2 -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRHOY1,ZRHOY2 -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRHOZ1,ZRHOZ2 -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZT,ZEXN,ZLV,ZLS,ZCPH +REAL, DIMENSION(:,:,:),allocatable :: ZRHOX1,ZRHOX2 +REAL, DIMENSION(:,:,:),allocatable :: ZRHOY1,ZRHOY2 +REAL, DIMENSION(:,:,:),allocatable :: ZRHOZ1,ZRHOZ2 +REAL, DIMENSION(:,:,:),allocatable :: ZT,ZEXN,ZLV,ZLS,ZCPH !$acc declare create(ZRHOX1,ZRHOX2,ZRHOY1,ZRHOY2,ZRHOZ1,ZRHOZ2) +!$acc declare create(ZT,ZEXN,ZLV,ZLS,ZCPH) + ! Temporary advected rhodj for PPM routines ! INTEGER :: JS,JR,JSV,JSPL, JI, JJ ! Loop index @@ -345,6 +342,42 @@ IF (MPPDB_INITIALIZED) THEN CALL MPPDB_CHECK(PRRS,"ADVECTION_METSV beg:PRRS") CALL MPPDB_CHECK(PRSVS,"ADVECTION_METSV beg:PRSVS") END IF + +allocate( ZRUCPPM ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRVCPPM ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRWCPPM ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZCFLU ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZCFLV ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZCFLW ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZCFL ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZTH ( SIZE(PTHT, 1), SIZE(PTHT, 2), SIZE(PTHT, 3) ) ) +allocate( ZTKE ( SIZE(PTKET,1), SIZE(PTKET,2), SIZE(PTKET,3) ) ) +allocate( ZRTHS_OTHER ( SIZE(PTHT, 1), SIZE(PTHT, 2), SIZE(PTHT, 3) ) ) +allocate( ZRTKES_OTHER ( SIZE(PTKET,1), SIZE(PTKET,2), SIZE(PTKET,3) ) ) +allocate( ZRTHS_PPM ( SIZE(PTHT, 1), SIZE(PTHT, 2), SIZE(PTHT, 3) ) ) +allocate( ZRTKES_PPM ( SIZE(PTKET,1), SIZE(PTKET,2), SIZE(PTKET,3) ) ) +allocate( ZR ( SIZE(PRT, 1), SIZE(PRT, 2), SIZE(PRT, 3), SIZE(PRT, 4) ) ) +allocate( ZSV ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), SIZE(PSVT,4) ) ) +allocate( ZSNWC ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), NBLOWSNOW_2D ) ) +allocate( ZSNWC_INIT ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), NBLOWSNOW_2D ) ) +allocate( ZRSNWCS ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), NBLOWSNOW_2D ) ) +allocate( ZRRS_OTHER ( SIZE(PRT, 1), SIZE(PRT, 2), SIZE(PRT, 3), SIZE(PRT, 4) ) ) +allocate( ZRSVS_OTHER ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), SIZE(PSVT,4) ) ) +allocate( ZRSNWCS_OTHER( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), NBLOWSNOW_2D ) ) +allocate( ZRRS_PPM ( SIZE(PRT, 1), SIZE(PRT, 2), SIZE(PRT, 3), SIZE(PRT, 4) ) ) +allocate( ZRSVS_PPM ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), SIZE(PSVT,4) ) ) +allocate( ZRSNWCS_PPM ( SIZE(PSVT, 1), SIZE(PSVT, 2), SIZE(PSVT, 3), NBLOWSNOW_2D ) ) +allocate( ZRHOX1 ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRHOX2 ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRHOY1 ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRHOY2 ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRHOZ1 ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZRHOZ2 ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZT ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZEXN ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZLV ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZLS ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) +allocate( ZCPH ( SIZE(PUT, 1), SIZE(PUT, 2), SIZE(PUT, 3) ) ) ! !* 0. INITIALIZATION ! -------------- @@ -359,22 +392,14 @@ IKE=SIZE(PSVT,3) - JPVEXT GTKE=(SIZE(PTKET)/=0) ! #ifdef _OPENACC -!IN argument CALL INIT_ON_HOST_AND_DEVICE(PTHVREF, PVALUE=-1e99,HNAME='ADVECTION_METSV::PTHVREF') -!IN argument CALL INIT_ON_HOST_AND_DEVICE(PRTHS, PVALUE=-1e99,HNAME='ADVECTION_METSV::PRTHS') -!IN argument CALL INIT_ON_HOST_AND_DEVICE(PRTKES, PVALUE=-1e99,HNAME='ADVECTION_METSV::PRTKES') -!IN argument CALL INIT_ON_HOST_AND_DEVICE(PRRS, PVALUE=-1e99,HNAME='ADVECTION_METSV::PRRS') -!IN argument CALL INIT_ON_HOST_AND_DEVICE(PRSVS, PVALUE=-1e99,HNAME='ADVECTION_METSV::PRSVS') CALL INIT_ON_HOST_AND_DEVICE(PRTKES_ADV,PVALUE=-1e99,HNAME='ADVECTION_METSV::PRTKES_ADV') - CALL INIT_ON_HOST_AND_DEVICE(ZRUCPPM,PVALUE=-1e90,HNAME='ADVECTION_METSV::ZRUCPPM') CALL INIT_ON_HOST_AND_DEVICE(ZRVCPPM,PVALUE=-1e91,HNAME='ADVECTION_METSV::ZRVCPPM') CALL INIT_ON_HOST_AND_DEVICE(ZRWCPPM,PVALUE=-1e92,HNAME='ADVECTION_METSV::ZRWCPPM') - CALL INIT_ON_HOST_AND_DEVICE(ZCFLU,PVALUE=-1e99,HNAME='ADVECTION_METSV::ZCFLU') CALL INIT_ON_HOST_AND_DEVICE(ZCFLV,PVALUE=-1e99,HNAME='ADVECTION_METSV::ZCFLV') CALL INIT_ON_HOST_AND_DEVICE(ZCFLW,PVALUE=-1e99,HNAME='ADVECTION_METSV::ZCFLW') CALL INIT_ON_HOST_AND_DEVICE(ZCFL, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZCFL') - CALL INIT_ON_HOST_AND_DEVICE(ZTH, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZTH') CALL INIT_ON_HOST_AND_DEVICE(ZTKE, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZTKE') CALL INIT_ON_HOST_AND_DEVICE(ZRTHS_OTHER, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZRTHS_OTHER') @@ -387,7 +412,6 @@ CALL INIT_ON_HOST_AND_DEVICE(ZRRS_OTHER, PVALUE=-1e99,HNAME='ADVECTION_METSV::Z CALL INIT_ON_HOST_AND_DEVICE(ZRSVS_OTHER, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZRSVS_OTHER') CALL INIT_ON_HOST_AND_DEVICE(ZRRS_PPM, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZRRS_PPM') CALL INIT_ON_HOST_AND_DEVICE(ZRSVS_PPM, PVALUE=-1e99,HNAME='ADVECTION_METSV::ZRSVS_PPM') - CALL INIT_ON_HOST_AND_DEVICE(ZRHOX1,PVALUE=-1e93,HNAME='ADVECTION_METSV::ZRHOX1') CALL INIT_ON_HOST_AND_DEVICE(ZRHOX2,PVALUE=-1e94,HNAME='ADVECTION_METSV::ZRHOX2') CALL INIT_ON_HOST_AND_DEVICE(ZRHOY1,PVALUE=-1e95,HNAME='ADVECTION_METSV::ZRHOY1') @@ -440,7 +464,7 @@ END IF !* 2.2 computes CFL numbers ! !PW: not necessary: data already on device due to contrav_device !$acc update device(ZRUCPPM,ZRVCPPM,ZRWCPPM) -!$acc kernels present(ZCFLU,ZCFLV,ZCFLW,ZCFL) present(ZRUCPPM,ZRVCPPM,ZRWCPPM) +!$acc kernels IF (.NOT. L1D) THEN ZCFLU = 0.0 ; ZCFLV = 0.0 ; ZCFLW = 0.0 ZCFLU(IIB:IIE,IJB:IJE,:) = ABS(ZRUCPPM(IIB:IIE,IJB:IJE,:) * PTSTEP) @@ -538,7 +562,7 @@ CALL GET_INDICE_ll( IIB,IJB,IIE,IJE) IKB=1+JPVEXT IKE=SIZE(ZCFLU,3)-JPVEXT ! -!$acc kernels present(ZCFLU,ZCFLV,ZCFLW,ZCFL) +!$acc kernels ZCFLU_MAX = MAXVAL(ZCFLU(IIB:IIE,IJB:IJE,IKB:IKE)) ZCFLV_MAX = MAXVAL(ZCFLV(IIB:IIE,IJB:IJE,IKB:IKE)) ZCFLW_MAX = MAXVAL(ZCFLW(IIB:IIE,IJB:IJE,IKB:IKE)) @@ -608,13 +632,7 @@ ZTSTEP_PPM = PTSTEP / REAL(KSPLIT) !* 2.4 normalized contravariant components for splitted PPM time-step ! !$acc update device(PRHODJ,PRTHS,PRTKES,PRRS,PRSVS) -!$acc kernels present(ZRUCPPM,ZRVCPPM,ZRWCPPM,PRHODJ) & -!$acc & present(PTHT,PTKET,PRT,PSVT) & -!$acc & present(PRTHS,PRTKES,PRRS,PRSVS) & -!$acc & present(ZRTHS_OTHER,ZRRS_OTHER(:,:,:,1:KRR),ZRSVS_OTHER(:,:,:,1:KSV)) & -!$acc & present(ZRTKES_OTHER) -!!$acc & pcopyout(ZRTHS_OTHER,ZRRS_OTHER(:,:,:,1:KRR),ZRSVS_OTHER(:,:,:,1:KSV)) & -!!$acc & pcopyout(ZRTKES_OTHER) +!$acc kernels ZRUCPPM = ZRUCPPM*ZTSTEP_PPM ZRVCPPM = ZRVCPPM*ZTSTEP_PPM ZRWCPPM = ZRWCPPM*ZTSTEP_PPM @@ -631,7 +649,7 @@ ZRWCPPM = ZRWCPPM*ZTSTEP_PPM ! Advection related processes from previous time-step will be taken into account in ZRTHS_PPM ! ZRTHS_OTHER = PRTHS - PTHT * PRHODJ / PTSTEP -IF (GTKE) ZRTKES_OTHER = PRTKES - PTKET * PRHODJ / PTSTEP +IF (GTKE) ZRTKES_OTHER = PRTKES - PTKET * PRHODJ / PTSTEP DO JR = 1, KRR ZRRS_OTHER(:,:,:,JR) = PRRS(:,:,:,JR) - PRT(:,:,:,JR) * PRHODJ(:,:,:) / PTSTEP END DO @@ -686,7 +704,7 @@ NULLIFY(TZFIELDS0_ll) CALL CLEANLIST_ll(TZFIELDS0_ll) !!$END IF !PW: TODO: update only what is needed... -!$acc update device(ZRTHS_OTHER,ZRTKES_OTHER,ZRRS_OTHER(:,:,:,1:KRR),ZRSVS_OTHER(:,:,:,1:KSV)) +!$acc update device(ZRTHS_OTHER,ZRTKES_OTHER,ZRRS_OTHER,ZRSVS_OTHER) ! ! @@ -700,9 +718,7 @@ CALL PPM_RHODJ(HLBCX,HLBCY, ZRUCPPM, ZRVCPPM, ZRWCPPM, & ZRHOZ1, ZRHOZ2 ) ! !* values of the fields at the beginning of the time splitting loop -!PW: not declared PRTKES_ADV as present due to bug in PGI 15.10 and 16.1 when zero size -!!$acc kernels present(PTHT,PTKET,PRT,PSVT) present(ZTH,ZTKE,ZR,ZSV,PRTKES_ADV) -!$acc kernels present(PTHT,PTKET,PRT,PSVT) present(ZTH,ZTKE,ZR,ZSV) +!$acc kernels ZTH(:,:,:) = PTHT(:,:,:) ZTKE(:,:,:) = PTKET(:,:,:) IF (KRR /=0 ) ZR(:,:,:,:) = PRT(:,:,:,:) @@ -730,7 +746,7 @@ DO JSPL=1,KSPLIT ! IF (LNEUTRAL) THEN !Must be done in a kernels region - !$acc kernels present(ZTH) +!$acc kernels ZTH=ZTH-PTHVREF !* To be removed with the new PPM scheme ? !$acc end kernels END IF @@ -739,7 +755,7 @@ DO JSPL=1,KSPLIT ZTH, ZTKE, ZR, ZRTHS_PPM, ZRTKES_PPM, ZRRS_PPM, HMET_ADV_SCHEME) IF (LNEUTRAL) THEN !Must be done in a kernels region - !$acc kernels present(ZTH) +!$acc kernels ZTH=ZTH+PTHVREF !* To be removed with the new PPM scheme ? !$acc end kernels END IF @@ -750,13 +766,7 @@ DO JSPL=1,KSPLIT ! ! Tendencies of PPM ! -!$acc kernels present(ZTH,ZTKE,ZR,ZSV,ZRTHS_PPM,ZRTKES_PPM,ZRRS_PPM,ZRSVS_PPM) & -!PW: not declared PRTKES_ADV as present due to bug in PGI 15.10 and 16.1 when zero size -!!$acc & present(PRTHS,PRTKES_ADV,PRRS,PRSVS) & -!$acc & present(PRTHS,PRRS,PRSVS) & -!$acc & pcopyin(PRTHS_CLD,PRRS_CLD,PRSVS_CLD) & -!$acc & present(ZRTHS_OTHER,ZRTKES_OTHER,ZRRS_OTHER(:,:,:,1:KRR),ZRSVS_OTHER(:,:,:,1:KSV)) -!!$acc & pcopyin(ZRTHS_OTHER,ZRTKES_OTHER,ZRRS_OTHER(:,:,:,1:KRR),ZRSVS_OTHER(:,:,:,1:KSV)) +!$acc kernels PRTHS(:,:,:) = PRTHS (:,:,:) + ZRTHS_PPM (:,:,:) / KSPLIT IF (GTKE) PRTKES_ADV(:,:,:) = PRTKES_ADV(:,:,:) + ZRTKES_PPM(:,:,:) / KSPLIT IF (KRR /=0) PRRS (:,:,:,:) = PRRS (:,:,:,:) + ZRRS_PPM (:,:,:,:) / KSPLIT @@ -851,7 +861,7 @@ END DO ! (previously done in tke_eps_sources) ! IF (GTKE) THEN -!$acc kernels present(PRTKES,PRTKES_ADV,PRHODJ) +!$acc kernels PRTKES(:,:,:) = PRTKES(:,:,:) + PRTKES_ADV(:,:,:) PRTKES(:,:,:) = MAX (PRTKES(:,:,:) , XTKEMIN * PRHODJ(:,:,:) / PTSTEP ) !$acc end kernels @@ -932,6 +942,39 @@ CALL MNH_REL_ZT3D(IZ1, IZ2) #endif !------------------------------------------------------------------------------- ! +deallocate( ZRUCPPM ) +deallocate( ZRVCPPM ) +deallocate( ZRWCPPM ) +deallocate( ZCFLU ) +deallocate( ZCFLV ) +deallocate( ZCFLW ) +deallocate( ZCFL ) +deallocate( ZTH ) +deallocate( ZTKE ) +deallocate( ZRTHS_OTHER ) +deallocate( ZRTKES_OTHER ) +deallocate( ZRTHS_PPM ) +deallocate( ZRTKES_PPM ) +deallocate( ZR ) +deallocate( ZSV ) +deallocate( ZSNWC) +deallocate( ZSNWC_INIT ) +deallocate( ZRSNWCS ) +deallocate( ZRRS_OTHER ) +deallocate( ZRSVS_OTHER ) +deallocate( ZRSNWCS_OTHER ) +deallocate( ZRRS_PPM ) +deallocate( ZRSVS_PPM ) +deallocate( ZRSNWCS_PPM ) +deallocate( ZRHOX1, ZRHOX2 ) +deallocate( ZRHOY1, ZRHOY2 ) +deallocate( ZRHOZ1, ZRHOZ2 ) +deallocate( ZT ) +deallocate( ZEXN ) +deallocate( ZLV ) +deallocate( ZLS ) +deallocate( ZCPH ) + IF (MPPDB_INITIALIZED) THEN !Check all INOUT arrays CALL MPPDB_CHECK(PRTHS,"ADVECTION_METSV end:PRTHS") diff --git a/src/MNH/advection_uvw.f90 b/src/MNH/advection_uvw.f90 index 01e2ad773d2440ea6d9cb21ce21d02b706907d44..8a6746c023ea4ca70eb9dab942252e6401d3539f 100644 --- a/src/MNH/advection_uvw.f90 +++ b/src/MNH/advection_uvw.f90 @@ -30,13 +30,10 @@ REAL, INTENT(IN) :: PTSTEP ! REAL, DIMENSION(:,:,:), INTENT(IN) :: PUT , PVT , PWT ! Variables at t -REAL, DIMENSION(:,:,:), INTENT(IN) :: PRHODJ -!$acc declare pcopyin(PUT,PVT,PWT,PRHODJ) +REAL, DIMENSION(:,:,:), INTENT(IN) :: PRHODJ REAL, DIMENSION(:,:,:), INTENT(IN) :: PDXX,PDYY,PDZZ,PDZX,PDZY -!$acc declare present(PDXX,PDYY,PDZZ,PDZX,PDZY) ! metric coefficients REAL, DIMENSION(:,:,:), INTENT(INOUT) :: PRUS , PRVS, PRWS -!$acc declare create(PRUS,PRVS,PRWS) ! Sources terms REAL, DIMENSION(:,:,:), INTENT(IN) :: PRUS_PRES, PRVS_PRES, PRWS_PRES ! @@ -143,7 +140,7 @@ REAL, INTENT(IN) :: PTSTEP REAL, DIMENSION(:,:,:), INTENT(IN) :: PUT , PVT , PWT ! Variables at t REAL, DIMENSION(:,:,:), INTENT(IN) :: PRHODJ -!$acc declare pcopyin(PUT,PVT,PWT,PRHODJ) +! !$acc declare copyin(PUT,PVT,PWT,PRHODJ) REAL, DIMENSION(:,:,:), INTENT(IN) :: PDXX,PDYY,PDZZ,PDZX,PDZY !$acc declare present(PDXX,PDYY,PDZZ,PDZX,PDZY) ! metric coefficients @@ -151,6 +148,7 @@ REAL, DIMENSION(:,:,:), INTENT(INOUT) :: PRUS , PRVS, PRWS !$acc declare create(PRUS,PRVS,PRWS) ! Sources terms REAL, DIMENSION(:,:,:), INTENT(IN) :: PRUS_PRES, PRVS_PRES, PRWS_PRES +! !$acc declare copyin(PRUS_PRES, PRVS_PRES, PRWS_PRES) ! ! !* 0.2 declarations of local variables @@ -159,37 +157,37 @@ REAL, DIMENSION(:,:,:), INTENT(IN) :: PRUS_PRES, PRVS_PRES, PRWS_PRES ! INTEGER :: IKE ! indice K End in z direction ! -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRUT -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRVT -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRWT +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRUT +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRVT +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRWT !$acc declare create(ZRUT,ZRVT,ZRWT) - ! cartesian + ! cartesian ! components of ! momentum ! -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRUCT -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRVCT -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRWCT +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRUCT +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRVCT +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRWCT !$acc declare create(ZRUCT,ZRVCT,ZRWCT) ! contravariant ! components ! of momentum ! -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZU, ZV, ZW +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZU, ZV, ZW !$acc declare create(ZU,ZV,ZW) ! Guesses at the end of the sub time step -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRUS_OTHER -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRVS_OTHER -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRWS_OTHER +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRUS_OTHER +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRVS_OTHER +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRWS_OTHER !$acc declare create(ZRUS_OTHER,ZRVS_OTHER,ZRWS_OTHER) -! Contribution of the RK time step -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRUS_ADV -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRVS_ADV -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZRWS_ADV +! Contribution of the RK time step +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRUS_ADV +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRVS_ADV +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZRWS_ADV !$acc declare create(ZRUS_ADV,ZRVS_ADV,ZRWS_ADV) -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZMXM_RHODJ -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZMYM_RHODJ -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZMZM_RHODJ +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZMXM_RHODJ +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZMYM_RHODJ +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZMZM_RHODJ !$acc declare create(ZMXM_RHODJ,ZMYM_RHODJ,ZMZM_RHODJ) ! ! Momentum tendencies due to advection @@ -213,6 +211,11 @@ INTEGER :: IZRUSB, IZRUSE, IZRVSB, IZRVSE, IZRWSB, IZRWSE ! !* 0. INITIALIZATION ! -------------- + +!PW: bug: use a data zone instead of declare. If not, crash at execution with PGI 18.10 +! (descriptor partially present in advecuvw_rk) +!$acc data copyin(PUT, PVT, PWT, PRHODJ, PRUS_PRES, PRVS_PRES, PRWS_PRES) + IF (MPPDB_INITIALIZED) THEN !Check all IN arrays CALL MPPDB_CHECK(PUT,"ADVECTION_UVW beg:PUT") @@ -233,7 +236,27 @@ IF (MPPDB_INITIALIZED) THEN CALL MPPDB_CHECK(PRWS,"ADVECTION_UVW beg:PRWS") END IF +ALLOCATE( ZRUT ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRVT ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRWT ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRUCT ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRVCT ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRWCT ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZU ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZV ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZW ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRUS_OTHER( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRVS_OTHER( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRWS_OTHER( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRUS_ADV ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRVS_ADV ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZRWS_ADV ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZMXM_RHODJ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZMYM_RHODJ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) +ALLOCATE( ZMZM_RHODJ( SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3) ) ) + #ifdef _OPENACC +#if 0 CALL INIT_ON_HOST_AND_DEVICE(ZRUT,-1e99,'ADVECTION_UVW::ZRUT') CALL INIT_ON_HOST_AND_DEVICE(ZRVT,-2e99,'ADVECTION_UVW::ZRVT') CALL INIT_ON_HOST_AND_DEVICE(ZRWT,-3e99,'ADVECTION_UVW::ZRWT') @@ -252,6 +275,7 @@ CALL INIT_ON_HOST_AND_DEVICE(ZRWS_ADV,-1e99,'ADVECTION_UVW::ZRWS_ADV') CALL INIT_ON_HOST_AND_DEVICE(ZMXM_RHODJ,-1e97,'ADVECTION_UVW::ZMXM_RHODJ') CALL INIT_ON_HOST_AND_DEVICE(ZMYM_RHODJ,-2e97,'ADVECTION_UVW::ZMYM_RHODJ') CALL INIT_ON_HOST_AND_DEVICE(ZMZM_RHODJ,-3e97,'ADVECTION_UVW::ZMZM_RHODJ') +#endif ! SELECT CASE (HTEMP_SCHEME) CASE('RK11') @@ -307,7 +331,7 @@ CALL MZM_DEVICE(PRHODJ,ZMZM_RHODJ) !* 1. COMPUTES THE CONTRAVARIANT COMPONENTS ! ------------------------------------- ! -!$acc kernels present(ZRUT,ZRVT,ZRWT) present(PUT,PVT,PWT) present(ZMXM_RHODJ,ZMYM_RHODJ,ZMZM_RHODJ) +!$acc kernels ZRUT = PUT(:,:,:) * ZMXM_RHODJ ZRVT = PVT(:,:,:) * ZMYM_RHODJ ZRWT = PWT(:,:,:) * ZMZM_RHODJ @@ -348,9 +372,7 @@ NULLIFY(TZFIELDS_ll) ! ------------------------------------------------------------ ! !$acc update device(PRUS,PRVS,PRWS) -!$acc kernels present(ZRUS_OTHER,ZRVS_OTHER,ZRWS_OTHER) & -!$acc & present(ZRUT,ZRVT,ZRWT) present(PRUS,PRVS,PRWS) & -!$acc & copyin(PRUS_PRES,PRVS_PRES,PRWS_PRES) +!$acc kernels ZRUS_OTHER = PRUS - ZRUT / PTSTEP + PRUS_PRES ZRVS_OTHER = PRVS - ZRVT / PTSTEP + PRVS_PRES ZRWS_OTHER = PRWS - ZRWT / PTSTEP + PRWS_PRES @@ -397,7 +419,7 @@ ZTSTEP = PTSTEP / REAL(ISPLIT) ! !------------------------------------------------------------------------------- ! -!$acc kernels present(ZU,ZV,ZW) present(PUT,PVT,PWT) +!$acc kernels ZU = PUT ZV = PVT ZW = PWT @@ -428,10 +450,7 @@ DO JSPL=1,ISPLIT ! ! Tendencies on wind !$acc update device(ZRUS_ADV,ZRVS_ADV,ZRWS_ADV) -!$acc kernels present(ZU,ZV,ZW) present(ZRUS_ADV,ZRVS_ADV,ZRWS_ADV) & -!$acc & present(ZMXM_RHODJ,ZMYM_RHODJ,ZMZM_RHODJ) & -!$acc & present(ZRUS_OTHER,ZRVS_OTHER,ZRWS_OTHER) & -!$acc & present(PRUS,PRVS,PRWS) +!$acc kernels PRUS(:,:,:) = PRUS(:,:,:) + ZRUS_ADV(:,:,:) / ISPLIT PRVS(:,:,:) = PRVS(:,:,:) + ZRVS_ADV(:,:,:) / ISPLIT PRWS(:,:,:) = PRWS(:,:,:) + ZRWS_ADV(:,:,:) / ISPLIT @@ -462,7 +481,7 @@ DO JSPL=1,ISPLIT CALL ADV_BOUNDARIES_DEVICE (HLBCX, HLBCY, ZV, PVT, 'V' ) CALL ADV_BOUNDARIES_DEVICE (HLBCX, HLBCY, ZW, PWT, 'W' ) #endif -!$acc kernels present(ZW) +!$acc kernels ZW (:,:,IKE+1 ) = 0. !$acc end kernels !$acc update self(ZU,ZV,ZW) @@ -486,6 +505,26 @@ CALL MNH_REL_ZT4D(ISPL, IZRVSB) CALL MNH_REL_ZT4D(ISPL, IZRUSB) CALL MNH_REL_ZT3D(IZUT, IZVT, IZWT, IZ1, IZ2) #endif + +DEALLOCATE( ZRUT ) +DEALLOCATE( ZRVT ) +DEALLOCATE( ZRWT ) +DEALLOCATE( ZRUCT ) +DEALLOCATE( ZRVCT ) +DEALLOCATE( ZRWCT ) +DEALLOCATE( ZU ) +DEALLOCATE( ZV ) +DEALLOCATE( ZW ) +DEALLOCATE( ZRUS_OTHER ) +DEALLOCATE( ZRVS_OTHER ) +DEALLOCATE( ZRWS_OTHER ) +DEALLOCATE( ZRUS_ADV ) +DEALLOCATE( ZRVS_ADV ) +DEALLOCATE( ZRWS_ADV ) +DEALLOCATE( ZMXM_RHODJ ) +DEALLOCATE( ZMYM_RHODJ ) +DEALLOCATE( ZMZM_RHODJ ) + IF (MPPDB_INITIALIZED) THEN !Check all INOUT arrays CALL MPPDB_CHECK(PRUS,"ADVECTION_UVW end:PRUS") @@ -493,5 +532,6 @@ IF (MPPDB_INITIALIZED) THEN CALL MPPDB_CHECK(PRWS,"ADVECTION_UVW end:PRWS") END IF +!$acc end data ! END SUBROUTINE ADVECTION_UVW diff --git a/src/MNH/advecuvw_rk.f90 b/src/MNH/advecuvw_rk.f90 index f7e1ca5f0ef23111783199959947aa4b48ae8592..9563e0dacfb01126980d2e5f2c358e2a8b72bf37 100644 --- a/src/MNH/advecuvw_rk.f90 +++ b/src/MNH/advecuvw_rk.f90 @@ -55,7 +55,7 @@ REAL, DIMENSION(:,:,:), INTENT(IN) :: PRUS_OTHER , PRVS_OTHER, PRWS_OTHER ! ! tendencies from other processes #ifdef _OPENACC ! Work arrays -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZUT, ZVT, ZWT +REAL, DIMENSION(:,:,:) :: ZUT, ZVT, ZWT !$acc declare present(ZUT,ZVT,ZWT) REAL, DIMENSION(:,:,:,:) :: ZRUS,ZRVS,ZRWS !$acc declare present(ZRUS,ZRVS,ZRWS) @@ -191,6 +191,12 @@ REAL, DIMENSION(:,:,:), INTENT(OUT) :: PRUS_ADV , PRVS_ADV, PRWS_ADV REAL, DIMENSION(:,:,:), INTENT(IN) :: PRUS_OTHER , PRVS_OTHER, PRWS_OTHER !$acc declare present(PRUS_OTHER,PRVS_OTHER,PRWS_OTHER) ! ! tendencies from other processes +#ifdef _OPENACC +REAL, DIMENSION(:,:,:) :: ZUT, ZVT, ZWT +!$acc declare present(ZUT,ZVT,ZWT) +REAL, DIMENSION(:,:,:,:) :: ZRUS,ZRVS,ZRWS +!$acc declare present(ZRUS,ZRVS,ZRWS) +#endif ! ! ! @@ -201,15 +207,11 @@ REAL, DIMENSION(:,:,:), INTENT(IN) :: PRUS_OTHER , PRVS_OTHER, PRWS_OTHER character(len=3) :: ynum INTEGER :: IKE ! indice K End in z direction ! -REAL, DIMENSION(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3)) :: ZUT, ZVT, ZWT -!$acc declare present(ZUT,ZVT,ZWT) -! Intermediate Guesses inside the RK loop -! #ifndef _OPENACC +REAL, DIMENSION(:,:,:), ALLOCATABLE :: ZUT, ZVT, ZWT +! Intermediate Guesses inside the RK loop +! REAL, DIMENSION(:,:,:,:), ALLOCATABLE :: ZRUS,ZRVS,ZRWS -#else -REAL, DIMENSION(:,:,:,:) :: ZRUS,ZRVS,ZRWS -!$acc declare present(ZRUS,ZRVS,ZRWS) #endif ! Momentum tendencies due to advection REAL, DIMENSION(:,:), ALLOCATABLE :: ZBUT ! Butcher array coefficients @@ -261,8 +263,14 @@ END IF !* 0. INITIALIZATION ! -------------- ! +#ifndef _OPENACC +allocate(ZUT(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3))) +allocate(ZVT(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3))) +allocate(ZWT(SIZE(PUT,1),SIZE(PUT,2),SIZE(PUT,3))) +#endif + #ifdef _OPENACC -!Data zone necessary to work around a bug seen with PGI at least up to 16.4 +!Data zone necessary to work around a bug seen with PGI at least up to 18.10 !If not, update on a section of ZRUS will update a section of the total size of ZRUS !$acc data present(ZRUS,ZRVS,ZRWS) CALL INIT_ON_HOST_AND_DEVICE(ZUT,4e99,'ADVECUVW_RK::ZUT') @@ -442,8 +450,8 @@ ZRWS = 0. DO JS = 1, ISPL ! #ifndef _OPENACC - CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZUT, PUT, 'U' ) - CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZVT, PVT, 'V' ) + CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZUT, PUT, 'U' ) + CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZVT, PVT, 'V' ) CALL ADV_BOUNDARIES (HLBCX, HLBCY, ZWT, PWT, 'W' ) #else CALL ADV_BOUNDARIES_DEVICE (HLBCX, HLBCY, ZUT, PUT, 'U' ) @@ -452,7 +460,7 @@ ZRWS = 0. #endif ! !$acc update self(ZUT,ZVT,ZWT) - CALL UPDATE_HALO_ll(TZFIELDMT_ll,IINFO_ll) + CALL UPDATE_HALO_ll(TZFIELDMT_ll,IINFO_ll) CALL UPDATE_HALO2_ll(TZFIELDMT_ll, TZHALO2MT_ll, IINFO_ll) !$acc update device(ZUT,ZVT,ZWT) ! @@ -460,7 +468,7 @@ ZRWS = 0. ! ------------------- ! - IF (HUVW_ADV_SCHEME=='WENO_K') THEN + IF (HUVW_ADV_SCHEME=='WENO_K') THEN CALL ADVECUVW_WENO_K (HLBCX, HLBCY, KWENO_ORDER, ZUT, ZVT, ZWT, & PRUCT, PRVCT, PRWCT, & ZRUS(:,:,:,JS), ZRVS(:,:,:,JS), ZRWS(:,:,:,JS), & @@ -468,9 +476,8 @@ ZRWS = 0. TZHALO2MT_ll ) #else TZHALO2MT_ll, ZT3D(:,:,:,IZMEAN), ZT3D(:,:,:,IZWORK) ) -!Not necessary: already done in ADVECUVW_WENO_K !$acc update self(ZRUS(:,:,:,JS),ZRVS(:,:,:,JS),ZRWS(:,:,:,JS)) #endif - ELSE IF ((HUVW_ADV_SCHEME=='CEN4TH') .AND. (HTEMP_SCHEME=='RKC4')) THEN + ELSE IF ((HUVW_ADV_SCHEME=='CEN4TH') .AND. (HTEMP_SCHEME=='RKC4')) THEN CALL ADVECUVW_4TH (HLBCX, HLBCY, PRUCT, PRVCT, PRWCT, & ZUT, ZVT, ZWT, & ZRUS(:,:,:,JS), ZRVS(:,:,:,JS), ZRWS(:,:,:,JS), & @@ -487,7 +494,16 @@ ZRWS = 0. CALL CLEANLIST_ll(TZFIELDS4_ll) !$acc update device(ZRUS(:,:,:,JS),ZRVS(:,:,:,JS),ZRWS(:,:,:,JS)) ! - IF ( JS /= ISPL ) THEN +! +! Guesses at the end of the RK loop +! +!$acc kernels present(PRUS_ADV,PRVS_ADV,PRWS_ADV,ZBUTS) present(ZRUS,ZRVS,ZRWS) + PRUS_ADV(:,:,:) = PRUS_ADV(:,:,:) + ZBUTS(JS) * ZRUS(:,:,:,JS) + PRVS_ADV(:,:,:) = PRVS_ADV(:,:,:) + ZBUTS(JS) * ZRVS(:,:,:,JS) + PRWS_ADV(:,:,:) = PRWS_ADV(:,:,:) + ZBUTS(JS) * ZRWS(:,:,:,JS) +!$acc end kernels +! + IF ( JS < ISPL ) THEN !$acc kernels present(ZUT,ZVT,ZWT) present(ZBUT) present(PU,PV,PW) & !$acc & present(ZRUS,ZRVS,ZRWS) present(PRUS_OTHER,PRVS_OTHER,PRWS_OTHER) & !$acc & present(PMXM_RHODJ,PMYM_RHODJ,PMZM_RHODJ) @@ -510,19 +526,6 @@ ZRWS = 0. END DO !$acc end kernels !$acc update self(ZUT,ZVT,ZWT) -! - ELSE -! -! Guesses at the end of the RK loop -! -!$acc kernels present(PRUS_ADV,PRVS_ADV,PRWS_ADV,ZBUTS) present(ZRUS,ZRVS,ZRWS) - DO JI = 1, ISPL - PRUS_ADV(:,:,:) = PRUS_ADV(:,:,:) + ZBUTS(JI) * ZRUS(:,:,:,JI) - PRVS_ADV(:,:,:) = PRVS_ADV(:,:,:) + ZBUTS(JI) * ZRVS(:,:,:,JI) - PRWS_ADV(:,:,:) = PRWS_ADV(:,:,:) + ZBUTS(JI) * ZRWS(:,:,:,JI) - END DO -!$acc end kernels -! END IF ! ! End of the RK loop @@ -533,6 +536,7 @@ ZRWS = 0. CALL MNH_REL_ZT3D(IZMEAN,IZWORK) #else DEALLOCATE(ZRUS, ZRVS, ZRWS) +deallocate(ZUT,ZVT,ZWT) #endif ! DEALLOCATE(ZBUT, ZBUTS) diff --git a/src/MNH/advecuvw_weno_k.f90 b/src/MNH/advecuvw_weno_k.f90 index d27d1fc8bcd0257e210192bd7bf21b81d36c39d3..2984522835ea0efa0b71bb47e8792197697a954e 100644 --- a/src/MNH/advecuvw_weno_k.f90 +++ b/src/MNH/advecuvw_weno_k.f90 @@ -39,7 +39,7 @@ TYPE(HALO2LIST_ll), POINTER :: TPHALO2LIST ! list for diffusion ! #ifdef _OPENACC ! Work arrays -REAL, DIMENSION(SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3)) :: ZMEAN, ZWORK +REAL, DIMENSION(:,:,:) :: ZMEAN, ZWORK !$acc declare present(ZMEAN,ZWORK) #endif ! @@ -128,8 +128,12 @@ TYPE(HALO2LIST_ll), POINTER :: TZHALO2_UT,TZHALO2_VT,TZHALO2_WT TYPE(LIST_ll), POINTER :: TZHALO2_ZMEAN INTEGER :: IINFO_ll ! return code of parallel routine ! -REAL, DIMENSION(SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3)) :: ZMEAN, ZWORK +#ifndef _OPENACC +REAL, DIMENSION(:,:,:), allocatable :: ZMEAN, ZWORK +#else +REAL, DIMENSION(:,:,:) :: ZMEAN, ZWORK !$acc declare present(ZMEAN,ZWORK) +#endif ! INTEGER :: K_SCHEME INTEGER :: IKU @@ -158,6 +162,11 @@ IF (MPPDB_INITIALIZED) THEN CALL MPPDB_CHECK(PRWS,"ADVECUVW_WENO_K beg:PRWS") END IF +#ifndef _OPENACC +allocate(ZMEAN(SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3))) +allocate(ZWORK(SIZE(PUT,1), SIZE(PUT,2), SIZE(PUT,3))) +#endif + #ifdef _OPENACC CALL INIT_ON_HOST_AND_DEVICE(ZMEAN,1e90,'ADVECUVW_WENO_K::ZMEAN') CALL INIT_ON_HOST_AND_DEVICE(ZWORK,2e90,'ADVECUVW_WENO_K::ZWORK')