SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
flxsurf3bx.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 !-------------------------------------- LICENCE BEGIN ------------------------------------
6 !Environment Canada - Atmospheric Science and Technology License/Disclaimer,
7 ! version 3; Last Modified: May 7, 2008.
8 !This is free but copyrighted software; you can use/redistribute/modify it under the terms
9 !of the Environment Canada - Atmospheric Science and Technology License/Disclaimer
10 !version 3 or (at your option) any later version that should be found at:
11 !http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html
12 !
13 !This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 !without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 !See the above mentioned License/Disclaimer for more details.
16 !You should have received a copy of the License/Disclaimer along with this software;
17 !if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec),
18 !CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
19 !-------------------------------------- LICENCE END --------------------------------------
20 !copyright (C) 2001 MSC-RPN COMM %%%RPNPHY%%%
21 !!!S/P FLXSURF3
22 !
23  SUBROUTINE flxsurf3bx(CMU, CTU, RIB, FTEMP, FVAP, ILMO, &
24  & ue, fcor, ta , qa , zu, zt, va, &
25  & tg , qg , h , z0 , z0t, &
26  & lzz0, lzz0t, fm, fh, n )
27 !
28  USE yomhook ,ONLY : lhook, dr_hook
29  USE parkind1 ,ONLY : jprb
30 !RJ: added modi, after freeform conversion
31  USE modi_vslog
32 !
33  IMPLICIT NONE
34  INTEGER :: n
35  REAL :: cmu(n),ctu(n),rib(n),fcor(n),ilmo(n)
36  REAL :: ftemp(n),fvap(n),ta(n),qa(n),zu(n),zt(n),va(n)
37  REAL :: tg(n),qg(n),h(n),z0(n),ue(n)
38  REAL :: z0t(n),lzz0(n),lzz0t(n)
39  REAL :: fm(n),fh(n)
40 !
41 !Author
42 ! Y.Delage (Jul 1990)
43 !Revision
44 ! 001 G. Pellerin (Jun 94) New function for unstable case
45 ! 002 G. Pellerin (Jui 94) New formulation for stable case
46 ! 003 B. Bilodeau (Nov 95) Replace VK by KARMAN
47 ! 004 M. Desgagne (Dec 95) Add safety code in function ff
48 ! and ensures that RIB is non zero
49 ! 005 R. Sarrazin (Jan 96) Correction for H
50 ! 006 C. Girard (Nov 95) - Diffuse T instead of Tv
51 ! 007 G. Pellerin (Feb 96) Revised calculation for H (stable)
52 ! 008 G. Pellerin (Feb 96) Remove corrective terms to CTU
53 ! 009 Y. Delage and B. Bilodeau (Jul 97) - Cleanup
54 ! 010 Y. Delage (Feb 98) - Addition of HMIN
55 ! 011 D. Talbot and Y. Delage (Jan 02) -
56 ! Correct bug of zero divide by dg in loop 35
57 ! 012 Y. Delage (Oct 03) - Set top of surface layer at ZU +Z0
58 ! - Output UE instead of UE**2 and rename subroutine
59 ! - Change iteration scheme for stable case
60 ! - Introduce log-linear profile for near-neutral stable cases
61 ! - set VAMIN inside flxsurf and initialise ILMO and H
62 ! - Put stability functions into local functions via stabfunc.h
63 ! 013 Y. Delage (Sep 04) - Input of wind and temperature/humidity
64 ! at different levels
65 ! 014 R. McTaggart-Cowan and B. Bilodeau (May 2006) -
66 ! Clean up stabfunc.h
67 ! 015 L. Spacek (Dec 07) - Correction of the log-linear profile
68 ! Double precision for rib calculations
69 !
70 !Object
71 ! to calculate surface layer transfer coefficients and fluxes
72 !
73 !Arguments
74 !
75 ! - Output -
76 ! CMU transfer coefficient of momentum times UE
77 ! CTU transfer coefficient of temperature times UE
78 ! RIB bulk Richardson number
79 ! FTEMP temperature flux
80 ! FVAP vapor flux
81 ! ILMO (1/length of Monin-Obukov)
82 ! UE friction velocity
83 ! H height of the boundary layer
84 ! FM momentum stability function
85 ! FH heat stability function
86 ! LZZ0 log ((zu+z0)/z0)
87 ! LZZ0T log ((zt+z0)/z0t)
88 !
89 ! - Input -
90 ! FCOR Coriolis factor
91 ! ZU height of wind input (measured from model base at topo height + Z0)
92 ! ZT height of temperature and humidity input
93 ! TA potential temperature at ZT
94 ! QA specific humidity at ZT
95 ! VA wind speed at ZU
96 ! TG surface temperature
97 ! QG specific humidity at the surface
98 ! Z0 roughness length for momentum flux calculations
99 ! Z0T roughness length for heat/moisture flux calculations
100 ! N horizontal dimension
101 !
102 !
103 !RJ #include "surfcon.h"
104 !RJ LOGICAL :: INIT
105 ! PHYSICAL CONSTANTS
106  REAL,PARAMETER :: cpd =.100546e+4 ! J K-1 kg-1 ! specific heat of dry air
107  REAL,PARAMETER :: cpv =.186946e+4 ! J K-1 kg-1 ! specific heat of water vapour
108  REAL,PARAMETER :: rgasd =.28705e+3 ! J K-1 kg-1 ! gas constant for dry air
109  REAL,PARAMETER :: rgasv =.46151e+3 ! J K-1 kg-1 ! gas constant for water vapour
110  REAL,PARAMETER :: trpl =.27316e+3 ! K ! triple point of water
111  REAL,PARAMETER :: tcdk =.27315e+3 ! ! conversion from kelvin to celsius
112  REAL,PARAMETER :: rauw =.1e+4 ! ! density of liquid H2O
113  REAL,PARAMETER :: eps1 =.62194800221014 ! ! RGASD/RGASV
114  REAL,PARAMETER :: eps2 =.3780199778986 ! ! 1 - EPS1
115  REAL,PARAMETER :: delta =.6077686814144 ! ! 1/EPS1 - 1
116  REAL,PARAMETER :: cappa =.28549121795 ! ! RGASD/CPD
117  REAL,PARAMETER :: tgl =.27316e+3 ! K ! ice temperature in the atmosphere
118  REAL,PARAMETER :: consol =.1367e+4 ! W m-2 ! solar constant
119  REAL,PARAMETER :: grav =.980616e+1 ! M s-2 ! gravitational acceleration
120  REAL,PARAMETER :: rayt =.637122e+7 ! M ! mean radius of the earth
121  REAL,PARAMETER :: stefan =.566948e-7 ! J m-2 s-1 K-4 ! Stefan-Boltzmann constant
122  REAL,PARAMETER :: pi =.314159265359e+1 ! ! PI constant = ACOS(-1)
123  REAL,PARAMETER :: omega =.7292e-4 ! s-1 ! angular speed of rotation of the earth
124  REAL,PARAMETER :: knams =.514791 ! ! conversion from knots to m/s
125  REAL,PARAMETER :: stlo =.6628486583943e-3 ! K s2 m-2 ! Schuman-Newell Lapse Rate
126  REAL,PARAMETER :: karman =.35 ! ! Von Karman constant
127  REAL,PARAMETER :: ric =.2 ! ! Critical Richardson number
128  REAL,PARAMETER :: chlc =.2501e+7 ! J kg-1 ! latent heat of condensation
129  REAL,PARAMETER :: chlf =.334e+6 ! J kg-1 ! latent heat of fusion
130  REAL,PARAMETER :: t1s =.27316e+3 ! K ! constant used to calculate L/Cp in fcn HTVOCP
131  REAL,PARAMETER :: t2s =.25816e+3 ! K ! constant used to calculate L/Cp in fcn HTVOCP
132  REAL,PARAMETER :: aw =.3135012829948e+4 ! ! constant used to calculate L/Cp in fcn HTVOCP
133  REAL,PARAMETER :: bw =.2367075766316e+1 ! ! constant used to calculate L/Cp in fcn HTVOCP
134  REAL,PARAMETER :: ai =.2864887713087e+4 ! ! constant used to calculate L/Cp in fcn HTVOCP
135  REAL,PARAMETER :: bi =.166093131502 ! ! constant used to calculate L/Cp in fcn HTVOCP
136  REAL,PARAMETER :: slp =.6666666666667e-1 ! ! constant used to calculate L/Cp in fcn HTVOCP
137 
138 !RJ #include "consphy.h"
139 ! INITIALIZES THE CONSTANTS FOR THE COMMONS OF THE FLXSURF3 ROUTINE FROM
140 ! CANADIAN METEOROLOGICAL CENTER
141  REAL,PARAMETER :: as = 12.
142  REAL,PARAMETER :: asx = 5.
143  REAL,PARAMETER :: ci = 40.
144  REAL,PARAMETER :: bs = 1.0
145  REAL,PARAMETER :: beta = 1.0
146  REAL,PARAMETER :: factn = 1.2
147  REAL,PARAMETER :: hmin = 30.
148  REAL,PARAMETER :: angmax= 0.85
149  REAL,PARAMETER :: rac3 = sqrt(3.)
150 !
151 !*
152 !
153  INTEGER,PARAMETER :: jdbl=8
154 !
155  INTEGER :: j
156  INTEGER :: it
157  INTEGER,PARAMETER :: itmax = 3
158  REAL,PARAMETER :: hmax = 1500.0
159  REAL,PARAMETER :: cormin = 0.7e-4
160  REAL,PARAMETER :: epsln = 1.0e-05
161  REAL,PARAMETER :: vamin = 0.1
162  REAL :: cm,ct,zp
163  REAL :: f,g,dg
164  REAL :: hi,he,hs,unsl
165  REAL(KIND=JDBL) :: dthv,tva,tvs
166  REAL :: hl,u
167  REAL :: cs,xx,xx0,yy,yy0
168  REAL :: zb,dd,ilmox
169  REAL :: df,zz,betsasx
170  REAL :: aa,bb,cc
171  REAL(KIND=JPRB) :: zhook_handle
172 !
173  df(zz)=(1-zz*hi)*sqrt(1+4*as*beta*unsl*zz/(1-zz*hi))
174  cs=as*2.5
175  betsasx=1./asx
176 !
177  IF (lhook) CALL dr_hook('FLXSURF3BX',0,zhook_handle)
178 !
179  DO j=1,n
180  lzz0(j)=1+zu(j)/z0(j)
181  lzz0t(j)=(zt(j)+z0(j))/z0t(j)
182  ENDDO
183 !
184  call vslog(lzz0t,lzz0t,n)
185  call vslog(lzz0 ,lzz0 ,n)
186 !
187  DO j=1,n
188 !
189 ! CALCULATE THE RICHARDSON NUMBER
190  zp=zu(j)**2/(zt(j)+z0(j)-z0t(j))
191  u=max(vamin,va(j))
192  tva=(1.0_jdbl+delta*qa(j))*ta(j)
193  tvs=(1.0_jdbl+delta*qg(j))*tg(j)
194  dthv=tva-tvs
195  rib(j)=grav/(tvs+0.5_jdbl*dthv)*zp*dthv/(u*u)
196  if (rib(j)>=0.0_jdbl) rib(j) = max(rib(j), epsln)
197  if (rib(j)<0.0_jdbl) rib(j) = min(rib(j),-epsln)
198 !
199 ! FIRST APPROXIMATION TO ILMO
200  IF(rib(j)>0.0_jdbl) THEN
201  fm(j)=lzz0(j)+cs*rib(j)/max(2*z0(j),1.0_jdbl)
202  fh(j)=beta*(lzz0t(j)+cs*rib(j))/ &
203  & max(sqrt(z0(j)*z0t(j)),1.0_jdbl)
204  ilmo(j)=rib(j)*fm(j)*fm(j)/(zp*fh(j))
205  f=max(abs(fcor(j)),cormin)
206  h(j)=bs*sqrt(karman*u/(ilmo(j)*f*fm(j)))
207  ELSE
208  fm(j)=lzz0(j)-min(0.7_jdbl+log(1-rib(j)),lzz0(j)-1)
209  fh(j)=beta*(lzz0t(j)-min(0.7_jdbl+log(1-rib(j)),lzz0t(j)-1))
210  ilmo(j)=rib(j)*fm(j)*fm(j)/(zp*fh(j))
211  ENDIF
212  ENDDO
213 !
214 ! - - - - - - - - - BEGINNING OF ITERATION LOOP - - - - - - - - - - -
215  DO 35 it=1,itmax
216  DO 35 j=1,n
217  u=max(vamin,va(j))
218  zp=zu(j)**2/(zt(j)+z0(j)-z0t(j))
219  IF(rib(j)>0.0_jdbl) THEN
220 !----------------------------------------------------------------------
221 ! STABLE CASE
222  ilmo(j)=max(epsln,ilmo(j))
223  hl=(zu(j)+10*z0(j))*factn
224  f=max(abs(fcor(j)),cormin)
225  hs=bs*sqrt(karman*u/(ilmo(j)*f*fm(j)))
226  h(j)=max(hmin,hs,hl,factn/(4*as*beta*ilmo(j)))
227  hi=1/h(j)
228 !CDIR IEXPAND
229  fm(j)=lzz0(j)+psi(zu(j)+z0(j),hi,ilmo(j))-psi(z0(j),hi,ilmo(j))
230 !CDIR IEXPAND
231  fh(j)=beta*(lzz0t(j)+psi(zt(j)+z0(j),hi,ilmo(j))-psi(z0t(j),hi, &
232  & ilmo(j)))
233  unsl=ilmo(j)
234  dg=-zp*fh(j)/(fm(j)*fm(j))*(1+beta*(df(zt(j)+z0(j))-df(z0t(j)))/&
235  & (2*fh(j))-(df(zu(j)+z0(j))-df(z0(j)))/fm(j))
236 !----------------------------------------------------------------------
237 ! UNSTABLE CASE
238  ELSE
239  ilmo(j)=min(0.,ilmo(j))
240 !CDIR IEXPAND
241  fm(j)=fmi(zu(j)+z0(j),z0(j),lzz0(j),ilmo(j),xx,xx0)
242 !CDIR IEXPAND
243  fh(j)=fhi(zt(j)+z0(j),z0t(j),lzz0t(j),ilmo(j),yy,yy0)
244  dg=-zp*fh(j)/(fm(j)*fm(j))*(1+beta/fh(j)*(1/yy-1/yy0)-2/fm(j)* &
245  & (1/xx-1/xx0))
246  ENDIF
247 !----------------------------------------------------------------------
248  IF(it<itmax) THEN
249  g=rib(j)-fh(j)/(fm(j)*fm(j))*zp*ilmo(j)
250  ilmo(j)=ilmo(j)-g/dg
251  ENDIF
252  35 CONTINUE
253 ! - - - - - - - - - END OF ITERATION LOOP - - - - - - - - - - - - - -
254 !
255  DO 80 j=1,n
256  u=max(vamin,va(j))
257  if(asx<as) then
258 !----------------------------------------------------------------------
259 ! CALCULATE ILMO AND STABILITY FUNCTIONS FROM LOG-LINEAR PROFILE
260 ! (SOLUTION OF A QUADRATIC EQATION)
261 !
262  zb=zu(j)/(zt(j)+z0(j)-z0t(j))
263 ! DISCRIMINANT
264  dd=(beta*lzz0t(j)*zb)**2-4*rib(j)*asx*lzz0(j)* &
265  & (beta*lzz0t(j)*zb-lzz0(j))
266  if(rib(j)>0.0_jdbl.and.rib(j)<betsasx.and.dd>=0.) then
267 ! COEFFICIENTS
268  aa=asx*asx*rib(j)-asx
269  bb=-beta*lzz0t(j)*zb+2*rib(j)*asx*lzz0(j)
270  cc=rib(j)*lzz0(j)**2
271 ! SOLUTION
272  if(bb>=0)then
273  ilmox=(-bb-sqrt(dd))/(2*zu(j)*aa)
274  else
275  ilmox=2*cc/(zu(j)*(-bb+sqrt(dd)))
276  endif
277  if(ilmox<ilmo(j)) then
278  ilmo(j)=ilmox
279  fm(j)=lzz0(j)+asx*zu(j)*ilmox
280  fh(j)=beta*lzz0t(j)+asx*(zt(j)+z0(j)-z0t(j))*ilmox
281  endif
282  endif
283  endif
284 !----------------------------------------------------------------------
285  cm=karman/fm(j)
286  ct=karman/fh(j)
287  ue(j)=u*cm
288  cmu(j)=cm*ue(j)
289  ctu(j)=ct*ue(j)
290  if (rib(j)>0.0_jdbl) then
291 ! stable case
292  h(j)=min(h(j),hmax)
293  else
294 ! unstable case
295  f=max(abs(fcor(j)),cormin)
296  he=max(hmin,0.3_jdbl*ue(j)/f)
297  h(j)=min(he,hmax)
298  endif
299  ftemp(j)=-ctu(j)*(ta(j)-tg(j))
300  fvap(j)=-ctu(j)*(qa(j)-qg(j))
301  80 CONTINUE
302  IF (lhook) CALL dr_hook('FLXSURF3BX',1,zhook_handle)
303  CONTAINS
304 !RJ: inlining directly
305 !RJ #include "stabfunc2.h"
306 !
307 ! Internal function FMI
308 ! Stability function for momentum in the unstable regime (ilmo<0)
309 ! Reference: Delage Y. and Girard C. BLM 58 (19-31) Eq. 19
310 !
311  FUNCTION fmi(Z2,Z02,LZZ02,ILMO2,X,X0)
312  IMPLICIT NONE
313 !
314  REAL :: fmi
315  REAL, INTENT(IN ) :: z2,z02,lzz02,ilmo2
316  REAL, INTENT(OUT) :: x,x0
317 !
318  x =(1-ci*z2 *beta*ilmo2)**(0.16666666)
319  x0=(1-ci*z02*beta*ilmo2)**(0.16666666)
320  fmi=lzz02+log((x0+1)**2*sqrt(x0**2-x0+1)*(x0**2+x0+1)**1.5 &
321  & /((x+1)**2*sqrt(x**2-x+1)*(x**2+x+1)**1.5)) &
322  & +rac3*atan(rac3*((x**2-1)*x0-(x0**2-1)*x)/ &
323  & ((x0**2-1)*(x**2-1)+3*x*x0))
324 !
325  RETURN
326  END FUNCTION fmi
327 !
328 ! Internal function FHI
329 ! Stability function for heat and moisture in the unstable regime (ilmo<0)
330 ! Reference: Delage Y. and Girard C. BLM 58 (19-31) Eq. 17
331 !
332  FUNCTION fhi(Z2,Z0T2,LZZ0T2,ILMO2,Y,Y0)
333  IMPLICIT NONE
334 !
335  REAL :: fhi
336  REAL, INTENT(IN ) :: z2,z0t2,lzz0t2,ilmo2
337  REAL, INTENT(OUT) :: y,y0
338 !
339  y =(1-ci*z2 *beta*ilmo2)**(0.33333333)
340  y0=(1-ci*z0t2*beta*ilmo2)**(0.33333333)
341  fhi=beta*(lzz0t2+1.5*log((y0**2+y0+1)/(y**2+y+1))+rac3* &
342  & atan(rac3*2*(y-y0)/((2*y0+1)*(2*y+1)+3)))
343 !
344  RETURN
345  END FUNCTION fhi
346 !
347 ! Internal function psi
348 ! Stability function for momentum in the stable regime (unsl>0)
349 ! Reference : Y. Delage, BLM, 82 (p23-48) (Eqs.33-37)
350 !
351  FUNCTION psi(Z2,HI2,ILMO2)
352  IMPLICIT NONE
353 !
354  REAL :: psi
355  REAL :: a,b,c,d
356  REAL, INTENT(IN ) :: ilmo2,z2,hi2
357 !
358  d = 4*as*beta*ilmo2
359  c = d*hi2 - hi2**2
360  b = d - 2*hi2
361  a = sqrt(1 + b*z2 - c*z2**2)
362  psi = 0.5 * (a-z2*hi2-log(1+b*z2*0.5+a)- &
363  & b/(2*sqrt(c))*asin((b-2*c*z2)/d))
364 !
365  RETURN
366  END FUNCTION psi
367 !
368  END SUBROUTINE flxsurf3bx
real function fhi(Z2, Z0T2, LZZ0T2, ILMO2, Y, Y0)
Definition: flxsurf3bx.F90:332
subroutine vslog(PA, PLOG, N)
Definition: vslog.F90:5
real function fmi(Z2, Z02, LZZ02, ILMO2, X, X0)
Definition: flxsurf3bx.F90:311
real function psi(Z2, HI2, ILMO2)
Definition: flxsurf3bx.F90:351
subroutine flxsurf3bx(CMU, CTU, RIB, FTEMP, FVAP, ILMO, UE, FCOR, TA, QA, ZU, ZT, VA, TG, QG, H, Z0, Z0T, LZZ0, LZZ0T, FM, FH, N)
Definition: flxsurf3bx.F90:23
subroutine dd(CDN, PX)