From dde37b23caf53dd5fcdb24c11115add7bbdbbee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Riette?= <sebastien.riette@meteo.fr> Date: Mon, 20 Jun 2022 15:20:59 +0200 Subject: [PATCH] S. Riette 20/6/2022 mnh_expand for compute_mf_cloud and shallow_mf --- .../turb/mode_compute_mf_cloud_bigaus.F90 | 18 ++++++++++++--- .../turb/mode_compute_mf_cloud_direct.F90 | 2 +- .../turb/mode_compute_mf_cloud_stat.F90 | 23 +++++++++++++------ src/common/turb/shallow_mf.F90 | 10 ++++++-- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/common/turb/mode_compute_mf_cloud_bigaus.F90 b/src/common/turb/mode_compute_mf_cloud_bigaus.F90 index da0e4f92b..767fc9718 100644 --- a/src/common/turb/mode_compute_mf_cloud_bigaus.F90 +++ b/src/common/turb/mode_compute_mf_cloud_bigaus.F90 @@ -91,7 +91,7 @@ REAL, DIMENSION(D%NIT,D%NKT) :: ZGRAD_Z_RT, & ! & ZSIGMF ! and sqrt(variance) REAL, DIMENSION(D%NIT) :: ZOMEGA_UP_M ! REAL, DIMENSION(D%NIT,D%NKT) :: ZW1 ! working array -INTEGER :: JK ! vertical loop control +INTEGER :: JI, JK ! loop control REAL, DIMENSION(D%NIT,D%NKT) :: ZEMF_M, ZTHV_UP_M, & ! & ZRSAT_UP_M, ZRT_UP_M,& ! Interpolation on mass points & ZFRAC_ICE_UP_M ! @@ -122,6 +122,7 @@ CALL MZF_MF(D, PFRAC_ICE_UP(:,:), ZFRAC_ICE_UP_M(:,:)) !computation of omega star up ZOMEGA_UP_M(:)=0. DO JK=D%NKB,D%NKE-D%NKL,D%NKL + !$mnh_expand_array(JI=D%NIB:D%NIE) !Vertical integration over the entire column but only buoyant points are used !ZOMEGA_UP_M(:)=ZOMEGA_UP_M(:) + & ! ZEMF_M(:,JK) * & @@ -135,28 +136,38 @@ DO JK=D%NKB,D%NKE-D%NKL,D%NKL (ZTHV_UP_M(:,JK)-PTHVM(:,JK)) * & (PZZ(:,JK+D%NKL)-PZZ(:,JK)) / & (PTHM(:,JK) * PRHODREF(:,JK)) + !$mnh_end_expand_array(JI=D%NIB:D%NIE) ENDDO +!$mnh_expand_array(JI=D%NIB:D%NIE) ZOMEGA_UP_M(:)=MAX(ZOMEGA_UP_M(:), 1.E-20) ZOMEGA_UP_M(:)=(CST%XG*ZOMEGA_UP_M(:))**(1./3.) +!$mnh_end_expand_array(JI=D%NIB:D%NIE) !computation of alpha up DO JK=D%NKA,D%NKU,D%NKL + !$mnh_expand_array(JI=D%NIB:D%NIE) ZALPHA_UP_M(:,JK)=ZEMF_M(:,JK)/(PARAMMF%XALPHA_MF*PRHODREF(:,JK)*ZOMEGA_UP_M(:)) + ZALPHA_UP_M(:,JK)=MAX(0., MIN(ZALPHA_UP_M(:,JK), 1.)) + !$mnh_end_expand_array(JI=D%NIB:D%NIE) ENDDO -ZALPHA_UP_M(:,:)=MAX(0., MIN(ZALPHA_UP_M(:,:), 1.)) !computation of sigma of the distribution DO JK=D%NKA,D%NKU,D%NKL + !$mnh_expand_array(JI=D%NIB:D%NIE) ZSIGMF(:,JK)=ZEMF_M(:,JK) * & (ZRT_UP_M(:,JK) - PRTM(:,JK)) * & PDEPTH(:) * ZGRAD_Z_RT(:,JK) / & (PARAMMF%XSIGMA_MF * ZOMEGA_UP_M(:) * PRHODREF(:,JK)) + !$mnh_end_expand_array(JI=D%NIB:D%NIE) ENDDO +!$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ZSIGMF(:,:)=SQRT(MAX(ABS(ZSIGMF(:,:)), 1.E-40)) +!$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ! !* 2. PDF integration ! ------------------------------------------------ ! +!$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) !The mean of the distribution is ZRT_UP !Computation of ZA and ZGAM (=efrc(ZA)) coefficient ZA(:,:)=(ZRSAT_UP_M(:,:)-ZRT_UP_M(:,:))/(sqrt(2.)*ZSIGMF(:,:)) @@ -172,7 +183,8 @@ ZCOND(:,:)=(EXP(-ZA(:,:)**2)-ZA(:,:)*SQRT(CST%XPI)*ZGAM(:,:))*ZSIGMF(:,:)/SQRT(2 ZCOND(:,:)=MAX(ZCOND(:,:), 0.) !due to approximation of ZGAM value, ZCOND could be slightly negative PRC_MF(:,:)=(1.-ZFRAC_ICE_UP_M(:,:)) * ZCOND(:,:) PRI_MF(:,:)=( ZFRAC_ICE_UP_M(:,:)) * ZCOND(:,:) - +!$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) +! IF (LHOOK) CALL DR_HOOK('COMPUTE_MF_CLOUD_BIGAUS',1,ZHOOK_HANDLE) END SUBROUTINE COMPUTE_MF_CLOUD_BIGAUS diff --git a/src/common/turb/mode_compute_mf_cloud_direct.F90 b/src/common/turb/mode_compute_mf_cloud_direct.F90 index 748ef6ece..ba6f5dde3 100644 --- a/src/common/turb/mode_compute_mf_cloud_direct.F90 +++ b/src/common/turb/mode_compute_mf_cloud_direct.F90 @@ -89,7 +89,7 @@ PRC_MF(:,:)=0. PRI_MF(:,:)=0. PCF_MF(:,:)=0. -DO JI=1,D%NIT +DO JI=D%NIB,D%NIE #ifdef REPRO48 JK0=KKLCL(JI)-D%NKL ! first mass level with cloud JK0=MAX(JK0, MIN(D%NKB,D%NKE)) !protection if KKL=1 diff --git a/src/common/turb/mode_compute_mf_cloud_stat.F90 b/src/common/turb/mode_compute_mf_cloud_stat.F90 index c15549060..4b1ca91a2 100644 --- a/src/common/turb/mode_compute_mf_cloud_stat.F90 +++ b/src/common/turb/mode_compute_mf_cloud_stat.F90 @@ -90,6 +90,7 @@ REAL, DIMENSION(D%NIT,D%NKT) :: ZFLXZ REAL, DIMENSION(D%NIT,D%NKT) :: ZT REAL, DIMENSION(D%NIT,D%NKT) :: ZAMOIST, ZATHETA REAL, DIMENSION(D%NIT,D%NKT) :: ZWK +INTEGER :: JI, JK REAL(KIND=JPRB) :: ZHOOK_HANDLE ! !* 0.2 initialisation @@ -115,14 +116,17 @@ IF (KRRL > 0) THEN ! CALL MZM_MF(D, PTHLM(:,:), ZFLXZ(:,:)) CALL GZ_M_W_MF(D, PTHLM(:,:), PDZZ(:,:), ZWK(:,:)) + !$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ZFLXZ(:,:) = -2 * PARAMMF%XTAUSIGMF * PEMF(:,:)*(PTHL_UP(:,:)-ZFLXZ(:,:)) * ZWK(:,:) -! -! Avoid negative values + ! + ! Avoid negative values ZFLXZ(:,:) = MAX(0.,ZFLXZ(:,:)) - + !$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) CALL MZF_MF(D, ZFLXZ(:,:), PSIGMF(:,:)) + !$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) PSIGMF(:,:) = PSIGMF(:,:) * ZATHETA(:,:)**2 + !$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ! ! @@ -133,18 +137,23 @@ IF (KRRL > 0) THEN ! CALL MZM_MF(D, PRTM(:,:), ZFLXZ(:,:)) CALL GZ_M_W_MF(D, PRTM(:,:), PDZZ(:,:), ZWK(:,:)) + !$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ZFLXZ(:,:) = -2 * PARAMMF%XTAUSIGMF * PEMF(:,:)*(PRT_UP(:,:)-ZFLXZ(:,:)) * ZWK(:,:) -! -! Avoid negative values + ! + ! Avoid negative values ZFLXZ(:,:) = MAX(0.,ZFLXZ(:,:)) -! + !$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) CALL MZF_MF(D, ZFLXZ(:,:), ZWK(:,:)) + !$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) PSIGMF(:,:) = PSIGMF(:,:) + ZAMOIST(:,:) **2 * ZWK(:,:) + !$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ! ! 1.3 Vertical part of Sigma_s ! - PSIGMF(:,:) = SQRT( MAX (PSIGMF(:,:) , 0.) ) + !$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) + PSIGMF(:,:) = SQRT( MAX (PSIGMF(:,:) , 0.) ) + !$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ELSE PSIGMF(:,:) = 0. END IF diff --git a/src/common/turb/shallow_mf.F90 b/src/common/turb/shallow_mf.F90 index 6eef6acc9..f3ff7848d 100644 --- a/src/common/turb/shallow_mf.F90 +++ b/src/common/turb/shallow_mf.F90 @@ -181,6 +181,7 @@ REAL, DIMENSION(D%NIT,D%NKT) :: ZRSAT_UP ! Rsat in updraft LOGICAL :: GENTR_DETR ! flag to recompute entrainment, detrainment and mass flux INTEGER, DIMENSION(D%NIT,D%NKT) :: IERR +INTEGER :: JI, JK ! REAL(KIND=JPRB) :: ZHOOK_HANDLE !------------------------------------------------------------------------ @@ -199,9 +200,11 @@ ENDIF ! Thermodynamics functions ZFRAC_ICE(:,:) = 0. IF (KRR.GE.4) THEN + !$mnh_expand_where(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) WHERE(PRM(:,:,2)+PRM(:,:,4) > 1.E-20) ZFRAC_ICE(:,:) = PRM(:,:,4) / (PRM(:,:,2)+PRM(:,:,4)) ENDWHERE + !$mnh_end_expand_where(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ENDIF CALL COMPUTE_FRAC_ICE(HFRAC_ICE,NEB,ZFRAC_ICE(:,:),PTHM(:,:)*PEXNM(:,:), IERR(:,:)) @@ -211,8 +214,9 @@ CALL THL_RT_FROM_TH_R_MF(D, CST, KRR,KRRL,KRRI, & ZTHLM, ZRTM ) ! Virtual potential temperature at t-dt +!$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ZTHVM(:,:) = PTHM(:,:)*((1.+CST%XRV / CST%XRD *PRM(:,:,1))/(1.+ZRTM(:,:))) - +!$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) ! !!! 2. Compute updraft !!! --------------- @@ -283,7 +287,9 @@ CALL COMPUTE_MF_CLOUD(D, CST, PARAMMF, KRR, KRRL, KRRI, & !!! 3. Compute fluxes of conservative variables and their divergence = tendency !!! ------------------------------------------------------------------------ ! -ZEMF_O_RHODREF=PEMF/PRHODREF +!$mnh_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) +ZEMF_O_RHODREF(:,:)=PEMF(:,:)/PRHODREF(:,:) +!$mnh_end_expand_array(JI=D%NIB:D%NIE,JK=D%NKTB:D%NKTE) IF ( PIMPL_MF > 1.E-10 ) THEN CALL MF_TURB(D, KSV, OMIXUV, & -- GitLab