/[MITgcm]/MITgcm/pkg/fizhi/fizhi_gwdrag.F
ViewVC logotype

Diff of /MITgcm/pkg/fizhi/fizhi_gwdrag.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by molod, Fri May 20 23:50:52 2005 UTC revision 1.9 by ce107, Thu Jun 16 16:46:12 2005 UTC
# Line 2  C $Header$ Line 2  C $Header$
2  C $Name$  C $Name$
3  #include "FIZHI_OPTIONS.h"  #include "FIZHI_OPTIONS.h"
4        subroutine gwdrag (myid,pz,pl,ple,dpres,pkz,uz,vz,tz,qz,phis_var,        subroutine gwdrag (myid,pz,pl,ple,dpres,pkz,uz,vz,tz,qz,phis_var,
5       .         dudt,dvdt,dtdt,im,jm,lm,bi,bj,istrip,npcs,imglobal)       .         dudt,dvdt,dtdt,im,jm,Lm,bi,bj,istrip,npcs,imglobal)
6  C***********************************************************************  C***********************************************************************
7  C  C
8  C  PURPOSE:  C  PURPOSE:
# Line 13  C  INPUT: Line 13  C  INPUT:
13  C  ======  C  ======
14  C  myid  ....... Process ID  C  myid  ....... Process ID
15  C  pz    ....... Surface Pressure [im,jm]  C  pz    ....... Surface Pressure [im,jm]
16  C  pl    ....... 3D pressure field [im,jm,lm]  C  pl    ....... 3D pressure field [im,jm,Lm]
17  C  ple   ....... 3d pressure at model level edges [im,jm,lm+1]  C  ple   ....... 3d pressure at model level edges [im,jm,Lm+1]
18  C  dpres ....... pressure difference across level [im,jm,lm]  C  dpres ....... pressure difference across level [im,jm,Lm]
19  C  pkz   ....... pressure**kappa [im,jm,lm]  C  pkz   ....... pressure**kappa [im,jm,Lm]
20  C  uz    ....... zonal velocity [im,jm,lm]  C  uz    ....... zonal velocity [im,jm,Lm]
21  C  vz    ....... meridional velocity [im,jm,lm]  C  vz    ....... meridional velocity [im,jm,Lm]
22  C  tz    ....... temperature [im,jm,lm]  C  tz    ....... temperature [im,jm,Lm]
23  C  qz    ....... specific humidity [im,jm,lm]  C  qz    ....... specific humidity [im,jm,Lm]
24  C  phis_var .... topography variance  C  phis_var .... topography variance
25  C  im    ....... number of grid points in x direction  C  im    ....... number of grid points in x direction
26  C  jm    ....... number of grid points in y direction  C  jm    ....... number of grid points in y direction
27  C  lm    ....... number of grid points in vertical  C  Lm    ....... number of grid points in vertical
28  C  istrip ...... 'strip' length for cache size control  C  istrip ...... 'strip' length for cache size control
29  C  npcs  ....... number of strips  C  npcs  ....... number of strips
30  C  imglobal .... (avg) number of longitude points around the globe  C  imglobal .... (avg) number of longitude points around the globe
# Line 38  C Line 38  C
38  C***********************************************************************  C***********************************************************************
39        implicit none        implicit none
40    
 #ifdef ALLOW_DIAGNOSTICS  
 #include "SIZE.h"  
 #include "DIAGNOSTICS_SIZE.h"  
 #include "DIAGNOSTICS.h"  
 #endif  
   
