Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ecbuild and switch argument intent from out to inout #15

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ projects :

- ecbuild :
git : https://github.com/ecmwf/ecbuild
version : 3.7.0
version : 3.8.4
bundle : false

- loki :
Expand Down
140 changes: 70 additions & 70 deletions src/cloudsc2_tl_loki/cloudsc2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ SUBROUTINE CLOUDSC2 ( &
! *PQM1* SPECIFIC HUMIDITY AT T-1 KG/KG
! *PQS* SATURATION SPECIFIC HUMIDITY KG/KG
! *PTM1* TEMPERATURE AT T-1 K
! *PL* CLOUD LIQUID WATER KG/KG
! *PI* CLOUD ICE KG/KG
! *PL* CLOUD LIQUID WATER KG/KG
! *PI* CLOUD ICE KG/KG
! *PAPHP1* PRESSURE AT HALF LEVELS AT T-1 PA [#]
! *PAPP1* PROVISIONAL PRESSURE ON FULL LEVELS PA
! *PLUDE* DETRAINED LIQUID WATER KG/(M3*S)
Expand All @@ -65,17 +65,17 @@ SUBROUTINE CLOUDSC2 ( &
! *PMFD* MASS FLUX IN CONVECTIVE DOWNDRAFTS KG/(M2*S)
! *PGTENT* ACCUMULATED TEMPERATURE TENDENCY K/S
! *PGTENQ* ACCUMULATED MOISTURE TENDENCY KG/(KG S)
! *PGTENL* ACCUMULATED CLOUD LIQUID WATER TENDENCY KG/(KG S)
! *PGTENI* ACCUMULATED CLOUD ICE TENDENCY KG/(KG S)
! *PSUPSAT* MOISTURE TENDENCY FROM SUPERSATURATION
! *PGTENL* ACCUMULATED CLOUD LIQUID WATER TENDENCY KG/(KG S)
! *PGTENI* ACCUMULATED CLOUD ICE TENDENCY KG/(KG S)
! *PSUPSAT* MOISTURE TENDENCY FROM SUPERSATURATION
! (STORED FROM PREVIOUS TIME-STEP) KG/KG

! OUTPUT PARAMETERS (REAL):

! *PTENT* PROCESS TEMPERATURE TENDENCY K/S
! *PTENQ* PROCESS MOISTURE TENDENCY KG/(KG S)
! *PTENL* PROCESS CLOUD LIQUID WATER TENDENCY KG/(KG S)
! *PTENI* PROCESS CLOUD ICE TENDENCY KG/(KG S)
! *PTENL* PROCESS CLOUD LIQUID WATER TENDENCY KG/(KG S)
! *PTENI* PROCESS CLOUD ICE TENDENCY KG/(KG S)
! *PCLC* CLOUD COVER OF INDIVIDUAL LAYER
! *PFHPSL* ENTHALPY FLUX DUE TO LARGE SCALE RAIN J/(M2*S)
! *PFHPSN* ENTHALPY FLUX DUE TO LARGE SCALE SNOW J/(M2*S)
Expand Down Expand Up @@ -122,40 +122,40 @@ SUBROUTINE CLOUDSC2 ( &
TYPE(TEPHLI) :: YPHLI
TYPE(TECLD) :: YCLD
TYPE(TECLDP) :: YCLDP
INTEGER(KIND=JPIM),INTENT(IN) :: KLON
INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
INTEGER(KIND=JPIM),INTENT(IN) :: KIDIA
INTEGER(KIND=JPIM),INTENT(IN) :: KFDIA
INTEGER(KIND=JPIM),INTENT(IN) :: KTDIA
LOGICAL ,INTENT(IN) :: LDRAIN1D
INTEGER(KIND=JPIM),INTENT(IN) :: KLON
INTEGER(KIND=JPIM),INTENT(IN) :: KLEV
INTEGER(KIND=JPIM),INTENT(IN) :: KIDIA
INTEGER(KIND=JPIM),INTENT(IN) :: KFDIA
INTEGER(KIND=JPIM),INTENT(IN) :: KTDIA
LOGICAL ,INTENT(IN) :: LDRAIN1D
REAL(KIND=JPRB) ,INTENT(IN) :: PTSPHY
REAL(KIND=JPRB) ,INTENT(IN) :: CETA(KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PAPHP1(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(IN) :: PAPP1(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PQM1(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PQS(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PTM1(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PL(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PI(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PLUDE(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PLU(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PMFU(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PMFD(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(OUT) :: PTENT(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(OUT) :: PTENQ(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(OUT) :: PTENL(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(OUT) :: PTENI(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENT(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENQ(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENL(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENI(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PAPHP1(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(IN) :: PAPP1(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PQM1(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PQS(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PTM1(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PL(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PI(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PLUDE(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PLU(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PMFU(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PMFD(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PTENT(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PTENQ(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PTENL(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PTENI(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENT(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENQ(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENL(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PGTENI(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(IN) :: PSUPSAT(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(OUT) :: PCLC(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(OUT) :: PFPLSL(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(OUT) :: PFPLSN(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(OUT) :: PFHPSL(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(OUT) :: PFHPSN(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(OUT) :: PCOVPTOT(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PCLC(KLON,KLEV)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PFPLSL(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PFPLSN(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PFHPSL(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PFHPSN(KLON,KLEV+1)
REAL(KIND=JPRB) ,INTENT(INOUT) :: PCOVPTOT(KLON,KLEV)

! -----------------------------------------------------------------

Expand All @@ -173,7 +173,7 @@ SUBROUTINE CLOUDSC2 ( &
! TUNABLE CONSTANTS (to be moved to include files later)
!=======================================================================

! zscal is a scale factor that linearly reduces the variance between
! zscal is a scale factor that linearly reduces the variance between
! qv=qv-crit and qv-qsat
! 0 = No scaling
! 1 = full scaling (i.e. variance=0 when qv=qsat)
Expand Down Expand Up @@ -208,12 +208,12 @@ SUBROUTINE CLOUDSC2 ( &
REAL(KIND=JPRB) :: ZQPD, ZQCD, ZFWATR, ZRFREEZE2
REAL(KIND=JPRB) :: ZQT, ZQTMST

REAL(KIND=JPRB) :: ZRH1,ZRH2,ZRH3,ZETA2,ZDETA1,ZDETA2
REAL(KIND=JPRB) :: ZRH1,ZRH2,ZRH3,ZETA2,ZDETA1,ZDETA2
REAL(KIND=JPRB) :: ZTRPAUS(KLON)
REAL(KIND=JPRB) :: ZCRH2,ZETA3
REAL(KIND=JPRB) :: ZRHO,ZRODQSDP,ZLDCP,DTDZMO,ZDQSDZ,ZDQC
REAL(KIND=JPRB) :: ZSUPSAT
REAL(KIND=JPRB) :: ZFAC1,ZFAC2,ZFAC3,ZFAC4
REAL(KIND=JPRB) :: ZRHO,ZRODQSDP,ZLDCP,DTDZMO,ZDQSDZ,ZDQC
REAL(KIND=JPRB) :: ZSUPSAT
REAL(KIND=JPRB) :: ZFAC1,ZFAC2,ZFAC3,ZFAC4

REAL(KIND=JPRB) :: ZEPS1,ZEPS2
REAL(KIND=JPRB) :: Z2S, Z5ALCP, ZALDCP, ZCOND1, ZQP, ZTARG
Expand Down Expand Up @@ -343,11 +343,11 @@ SUBROUTINE CLOUDSC2 ( &
!* 3. COMPUTE LAYER CLOUD AMOUNTS
! ---------------------------

! Large loop over KLEV
! Calculates
! Large loop over KLEV
! Calculates
! 1. diagnostic CC and QL
! 2. Convective CC and QL
! 3. Rainfall
! 3. Rainfall

DO JK=KTDIA,KLEV

Expand Down Expand Up @@ -401,13 +401,13 @@ SUBROUTINE CLOUDSC2 ( &
ZRH3=1.0_JPRB
ZDETA2=0.3_JPRB
ZDETA1=0.09_JPRB+0.16_JPRB*(0.4_JPRB-ZETA3)/0.3_JPRB
IF (CETA(JK) < ZETA3) THEN
IF (CETA(JK) < ZETA3) THEN
ZCRH2=ZRH3
ELSE IF (CETA(JK) >= ZETA3 .AND. CETA(JK) < (ZETA3+ZDETA2)) THEN
ELSE IF (CETA(JK) >= ZETA3 .AND. CETA(JK) < (ZETA3+ZDETA2)) THEN
ZCRH2=ZRH3+(ZRH2-ZRH3)*((CETA(JK)-ZETA3)/ZDETA2)
ELSE IF (CETA(JK) >= (ZETA3+ZDETA2) .AND. CETA(JK) < (1.0_JPRB-ZDETA1)) THEN
ELSE IF (CETA(JK) >= (ZETA3+ZDETA2) .AND. CETA(JK) < (1.0_JPRB-ZDETA1)) THEN
ZCRH2=ZRH2
ELSE IF (CETA(JK) >= (1.0_JPRB-ZDETA1)) THEN
ELSE IF (CETA(JK) >= (1.0_JPRB-ZDETA1)) THEN
ZCRH2=ZRH1+(ZRH2-ZRH1)*((1.0_JPRB-CETA(JK))/ZDETA1)**0.5_JPRB
ENDIF
! Allow ice supersaturation at cold temperatures
Expand Down Expand Up @@ -435,7 +435,7 @@ SUBROUTINE CLOUDSC2 ( &
ZQCD=ZQSAT(JL)-ZQCRIT(JL)
PCLC(JL,JK)=1.0_JPRB-SQRT(ZQPD/(ZQCD-ZSCALM(JL,JK)*(ZQT-ZQCRIT(JL))))
ZQC(JL,JK)=(ZSCALM(JL,JK)*ZQPD+(1.0_JPRB-ZSCALM(JL,JK))*ZQCD) &
& *PCLC(JL,JK)**2
& *PCLC(JL,JK)**2
ENDIF
ENDDO

Expand All @@ -451,7 +451,7 @@ SUBROUTINE CLOUDSC2 ( &
ENDIF
IF (LLO1) THEN
PCLC(JL,JK)=PCLC(JL,JK)+&
& (1.0_JPRB-PCLC(JL,JK))*(1.0_JPRB-EXP(-ZLUDE(JL,JK)/PLU(JL,JK+1)))
& (1.0_JPRB-PCLC(JL,JK))*(1.0_JPRB-EXP(-ZLUDE(JL,JK)/PLU(JL,JK+1)))
ZQC(JL,JK)=ZQC(JL,JK)+ZLUDE(JL,JK)
ENDIF
ENDDO
Expand Down Expand Up @@ -482,7 +482,7 @@ SUBROUTINE CLOUDSC2 ( &
ENDDO


! Calculate precipitation overlap.
! Calculate precipitation overlap.
! Simple form based on Maximum Overlap.

DO JL=KIDIA,KFDIA
Expand Down Expand Up @@ -520,7 +520,7 @@ SUBROUTINE CLOUDSC2 ( &
ELSE
ZLCRIT=RCLCRIT*2._JPRB
ENDIF
ZCLDL=ZQLWC(JL,JK)/PCLC(JL,JK) ! in-cloud liquid
ZCLDL=ZQLWC(JL,JK)/PCLC(JL,JK) ! in-cloud liquid
ZD=ZCKCODTL*(1.0_JPRB-EXP(-(ZCLDL/ZLCRIT)**2))
ZLNEW=PCLC(JL,JK)*ZCLDL*EXP(-ZD)
ZPRR=ZQLWC(JL,JK)-ZLNEW
Expand All @@ -537,7 +537,7 @@ SUBROUTINE CLOUDSC2 ( &
ELSE
ZLCRIT=RCLCRIT*2._JPRB
ENDIF
ZCLDI=ZQIWC(JL,JK)/PCLC(JL,JK) ! in-cloud ice
ZCLDI=ZQIWC(JL,JK)/PCLC(JL,JK) ! in-cloud ice
ZD=ZCKCODTI*EXP(0.025_JPRB*(ZTP1(JL,JK)-RTT))*(1.0_JPRB-EXP(-(ZCLDI/ZLCRIT)**2))
ZINEW=PCLC(JL,JK)*ZCLDI*EXP(-ZD)
ZPRS=ZQIWC(JL,JK)-ZINEW
Expand All @@ -557,7 +557,7 @@ SUBROUTINE CLOUDSC2 ( &
ZFWATR=0.0_JPRB
ELSE
ZFWATR=1.0_JPRB
ENDIF
ENDIF

ZRN=ZFWATR*ZDR
ZSN=(1.0_JPRB-ZFWATR)*ZDR
Expand All @@ -568,17 +568,17 @@ SUBROUTINE CLOUDSC2 ( &

ZPRTOT=ZRFLN(JL)+ZSFLN(JL)
LLO2=ZPRTOT>ZEPS2 .AND. ZCOVPCLR(JL)>ZEPS2 .AND. (LEVAPLS2 .OR. LDRAIN1D)
IF (LLO2) THEN
IF (LLO2) THEN

ZPRECLR=ZPRTOT*ZCOVPCLR(JL)/ZCOVPTOT(JL)

! This is the humidity in the moistest zcovpclr region

ZQE=PQS(JL,JK)-(PQS(JL,JK)-ZQLIM(JL))*ZCOVPCLR(JL)/&
& (1.0_JPRB-PCLC(JL,JK))**2
& (1.0_JPRB-PCLC(JL,JK))**2
ZBETA=RG*RPECONS*(SQRT(PAPP1(JL,JK) &
& /PAPHP1(JL,KLEV+1))/5.09E-3_JPRB*ZPRECLR &
& /ZCOVPCLR(JL))**0.5777_JPRB
& /ZCOVPCLR(JL))**0.5777_JPRB

! implicit solution:
ZB=PTSPHY*ZBETA*(PQS(JL,JK)-ZQE)/(1.0_JPRB+ZBETA*PTSPHY*ZCORQS(JL))
Expand Down Expand Up @@ -636,7 +636,7 @@ SUBROUTINE CLOUDSC2 ( &
! IK=JK
! ICALL=0
! CALL CUADJTQS ( KIDIA, KFDIA, KLON, KLEV, IK,&
! & ZPP , ZTP1 , ZQP1 , LLFLAG, ICALL )
! & ZPP , ZTP1 , ZQP1 , LLFLAG, ICALL )
! -----------------------------------
! Manually inlined CUADJTQS
! -----------------------------------
Expand All @@ -657,28 +657,28 @@ SUBROUTINE CLOUDSC2 ( &
ZQP =1.0_JPRB/ZPP(JL)
ZTARG =ZTP1(JL,JK)
ZFOEEW(JL) =R2ES*EXP(Z3ES*(ZTARG -RTT)/(ZTARG -Z4ES))
ZQSAT(JL) =ZQP *ZFOEEW(JL)
ZQSAT(JL) =ZQP *ZFOEEW(JL)
IF (ZQSAT(JL) > ZQMAX) THEN
ZQSAT(JL) =ZQMAX
ENDIF
ZCOR =1.0_JPRB/(1.0_JPRB-RETV *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