!----------------------------------------------------------------------- ! !NCEP_MESO:MODEL_LAYER: HORIZONTAL DIFFUSION ! !----------------------------------------------------------------------- ! #include "nmm_loop_basemacros.h" #include "nmm_loop_macros.h" ! !----------------------------------------------------------------------- ! MODULE MODULE_DIFFUSION_NMM ! !----------------------------------------------------------------------- USE MODULE_MODEL_CONSTANTS !----------------------------------------------------------------------- ! LOGICAL :: SECOND=.TRUE. INTEGER :: KSMUD=1 ! !----------------------------------------------------------------------- ! CONTAINS ! !*********************************************************************** SUBROUTINE HDIFF(NTSD,DT,FIS,DY,HDAC,HDACV & & ,HTM,HBM2,VTM,DETA1,SIGMA & & ,T,Q,U,V,Q2,Z,W,SM,SICE & & ,IHE,IHW,IVE,IVW,INDX3_WRK & & ,IDS,IDE,JDS,JDE,KDS,KDE & & ,IMS,IME,JMS,JME,KMS,KME & & ,ITS,ITE,JTS,JTE,KTS,KTE) !*********************************************************************** !$$$ SUBPROGRAM DOCUMENTATION BLOCK ! . . . ! SUBPROGRAM: HDIFF HORIZONTAL DIFFUSION ! PRGRMMR: JANJIC ORG: W/NP22 DATE: 93-11-17 ! ! ABSTRACT: ! HDIFF CALCULATES THE CONTRIBUTION OF THE HORIZONTAL DIFFUSION ! TO THE TENDENCIES OF TEMPERATURE, SPECIFIC HUMIDITY, WIND ! COMPONENTS, AND TURBULENT KINETIC ENERGY AND THEN UPDATES THOSE ! VARIABLES. A SECOND-ORDER NONLINEAR SCHEME SIMILAR TO ! SMAGORINSKY'S IS USED WHERE THE DIFFUSION COEFFICIENT IS ! A FUNCTION OF THE DEFORMATION FIELD AND OF THE TURBULENT ! KINETIC ENERGY. ! ! PROGRAM HISTORY LOG: ! 87-06-?? JANJIC - ORIGINATOR ! 95-03-25 BLACK - CONVERSION FROM 1-D TO 2-D IN HORIZONTAL ! 96-03-28 BLACK - ADDED EXTERNAL EDGE ! 98-10-30 BLACK - MODIFIED FOR DISTRIBUTED MEMORY ! 02-02-07 BLACK - CONVERTED TO WRF STRUCTURE ! 02-08-29 MICHALAKES - ! 02-09-06 WOLFE - ! 03-05-27 JANJIC - ADDED SLOPE ADJUSTMENT ! 04-11-18 BLACK - THREADED ! 06-08-15 JANJIC - ENHANCEMENT AT SLOPING SEA COAST ! ! USAGE: CALL HDIFF FROM SUBROUTINE SOLVE_RUNSTREAM ! ! INPUT ARGUMENT LIST: ! ! OUTPUT ARGUMENT LIST: ! ! OUTPUT FILES: ! NONE ! ! SUBPROGRAMS CALLED: ! ! UNIQUE: NONE ! ! LIBRARY: NONE ! ! ATTRIBUTES: ! LANGUAGE: FORTRAN 90 ! MACHINE : IBM SP !$$$ !*********************************************************************** !----------------------------------------------------------------------- ! IMPLICIT NONE ! !----------------------------------------------------------------------- ! INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE & & ,IMS,IME,JMS,JME,KMS,KME & & ,ITS,ITE,JTS,JTE,KTS,KTE ! INTEGER,INTENT(IN) :: NTSD ! REAL,INTENT(IN) :: DT,DY ! REAL,DIMENSION(KMS:KME),INTENT(IN) :: DETA1 ! REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: FIS,HBM2 & & ,HDAC,HDACV & & ,SM,SICE ! REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(IN) :: HTM,VTM,Z,W ! REAL,DIMENSION(IMS:IME,KMS:KME,JMS:JME),INTENT(INOUT) :: T,Q,Q2 & & ,U,V ! INTEGER, DIMENSION(JMS:JME), INTENT(IN) :: IHE,IHW,IVE,IVW ! !----------------------------------------------------------------------- !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !*** NMM_MAX_DIM is set in configure.wrf and must agree with !*** the value of dimspec q in the Registry/Registry. !!!!!!!!!!!!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !----------------------------------------------------------------------- ! INTEGER,DIMENSION(-3:3,NMM_MAX_DIM,0:6),INTENT(IN) :: INDX3_WRK ! INTEGER,INTENT(IN) :: SIGMA ! !----------------------------------------------------------------------- ! !*** LOCAL VARIABLES ! LOGICAL :: CILINE,WATSLOP ! INTEGER :: I,J,J1_P1,J1_P2,J2_00,J2_M1,J2_P1,J3_00,J3_P1,J3_P2 & & ,J4_00,J4_M1,J4_M2,J4_P1,J4_P2,JJ,JKNT,JSTART,K,KS ! REAL :: DEF_J,DEFSK,DEFTK,HKNE_J,HKSE_J,Q2L,RDY,SLOP,SLOPHC & & ,UTK,VKNE_J,VKSE_J,VTK,DEF1,DEF2,DEF3,DEF4 ! REAL,DIMENSION(ITS-5:ITE+5,KTS:KTE) :: Q2L_IK,SNE,SSE ! !*** TYPE 1 WORKING ARRAY (SEE PFDHT) ! REAL,DIMENSION(ITS-5:ITE+5,KTS:KTE,-2:2) :: DEF ! !*** TYPE 2 WORKING ARRAY (SEE PFDHT) ! REAL,DIMENSION(ITS-5:ITE+5,KTS:KTE,-2:1) :: HKNE,QNE,Q2NE,TNE & & ,UNE,VKNE,VNE ! !*** TYPE 3 WORKING ARRAY (SEE PFDHT) ! REAL,DIMENSION(ITS-5:ITE+5,KTS:KTE,-1:2) :: HKSE,QSE,Q2SE,TSE & & ,USE,VKSE,VSE ! !*** TYPE 4 WORKING ARRAY (SEE PFDHT) ! REAL,DIMENSION(ITS-5:ITE+5,KTS:KTE,-1:1) :: CKE,QDIF,Q2DIF & & ,TDIF,UDIF,VDIF ! !----------------------------------------------------------------------- !*********************************************************************** !----------------------------------------------------------------------- ! JSTART=MYJS2 !----------------------------------------------------------------------- ! SLOPHC=SLOPHT*SQRT(2.)*0.5 RDY=1./DY ! !----------------------------------------------------------------------- !*** !*** DIFFUSING Q2 AT GROUND LEVEL DOES NOT MATTER !*** BECAUSE USTAR2 IS RECALCULATED !*** !----------------------------------------------------------------------- !*** MARCH NORTHWARD THROUGH THE SOUTHERNMOST SLABS TO BEGIN !*** FILLING THE MAIN WORKING ARRAYS WHICH ARE MULTI-DIMENSIONED !*** IN J BECAUSE THEY ARE DIFFERENCED OR AVERAGED IN J. !----------------------------------------------------------------------- ! DO J=-2,2 DO K=KTS,KTE DO I=ITS-5,ITE+5 DEF(I,K,J)=0. ENDDO ENDDO ENDDO ! DO J=-2,1 DO K=KTS,KTE DO I=ITS-5,ITE+5 TNE(I,K,J)=0. QNE(I,K,J)=0. Q2NE(I,K,J)=0. HKNE(I,K,J)=0. UNE(I,K,J)=0. VNE(I,K,J)=0. VKNE(I,K,J)=0. ENDDO ENDDO ENDDO ! DO J=-1,2 DO K=KTS,KTE DO I=ITS-5,ITE+5 TSE(I,K,J)=0. QSE(I,K,J)=0. Q2SE(I,K,J)=0. HKSE(I,K,J)=0. USE(I,K,J)=0. VSE(I,K,J)=0. VKSE(I,K,J)=0. ENDDO ENDDO ENDDO !----------------------------------------------------------------------- ! !$omp parallel do & !$omp& private(def_j,def1,def2,def3,def4,defsk,deftk,i,j,jj,k,q2l) DO J=-2,1 JJ=JSTART+J ! DO K=KTS,KTE DO I=MYIS_P1,MYIE_P1 DEFTK=U(I+IHE(JJ),K,JJ)-U(I+IHW(JJ),K,JJ) & & -V(I,K,JJ+1)+V(I,K,JJ-1) DEFSK=U(I,K,JJ+1)-U(I,K,JJ-1) & & +V(I+IHE(JJ),K,JJ)-V(I+IHW(JJ),K,JJ) Q2L=MAX(Q2(I,K,JJ),EPSQ2) IF(Q2L<=EPSQ2)Q2L=0. ! DEF1=W(I+IHW(JJ),K,JJ-1)-W(I,K,JJ) DEF2=W(I+IHE(JJ),K,JJ-1)-W(I,K,JJ) DEF3=W(I+IHW(JJ),K,JJ+1)-W(I,K,JJ) DEF4=W(I+IHE(JJ),K,JJ+1)-W(I,K,JJ) ! DEF_J=DEFTK*DEFTK+DEFSK*DEFSK+DEF1*DEF1+DEF2*DEF2+ & & DEF3*DEF3+DEF4*DEF4+SCQ2*Q2L DEF_J=SQRT(DEF_J+DEF_J)*HBM2(I,JJ) DEF_J=MAX(DEF_J,DEFC) DEF_J=MIN(DEF_J,DEFM) DEF_J=DEF_J*0.1 DEF(I,K,J)=DEF_J ENDDO ENDDO ! ENDDO !----------------------------------------------------------------------- ! !$omp parallel do & !$omp& private(hkne_j,i,j,jj,k,slop,sne,vkne_j) DO J=-2,0 JJ=JSTART+J ! !----------------------------------------------------------------------- !*** SLOPE SWITCHES FOR MOISTURE !----------------------------------------------------------------------- ! IF(SIGMA==1)THEN DO K=KTS,KTE ! !----------------------------------------------------------------------- !*** PRESSURE DOMAIN !----------------------------------------------------------------------- ! IF(DETA1(K)>0.)THEN DO I=MYIS_P1,MYIE1_P1 SNE(I,K)=1. ENDDO ! !----------------------------------------------------------------------- !*** SIGMA DOMAIN !----------------------------------------------------------------------- ! ELSE DO I=MYIS_P1,MYIE1_P1 SLOP=ABS((Z(I+IHE(JJ),K,JJ+1)-Z(I,K,JJ))*RDY) ! CILINE=((SM(I+IHE(JJ),JJ+1)/=SM(I,JJ)) .OR. & (SICE(I+IHE(JJ),JJ+1)/=SICE(I,JJ))) ! WATSLOP=(SM(I+IHE(JJ),JJ+1)==1.0 .AND. & SM(I,JJ)==1.0 .AND. SLOP/=0.) ! IF(SLOP0.)THEN DO I=MYIS_P1,MYIE1_P1 SSE(I,K)=1. ENDDO ! !----------------------------------------------------------------------- !*** SIGMA DOMAIN !----------------------------------------------------------------------- ! ELSE DO I=MYIS_P1,MYIE1_P1 SLOP=ABS((Z(I+IHE(JJ),K,JJ-1)-Z(I,K,JJ))*RDY) ! CILINE=((SM(I+IHE(JJ),JJ-1)/=SM(I,JJ)) .OR. & (SICE(I+IHE(JJ),JJ-1)/=SICE(I,JJ))) ! WATSLOP=(SM(I+IHE(JJ),JJ-1)==1.0 .AND. & SM(I,JJ)==1.0 .AND. SLOP/=0.) ! IF(SLOP0.)THEN DO I=MYIS_P1,MYIE1_P1 SNE(I,K)=1. SSE(I,K)=1. ENDDO ! !----------------------------------------------------------------------- !*** SIGMA DOMAIN !----------------------------------------------------------------------- ! ELSE DO I=MYIS_P1,MYIE1_P1 SLOP=ABS((Z(I+IHE(J+1),K,J+2)-Z(I,K,J+1))*RDY) ! CILINE=((SM(I+IHE(J+1),J+2)/=SM(I,J+1)) .OR. & (SICE(I+IHE(J+1),J+2)/=SICE(I,J+1))) ! WATSLOP=(SM(I+IHE(J+1),J+2)==1.0 .AND. & SM(I,J+1)==1.0 .AND. SLOP/=0.) ! IF(SLOP