41  c Input Variables  c Input Variables
42  c ---------------  c ---------------
43        integer myid,im,jm,lm,bi,bj,istrip,npcs,imglobal        integer myid,im,jm,Lm,bi,bj,istrip,npcs,imglobal
44        real pz(im,jm)        _RL pz(im,jm)
45        real pl(im,jm,lm)        _RL pl(im,jm,Lm)
46        real ple(im,jm,lm+1)        _RL ple(im,jm,Lm+1)
47        real dpres(im,jm,lm)        _RL dpres(im,jm,Lm)
48        real pkz(im,jm,lm)        _RL pkz(im,jm,Lm)
49        real uz(im,jm,lm)        _RL uz(im,jm,Lm)
50        real vz(im,jm,lm)        _RL vz(im,jm,Lm)
51        real tz(im,jm,lm)        _RL tz(im,jm,Lm)
52        real qz(im,jm,lm)        _RL qz(im,jm,Lm)
53        real phis_var(im,jm)        _RL phis_var(im,jm)
54    
55        real dudt(im,jm,lm)        _RL dudt(im,jm,Lm)
56        real dvdt(im,jm,lm)        _RL dvdt(im,jm,Lm)
57        real dtdt(im,jm,lm)        _RL dtdt(im,jm,Lm)
58    
59  c Local Variables  c Local Variables
60  c ---------------  c ---------------
61        real tv(im,jm,lm)        _RL tv(im,jm,Lm)
62        real dragu(im,jm,lm), dragv(im,jm,lm)        _RL dragu(im,jm,Lm), dragv(im,jm,Lm)
63        real dragt(im,jm,lm)        _RL dragt(im,jm,Lm)
64        real dragx(im,jm), dragy(im,jm)        _RL dragx(im,jm), dragy(im,jm)
65        real sumu(im,jm)        _RL sumu(im,jm)
66        integer nthin(im,jm),nbase(im,jm)        integer nthin(im,jm),nbase(im,jm)
67        integer nthini, nbasei        integer nthini, nbasei
68    
69        real phis_std(im,jm)        _RL phis_std(im,jm)
70    
71        real std(istrip), ps(istrip)        _RL std(istrip), ps(istrip)
72        real us(istrip,lm), vs(istrip,lm), ts(istrip,lm)        _RL us(istrip,Lm), vs(istrip,Lm), ts(istrip,Lm)
73        real dragus(istrip,lm), dragvs(istrip,lm)        _RL dragus(istrip,Lm), dragvs(istrip,Lm)
74        real dragxs(istrip), dragys(istrip)        _RL dragxs(istrip), dragys(istrip)
75        real plstr(istrip,lm),plestr(istrip,lm),dpresstr(istrip,lm)        _RL plstr(istrip,Lm),plestr(istrip,Lm),dpresstr(istrip,Lm)
76        integer nthinstr(istrip),nbasestr(istrip)        integer nthinstr(istrip),nbasestr(istrip)
77    
78        integer n,i,j,L        integer n,i,j,L
79        real    getcon, pi        _RL getcon, pi
80        real    grav, rgas, cp, cpinv, lstar        _RL grav, rgas, cp, cpinv, lstar
81    #ifdef ALLOW_DIAGNOSTICS
82          logical  diagnostics_is_on
83          external diagnostics_is_on
84          _RL tmpdiag(im,jm)
85    #endif
86    
87  c Initialization  c Initialization
88  c --------------  c --------------
# Line 99  c ----------------------- Line 98  c -----------------------
98        do j=1,jm        do j=1,jm
99        do i=1,im        do i=1,im
100    
101        do nthini = 1,lm+1        do nthini = 1,Lm+1
102         if( 1000.0-ple(i,j,lm+2-nthini).gt.25. ) then         if( pz(i,j)-ple(i,j,Lm+2-nthini).gt.25. ) then
103          nthin(i,j) = nthini          nthin(i,j) = nthini
104          goto 10          goto 10
105         endif         endif
106        enddo        enddo
107     10 continue     10 continue
108        do nbasei = 1,lm+1        do nbasei = 1,Lm+1
109         if( ple(i,j,lm+2-nbasei).lt.666.7 ) then         if( ple(i,j,Lm+2-nbasei).lt.(0.667*pz(i,j)) ) then
110          nbase(i,j) = nbasei          nbase(i,j) = nbasei
111          goto 20          goto 20
112         endif         endif
113        enddo        enddo
114     20 continue     20 continue
115        if( 666.7-ple(i,j,lm+2-nbase(i,j)) .gt.        if( (0.667*pz(i,j))-ple(i,j,Lm+2-nbase(i,j)) .gt.
116       .           ple(i,j,lm+3-nbase(i,j))-666.7 ) then       .           ple(i,j,Lm+3-nbase(i,j))-(0.667*pz(i,j)) ) then
117        nbase(i,j) = nbase(i,j)-1        nbase(i,j) = nbase(i,j)-1
118        endif        endif
119    
120        enddo        enddo
121        enddo        enddo
122    
123  c Compute Topography Sub-Grid Standard Deviation  c Compute Topography Sub-Grid Standard Deviation
124    c        and constrain the Maximum Value
125  c ----------------------------------------------  c ----------------------------------------------
126        do j=1,jm        do j=1,jm
127        do i=1,im        do i=1,im
128        phis_std(i,j) = min( 400.0, sqrt( max(0.0,phis_var(i,j)) )/grav )        phis_std(i,j) = min( 400.0 _d 0, sqrt( max(0.0 _d 0,phis_var(i,j)) )/grav )
129        enddo        enddo
130        enddo        enddo
131    
132  c Compute Virtual Temperatures  c Compute Virtual Temperatures
133  c ----------------------------  c ----------------------------
134        do L = 1,lm        do L = 1,Lm
135        do j = 1,jm        do j = 1,jm
136        do i = 1,im        do i = 1,im
137        tv(i,j,L) = tz(i,j,L)*pkz(i,j,L)*(1.+.609*qz(i,j,L))        tv(i,j,L) = tz(i,j,L)*pkz(i,j,L)*(1.+.609*qz(i,j,L))
# Line 138  c ---------------------------- Line 139  c ----------------------------
139        enddo        enddo
140        enddo        enddo
141    
142          do L = 1,Lm
143          do j = 1,jm
144          do i = 1,im
145           dragu(i,j,L) = 0.
146           dragv(i,j,L) = 0.
147           dragt(i,j,L) = 0.
148          enddo
149          enddo
150          enddo
151    
152  c Call Gravity Wave Drag Paramterization on A-Grid  c Call Gravity Wave Drag Paramterization on A-Grid
153  c ------------------------------------------------  c ------------------------------------------------
154    
155        do n=1,npcs        do n=1,npcs
156    
157        call strip ( phis_std,std,im*jm,istrip,1,n )        call stripit ( phis_std,std,im*jm,im*jm,istrip,1,n )
158    
159        call strip ( pz,ps,im*jm,istrip,1 ,n )        call stripit ( pz,ps,im*jm,im*jm,istrip,1 ,n )
160        call strip ( uz,us,im*jm,istrip,lm,n )        call stripit ( uz,us,im*jm,im*jm,istrip,Lm,n )
161        call strip ( vz,vs,im*jm,istrip,lm,n )        call stripit ( vz,vs,im*jm,im*jm,istrip,Lm,n )
162        call strip ( tv,ts,im*jm,istrip,lm,n )        call stripit ( tv,ts,im*jm,im*jm,istrip,Lm,n )
163        call strip ( pl,plstr,im*jm,istrip,lm,n )        call stripit ( pl,plstr,im*jm,im*jm,istrip,Lm,n )
164        call strip ( ple,plestr,im*jm,istrip,lm,n )        call stripit ( ple,plestr,im*jm,im*jm,istrip,Lm,n )
165        call strip ( dpres,dpresstr,im*jm,istrip,lm,n )        call stripit ( dpres,dpresstr,im*jm,im*jm,istrip,Lm,n )
166        call stripint ( nthin,nthinstr,im*jm,istrip,lm,n )        call stripitint ( nthin,nthinstr,im*jm,im*jm,istrip,1,n )
167        call stripint ( nbase,nbasestr,im*jm,istrip,lm,n )        call stripitint ( nbase,nbasestr,im*jm,im*jm,istrip,1,n )
168    
169        call GWDD ( ps,us,vs,ts,        call GWDD ( ps,us,vs,ts,
170       .            dragus,dragvs,dragxs,dragys,std,       .            dragus,dragvs,dragxs,dragys,std,
171       .            plstr,plestr,dpresstr,grav,rgas,cp,       .            plstr,plestr,dpresstr,grav,rgas,cp,
172       .            istrip,lm,nthinstr,nbasestr,lstar )       .            istrip,Lm,nthinstr,nbasestr,lstar )
173    
174        call paste ( dragus,dragu,istrip,im*jm,lm,n )        call pastit( dragus,dragu,istrip,im*jm,im*jm,Lm,n )
175        call paste ( dragvs,dragv,istrip,im*jm,lm,n )        call pastit( dragvs,dragv,istrip,im*jm,im*jm,Lm,n )
176        call paste ( dragxs,dragx,istrip,im*jm,1 ,n )        call pastit( dragxs,dragx,istrip,im*jm,im*jm,1 ,n )
177        call paste ( dragys,dragy,istrip,im*jm,1 ,n )        call pastit( dragys,dragy,istrip,im*jm,im*jm,1 ,n )
178    
179        enddo        enddo
180    
181  c Add Gravity-Wave Drag to Wind and Theta Tendencies  c Add Gravity-Wave Drag to Wind and Theta Tendencies
182  c --------------------------------------------------  c --------------------------------------------------
183        do L = 1,lm        do L = 1,Lm
184        do j = 1,jm        do j = 1,jm
185        do i = 1,im        do i = 1,im
186        dragu(i,j,L) = sign( min(0.006,abs(dragu(i,j,L))),dragu(i,j,L) )        dragu(i,j,L) = sign( min(0.006 _d 0,abs(dragu(i,j,L))),dragu(i,j,L) )
187        dragv(i,j,L) = sign( min(0.006,abs(dragv(i,j,L))),dragv(i,j,L) )        dragv(i,j,L) = sign( min(0.006 _d 0,abs(dragv(i,j,L))),dragv(i,j,L) )
188        dragt(i,j,L) = -( uz(i,j,L)*dragu(i,j,L)+vz(i,j,L)*dragv(i,j,L) )        dragt(i,j,L) = -( uz(i,j,L)*dragu(i,j,L)+vz(i,j,L)*dragv(i,j,L) )
189       .                                                         *cpinv       .                                                         *cpinv
190         dudt(i,j,L) = dudt(i,j,L) + dragu(i,j,L)         dudt(i,j,L) = dudt(i,j,L) + dragu(i,j,L)
# Line 185  c -------------------------------------- Line 196  c --------------------------------------
196    
197  c Compute Diagnostics  c Compute Diagnostics
198  c -------------------  c -------------------
199        if( igwdu.ne.0 .or. igwdv.ne.0 .or. igwdt.ne.0 ) then  #ifdef ALLOW_DIAGNOSTICS
200        do L = 1,lm        do L = 1,Lm
201         if( igwdu.ne.0 ) then  
202          do j = 1,jm        if(diagnostics_is_on('GWDU    ',myid) ) then
203          do i = 1,im         do j=1,jm
204          qdiag(i,j,igwdu+L-1,bi,bj) = qdiag(i,j,igwdu+L-1,bi,bj) +         do i=1,im
205       .                                         dragu(i,j,L)*86400          tmpdiag(i,j) = dragu(i,j,L)*86400
206          enddo         enddo
207          enddo         enddo
208         endif         call diagnostics_fill(tmpdiag,'GWDU    ',L,1,3,bi,bj,myid)
209         if( igwdv.ne.0 ) then        endif
210          do j = 1,jm  
211          do i = 1,im        if(diagnostics_is_on('GWDV    ',myid) ) then
212          qdiag(i,j,igwdv+L-1,bi,bj) = qdiag(i,j,igwdv+L-1,bi,bj) +         do j=1,jm
213       .                                         dragv(i,j,L)*86400         do i=1,im
214          enddo          tmpdiag(i,j) = dragv(i,j,L)*86400
215          enddo         enddo
216         endif         enddo
217         if( igwdt.ne.0 ) then         call diagnostics_fill(tmpdiag,'GWDV    ',L,1,3,bi,bj,myid)
218          do j = 1,jm        endif
219          do i = 1,im  
220          qdiag(i,j,igwdt+L-1,bi,bj) = qdiag(i,j,igwdt+L-1,bi,bj) +        if(diagnostics_is_on('GWDT    ',myid) ) then
221       .                                         dragt(i,j,L)*86400         do j=1,jm
222          enddo         do i=1,im
223          enddo          tmpdiag(i,j) = dragt(i,j,L)*86400
224         endif         enddo
225        enddo         enddo
226           call diagnostics_fill(tmpdiag,'GWDT    ',L,1,3,bi,bj,myid)
227        endif        endif
228    
229          enddo
230    
231  c Gravity Wave Drag at Surface (U-Wind)  c Gravity Wave Drag at Surface (U-Wind)
232  c -------------------------------------  c -------------------------------------
233        if( igwdus.ne.0 ) then        if(diagnostics_is_on('GWDUS   ',myid) ) then
234        do j = 1,jm         call diagnostics_fill(dragx,'GWDUS   ',0,1,3,bi,bj,myid)
       do i = 1,im  
       qdiag(i,j,igwdus,bi,bj) = qdiag(i,j,igwdus,bi,bj) + dragx(i,j)  
       enddo  
       enddo  
