source: LMDZ6/trunk/libf/phylmd/tend_to_tke.f90

Last change on this file was 5835, checked in by rkazeroni, 2 months ago

For GPU porting of tend_to_tke routine:

  • Put routine into module (speeds up source-to-source transformation)
  • Add "horizontal" comment to specify possible names of horizontal variables
  • Fix wrong dimensionality of pctsrf in the argument declaration (leads to GPU memory allocation problems)
File size: 5.1 KB
RevLine 
[2728]1!***************************************************************************************
2! tend_to_tke.F90
3!*************
4!
5! Subroutine that adds a tendency on the TKE created by the
6! fluxes of momentum retrieved from the wind speed tendencies
7! of the physics.
8!
9! The basic concept is the following:
10! the TKE equation writes  de/dt = -u'w' du/dz -v'w' dv/dz +g/theta dtheta/dz +......
11!
12!
13! We expect contributions to the term u'w' and v'w' that do not come from the Yamada
14! scheme, for instance: gravity waves, drag from high vegetation..... These contributions
15! need to be accounted for.
16! we explicitely calculate the fluxes, integrating the wind speed
17!                        tendency from the top of the atmospher
18!
19!
20!
21! contacts: Frederic Hourdin, Etienne Vignon
22!
23! History:
24!---------
25! - 1st redaction, Etienne, 15/10/2016
26! Ajout des 4 sous surfaces pour la tke
27! on sort l'ajout des tendances du if sur les deux cas, pour ne pas
28! dupliuqer les lignes
29! on enleve le pas de temps qui disprait dans les calculs
30!
31!
32!**************************************************************************************
33
[5835]34!$gpum horizontal klon
35MODULE tend_to_tke_mod
36  PRIVATE
37
38  PUBLIC tend_to_tke
39
40  CONTAINS
41
[3198]42 SUBROUTINE tend_to_tke(dt,plev,exner,temp,windu,windv,dt_a,du_a,dv_a,pctsrf,tke)
[2728]43
44 USE dimphy, ONLY: klon, klev
45 USE indice_sol_mod, ONLY: nbsrf
[3210]46
[5285]47USE yomcst_mod_h
[3210]48IMPLICIT NONE
[2728]49
[5274]50
[2728]51! Declarations
52!==============
53
54
55! Inputs
56!-------
57  REAL dt                   ! Time step [s]
58  REAL plev(klon,klev+1)    ! inter-layer pressure [Pa]
59  REAL temp(klon,klev)      ! temperature [K], grid-cell average or for a one subsurface
60  REAL windu(klon,klev)     ! zonal wind [m/s], grid-cell average or for a one subsurface
61  REAL windv(klon,klev)     ! meridonal wind [m/s], grid-cell average or for a one subsurface
62  REAL exner(klon,klev)     ! Fonction d'Exner = T/theta
63  REAL dt_a(klon,klev)      ! Temperature tendency [K], grid-cell average or for a one subsurface
64  REAL du_a(klon,klev)      ! Zonal wind speed tendency [m/s], grid-cell average or for a one subsurface
65  REAL dv_a(klon,klev)      ! Meridional wind speed tendency [m/s], grid-cell average or for a one subsurface
[5835]66  REAL pctsrf(klon,nbsrf)   ! Turbulent Kinetic energy [m2/s2], grid-cell average or for a subsurface
[2728]67
68! Inputs/Outputs
69!---------------
[3188]70  REAL tke(klon,klev+1,nbsrf+1)       ! Turbulent Kinetic energy [m2/s2], grid-cell average or for a subsurface
[2728]71
72
73! Local
74!-------
75
76
[3210]77  INTEGER i,k,isrf                 ! indices
[2728]78  REAL    masse(klon,klev)          ! mass in the layers [kg/m2]
79  REAL    unsmasse(klon,klev+1)     ! linear mass in the layers [kg/m2]
80  REAL    flux_rhotw(klon,klev+1)   ! flux massique de tempe. pot. rho*u'*theta'
81  REAL    flux_rhouw(klon,klev+1)   ! flux massique de quantit?? de mouvement rho*u'*w' [kg/m/s2]
82  REAL    flux_rhovw(klon,klev+1)   ! flux massique de quantit?? de mouvement rho*v'*w' [kg/m/s2]
83  REAL    tendt(klon,klev)        ! new temperature tke tendency [m2/s2/s]
84  REAL    tendu(klon,klev)        ! new zonal tke tendency [m2/s2/s]
85  REAL    tendv(klon,klev)        ! new meridonal tke tendency [m2/s2/s]
86 
87
88
89
90! First calculations:
91!=====================
92
93      unsmasse(:,:)=0.
94      DO k=1,klev
95         masse(:,k)=(plev(:,k)-plev(:,k+1))/RG
96         unsmasse(:,k)=unsmasse(:,k)+0.5/masse(:,k)
97         unsmasse(:,k+1)=unsmasse(:,k+1)+0.5/masse(:,k)
98      END DO
99
100      tendu(:,:)=0.0
101      tendv(:,:)=0.0
102
103! Method 1: Calculation of fluxes using a downward integration
104!============================================================
105
106
107 
108! Flux calculation
109
110 flux_rhotw(:,klev+1)=0.
111 flux_rhouw(:,klev+1)=0.
112 flux_rhovw(:,klev+1)=0.
113
114   DO k=klev,1,-1
115      flux_rhotw(:,k)=flux_rhotw(:,k+1)+masse(:,k)*dt_a(:,k)/exner(:,k)
116      flux_rhouw(:,k)=flux_rhouw(:,k+1)+masse(:,k)*du_a(:,k)
117      flux_rhovw(:,k)=flux_rhovw(:,k+1)+masse(:,k)*dv_a(:,k)
118   ENDDO
119
120
121! TKE update:
122
123   DO k=2,klev
124      tendt(:,k)=-flux_rhotw(:,k)*(exner(:,k)-exner(:,k-1))*unsmasse(:,k)*RCPD
125      tendu(:,k)=-flux_rhouw(:,k)*(windu(:,k)-windu(:,k-1))*unsmasse(:,k)
126      tendv(:,k)=-flux_rhovw(:,k)*(windv(:,k)-windv(:,k-1))*unsmasse(:,k)
127   ENDDO
128   tendt(:,1)=-flux_rhotw(:,1)*(exner(:,1)-1.)*unsmasse(:,1)*RCPD
129   tendu(:,1)=-1.*flux_rhouw(:,1)*windu(:,1)*unsmasse(:,1)
130   tendv(:,1)=-1.*flux_rhovw(:,1)*windv(:,1)*unsmasse(:,1)
131
132
[3208]133 DO isrf=1,nbsrf
[2728]134    DO k=1,klev
[3198]135       DO i=1,klon
136          IF (pctsrf(i,isrf)>0.) THEN
137            tke(i,k,isrf)= tke(i,k,isrf)+tendu(i,k)+tendv(i,k)+tendt(i,k)
138            tke(i,k,isrf)= max(tke(i,k,isrf),1.e-10)
139          ENDIF
140       ENDDO
[2728]141    ENDDO
142 ENDDO
143
144
[2897]145!  IF (klon==1) THEN
146!  CALL iophys_ecrit('u',klev,'u','',windu)
147!  CALL iophys_ecrit('v',klev,'v','',windu)
148!  CALL iophys_ecrit('t',klev,'t','',temp)
149!  CALL iophys_ecrit('tke1',klev,'tke1','',tke(:,1:klev,1))
150!  CALL iophys_ecrit('tke2',klev,'tke2','',tke(:,1:klev,2))
151!  CALL iophys_ecrit('tke3',klev,'tke3','',tke(:,1:klev,3))
152!  CALL iophys_ecrit('tke4',klev,'tke4','',tke(:,1:klev,4))
153!  CALL iophys_ecrit('theta',klev,'theta','',temp/exner)
154!  CALL iophys_ecrit('Duv',klev,'Duv','',tendu(:,1:klev)+tendv(:,1:klev))
155!  CALL iophys_ecrit('Dt',klev,'Dt','',tendt(:,1:klev))
156!  ENDIF
[2728]157
[3188]158 END SUBROUTINE tend_to_tke
[5835]159
160END MODULE tend_to_tke_mod
Note: See TracBrowser for help on using the repository browser.