diff --git a/src/MNH/rain_ice.f90 b/src/MNH/rain_ice.f90 index 6986884c044507eacf39cd73780cca8143b4c896..3987911a8b14d2189687059c702c2f0e135718ef 100644 --- a/src/MNH/rain_ice.f90 +++ b/src/MNH/rain_ice.f90 @@ -983,10 +983,10 @@ INTEGER, SAVE :: IOLDALLOCG = 6000 INTEGER, SAVE :: IOLDALLOCH = 6000 ! REAL, DIMENSION(SIZE(PRHODREF,1),SIZE(PRHODREF,2),SIZE(PRHODREF,3)) :: ZCONC3D ! droplet condensation -!$acc declare create(IC1,IC2,IC3,IR1,IR2,IR3,IS1,IS2,IS3, & -!$acc & II1,II2,II3,IG1,IG2,IG3,IH1,IH2,IH3, & -!$acc & ILISTR,ILISTC,ILISTI,ILISTS,ILISTG,ILISTH, & -!$acc & ZCONC3D) +!$acc declare device_resident(IC1,IC2,IC3,IR1,IR2,IR3,IS1,IS2,IS3, & +!$acc & II1,II2,II3,IG1,IG2,IG3,IH1,IH2,IH3, & +!$acc & ILISTR,ILISTC,ILISTI,ILISTS,ILISTG,ILISTH) & +!$acc & create(ZCONC3D) !------------------------------------------------------------------------------- ! ! @@ -1000,13 +1000,6 @@ PINPRS (:,:) = 0. PINPRG (:,:) = 0. IF ( KRR == 7 ) PINPRH (:,:) = 0. !$acc end kernels -IF (OSEDIC) THEN -!$acc update self(PINPRC) -ENDIF -!$acc update self(PINPRR,PINPRR3D,PINPRS,PINPRG) -IF ( KRR == 7 ) THEN -!$acc update self(PINPRH) -ENDIF ! !* 1. Parameters for cloud sedimentation ! @@ -1059,21 +1052,14 @@ ILENALLOCI = 0 ILENALLOCS = 0 ILENALLOCG = 0 IF ( KRR == 7 ) ILENALLOCH = 0 -!$acc end kernels ! ! ZPiS = Specie i source creating during the current time step ! PRiS = Source of the previous time step ! IF (OSEDIC) THEN - ZPRCS(:,:,:) = 0.0 ZPRCS(:,:,:) = PRCS(:,:,:)-PRCT(:,:,:)* ZINVTSTEP PRCS(:,:,:) = PRCT(:,:,:)* ZINVTSTEP END IF -ZPRRS(:,:,:) = 0.0 -ZPRSS(:,:,:) = 0.0 -ZPRGS(:,:,:) = 0.0 -IF ( KRR == 7 ) ZPRHS(:,:,:) = 0.0 -! ZPRRS(:,:,:) = PRRS(:,:,:)-PRRT(:,:,:)* ZINVTSTEP ZPRSS(:,:,:) = PRSS(:,:,:)-PRST(:,:,:)* ZINVTSTEP ZPRGS(:,:,:) = PRGS(:,:,:)-PRGT(:,:,:)* ZINVTSTEP @@ -1082,11 +1068,22 @@ PRRS(:,:,:) = PRRT(:,:,:)* ZINVTSTEP PRSS(:,:,:) = PRST(:,:,:)* ZINVTSTEP PRGS(:,:,:) = PRGT(:,:,:)* ZINVTSTEP IF ( KRR == 7 ) PRHS(:,:,:) = PRHT(:,:,:)* ZINVTSTEP +!$acc end kernels +!$acc update self(ZPRRS,ZPRSS,ZPRGS) +#ifdef _OPENACC +IF (OSEDIC) THEN +!$acc update self(ZPRCS) +END IF +IF ( KRR == 7 ) THEN +!$acc update self(ZPRHS) +END IF +#endif ! ! PRiS = Source of the previous time step + source created during the subtime ! step ! DO JN = 1 , KSPLITR +!$acc kernels IF( JN==1 ) THEN IF (OSEDIC) PRCS(:,:,:) = PRCS(:,:,:) + ZPRCS(:,:,:)/KSPLITR PRRS(:,:,:) = PRRS(:,:,:) + ZPRRS(:,:,:)/KSPLITR @@ -1103,17 +1100,6 @@ DO JN = 1 , KSPLITR PRGS(:,:,:) = PRGS(:,:,:) + ZPRGS(:,:,:)*ZTSPLITR IF ( KRR == 7 ) PRHS(:,:,:) = PRHS(:,:,:) + ZPRHS(:,:,:)*ZTSPLITR END IF - ! -!$acc update device(PRRS,PRIS,PRSS,PRGS) -#ifdef _OPENACC -IF (OSEDIC) THEN -!$acc update device(PRCS) -END IF -IF (KRR==7) THEN -!$acc update device(PRHS) -END IF -#endif -!$acc kernels IF (OSEDIC) GSEDIMC(IIB:IIE,IJB:IJE,IKTB:IKTE) = & PRCS(IIB:IIE,IJB:IJE,IKTB:IKTE)>ZRTMIN(2) GSEDIMR(IIB:IIE,IJB:IJE,IKTB:IKTE) = & @@ -1127,15 +1113,6 @@ END IF IF ( KRR == 7 ) GSEDIMH(IIB:IIE,IJB:IJE,IKTB:IKTE) = & PRHS(IIB:IIE,IJB:IJE,IKTB:IKTE)>ZRTMIN(7) !$acc end kernels -!$acc update self(GSEDIMR,GSEDIMI,GSEDIMS,GSEDIMG,ZRTMIN) -#ifdef _OPENACC -IF (OSEDIC) THEN -!$acc update self(GSEDIMC) -END IF -IF (KRR==7) THEN -!$acc update self(GSEDIMH) -END IF -#endif ! #ifndef _OPENACC IF (OSEDIC) ISEDIMC = COUNTJV3D( GSEDIMC(:,:,:),IC1(:),IC2(:),IC3(:)) @@ -1151,20 +1128,15 @@ END IF CALL COUNTJV3D_DEVICE(GSEDIMS,IS1,IS2,IS3,ISEDIMS) CALL COUNTJV3D_DEVICE(GSEDIMG,IG1,IG2,IG3,ISEDIMG) IF ( KRR == 7 ) CALL COUNTJV3D_DEVICE(GSEDIMH,IH1,IH2,IH3,ISEDIMH) -!$acc update self(IR1,IR2,IR3,IS1,IS2,IS3,II1,II2,II3,IG1,IG2,IG3) -IF (OSEDIC) THEN -!$acc update self(IC1,IC2,IC3) -END IF -IF (KRR==7) THEN -!$acc update self(IH1,IH2,IH3) -END IF #endif ! !* 2.1 for cloud ! IF (OSEDIC) THEN +!$acc kernels ZWSED(:,:,:) = 0. IF( JN==1 ) PRCS(:,:,:) = PRCS(:,:,:) * PTSTEP +!$acc end kernels IF( ISEDIMC >= 1 ) THEN IF ( ISEDIMC .GT. ILENALLOCC ) THEN IF ( ILENALLOCC .GT. 0 ) THEN @@ -1179,6 +1151,7 @@ END IF ZWLBDA(ILENALLOCC), ZCC(ILENALLOCC) ) END IF ! +!$acc kernels DO JL=1,ISEDIMC ZRCS(JL) = PRCS(IC1(JL),IC2(JL),IC3(JL)) ZRHODREFC(JL) = PRHODREF(IC1(JL),IC2(JL),IC3(JL)) @@ -1198,7 +1171,9 @@ END IF ILISTC(ILISTLENC) = JL END IF END DO +!$acc end kernels ! +!$acc kernels DO JJ = 1, ILISTLENC JL = ILISTC(JJ) IF (ZRCS(JL) .GT. ZRTMIN(2) .AND. ZRCT(JL) .GT. XRTMIN(2)) THEN @@ -1225,8 +1200,9 @@ END IF #endif END IF END DO -!$acc update device(ZZT,ZPRES) +!$acc end kernels END IF +!$acc kernels DO JK = IKTB , IKTE PRCS(:,:,JK) = PRCS(:,:,JK) + ZW(:,:,JK)*(ZWSED(:,:,JK+KKL)-ZWSED(:,:,JK)) END DO @@ -1234,12 +1210,15 @@ END IF IF( JN==KSPLITR ) THEN PRCS(:,:,:) = PRCS(:,:,:) * ZINVTSTEP END IF +!$acc end kernels END IF ! !* 2.2 for rain ! +!$acc kernels IF( JN==1 ) PRRS(:,:,:) = PRRS(:,:,:) * PTSTEP ZWSED(:,:,:) = 0. +!$acc end kernels IF( ISEDIMR >= 1 ) THEN IF ( ISEDIMR .GT. ILENALLOCR ) THEN IF ( ILENALLOCR .GT. 0 ) THEN @@ -1250,7 +1229,7 @@ END IF ALLOCATE(ZRRS(ILENALLOCR), ZRHODREFR(ILENALLOCR), ILISTR(ILENALLOCR)) END IF ! -!$acc update device(PRRS) +!acc kernels present(PRRS,PRHODREF,ZRTMIN,ILISTR,ZWSED,IR1,IR2,IR3,ZRRS,ZRHODREFR) copyin(XEXSEDR) default(none) !$acc kernels DO JL=1,ISEDIMR ZRRS(JL) = PRRS(IR1(JL),IR2(JL),IR3(JL)) @@ -1265,8 +1244,7 @@ END IF END IF END DO !$acc end kernels -!$acc update self(ZRHODREFR,ZRRS,ILISTR) -!acc kernels +!$acc kernels present(ILISTR,ZWSED,IR1,IR2,IR3,ZRRS,ZRHODREFR) copyin(XEXSEDR) default(none) DO JJ = 1, ILISTLENR JL = ILISTR(JJ) #ifndef MNH_BITREP @@ -1277,8 +1255,9 @@ END IF BR_POW(ZRHODREFR(JL),XEXSEDR-XCEXVT) #endif END DO -!acc end kernels +!$acc end kernels END IF +!$acc kernels DO JK = IKTB , IKTE PRRS(:,:,JK) = PRRS(:,:,JK) + ZW(:,:,JK)*(ZWSED(:,:,JK+KKL)-ZWSED(:,:,JK)) END DO @@ -1287,11 +1266,14 @@ END IF IF ( JN==KSPLITR ) THEN PRRS(:,:,:) = PRRS(:,:,:) * ZINVTSTEP END IF +!$acc end kernels ! !* 2.3 for pristine ice ! +!$acc kernels IF( JN==1 ) PRIS(:,:,:) = PRIS(:,:,:) * PTSTEP ZWSED(:,:,:) = 0. +!$acc end kernels IF( ISEDIMI >= 1 ) THEN IF ( ISEDIMI .GT. ILENALLOCI ) THEN IF ( ILENALLOCI .GT. 0 ) THEN @@ -1302,6 +1284,7 @@ END IF ALLOCATE(ZRIS(ILENALLOCI), ZRHODREFI(ILENALLOCI), ILISTI(ILENALLOCI)) END IF ! +!$acc kernels DO JL=1,ISEDIMI ZRIS(JL) = PRIS(II1(JL),II2(JL),II3(JL)) ZRHODREFI(JL) = PRHODREF(II1(JL),II2(JL),II3(JL)) @@ -1314,6 +1297,8 @@ END IF ILISTI(ILISTLENI) = JL END IF END DO +!$acc end kernels +!$acc kernels DO JJ = 1, ILISTLENI JL = ILISTI(JJ) #ifndef MNH_BITREP @@ -1328,18 +1313,23 @@ END IF BR_LOG(ZRHODREFI(JL)*ZRIS(JL)) ),XEXCSEDI) #endif END DO +!$acc end kernels END IF +!$acc kernels DO JK = IKTB , IKTE PRIS(:,:,JK) = PRIS(:,:,JK) + ZW(:,:,JK)*(ZWSED(:,:,JK+KKL)-ZWSED(:,:,JK)) END DO IF( JN==KSPLITR ) THEN PRIS(:,:,:) = PRIS(:,:,:) * ZINVTSTEP END IF +!$acc end kernels ! !* 2.4 for aggregates/snow ! +!$acc kernels IF( JN==1 ) PRSS(:,:,:) = PRSS(:,:,:) * PTSTEP ZWSED(:,:,:) = 0. +!$acc end kernels IF( ISEDIMS >= 1 ) THEN IF ( ISEDIMS .GT. ILENALLOCS ) THEN IF ( ILENALLOCS .GT. 0 ) THEN @@ -1350,6 +1340,7 @@ END IF ALLOCATE(ZRSS(ILENALLOCS), ZRHODREFS(ILENALLOCS), ILISTS(ILENALLOCS)) END IF ! +!$acc kernels DO JL=1,ISEDIMS ZRSS(JL) = PRSS(IS1(JL),IS2(JL),IS3(JL)) ZRHODREFS(JL) = PRHODREF(IS1(JL),IS2(JL),IS3(JL)) @@ -1362,6 +1353,8 @@ END IF ILISTS(ILISTLENS) = JL END IF END DO +!$acc end kernels +!$acc kernels present(ILISTS,IS1,IS2,IS3,ZRSS,ZRHODREFS,ZWSED) copyin(XEXSEDS) default(none) DO JJ = 1, ILISTLENS JL = ILISTS(JJ) #ifndef MNH_BITREP @@ -1372,7 +1365,9 @@ END IF BR_POW(ZRHODREFS(JL),XEXSEDS-XCEXVT) #endif END DO +!$acc end kernels END IF +!$acc kernels DO JK = IKTB , IKTE PRSS(:,:,JK) = PRSS(:,:,JK) + ZW(:,:,JK)*(ZWSED(:,:,JK+KKL)-ZWSED(:,:,JK)) END DO @@ -1380,11 +1375,14 @@ END IF IF( JN==KSPLITR ) THEN PRSS(:,:,:) = PRSS(:,:,:) * ZINVTSTEP END IF +!$acc end kernels ! !* 2.5 for graupeln ! +!$acc kernels ZWSED(:,:,:) = 0. IF( JN==1 ) PRGS(:,:,:) = PRGS(:,:,:) * PTSTEP +!$acc end kernels IF( ISEDIMG >= 1 ) THEN IF ( ISEDIMG .GT. ILENALLOCG ) THEN IF ( ILENALLOCG .GT. 0 ) THEN @@ -1395,6 +1393,7 @@ END IF ALLOCATE(ZRGS(ILENALLOCG), ZRHODREFG(ILENALLOCG), ILISTG(ILENALLOCG)) END IF ! +!$acc kernels DO JL=1,ISEDIMG ZRGS(JL) = PRGS(IG1(JL),IG2(JL),IG3(JL)) ZRHODREFG(JL) = PRHODREF(IG1(JL),IG2(JL),IG3(JL)) @@ -1407,6 +1406,8 @@ END IF ILISTG(ILISTLENG) = JL END IF END DO +!$acc end kernels +!$acc kernels present(ILISTG,IG1,IG2,IG3,ZRGS,ZRHODREFG,ZWSED) copyin(XEXSEDG) default(none) DO JJ = 1, ILISTLENG JL = ILISTG(JJ) #ifndef MNH_BITREP @@ -1417,7 +1418,9 @@ END IF BR_POW(ZRHODREFG(JL),XEXSEDG-XCEXVT) #endif END DO +!$acc end kernels END IF +!$acc kernels DO JK = IKTB , IKTE PRGS(:,:,JK) = PRGS(:,:,JK) + ZW(:,:,JK)*(ZWSED(:,:,JK+KKL)-ZWSED(:,:,JK)) END DO @@ -1425,12 +1428,15 @@ END IF IF( JN==KSPLITR ) THEN PRGS(:,:,:) = PRGS(:,:,:) * ZINVTSTEP END IF +!$acc end kernels ! !* 2.6 for hail ! IF ( KRR == 7 ) THEN +!$acc kernels IF( JN==1 ) PRHS(:,:,:) = PRHS(:,:,:) * PTSTEP ZWSED(:,:,:) = 0. +!$acc end kernels IF( ISEDIMH >= 1 ) THEN IF ( ISEDIMH .GT. ILENALLOCH ) THEN IF ( ILENALLOCH .GT. 0 ) THEN @@ -1441,6 +1447,7 @@ END IF ALLOCATE(ZRHS(ILENALLOCH), ZRHODREFH(ILENALLOCH), ILISTH(ILENALLOCH)) END IF ! +!$acc kernels DO JL=1,ISEDIMH ZRHS(JL) = PRHS(IH1(JL),IH2(JL),IH3(JL)) ZRHODREFH(JL) = PRHODREF(IH1(JL),IH2(JL),IH3(JL)) @@ -1453,6 +1460,8 @@ END IF ILISTH(ILISTLENH) = JL END IF END DO +!$acc end kernels +!$acc kernels present(ILISTH,IH1,IH2,IH3,ZRHS,ZRHODREFH,ZWSED) copyin(XEXSEDH) default(none) DO JJ = 1, ILISTLENH JL = ILISTH(JJ) #ifndef MNH_BITREP @@ -1463,7 +1472,9 @@ END IF BR_POW(ZRHODREFH(JL),XEXSEDH-XCEXVT) #endif END DO +!$acc end kernels END IF +!$acc kernels DO JK = IKTB , IKTE PRHS(:,:,JK) = PRHS(:,:,JK) + ZW(:,:,JK)*(ZWSED(:,:,JK+KKL)-ZWSED(:,:,JK)) END DO @@ -1471,9 +1482,19 @@ END IF IF( JN==KSPLITR ) THEN PRHS(:,:,:) = PRHS(:,:,:) * ZINVTSTEP END IF +!$acc end kernels END IF ! END DO +!$acc update self(PRRS,PRSS,PRGS,PRIS,PINPRR,PINPRR3D,PINPRS,PINPRG) +#ifdef _OPENACC +IF (OSEDIC) THEN +!$acc update self(PRCS,PINPRC) +END IF +IF (KRR==7) THEN +!$acc update self(PRHS,PINPRH) +END IF +#endif ! IF (OSEDIC) THEN IF (ILENALLOCC .GT. 0) DEALLOCATE (ZRCS, ZRHODREFC, & @@ -2177,20 +2198,14 @@ IF( INEGT >= 1 ) THEN END IF ! f(L_s*(RVHENI)) ZZW(:) = MAX( ZZW(:)+ZCIT(:),ZCIT(:) ) -!$acc end kernels -!acc update self(GNEGT) -!acc update self(ZZW) #ifndef _OPENACC PCIT(:,:,:) = MAX( UNPACK( ZZW(:),MASK=GNEGT(:,:,:),FIELD=0.0 ) , & PCIT(:,:,:) ) #else -!$acc kernels ZW(:,:,:) = 0.0 DO JL=1,INEGT ZW(I1(JL),I2(JL),I3(JL)) = ZZW(JL) END DO -!$acc end kernels -!$acc kernels PCIT(:,:,:) = MAX( ZW(:,:,:), PCIT(:,:,:) ) !$acc end kernels #endif @@ -2625,14 +2640,12 @@ INTEGER :: JL ! and PACK intrinsics !------------------------------------------------------------------------------- ! !* 5.1 cloud droplet riming of the aggregates -! -!$acc kernels - ZZW1(:,:) = 0.0 -!$acc end kernels ! ALLOCATE(GRIM(IMICRO)) ALLOCATE(I1(IMICRO)) !I1 is bigger than necessary but it easier to do it now (instead of computing IGRIM before allocating I1) +! !$acc kernels + ZZW1(:,:) = 0.0 ! GRIM(:) = (ZRCT(:)>0.0) .AND. (ZRST(:)>0.0) .AND. & GRIM(:) = (ZRCT(:)>XRTMIN(2)) .AND. (ZRST(:)>XRTMIN(5)) .AND. & (ZRCS(:)>0.0) .AND. (ZZT(:)<XTT) @@ -2657,18 +2670,20 @@ INTEGER :: JL ! and PACK intrinsics #ifndef _OPENACC ZVEC1(:) = PACK( ZLBDAS(:),MASK=GRIM(:) ) #else -!$acc kernels +!$acc kernels default(none) & +!$acc & copyin(XRIMINTP1,XEXCRIMSS,XGAMINC_RIM1,XGAMINC_RIM2) & +!$acc & present(GRIM,ZLBDAS,ZRHODREF,ZLSFACT,ZLVFACT,ZZW1,IVEC2,ZVEC1,ZVEC2,ZRCT,ZRCS,ZRSS,ZTHS,ZZW) & +!$acc & copyin(XEXCRIMSG,XEXSRIMCG) & +!$acc & present(GWORK,ZRGS) DO JL=1,IGRIM ZVEC1(JL) = ZLBDAS(I1(JL)) END DO -!$acc end kernels #endif ! ! 5.1.2 find the next lower indice for the ZLBDAS in the geometrical ! set of Lbda_s used to tabulate some moments of the incomplete ! gamma function ! -!$acc kernels ZVEC2(:) = MAX( 1.00001, MIN( FLOAT(NGAMINC)-0.00001, & #ifndef MNH_BITREP XRIMINTP1 * LOG( ZVEC1(:) ) + XRIMINTP2 ) ) @@ -2683,23 +2698,17 @@ INTEGER :: JL ! and PACK intrinsics ! ZVEC1(:) = XGAMINC_RIM1( IVEC2(:)+1 )* ZVEC2(:) & - XGAMINC_RIM1( IVEC2(:) )*(ZVEC2(:) - 1.0) -!$acc end kernels #ifndef _OPENACC ZZW(:) = UNPACK( VECTOR=ZVEC1(:),MASK=GRIM,FIELD=0.0 ) #else -!$acc kernels ZZW(:) = 0.0 DO JL=1,IGRIM ZZW(I1(JL)) = ZVEC1(JL) END DO -!$acc end kernels #endif ! ! 5.1.4 riming of the small sized aggregates ! -!$acc kernels default(none) & -!$acc & copyin(XEXCRIMSS,XGAMINC_RIM2) & -!$acc & present(GRIM,ZLBDAS,ZRHODREF,ZLSFACT,ZLVFACT,ZZW1,IVEC2,ZVEC1,ZVEC2,ZRCT,ZRCS,ZRSS,ZTHS) WHERE ( GRIM(:) ) #ifndef MNH_BITREP ZZW1(:,1) = MIN( ZRCS(:), & @@ -2722,23 +2731,17 @@ INTEGER :: JL ! and PACK intrinsics ! ZVEC1(:) = XGAMINC_RIM2( IVEC2(:)+1 )* ZVEC2(:) & - XGAMINC_RIM2( IVEC2(:) )*(ZVEC2(:) - 1.0) -!$acc end kernels #ifndef _OPENACC ZZW(:) = UNPACK( VECTOR=ZVEC1(:),MASK=GRIM,FIELD=0.0 ) #else -!$acc kernels ZZW(:) = 0.0 DO JL=1,IGRIM ZZW(I1(JL)) = ZVEC1(JL) END DO -!$acc end kernels #endif ! ! 5.1.6 riming-conversion of the large sized aggregates into graupeln ! -! -!$acc kernels default(none) copyin(XEXCRIMSG,XEXSRIMCG) & -!$acc & present(GRIM,GWORK,ZLBDAS,ZRHODREF,ZLSFACT,ZLVFACT,ZZW1,ZRCT,ZRCS,ZRSS,ZRGS,ZTHS) GWORK(:) = GRIM(:) .AND. (ZRSS(:)>0.0) WHERE ( GWORK(:) ) #ifndef MNH_BITREP