235        endif        endif
236    
237  c Gravity Wave Drag at Surface (V-Wind)  c Gravity Wave Drag at Surface (V-Wind)
238  c -------------------------------------  c -------------------------------------
239        if( igwdvs.ne.0 ) then        if(diagnostics_is_on('GWDVS   ',myid) ) then
240        do j = 1,jm         call diagnostics_fill(dragy,'GWDVS   ',0,1,3,bi,bj,myid)
       do i = 1,im  
       qdiag(i,j,igwdvs,bi,bj) = qdiag(i,j,igwdvs,bi,bj) + dragy(i,j)  
       enddo  
       enddo  
241        endif        endif
242    
243  c Gravity Wave Drag at Model Top (U-Wind)  c Gravity Wave Drag at Model Top (U-Wind)
244  c ---------------------------------------  c ---------------------------------------
245        if( igwdut.ne.0 ) then        if(diagnostics_is_on('GWDUT   ',myid) ) then
246        do j = 1,jm        do j = 1,jm
247        do i = 1,im        do i = 1,im
248        sumu(i,j) = 0.0        sumu(i,j) = 0.0
249        enddo        enddo
250        enddo        enddo
251        do L = 1,lm        do L = 1,Lm
252        do j = 1,jm        do j = 1,jm
253        do i = 1,im        do i = 1,im
254        sumu(i,j) = sumu(i,j) + dragu(i,j,L)*dpres(i,j,L)/pz(i,j)        sumu(i,j) = sumu(i,j) + dragu(i,j,L)*dpres(i,j,L)/pz(i,j)
255        enddo        enddo
256        enddo        enddo
257        enddo        enddo
258        do j = 1,jm         do j=1,jm
259        do i = 1,im         do i=1,im
260        qdiag(i,j,igwdut,bi,bj) = qdiag(i,j,igwdut,bi,bj) + dragx(i,j)          tmpdiag(i,j) = dragx(i,j) + sumu(i,j)*pz(i,j)/grav*100
261       .                  + sumu(i,j)*pz(i,j)/grav*100         enddo
262        enddo         enddo
263        enddo         call diagnostics_fill(tmpdiag,'GWDUT   ',0,1,3,bi,bj,myid)
264        endif        endif
265    
266  c Gravity Wave Drag at Model Top (V-Wind)  c Gravity Wave Drag at Model Top (V-Wind)
267  c ---------------------------------------  c ---------------------------------------
268        if( igwdvt.ne.0 ) then        if(diagnostics_is_on('GWDVT   ',myid) ) then
269        do j = 1,jm        do j = 1,jm
270        do i = 1,im        do i = 1,im
271        sumu(i,j) = 0.0        sumu(i,j) = 0.0
272        enddo        enddo
273        enddo        enddo
274        do L = 1,lm        do L = 1,Lm
275        do j = 1,jm        do j = 1,jm
276        do i = 1,im        do i = 1,im
277        sumu(i,j) = sumu(i,j) + dragv(i,j,L)*dpres(i,j,L)/pz(i,j)        sumu(i,j) = sumu(i,j) + dragv(i,j,L)*dpres(i,j,L)/pz(i,j)
278        enddo        enddo
279        enddo        enddo
280        enddo        enddo
281        do j = 1,jm         do j=1,jm
282        do i = 1,im         do i=1,im
283        qdiag(i,j,igwdvt,bi,bj) = qdiag(i,j,igwdvt,bi,bj) + dragy(i,j)          tmpdiag(i,j) = dragy(i,j) + sumu(i,j)*pz(i,j)/grav*100
284       .                  + sumu(i,j)*pz(i,j)/grav*100         enddo
285        enddo         enddo
286        enddo         call diagnostics_fill(tmpdiag,'GWDVT   ',0,1,3,bi,bj,myid)
287        endif        endif
288    #endif
       ngwdu  = ngwdu  + 1  
       ngwdv  = ngwdv  + 1  
       ngwdt  = ngwdt  + 1  
       ngwdus = ngwdus + 1  
       ngwdvs = ngwdvs + 1  
       ngwdut = ngwdut + 1  
       ngwdvt = ngwdvt + 1  
