source: trunk/src/cor30a.pro @ 5

Last change on this file since 5 was 5, checked in by pinsard, 14 years ago

first commit with original work of Praveen

  • Property svn:executable set to *
File size: 9.1 KB
Line 
1;----------------------------------------------------------------------------------------------
2function cor30a, u,us,ts,t,Qs,Q,Rs,Rl,rain,zi,P,zu,zt,zq,lat,jcool,jwave,twave,hwave
3;
4; COARE v3 algorithm to compute fluxes
5;       version with shortened iteration  modified Rt and Rq
6;       uses wave information wave period in s and wave ht in m
7;       no wave, standard coare 2.6 charnock:  jwave=0
8;       Oost et al.  zo=50/2/pi L (u*/c)^4.5 if jwave=1
9;       taylor and yelland  zo=1200 h*(L/h)^4.5 jwave=2
10;
11; u         ;wind speed (m/s)  at height zu (m)
12; us        ;surface current speed in the wind direction (m/s)
13; ts        ;bulk water temperature (C) if jcool=1, interface water T if jcool=0
14; t         ;bulk air temperature (C), height zt
15; Qs        ;bulk water spec hum (g/kg) if jcool=1, ...
16; Q         ;bulk air spec hum (g/kg), height zq
17; Rs        ;downward solar flux (W/m^2)    (modified because of cool skin)
18; Rl        ;downard IR flux (W/m^2)        (modified because of cool skin)
19; rain      ;rain rate (mm/hr)
20; zi        ;PBL depth (m)
21; P         ;Atmos surface pressure (mb)
22; zu        ;wind speed measurement height (m)
23; zt        ;air T measurement height (m)
24; zq        ;air q measurement height (m)
25; lat       ;latitude (deg, N=+)
26; jcool     ;implement cool calculation skin switch, 0=no, 1=yes
27; jwave     ;implement wave dependent roughness model
28; twave     ;wave period (s)
29; hwave     ;wave height (m)
30;
31;Example of values:
32;         u  us  ts  ta   qs   qa   Qsw IRd   r  pbl  Ps   zu   zt  zq lat   
33;x=cor30a(5.5,0,28.7,27.2,24.2,18.5,141.,419.,0.,600.,1010.,15.,15.,15.,0.,1,1,5.,1.) ;sample data stream
34;
35;Result with these sample values with Matlab code:
36;     8.64830      101.640    0.0352910  2.17780e-05  0.000115000  0.000115000
37;    -29.5800     0.175430   -0.0423670 -0.000205610     0.250950  0.000351300
38; 0.000969740      0.00000  8.11390e-05  0.000997340   0.00121410   0.00121400
39; 0.000941350   0.00107910   0.00107910     0.780060
40;
41;Result obtained with this idl routine:
42;     8.64829      101.640    0.0352913  2.17780e-05  0.000115000  0.000115000
43;    -29.5802     0.175432   -0.0423667 -0.000205610     0.250948  0.000351304
44; 0.000969737      0.00000  8.11394e-05  0.000997343   0.00121407   0.00121400
45; 0.000941351   0.00107908   0.00107908     0.780056
46;
47; Maximum error on any parameter: .002 %    validated!
48;
49;----------------------------------------------------------------------------------------------
50
51Qs=Qs/1000.
52Q=Q/1000.
53
54;***********   set constants *************
55pi=!pi
56Beta=1.2
57von=0.4
58fdg=1.00
59tdk=273.16
60;grav=grv(lat)
61grav=9.8
62;*************  air constants ************
63Rgas=287.1
64LLe=(2.501-.00237*ts)*1e6
65cpa=1004.67
66cpv=cpa*(1+0.84*Q)
67rhoa=P*100/(Rgas*(t+tdk)*(1+0.61*Q))
68visa=1.326e-5*(1+6.542e-3*t+8.301e-6*t*t-4.84e-9*t*t*t)
69;************  cool skin constants  *******
70Al=2.1e-5*(ts+3.2)^0.79
71be=0.026
72cpw=4000
73rhow=1022
74visw=1e-6
75tcw=0.6
76bigc=16*grav*cpw*(rhow*visw)^3/(tcw*tcw*rhoa*rhoa)
77wetc=0.622*LLe*Qs/(Rgas*(ts+tdk)^2)
78     
79;***************   wave parameters  *********
80lwave=grav/2/pi*twave^2
81cwave=grav/2/pi*twave
82     
83;**************  compute aux stuff *******
84Rns=Rs*.945
85Rnl=0.97*(5.67e-8*(ts-0.3*jcool+tdk)^4-Rl)
86
87
88
89;***************   Begin bulk loop *******
90     
91;***************  first guess ************
92du=u-us
93dt=ts-t-.0098*zt
94dq=Qs-Q
95ta=t+tdk
96ug=0.5
97dter=0.3 
98dqer=wetc*dter
99ut=sqrt(du*du+ug*ug)
100u10=ut*alog(10./1e-4)/alog(zu/1e-4)
101usr=.035*u10
102zo10=0.011*usr*usr/grav+0.11*visa/usr
103Cd10=(von/alog(10./zo10))^2
104Ch10=0.00115
105Ct10=Ch10/sqrt(Cd10)
106zot10=10/exp(von/Ct10)
107Cd=(von/alog(zu/zo10))^2
108Ct=von/alog(zt/zot10)
109CC=von*Ct/Cd
110Ribcu=-zu/zi/.004/Beta^3
111Ribu=-grav*zu/ta*((dt-dter*jcool)+.61*ta*dq)/ut^2
112nits=3
113;;if (Ribu le 0.) then begin
114;;  zetu=CC*Ribu/(1+Ribu/Ribcu)
115;;endif else begin
116;;  zetu=CC*Ribu*(1+27./9*Ribu/CC)
117;;endelse
118sw=(Ribu le 0.)
119zetu=sw*(CC*Ribu/(1+Ribu/Ribcu))+(1-sw)*(CC*Ribu*(1+27./9*Ribu/CC))
120;;
121L10=zu/zetu
122;;if (zetu gt 50 ) then nits=1
123usr=ut*von/(alog(zu/zo10)-psiu(zu/L10))
124tsr=-(dt-dter*jcool)*von*fdg/(alog(zt/zot10)-psit(zt/L10))
125qsr=-(dq-wetc*dter*jcool)*von*fdg/(alog(zq/zot10)-psit(zq/L10))
126
127tkt=.001
128       
129;;charn=0.011
130;;if (ut gt 10.) then charn=0.011+(ut-10)/(18.-10)*(0.018-0.011)
131;;if (ut gt 18.) then charn=0.018
132charn=(((0.011+(ut-10)/(18.-10)*(0.018-0.011)) > .011) < .018)
133;;
134   
135;***************  bulk loop ************
136for i=1,nits do begin
137  zet=von*grav*zu/ta*(tsr*(1+0.61*Q)+.61*ta*qsr)/(usr*usr)/(1+0.61*Q)
138  case jwave of
139    0: zo=charn*usr*usr/grav+0.11*visa/usr
140    1: zo=50./2/pi*lwave*(usr/cwave)^4.5+0.11*visa/usr ;Oost et al
141    2: zo=1200*hwave*(hwave/lwave)^4.5+0.11*visa/usr  ;Taylor and Yelland
142  endcase
143  rr=zo*usr/visa
144  L=zu/zet
145;;zoq=min([1.15e-4,5.5e-5/rr^.6])
146  zoq=(5.5e-5/rr^.6 < 1.15e-4)
147;;
148  zot=zoq
149  usr=ut*von/(alog(zu/zo)-psiu(zu/L))
150  tsr=-(dt-dter*jcool)*von*fdg/(alog(zt/zot)-psit(zt/L))
151  qsr=-(dq-wetc*dter*jcool)*von*fdg/(alog(zq/zoq)-psit(zq/L))
152  Bf=-grav/ta*usr*(tsr+.61*ta*qsr)
153;;if (Bf gt 0) then begin
154;;  ug=Beta*(Bf*zi)^.333
155;;endif else begin
156;;  ug=.2
157;;endelse
158  sw=(Bf gt 0)
159  ug=sw*(Beta*(Bf*zi)^.333)+(1-sw)*.2
160;;
161  ut=sqrt(du*du+ug*ug)
162  Rnl=0.97*(5.67e-8*(ts-dter*jcool+tdk)^4-Rl)
163  hsb=-rhoa*cpa*usr*tsr
164  hlb=-rhoa*LLe*usr*qsr
165  qout=Rnl+hsb+hlb
166  dels=Rns*(.065+11*tkt-6.6e-5/tkt*(1-exp(-tkt/8.0e-4)))        ; Eq.16 Shortwave
167  qcol=qout-dels
168  alq=Al*qcol+be*hlb*cpw/LLe                                    ; Eq. 7 Buoy flux water
169
170;;  if (alq gt 0) then begin
171;;    xlamx=6./(1+(bigc*alq/usr^4)^.75)^.333                    ; Eq 13 Saunders
172;;    tkt=xlamx*visw/(sqrt(rhoa/rhow)*usr)                      ;Eq.11 Sub. thk
173;;  endif else begin
174;;    xlamx=6.0
175;;;;  tkt=min([.01,xlamx*visw/(sqrt(rhoa/rhow)*usr)])           ;Eq.11 Sub. thk
176;;    tkt=(xlamx*visw/(sqrt(rhoa/rhow)*usr) < .01)
177;;;;
178;;  endelse
179  sw=(alq gt 0)
180  xlamx=sw*(6./(1+(bigc*alq/usr^4)^.75)^.333)+(1-sw)*6.0
181  tkt=sw*(xlamx*visw/(sqrt(rhoa/rhow)*usr))+(1-sw)*(xlamx*visw/(sqrt(rhoa/rhow)*usr) < .01)
182;;
183     
184  dter=qcol*tkt/tcw ;  Eq.12 Cool skin
185  dqer=wetc*dter
186     
187endfor      ;bulk iter loop
188
189tau=rhoa*usr*usr*du/ut                 ;stress
190hsb=-rhoa*cpa*usr*tsr                  ;sens
191hlb=-rhoa*LLe*usr*qsr                  ;lat
192                                       ; net solar Rns
193                                       ; net lw    Rnl
194
195;****************   rain heat flux ********
196dwat=2.11e-5*((t+tdk)/tdk)^1.94                         ;! water vapour diffusivity
197dtmp=(1.+3.309e-3*t-1.44e-6*t*t)*0.02411/(rhoa*cpa)     ;!heat diffusivity
198alfac= 1/(1+(wetc*LLe*dwat)/(cpa*dtmp))                 ;! wet bulb factor
199RF= rain*alfac*cpw*((ts-t-dter*jcool)+(Qs-Q-dqer*jcool)*LLe/cpa)/3600.
200
201
202;y=[[Rns],[-1.*Rnl],[-1.*hlb],[-1.*hsb],[-1.*RF],[tau]]
203
204;;****************   Webb et al. correection  ************
205;wbar=1.61*hlb/LLe/(1+1.61*Q)/rhoa+hsb/rhoa/cpa/ta      ;formulation in hlb already includes webb
206;hl_webb=rhoa*wbar*Q*LLe
207;;**************   compute transfer coeffs relative to ut @meas. ht **********
208;;Cd=tau/rhoa/ut/max([.1,du])
209;Cd=tau/rhoa/ut/(du > .1)
210;;;
211Ch=-usr*tsr/ut/(dt-dter*jcool)
212Ce=-usr*qsr/(dq-dqer*jcool)/ut
213;;************  10-m neutral coeff realtive to ut ********
214;Cdn_10=von*von/alog(10./zo)/alog(10./zo)
215;Chn_10=von*von*fdg/alog(10./zo)/alog(10./zot)
216;Cen_10=von*von*fdg/alog(10./zo)/alog(10./zoq)
217
218y=[[Rns],[-1.*Rnl],[-1.*hlb],[-1.*hsb],[-1.*RF],[tau],[Ch],[Ce]]   
219;;y=[hsb,hlb,tau,zo,zot,zoq,L,usr,tsr,qsr,dter,dqer,tkt,RF,wbar,Cd,Ch,Ce,Cdn_10,Chn_10,Cen_10,ug ]
220;   1   2   3   4  5   6  7  8   9  10   11   12  13  14  15  16 17 18    19      20    21  22
221;       hsb=                    sensible heat flux (w/m^2)
222;       hlb=                    latent heat flux (w/m^2)
223;       RF=                     rain heat flux(w/m^2)
224;       wbar=                   webb mean w (m/s)
225;       tau=                    stress (nt/m^2)
226;       zo=                     velocity roughness length (m)
227;       zot                     temperature roughness length (m)
228;       zoq=                    moisture roughness length (m)
229;       L=                      Monin_Obukhov stability length
230;       usr=                    turbulent friction velocity (m/s), including gustiness
231;       tsr                     temperature scaling parameter (K)
232;       qsr                     humidity scaling parameter (g/g)
233;       dter=                   cool skin temperature depression (K)
234;       dqer=                   cool skin humidity depression (g/g)
235;       tkt=                    cool skin thickness (m)
236;       Cd=                     velocity drag coefficient at zu, referenced to u
237;       Ch=                     heat transfer coefficient at zt
238;       Ce=                     moisture transfer coefficient at zq
239;       Cdn_10=                 10-m velocity drag coeeficient, including gustiness
240;       Chn_10=                 10-m heat transfer coeeficient, including gustiness
241;       Cen_10=                 10-m humidity transfer coeeficient, including gustiness
242
243
244
245return, y
246
247end
248;----------------------------------------------------------------------------------------------
249
Note: See TracBrowser for help on using the repository browser.