289    
290        return        return
291        end        end
292        SUBROUTINE GWDD ( ps,u,v,t,dudt,dvdt,xdrag,ydrag,        SUBROUTINE GWDD ( ps,u,v,t,dudt,dvdt,xdrag,ydrag,
293       .                  std,pl,ple,dpres,       .                  std,pl,ple,dpres,
294       .                  grav,rgas,cp,irun,lm,nthin,nbase,lstar )       .                  grav,rgas,cp,irun,Lm,nthin,nbase,lstar )
295  C***********************************************************************  C***********************************************************************
296  C  C
297  C Description:  C Description:
# Line 314  C    grav ....... Gravitational constant Line 313  C    grav ....... Gravitational constant
313  C    rgas ....... Gas constant  C    rgas ....... Gas constant
314  C    cp ......... Specific Heat at constant pressure  C    cp ......... Specific Heat at constant pressure
315  C    irun ....... Number of grid-points in horizontal dimension  C    irun ....... Number of grid-points in horizontal dimension
316  C    lm ......... Number of grid-points in vertical   dimension  C    Lm ......... Number of grid-points in vertical   dimension
317  C    lstar ...... Monochromatic Wavelength/(2*pi)  C    lstar ...... Monochromatic Wavelength/(2*pi)
318  C  C
319  C Output:  C Output:
# Line 324  C    dvdt ....... Meridional Acceleratio Line 323  C    dvdt ....... Meridional Acceleratio
323  C    xdrag ...... Zonal Surface and Base Layer Stress (Pa)  C    xdrag ...... Zonal Surface and Base Layer Stress (Pa)
324  C    ydrag ...... Meridional Surface and Base Layer Stress (Pa)  C    ydrag ...... Meridional Surface and Base Layer Stress (Pa)
325  C  C
326    C NOTE: Quantities computed locally in GWDD use a
327    C              bottom-up counting of levels
328    C       The fizhi code uses a top-down so all
329    C       Quantities that came in through the arg list
330    C       must use reverse vertical indexing!!!
331  C***********************************************************************  C***********************************************************************
332    
333        implicit none        implicit none
334    
335  c Input Variables  c Input Variables
336  c ---------------  c ---------------
337        integer irun,lm        integer irun,Lm
338        real ps(irun)        _RL ps(irun)
339        real u(irun,lm), v(irun,lm), t(irun,lm)        _RL u(irun,Lm), v(irun,Lm), t(irun,Lm)
340        real dudt(irun,lm), dvdt(irun,lm)        _RL dudt(irun,Lm), dvdt(irun,Lm)
341        real xdrag(irun), ydrag(irun)        _RL xdrag(irun), ydrag(irun)
342        real std(irun)        _RL std(irun)
343        real ple(irun,lm+1), pl(irun,lm), dpres(irun,lm)        _RL ple(irun,Lm+1), pl(irun,Lm), dpres(irun,Lm)
344        real grav, rgas, cp        _RL grav, rgas, cp
345        integer nthin(irun),nbase(irun)        integer nthin(irun),nbase(irun)
346        real lstar        _RL lstar
347    
348  c Dynamic Allocation Variables  c Dynamic Allocation Variables
349  c ----------------------------  c ----------------------------
350        real ubar(irun), vbar(irun), robar(irun)        _RL ubar(irun), vbar(irun), robar(irun)
351        real speed(irun), ang(irun)        _RL speed(irun), ang(irun)
352        real bv(irun,lm)        _RL bv(irun,Lm)
353        real nbar(irun)        _RL nbar(irun)
354    
355        real tstd(irun)        _RL XTENS(irun,Lm+1), YTENS(irun,Lm+1)
356        real XTENS(irun,lm+1), YTENS(irun,lm+1)        _RL TENSIO(irun,Lm+1)
357        real TENSIO(irun,lm+1)        _RL DRAGSF(irun)
358        real DRAGSF(irun)        _RL RO(irun,Lm), DZ(irun,Lm)
       real RO(irun,lm), DZ(irun,lm)  
359    
360        integer icrilv(irun)        integer icrilv(irun)
361    
362  c Local Variables  c Local Variables
363  c ---------------  c ---------------
364        integer  i,l        integer  i,L
365        real a,g,stdmax,agrav,akwnmb        _RL a,g,agrav,akwnmb
366        real gocp,roave,roiave,frsf,gstar,vai1,vai2        _RL gocp,roave,roiave,frsf,gstar,vai1,vai2
367        real vaisd,velco,deluu,delvv,delve2,delz,vsqua        _RL vaisd,velco,deluu,delvv,delve2,delz,vsqua
368        real richsn,crifro,crif2,fro2,coef        _RL richsn,crifro,crif2,fro2,coef
369    
370  c Initialization  c Initialization
371  c --------------  c --------------
372        a      = 1.0        a      = 1.0
373        g      = 1.0        g      = 1.0
374        agrav  = 1.0/GRAV        agrav  = 1.0/grav
375        akwnmb = 1.0/lstar        akwnmb = 1.0/lstar
376        gocp   = GRAV/CP        gocp   = grav/cp
377    
378  c Constrain the Maximum Value of the Standard Deviation  c Compute Atmospheric Density (with virtual temp)
379  c -----------------------------------------------------  c -----------------------------------------------
380        stdmax = 400.        do l = 1,Lm
381        do i = 1,irun        do i = 1,irun
382           tstd(i) = std(i)         ro(i,L) = pl(i,Lm+1-L)/(rgas*t(i,Lm+1-L))
       if( std(i).gt.stdmax ) tstd(i) = stdmax  
       enddo  
   
 c Compute Atmospheric Density  
 c ---------------------------  
       do l = 1,lm  
       do i = 1,irun  
       ro(i,l) = pl(i,l)/(rgas*t(i,lm+1-l))  
383        enddo        enddo
384        enddo        enddo
385    
386  c Compute Layer Thicknesses  c Compute Layer Thicknesses
387  c -------------------------  c -------------------------
388        do l = 2,lm        do l = 2,Lm
389        do i = 1,irun        do i = 1,irun
390        roiave  = ( 1./ro(i,l-1) + 1./ro(i,l) )*0.5         roiave  = ( 1./ro(i,L-1) + 1./ro(i,L) )*0.5
391        dz(i,l) = agrav*roiave*( pl(i,l-1)-pl(i,l) )         dz(i,L) = agrav*roiave*( pl(i,Lm+2-L)-pl(i,Lm+1-L) )
392        enddo        enddo
393        enddo        enddo
394    
395    
396  c******************************************************  c***********************************************************************
397  c          Surface and Base Layer Stress              *  c          Surface and Base Layer Stress                               *
398  c******************************************************  c***********************************************************************
399    
400  c Definition of Surface Wind Vector  c Definition of Surface Wind Vector
401  c ---------------------------------  c ---------------------------------
402        do  i = 1,irun        do  i = 1,irun
403        robar(i) = 0.0         robar(i) = 0.0
404         ubar(i) = 0.0         ubar(i) = 0.0
405         vbar(i) = 0.0         vbar(i) = 0.0
406        enddo        enddo
407    
408        do  i = 1,irun        do  i = 1,irun
409        do  L = 1,nbase(i)-1        do  L = 1,nbase(i)-1
410        robar(i) = robar(i) + ro(i,L)     *(ple(i,L)-ple(i,L+1))         robar(i) = robar(i) + ro(i,L) * (ple(i,Lm+2-L)-ple(i,Lm+1-L))
411         ubar(i) =  ubar(i) +  u(i,lm+1-L)*(ple(i,L)-ple(i,L+1))         ubar(i) = ubar(i) + u(i,Lm+1-L) * (ple(i,Lm+2-L)-ple(i,Lm+1-L))
412         vbar(i) =  vbar(i) +  v(i,lm+1-L)*(ple(i,L)-ple(i,L+1))         vbar(i) = vbar(i) + v(i,Lm+1-L) * (ple(i,Lm+2-L)-ple(i,Lm+1-L))
413        enddo        enddo
414        enddo        enddo
415    
416        do  i = 1,irun        do  i = 1,irun
417        robar(i) = robar(i)/(ple(i,1)-ple(i,nbase(i))) * 100.0         robar(i) = robar(i)/(ps(i)-ple(i,Lm+1-(nbase(i)-1))) * 100.0
418         ubar(i) =  ubar(i)/(ple(i,1)-ple(i,nbase(i)))         ubar(i) = ubar(i)/(ps(i)-ple(i,Lm+1-(nbase(i)-1)))
419         vbar(i) =  vbar(i)/(ple(i,1)-ple(i,nbase(i)))         vbar(i) = vbar(i)/(ps(i)-ple(i,Lm+1-(nbase(i)-1)))
   
       speed(i) = SQRT( ubar(i)*ubar(i) + vbar(i)*vbar(i) )  
         ang(i) = ATAN2(vbar(i),ubar(i))  
420    
421           speed(i) = sqrt( ubar(i)*ubar(i) + vbar(i)*vbar(i) )
422           ang(i) = atan2(vbar(i),ubar(i))
423        enddo        enddo
424    
425  c Brunt Vaisala Frequency  c Brunt Vaisala Frequency
426  c -----------------------  c -----------------------
427        do i = 1,irun        do i = 1,irun
428        do l = 2,nbase(i)         do l = 2,nbase(i)
429            VAI1 = (T(i,lm+1-l)-T(i,lm+2-l))/DZ(i,l)+GOCP          vai1 = (t(i,Lm+1-L)-t(i,Lm+2-L))/dz(i,L)+gocp
430        if( VAI1.LT.0.0 ) then          if( vai1.LT.0.0 ) then
431            VAI1 =  0.0           vai1 =  0.0
432        endif          endif
433        VAI2    = 2.0*GRAV/( T(i,lm+1-l)+T(i,lm+2-l) )          vai2    = 2.0*grav/( t(i,Lm+1-L)+t(i,Lm+2-L) )
434        VSQUA   = VAI1*VAI2          vsqua   = vai1*vai2
435        BV(i,l) = SQRT(VSQUA)          bv(i,L) = sqrt(vsqua)
436        enddo         enddo
437        enddo        enddo
438    
439  c Stress at the Surface Level  c Stress at the Surface Level
440  c ---------------------------  c ---------------------------
441        do i = 1,irun        do i = 1,irun
442        nbar(i) = 0.0         nbar(i) = 0.0
443        enddo        enddo
444        do i = 1,irun        do i = 1,irun
445        do l = 2,nbase(i)        do l = 2,nbase(i)
446        NBAR(i) = NBAR(i) + BV(i,l)*(pl(i,l-1)-pl(i,l))         nbar(i) = nbar(i) + bv(i,L)*(pl(i,Lm+2-L)-pl(i,Lm+1-L))
447        enddo        enddo
448        enddo        enddo
449    
450        do i = 1,irun        do i = 1,irun
451        NBAR(i) = NBAR(i)/(pl(i,1)-pl(i,nbase(i)))         nbar(i) = nbar(i)/(pl(i,Lm)-pl(i,Lm+1-nbase(i)))
452        FRSF    = NBAR(i)*tstd(i)/speed(i)         frsf = nbar(i)*std(i)/speed(i)
453    
454        if( speed(i).eq.0.0 .or. nbar(i).eq.0.0 ) then         if( speed(i).eq.0.0 .or. nbar(i).eq.0.0 ) then
455        TENSIO(i,1) = 0.0          tensio(i,1) = 0.0
456        else         else
457        GSTAR = G*FRSF*FRSF/(FRSF*FRSF+A*A)          gstar = g*frsf*frsf/(frsf*frsf+a*a)
458        TENSIO(i,1) = GSTAR*(ROBAR(i)*speed(i)*speed(i)*speed(i))          tensio(i,1) = gstar*(robar(i)*speed(i)*speed(i)*speed(i))
459       .            / (NBAR(i)*LSTAR)       .            / (nbar(i)*lstar)
460        endif         endif
461    
462         XTENS(i,1) = TENSIO(i,1) * cos(ang(i))         xtens(i,1) = tensio(i,1) * cos(ang(i))
463         YTENS(i,1) = TENSIO(i,1) * sin(ang(i))         ytens(i,1) = tensio(i,1) * sin(ang(i))
464        DRAGSF(i)   = TENSIO(i,1)         dragsf(i) = tensio(i,1)
465         XDRAG(i)   =  XTENS(i,1)         xdrag(i) = xtens(i,1)
466         YDRAG(i)   =  YTENS(i,1)         ydrag(i) = ytens(i,1)
467        enddo        enddo
468    
469  c Check for Very thin lowest layer  c Check for Very thin lowest layer
470  c --------------------------------  c --------------------------------
471        do i = 1,irun        do i = 1,irun
472        if( NTHIN(i).gt.1 ) then         if( nthin(i).gt.1 ) then
473        do l = 1,nthin(i)          do l = 1,nthin(i)
474        TENSIO(i,l) = TENSIO(i,1)           tensio(i,L) = tensio(i,1)
475         XTENS(i,l) =  XTENS(i,1)           xtens(i,L) = xtens(i,1)
476         YTENS(i,l) =  YTENS(i,1)           ytens(i,L) = ytens(i,1)
477        enddo          enddo
478        endif         endif
479        enddo        enddo
480    
481  c******************************************************  c******************************************************
# Line 489  c  Compute Gravity Wave Stress from NTHI Line 483  c  Compute Gravity Wave Stress from NTHI
483  c******************************************************  c******************************************************
484    
485        do i = 1,irun        do i = 1,irun
486        do l = nthin(i)+1,nbase(i)         do l = nthin(i)+1,nbase(i)
487    
488        velco = 0.5*( (u(i,lm+1-l)*ubar(i) + v(i,lm+1-l)*vbar(i))          velco = 0.5*( (u(i,Lm+1-L)*ubar(i) + v(i,Lm+1-L)*vbar(i))
489       .            + (u(i,lm+2-l)*ubar(i) + v(i,lm+2-l)*vbar(i))  )       .            + (u(i,Lm+2-L)*ubar(i) + v(i,Lm+2-L)*vbar(i))  )
490       .      /   speed(i)       .      /   speed(i)
491    
492  C Convert to Newton/m**2  C Convert to Newton/m**2
493        roave = 0.5*(ro(i,l-1)+ro(i,l)) * 100.0              roave = 0.5*(ro(i,L-1)+ro(i,L)) * 100.0    
494    
495        if( VELCO.le.0.0 ) then          if( velco.le.0.0 ) then
496        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
497        goto 1500           goto 1500
498        endif          endif
499                                            
500  c Froude number squared  c Froude number squared
501  c ---------------------  c ---------------------
502        FRO2   = bv(i,l)/(AKWNMB*ROAVE*VELCO*VELCO*VELCO)*TENSIO(i,l-1)          fro2 = bv(i,L)/(akwnmb*roave*velco*velco*velco)*tensio(i,L-1)
503        DELUU  = u(i,lm+1-l)-u(i,lm+2-l)          deluu = u(i,Lm+1-L)-u(i,Lm+2-L)
504        DELVV  = v(i,lm+1-l)-v(i,lm+2-l)          delvv = v(i,Lm+1-L)-v(i,Lm+2-L)
505        DELVE2 = ( DELUU*DELUU + DELVV*DELVV )          delve2 = ( deluu*deluu + delvv*delvv )
506    
507  c Compute Richarson Number  c Compute Richarson Number
508  c ------------------------  c ------------------------
509        if( DELVE2.ne.0.0 ) then          if( delve2.ne.0.0 ) then
510          DELZ = DZ(i,l)           delz = dz(i,L)
511         VSQUA = BV(i,l)*BV(i,l)           vsqua = bv(i,L)*bv(i,L)
512        RICHSN = DELZ*DELZ*VSQUA/DELVE2           richsn = delz*delz*vsqua/delve2
513        else          else
514        RICHSN = 99999.0           richsn = 99999.0
515        endif          endif
516    
517        if( RICHSN.le.0.25 ) then          if( richsn.le.0.25 ) then
518        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
519        goto 1500           goto 1500
520        endif          endif
521    
522  c Stress in the Base Layer changes if the local Froude number  c Stress in the Base Layer changes if the local Froude number
523  c exceeds the Critical Froude number  c exceeds the Critical Froude number
524  c ----------------------------------  c ----------------------------------
525                    CRIFRO = 1.0 - 0.25/RICHSN          crifro = 1.0 - 0.25/richsn
526                     CRIF2 = CRIFRO*CRIFRO          crif2 = crifro*crifro
527        if( l.eq.2 ) CRIF2 = MIN(0.7,CRIF2)          if( l.eq.2 ) crif2 = min(0.7 _d 0,crif2)
528    
529        if( FRO2.gt.CRIF2 ) then          if( fro2.gt.crif2 ) then
530        TENSIO(i,l) = CRIF2/FRO2*TENSIO(i,l-1)           tensio(i,L) = crif2/fro2*tensio(i,L-1)
531        else          else
532        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
533        endif          endif
534    
535  1500  CONTINUE  1500    continue
536        XTENS(i,l) = TENSIO(i,l)*COS(ang(i))          xtens(i,L) = tensio(i,L)*cos(ang(i))
537        YTENS(i,l) = TENSIO(i,l)*SIN(ang(i))          ytens(i,L) = tensio(i,L)*sin(ang(i))
538    
539        enddo         enddo
540        enddo        enddo
541    
542  c******************************************************  c******************************************************
# Line 550  c    Compute Gravity Wave Stress from Ba Line 544  c    Compute Gravity Wave Stress from Ba
544  c******************************************************  c******************************************************
545    
546        do i = 1,irun        do i = 1,irun
547        icrilv(i) = 0         icrilv(i) = 0
548        enddo        enddo
549    
550        do i = 1,irun        do i = 1,irun
551        do l = nbase(i)+1,lm+1         do l = nbase(i)+1,Lm+1
552    
553        TENSIO(i,l) = 0.0          tensio(i,L) = 0.0
554    
555  c Check for Critical Level Absorption  c Check for Critical Level Absorption
556  c -----------------------------------  c -----------------------------------
557        if( icrilv(i).eq.1 ) goto 130          if( icrilv(i).eq.1 ) goto 130
558    
559  c Let Remaining Stress escape out the top edge of model  c Let Remaining Stress escape out the top edge of model
560  c -----------------------------------------------------  c -----------------------------------------------------
561        if( l.eq.lm+1 ) then          if( l.eq.Lm+1 ) then
562        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
563        goto 130           goto 130
564        endif          endif
565    
566        ROAVE = 0.5*(ro(i,l-1)+ro(i,l)) * 100.0          roave = 0.5*(ro(i,L-1)+ro(i,L)) * 100.0
567        VAI1  = (T(i,lm+1-l)-T(i,lm+2-l))/DZ(i,l)+GOCP          vai1  = (t(i,Lm+1-L)-t(i,Lm+2-L))/dz(i,L)+gocp
568    
569        if( VAI1.lt.0.0 ) then          if( vai1.lt.0.0 ) then
570        icrilv(i)   = 1           icrilv(i)   = 1
571        TENSIO(i,l) = 0.0           tensio(i,L) = 0.0
572        goto 130           goto 130
573        endif          endif
574    
575            vai2  = 2.0*grav/(t(i,Lm+1-L)+t(i,Lm+2-L))
576            vsqua = vai1*vai2
577            vaisd = sqrt(vsqua)
578    
579        VAI2  = 2.0*GRAV/(T(i,lm+1-l)+T(i,lm+2-l))          velco = 0.5*( (u(i,Lm+1-L)*ubar(i) + v(i,Lm+1-L)*vbar(i))
580        VSQUA = VAI1*VAI2       .            + (u(i,Lm+2-L)*ubar(i) + v(i,Lm+2-L)*vbar(i))  )
       VAISD = SQRT(VSQUA)  
   
       velco = 0.5*( (u(i,lm+1-l)*ubar(i) + v(i,lm+1-l)*vbar(i))  
      .            + (u(i,lm+2-l)*ubar(i) + v(i,lm+2-l)*vbar(i))  )  
581       .      /   speed(i)       .      /   speed(i)
582    
583        if( velco.lt.0.0 ) then          if( velco.lt.0.0 ) then
584        icrilv(i)   = 1           icrilv(i)   = 1
585        TENSIO(i,l) = 0.0           tensio(i,L) = 0.0
586        goto 130           goto 130
587        endif          endif
588    
589  c Froude number squared  c Froude number squared
590  c ---------------------  c ---------------------
591        FRO2   = vaisd/(AKWNMB*ROAVE*VELCO*VELCO*VELCO)*TENSIO(i,l-1)          fro2 = vaisd/(akwnmb*roave*velco*velco*velco)*tensio(i,L-1)
592        DELUU  = u(i,lm+1-l)-u(i,lm+2-l)          deluu = u(i,Lm+1-L)-u(i,Lm+2-L)
593        DELVV  = v(i,lm+1-l)-v(i,lm+2-l)          delvv = v(i,Lm+1-L)-v(i,Lm+2-L)
594        DELVE2 = ( DELUU*DELUU + DELVV*DELVV )          delve2 = ( deluu*deluu + delvv*delvv )
595    
596  c Compute Richarson Number  c Compute Richarson Number
597  c ------------------------  c ------------------------
598        if( DELVE2.ne.0.0 ) then          if( delve2.ne.0.0 ) then
599        DELZ   = DZ(i,l)           delz   = dz(i,L)
600        RICHSN = DELZ*DELZ*VSQUA/DELVE2           richsn = delz*delz*vsqua/delve2
601        else          else
602        RICHSN = 99999.0           richsn = 99999.0
603        endif          endif
604    
605        if( RICHSN.le.0.25 ) then          if( richsn.le.0.25 ) then
606        TENSIO(i,l) = 0.0           tensio(i,L) = 0.0
607        icrilv(i)   = 1           icrilv(i)   = 1
608        goto 130           goto 130
609        endif          endif
610    
611  c Stress in Layer changes if the local Froude number  c Stress in Layer changes if the local Froude number
612  c exceeds the Critical Froude number  c exceeds the Critical Froude number
613  c ----------------------------------  c ----------------------------------
614        CRIFRO = 1.0 - 0.25/RICHSN          crifro = 1.0 - 0.25/richsn
615         CRIF2 = CRIFRO*CRIFRO          crif2 = crifro*crifro
   
       if( FRO2.ge.CRIF2 ) then  
       TENSIO(i,l) = CRIF2/FRO2*TENSIO(i,l-1)  
       else  
       TENSIO(i,l) = TENSIO(i,l-1)  
       endif  
616    
617    130 continue          if( fro2.ge.crif2 ) then
618        XTENS(i,l) = TENSIO(i,l)*COS(ang(i))           tensio(i,L) = crif2/fro2*tensio(i,L-1)
619        YTENS(i,l) = TENSIO(i,l)*SIN(ang(i))          else
620        enddo           tensio(i,L) = tensio(i,L-1)
621            endif
622    
623      130   continue
624            xtens(i,L) = tensio(i,L)*cos(ang(i))
625            ytens(i,L) = tensio(i,L)*sin(ang(i))
626           enddo
627        enddo        enddo
628    
629  C ******************************************************  C ******************************************************
# Line 637  C       MOMENTUM CHANGE FOR FREE ATMOSPH Line 631  C       MOMENTUM CHANGE FOR FREE ATMOSPH
631  C ******************************************************  C ******************************************************
632    
633        do i = 1,irun        do i = 1,irun
634        do l = nthin(i)+1,lm        do l = nthin(i)+1,Lm
635        coef = -grav*ple(i,lm+1)/dpres(i,lm+1-l)         coef = -grav*ps(i)/dpres(i,Lm+1-L)
636        dudt(i,lm+1-l) = coef*(XTENS(i,l+1)-XTENS(i,l))         dudt(i,Lm+1-L) = coef*(xtens(i,L+1)-xtens(i,L))
637        dvdt(i,lm+1-l) = coef*(YTENS(i,l+1)-YTENS(i,l))         dvdt(i,Lm+1-L) = coef*(ytens(i,L+1)-ytens(i,L))
638        enddo        enddo
639        enddo        enddo
640    
641  c Momentum change near the surface  c Momentum change near the surface
642  c --------------------------------  c --------------------------------
643        do i = 1,irun        do i = 1,irun
644        coef = grav*ple(i,lm+1)/(ple(i,lm+1-nthin(i))-ple(i,lm+1))         coef = grav*ps(i)/(ple(i,Lm+1-nthin(i))-ple(i,Lm+1))
645        dudt(i,lm) = coef*(XTENS(i,nthin(i)+1)-XTENS(i,1))         dudt(i,Lm) = coef*(xtens(i,nthin(i)+1)-xtens(i,1))
646        dvdt(i,lm) = coef*(YTENS(i,nthin(i)+1)-YTENS(i,1))         dvdt(i,Lm) = coef*(ytens(i,nthin(i)+1)-ytens(i,1))
647        enddo        enddo
648    
649  c If Lowest layer is very thin, it is strapped to next layer  c If Lowest layer is very thin, it is strapped to next layer
650  c ----------------------------------------------------------  c ----------------------------------------------------------
651        do i = 1,irun        do i = 1,irun
652        if( nthin(i).gt.1 ) then         if( nthin(i).gt.1 ) then
653        do l = 2,nthin(i)          do l = 2,nthin(i)
654        dudt(i,lm+1-l) = dudt(i,lm)           dudt(i,Lm+1-L) = dudt(i,Lm)
655        dvdt(i,lm+1-l) = dvdt(i,lm)           dvdt(i,Lm+1-L) = dvdt(i,Lm)
656        enddo          enddo
657        endif         endif
658        enddo        enddo
659    
660  c Convert Units to (m/sec**2)  c Convert Units to (m/sec**2)
661  c ---------------------------  c ---------------------------
662        do l = 1,lm        do l = 1,Lm
663        do i = 1,irun        do i = 1,irun
664        dudt(i,l) = - dudt(i,l)/ps(i)*0.01         dudt(i,L) = - dudt(i,L)/ps(i)*0.01
665        dvdt(i,l) = - dvdt(i,l)/ps(i)*0.01         dvdt(i,L) = - dvdt(i,L)/ps(i)*0.01
666        enddo        enddo
667        enddo        enddo
668    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.22