/[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.3 by molod, Tue May 24 00:02:29 2005 UTC revision 1.4 by molod, Wed May 25 19:27:19 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 40  C*************************************** Line 40  C***************************************
40    
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        _RL pz(im,jm)        _RL pz(im,jm)
45        _RL pl(im,jm,lm)        _RL pl(im,jm,Lm)
46        _RL ple(im,jm,lm+1)        _RL ple(im,jm,Lm+1)
47        _RL dpres(im,jm,lm)        _RL dpres(im,jm,Lm)
48        _RL pkz(im,jm,lm)        _RL pkz(im,jm,Lm)
49        _RL uz(im,jm,lm)        _RL uz(im,jm,Lm)
50        _RL vz(im,jm,lm)        _RL vz(im,jm,Lm)
51        _RL tz(im,jm,lm)        _RL tz(im,jm,Lm)
52        _RL qz(im,jm,lm)        _RL qz(im,jm,Lm)
53        _RL phis_var(im,jm)        _RL phis_var(im,jm)
54    
55        _RL dudt(im,jm,lm)        _RL dudt(im,jm,Lm)
56        _RL dvdt(im,jm,lm)        _RL dvdt(im,jm,Lm)
57        _RL dtdt(im,jm,lm)        _RL dtdt(im,jm,Lm)
58    
59  c Local Variables  c Local Variables
60  c ---------------  c ---------------
61        _RL tv(im,jm,lm)        _RL tv(im,jm,Lm)
62        _RL dragu(im,jm,lm), dragv(im,jm,lm)        _RL dragu(im,jm,Lm), dragv(im,jm,Lm)
63        _RL dragt(im,jm,lm)        _RL dragt(im,jm,Lm)
64        _RL dragx(im,jm), dragy(im,jm)        _RL dragx(im,jm), dragy(im,jm)
65        _RL sumu(im,jm)        _RL sumu(im,jm)
66        integer nthin(im,jm),nbase(im,jm)        integer nthin(im,jm),nbase(im,jm)
# Line 69  c --------------- Line 69  c ---------------
69        _RL phis_std(im,jm)        _RL phis_std(im,jm)
70    
71        _RL std(istrip), ps(istrip)        _RL std(istrip), ps(istrip)
72        _RL us(istrip,lm), vs(istrip,lm), ts(istrip,lm)        _RL us(istrip,Lm), vs(istrip,Lm), ts(istrip,Lm)
73        _RL dragus(istrip,lm), dragvs(istrip,lm)        _RL dragus(istrip,Lm), dragvs(istrip,Lm)
74        _RL dragxs(istrip), dragys(istrip)        _RL dragxs(istrip), dragys(istrip)
75        _RL 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
# Line 84  c --------------- Line 84  c ---------------
84        _RL tmpdiag(im,jm)        _RL tmpdiag(im,jm)
85  #endif  #endif
86    
       return  
   
87  c Initialization  c Initialization
88  c --------------  c --------------
89        pi    = 4.0*atan(1.0)        pi    = 4.0*atan(1.0)
# Line 100  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          if(diagnostics_is_on('SDIAG1  ',myid) ) then
124           do j=1,jm
125           do i=1,im
126            tmpdiag(i,j) = float(nthin(i,j))
127           enddo
128           enddo
129           call diagnostics_fill(tmpdiag,'SDIAG1  ',0,1,3,bi,bj,myid)
130          endif
131          if(diagnostics_is_on('SDIAG2  ',myid) ) then
132           do j=1,jm
133           do i=1,im
134            tmpdiag(i,j) = float(nbase(i,j))
135           enddo
136           enddo
137           call diagnostics_fill(tmpdiag,'SDIAG2  ',0,1,3,bi,bj,myid)
138          endif
139    
140  c Compute Topography Sub-Grid Standard Deviation  c Compute Topography Sub-Grid Standard Deviation
141    c        and constrain the Maximum Value
142  c ----------------------------------------------  c ----------------------------------------------
143        do j=1,jm        do j=1,jm
144        do i=1,im        do i=1,im
# Line 129  c -------------------------------------- Line 146  c --------------------------------------
146        enddo        enddo
147        enddo        enddo
148    
149          if(diagnostics_is_on('SDIAG3  ',myid) ) then
150           do j=1,jm
151           do i=1,im
152            tmpdiag(i,j) = phis_std(i,j)
153           enddo
154           enddo
155           call diagnostics_fill(tmpdiag,'SDIAG3  ',0,1,3,bi,bj,myid)
156          endif
157    
158  c Compute Virtual Temperatures  c Compute Virtual Temperatures
159  c ----------------------------  c ----------------------------
160        do L = 1,lm        do L = 1,Lm
161        do j = 1,jm        do j = 1,jm
162        do i = 1,im        do i = 1,im
163        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 139  c ---------------------------- Line 165  c ----------------------------
165        enddo        enddo
166        enddo        enddo
167    
168          do L = 1,Lm
169          do j = 1,jm
170          do i = 1,im
171           dragu(i,j,L) = 0.
172           dragv(i,j,L) = 0.
173           dragt(i,j,L) = 0.
174          enddo
175          enddo
176          enddo
177    
178  c Call Gravity Wave Drag Paramterization on A-Grid  c Call Gravity Wave Drag Paramterization on A-Grid
179  c ------------------------------------------------  c ------------------------------------------------
180    
# Line 147  c -------------------------------------- Line 183  c --------------------------------------
183        call strip ( phis_std,std,im*jm,istrip,1,n )        call strip ( phis_std,std,im*jm,istrip,1,n )
184    
185        call strip ( pz,ps,im*jm,istrip,1 ,n )        call strip ( pz,ps,im*jm,istrip,1 ,n )
186        call strip ( uz,us,im*jm,istrip,lm,n )        call strip ( uz,us,im*jm,istrip,Lm,n )
187        call strip ( vz,vs,im*jm,istrip,lm,n )        call strip ( vz,vs,im*jm,istrip,Lm,n )
188        call strip ( tv,ts,im*jm,istrip,lm,n )        call strip ( tv,ts,im*jm,istrip,Lm,n )
189        call strip ( pl,plstr,im*jm,istrip,lm,n )        call strip ( pl,plstr,im*jm,istrip,Lm,n )
190        call strip ( ple,plestr,im*jm,istrip,lm,n )        call strip ( ple,plestr,im*jm,istrip,Lm,n )
191        call strip ( dpres,dpresstr,im*jm,istrip,lm,n )        call strip ( dpres,dpresstr,im*jm,istrip,Lm,n )
192        call stripint ( nthin,nthinstr,im*jm,istrip,lm,n )        call stripint ( nthin,nthinstr,im*jm,istrip,1,n )
193        call stripint ( nbase,nbasestr,im*jm,istrip,lm,n )        call stripint ( nbase,nbasestr,im*jm,istrip,1,n )
194    
195        call GWDD ( ps,us,vs,ts,        call GWDD ( ps,us,vs,ts,
196       .            dragus,dragvs,dragxs,dragys,std,       .            dragus,dragvs,dragxs,dragys,std,
197       .            plstr,plestr,dpresstr,grav,rgas,cp,       .            plstr,plestr,dpresstr,grav,rgas,cp,
198       .            istrip,lm,nthinstr,nbasestr,lstar )       .            istrip,Lm,nthinstr,nbasestr,lstar )
199    
200        call paste ( dragus,dragu,istrip,im*jm,lm,n )        call paste ( dragus,dragu,istrip,im*jm,Lm,n )
201        call paste ( dragvs,dragv,istrip,im*jm,lm,n )        call paste ( dragvs,dragv,istrip,im*jm,Lm,n )
202        call paste ( dragxs,dragx,istrip,im*jm,1 ,n )        call paste ( dragxs,dragx,istrip,im*jm,1 ,n )
203        call paste ( dragys,dragy,istrip,im*jm,1 ,n )        call paste ( dragys,dragy,istrip,im*jm,1 ,n )
204    
# Line 170  c -------------------------------------- Line 206  c --------------------------------------
206    
207  c Add Gravity-Wave Drag to Wind and Theta Tendencies  c Add Gravity-Wave Drag to Wind and Theta Tendencies
208  c --------------------------------------------------  c --------------------------------------------------
209        do L = 1,lm        do L = 1,Lm
210        do j = 1,jm        do j = 1,jm
211        do i = 1,im        do i = 1,im
212        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,abs(dragu(i,j,L))),dragu(i,j,L) )
213        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,abs(dragv(i,j,L))),dragv(i,j,L) )
214        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) )
215       .                                                         *cpinv       .                                                         *cpinv
216         dudt(i,j,L) = dudt(i,j,L) + dragu(i,j,L)  c      dudt(i,j,L) = dudt(i,j,L) + dragu(i,j,L)
217         dvdt(i,j,L) = dvdt(i,j,L) + dragv(i,j,L)  c      dvdt(i,j,L) = dvdt(i,j,L) + dragv(i,j,L)
218         dtdt(i,j,L) = dtdt(i,j,L) + dragt(i,j,L)*pz(i,j)/pkz(i,j,L)  c      dtdt(i,j,L) = dtdt(i,j,L) + dragt(i,j,L)/pkz(i,j,L)
219        enddo        enddo
220        enddo        enddo
221        enddo        enddo
# Line 187  c -------------------------------------- Line 223  c --------------------------------------
223  c Compute Diagnostics  c Compute Diagnostics
224  c -------------------  c -------------------
225  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
226        do L = 1,lm        do L = 1,Lm
227    
228        if(diagnostics_is_on('GWDU    ',myid) ) then        if(diagnostics_is_on('GWDU    ',myid) ) then
229         do j=1,jm         do j=1,jm
# Line 238  c -------------------------------------- Line 274  c --------------------------------------
274        sumu(i,j) = 0.0        sumu(i,j) = 0.0
275        enddo        enddo
276        enddo        enddo
277        do L = 1,lm        do L = 1,Lm
278        do j = 1,jm        do j = 1,jm
279        do i = 1,im        do i = 1,im
280        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)
# Line 261  c -------------------------------------- Line 297  c --------------------------------------
297        sumu(i,j) = 0.0        sumu(i,j) = 0.0
298        enddo        enddo
299        enddo        enddo
300        do L = 1,lm        do L = 1,Lm
301        do j = 1,jm        do j = 1,jm
302        do i = 1,im        do i = 1,im
303        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)
# Line 281  c -------------------------------------- Line 317  c --------------------------------------
317        end        end
318        SUBROUTINE GWDD ( ps,u,v,t,dudt,dvdt,xdrag,ydrag,        SUBROUTINE GWDD ( ps,u,v,t,dudt,dvdt,xdrag,ydrag,
319       .                  std,pl,ple,dpres,       .                  std,pl,ple,dpres,
320       .                  grav,rgas,cp,irun,lm,nthin,nbase,lstar )       .                  grav,rgas,cp,irun,Lm,nthin,nbase,lstar )
321  C***********************************************************************  C***********************************************************************
322  C  C
323  C Description:  C Description:
# Line 303  C    grav ....... Gravitational constant Line 339  C    grav ....... Gravitational constant
339  C    rgas ....... Gas constant  C    rgas ....... Gas constant
340  C    cp ......... Specific Heat at constant pressure  C    cp ......... Specific Heat at constant pressure
341  C    irun ....... Number of grid-points in horizontal dimension  C    irun ....... Number of grid-points in horizontal dimension
342  C    lm ......... Number of grid-points in vertical   dimension  C    Lm ......... Number of grid-points in vertical   dimension
343  C    lstar ...... Monochromatic Wavelength/(2*pi)  C    lstar ...... Monochromatic Wavelength/(2*pi)
344  C  C
345  C Output:  C Output:
# Line 313  C    dvdt ....... Meridional Acceleratio Line 349  C    dvdt ....... Meridional Acceleratio
349  C    xdrag ...... Zonal Surface and Base Layer Stress (Pa)  C    xdrag ...... Zonal Surface and Base Layer Stress (Pa)
350  C    ydrag ...... Meridional Surface and Base Layer Stress (Pa)  C    ydrag ...... Meridional Surface and Base Layer Stress (Pa)
351  C  C
352    C NOTE: Quantities computed locally in GWDD use a
353    C              bottom-up counting of levels
354    C       The fizhi code uses a top-down so all
355    C       Quantities that came in through the arg list
356    C       must use reverse vertical indexing!!!
357  C***********************************************************************  C***********************************************************************
358    
359        implicit none        implicit none
360    
361  c Input Variables  c Input Variables
362  c ---------------  c ---------------
363        integer irun,lm        integer irun,Lm
364        _RL ps(irun)        _RL ps(irun)
365        _RL u(irun,lm), v(irun,lm), t(irun,lm)        _RL u(irun,Lm), v(irun,Lm), t(irun,Lm)
366        _RL dudt(irun,lm), dvdt(irun,lm)        _RL dudt(irun,Lm), dvdt(irun,Lm)
367        _RL xdrag(irun), ydrag(irun)        _RL xdrag(irun), ydrag(irun)
368        _RL std(irun)        _RL std(irun)
369        _RL ple(irun,lm+1), pl(irun,lm), dpres(irun,lm)        _RL ple(irun,Lm+1), pl(irun,Lm), dpres(irun,Lm)
370        _RL grav, rgas, cp        _RL grav, rgas, cp
371        integer nthin(irun),nbase(irun)        integer nthin(irun),nbase(irun)
372        _RL lstar        _RL lstar
# Line 334  c Dynamic Allocation Variables Line 375  c Dynamic Allocation Variables
375  c ----------------------------  c ----------------------------
376        _RL ubar(irun), vbar(irun), robar(irun)        _RL ubar(irun), vbar(irun), robar(irun)
377        _RL speed(irun), ang(irun)        _RL speed(irun), ang(irun)
378        _RL bv(irun,lm)        _RL bv(irun,Lm)
379        _RL nbar(irun)        _RL nbar(irun)
380    
381        _RL tstd(irun)        _RL XTENS(irun,Lm+1), YTENS(irun,Lm+1)
382        _RL XTENS(irun,lm+1), YTENS(irun,lm+1)        _RL TENSIO(irun,Lm+1)
       _RL TENSIO(irun,lm+1)  
383        _RL DRAGSF(irun)        _RL DRAGSF(irun)
384        _RL RO(irun,lm), DZ(irun,lm)        _RL RO(irun,Lm), DZ(irun,Lm)
385    
386        integer icrilv(irun)        integer icrilv(irun)
387    
388  c Local Variables  c Local Variables
389  c ---------------  c ---------------
390        integer  i,l        integer  i,L
391        _RL a,g,stdmax,agrav,akwnmb        _RL a,g,agrav,akwnmb
392        _RL gocp,roave,roiave,frsf,gstar,vai1,vai2        _RL gocp,roave,roiave,frsf,gstar,vai1,vai2
393        _RL vaisd,velco,deluu,delvv,delve2,delz,vsqua        _RL vaisd,velco,deluu,delvv,delve2,delz,vsqua
394        _RL richsn,crifro,crif2,fro2,coef        _RL richsn,crifro,crif2,fro2,coef
# Line 357  c Initialization Line 397  c Initialization
397  c --------------  c --------------
398        a      = 1.0        a      = 1.0
399        g      = 1.0        g      = 1.0
400        agrav  = 1.0/GRAV        agrav  = 1.0/grav
401        akwnmb = 1.0/lstar        akwnmb = 1.0/lstar
402        gocp   = GRAV/CP        gocp   = grav/cp
   
 c Constrain the Maximum Value of the Standard Deviation  
 c -----------------------------------------------------  
       stdmax = 400.  
       do i = 1,irun  
          tstd(i) = std(i)  
       if( std(i).gt.stdmax ) tstd(i) = stdmax  
       enddo  
403    
404  c Compute Atmospheric Density  c Compute Atmospheric Density (with virtual temp)
405  c ---------------------------  c -----------------------------------------------
406        do l = 1,lm        do l = 1,Lm
407        do i = 1,irun        do i = 1,irun
408        ro(i,l) = pl(i,l)/(rgas*t(i,lm+1-l))         ro(i,L) = pl(i,Lm+1-L)/(rgas*t(i,Lm+1-L))
409        enddo        enddo
410        enddo        enddo
411    
412  c Compute Layer Thicknesses  c Compute Layer Thicknesses
413  c -------------------------  c -------------------------
414        do l = 2,lm        do l = 2,Lm
415        do i = 1,irun        do i = 1,irun
416        roiave  = ( 1./ro(i,l-1) + 1./ro(i,l) )*0.5         roiave  = ( 1./ro(i,L-1) + 1./ro(i,L) )*0.5
417        dz(i,l) = agrav*roiave*( pl(i,l-1)-pl(i,l) )         dz(i,L) = agrav*roiave*( pl(i,Lm+1-L-1)-pl(i,Lm+1-L) )
418        enddo        enddo
419        enddo        enddo
420    
421    
422  c******************************************************  c***********************************************************************
423  c          Surface and Base Layer Stress              *  c          Surface and Base Layer Stress                               *
424  c******************************************************  c***********************************************************************
425    
426  c Definition of Surface Wind Vector  c Definition of Surface Wind Vector
427  c ---------------------------------  c ---------------------------------
428        do  i = 1,irun        do  i = 1,irun
429        robar(i) = 0.0         robar(i) = 0.0
430         ubar(i) = 0.0         ubar(i) = 0.0
431         vbar(i) = 0.0         vbar(i) = 0.0
432        enddo        enddo
433    
434        do  i = 1,irun        do  i = 1,irun
435        do  L = 1,nbase(i)-1        do  L = 1,nbase(i)-1
436        robar(i) = robar(i) + ro(i,L)     *(ple(i,L)-ple(i,L+1))         robar(i) = robar(i) + ro(i,L) * (ple(i,Lm+1-L)-ple(i,Lm+1-L+1))
437         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+1-L)-ple(i,Lm+1-L+1))
438         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+1-L)-ple(i,Lm+1-L+1))
439        enddo        enddo
440        enddo        enddo
441    
442        do  i = 1,irun        do  i = 1,irun
443        robar(i) = robar(i)/(ple(i,1)-ple(i,nbase(i))) * 100.0         robar(i) = robar(i)/(ple(i,Lm)-ple(i,Lm+1-nbase(i))) * 100.0
444         ubar(i) =  ubar(i)/(ple(i,1)-ple(i,nbase(i)))         ubar(i) = ubar(i)/(ple(i,Lm)-ple(i,Lm+1-nbase(i)))
445         vbar(i) =  vbar(i)/(ple(i,1)-ple(i,nbase(i)))         vbar(i) = vbar(i)/(ple(i,Lm)-ple(i,Lm+1-nbase(i)))
   
       speed(i) = SQRT( ubar(i)*ubar(i) + vbar(i)*vbar(i) )  
         ang(i) = ATAN2(vbar(i),ubar(i))  
446    
447           speed(i) = sqrt( ubar(i)*ubar(i) + vbar(i)*vbar(i) )
448           ang(i) = atan2(vbar(i),ubar(i))
449        enddo        enddo
450    
451  c Brunt Vaisala Frequency  c Brunt Vaisala Frequency
452  c -----------------------  c -----------------------
453        do i = 1,irun        do i = 1,irun
454        do l = 2,nbase(i)         do l = 2,nbase(i)
455            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
456        if( VAI1.LT.0.0 ) then          if( vai1.LT.0.0 ) then
457            VAI1 =  0.0           vai1 =  0.0
458        endif          endif
459        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) )
460        VSQUA   = VAI1*VAI2          vsqua   = vai1*vai2
461        BV(i,l) = SQRT(VSQUA)          bv(i,L) = sqrt(vsqua)
462        enddo         enddo
463        enddo        enddo
464    
465  c Stress at the Surface Level  c Stress at the Surface Level
466  c ---------------------------  c ---------------------------
467        do i = 1,irun        do i = 1,irun
468        nbar(i) = 0.0         nbar(i) = 0.0
469        enddo        enddo
470        do i = 1,irun        do i = 1,irun
471        do l = 2,nbase(i)        do l = 2,nbase(i)
472        NBAR(i) = NBAR(i) + BV(i,l)*(pl(i,l-1)-pl(i,l))         nbar(i) = nbar(i) + bv(i,L)*(pl(i,Lm+1-L-1)-pl(i,Lm+1-L))
473        enddo        enddo
474        enddo        enddo
475    
476        do i = 1,irun        do i = 1,irun
477        NBAR(i) = NBAR(i)/(pl(i,1)-pl(i,nbase(i)))         nbar(i) = nbar(i)/(pl(i,Lm)-pl(i,Lm+1-nbase(i)))
478        FRSF    = NBAR(i)*tstd(i)/speed(i)         frsf = nbar(i)*std(i)/speed(i)
479    
480        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
481        TENSIO(i,1) = 0.0          tensio(i,1) = 0.0
482        else         else
483        GSTAR = G*FRSF*FRSF/(FRSF*FRSF+A*A)          gstar = g*frsf*frsf/(frsf*frsf+a*a)
484        TENSIO(i,1) = GSTAR*(ROBAR(i)*speed(i)*speed(i)*speed(i))          tensio(i,1) = gstar*(robar(i)*speed(i)*speed(i)*speed(i))
485       .            / (NBAR(i)*LSTAR)       .            / (nbar(i)*lstar)
486        endif         endif
487    
488         XTENS(i,1) = TENSIO(i,1) * cos(ang(i))         xtens(i,1) = tensio(i,1) * cos(ang(i))
489         YTENS(i,1) = TENSIO(i,1) * sin(ang(i))         ytens(i,1) = tensio(i,1) * sin(ang(i))
490        DRAGSF(i)   = TENSIO(i,1)         dragsf(i) = tensio(i,1)
491         XDRAG(i)   =  XTENS(i,1)         xdrag(i) = xtens(i,1)
492         YDRAG(i)   =  YTENS(i,1)         ydrag(i) = ytens(i,1)
493        enddo        enddo
494    
495  c Check for Very thin lowest layer  c Check for Very thin lowest layer
496  c --------------------------------  c --------------------------------
497        do i = 1,irun        do i = 1,irun
498        if( NTHIN(i).gt.1 ) then         if( nthin(i).gt.1 ) then
499        do l = 1,nthin(i)          do l = 1,nthin(i)
500        TENSIO(i,l) = TENSIO(i,1)           tensio(i,L) = tensio(i,1)
501         XTENS(i,l) =  XTENS(i,1)           xtens(i,L) = xtens(i,1)
502         YTENS(i,l) =  YTENS(i,1)           ytens(i,L) = ytens(i,1)
503        enddo          enddo
504        endif         endif
505        enddo        enddo
506    
507  c******************************************************  c******************************************************
# Line 478  c  Compute Gravity Wave Stress from NTHI Line 509  c  Compute Gravity Wave Stress from NTHI
509  c******************************************************  c******************************************************
510    
511        do i = 1,irun        do i = 1,irun
512        do l = nthin(i)+1,nbase(i)         do l = nthin(i)+1,nbase(i)
513    
514        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))
515       .            + (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))  )
516       .      /   speed(i)       .      /   speed(i)
517    
518  C Convert to Newton/m**2  C Convert to Newton/m**2
519        roave = 0.5*(ro(i,l-1)+ro(i,l)) * 100.0              roave = 0.5*(ro(i,L-1)+ro(i,L)) * 100.0    
520    
521        if( VELCO.le.0.0 ) then          if( velco.le.0.0 ) then
522        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
523        goto 1500           goto 1500
524        endif          endif
525                                            
526  c Froude number squared  c Froude number squared
527  c ---------------------  c ---------------------
528        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)
529        DELUU  = u(i,lm+1-l)-u(i,lm+2-l)          deluu = u(i,Lm+1-L)-u(i,Lm+2-L)
530        DELVV  = v(i,lm+1-l)-v(i,lm+2-l)          delvv = v(i,Lm+1-L)-v(i,Lm+2-L)
531        DELVE2 = ( DELUU*DELUU + DELVV*DELVV )          delve2 = ( deluu*deluu + delvv*delvv )
532    
533  c Compute Richarson Number  c Compute Richarson Number
534  c ------------------------  c ------------------------
535        if( DELVE2.ne.0.0 ) then          if( delve2.ne.0.0 ) then
536          DELZ = DZ(i,l)           delz = dz(i,L)
537         VSQUA = BV(i,l)*BV(i,l)           vsqua = bv(i,L)*bv(i,L)
538        RICHSN = DELZ*DELZ*VSQUA/DELVE2           richsn = delz*delz*vsqua/delve2
539        else          else
540        RICHSN = 99999.0           richsn = 99999.0
541        endif          endif
542    
543        if( RICHSN.le.0.25 ) then          if( richsn.le.0.25 ) then
544        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
545        goto 1500           goto 1500
546        endif          endif
547    
548  c Stress in the Base Layer changes if the local Froude number  c Stress in the Base Layer changes if the local Froude number
549  c exceeds the Critical Froude number  c exceeds the Critical Froude number
550  c ----------------------------------  c ----------------------------------
551                    CRIFRO = 1.0 - 0.25/RICHSN          crifro = 1.0 - 0.25/richsn
552                     CRIF2 = CRIFRO*CRIFRO          crif2 = crifro*crifro
553        if( l.eq.2 ) CRIF2 = MIN(0.7,CRIF2)          if( l.eq.2 ) crif2 = min(0.7,crif2)
554    
555        if( FRO2.gt.CRIF2 ) then          if( fro2.gt.crif2 ) then
556        TENSIO(i,l) = CRIF2/FRO2*TENSIO(i,l-1)           tensio(i,L) = crif2/fro2*tensio(i,L-1)
557        else          else
558        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
559        endif          endif
560    
561  1500  CONTINUE  1500    continue
562        XTENS(i,l) = TENSIO(i,l)*COS(ang(i))          xtens(i,L) = tensio(i,L)*cos(ang(i))
563        YTENS(i,l) = TENSIO(i,l)*SIN(ang(i))          ytens(i,L) = tensio(i,L)*sin(ang(i))
564    
565        enddo         enddo
566        enddo        enddo
567    
568  c******************************************************  c******************************************************
# Line 539  c    Compute Gravity Wave Stress from Ba Line 570  c    Compute Gravity Wave Stress from Ba
570  c******************************************************  c******************************************************
571    
572        do i = 1,irun        do i = 1,irun
573        icrilv(i) = 0         icrilv(i) = 0
574        enddo        enddo
575    
576        do i = 1,irun        do i = 1,irun
577        do l = nbase(i)+1,lm+1         do l = nbase(i)+1,Lm+1
578    
579        TENSIO(i,l) = 0.0          tensio(i,L) = 0.0
580    
581  c Check for Critical Level Absorption  c Check for Critical Level Absorption
582  c -----------------------------------  c -----------------------------------
583        if( icrilv(i).eq.1 ) goto 130          if( icrilv(i).eq.1 ) goto 130
584    
585  c Let Remaining Stress escape out the top edge of model  c Let Remaining Stress escape out the top edge of model
586  c -----------------------------------------------------  c -----------------------------------------------------
587        if( l.eq.lm+1 ) then          if( l.eq.Lm+1 ) then
588        TENSIO(i,l) = TENSIO(i,l-1)           tensio(i,L) = tensio(i,L-1)
589        goto 130           goto 130
590        endif          endif
591    
592        ROAVE = 0.5*(ro(i,l-1)+ro(i,l)) * 100.0          roave = 0.5*(ro(i,L-1)+ro(i,L)) * 100.0
593        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
594    
595        if( VAI1.lt.0.0 ) then          if( vai1.lt.0.0 ) then
596        icrilv(i)   = 1           icrilv(i)   = 1
597        TENSIO(i,l) = 0.0           tensio(i,L) = 0.0
598        goto 130           goto 130
599        endif          endif
600    
601            vai2  = 2.0*grav/(t(i,Lm+1-L)+t(i,Lm+2-L))
602            vsqua = vai1*vai2
603            vaisd = sqrt(vsqua)
604    
605        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))
606        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))  )  
607       .      /   speed(i)       .      /   speed(i)
608    
609        if( velco.lt.0.0 ) then          if( velco.lt.0.0 ) then
610        icrilv(i)   = 1           icrilv(i)   = 1
611        TENSIO(i,l) = 0.0           tensio(i,L) = 0.0
612        goto 130           goto 130
613        endif          endif
614    
615  c Froude number squared  c Froude number squared
616  c ---------------------  c ---------------------
617        FRO2   = vaisd/(AKWNMB*ROAVE*VELCO*VELCO*VELCO)*TENSIO(i,l-1)          fro2 = vaisd/(akwnmb*roave*velco*velco*velco)*tensio(i,L-1)
618        DELUU  = u(i,lm+1-l)-u(i,lm+2-l)          deluu = u(i,Lm+1-L)-u(i,Lm+2-L)
619        DELVV  = v(i,lm+1-l)-v(i,lm+2-l)          delvv = v(i,Lm+1-L)-v(i,Lm+2-L)
620        DELVE2 = ( DELUU*DELUU + DELVV*DELVV )          delve2 = ( deluu*deluu + delvv*delvv )
621    
622  c Compute Richarson Number  c Compute Richarson Number
623  c ------------------------  c ------------------------
624        if( DELVE2.ne.0.0 ) then          if( delve2.ne.0.0 ) then
625        DELZ   = DZ(i,l)           delz   = dz(i,L)
626        RICHSN = DELZ*DELZ*VSQUA/DELVE2           richsn = delz*delz*vsqua/delve2
627        else          else
628        RICHSN = 99999.0           richsn = 99999.0
629        endif          endif
630    
631        if( RICHSN.le.0.25 ) then          if( richsn.le.0.25 ) then
632        TENSIO(i,l) = 0.0           tensio(i,L) = 0.0
633        icrilv(i)   = 1           icrilv(i)   = 1
634        goto 130           goto 130
635        endif          endif
636    
637  c Stress in Layer changes if the local Froude number  c Stress in Layer changes if the local Froude number
638  c exceeds the Critical Froude number  c exceeds the Critical Froude number
639  c ----------------------------------  c ----------------------------------
640        CRIFRO = 1.0 - 0.25/RICHSN          crifro = 1.0 - 0.25/richsn
641         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  
642    
643    130 continue          if( fro2.ge.crif2 ) then
644        XTENS(i,l) = TENSIO(i,l)*COS(ang(i))           tensio(i,L) = crif2/fro2*tensio(i,L-1)
645        YTENS(i,l) = TENSIO(i,l)*SIN(ang(i))          else
646        enddo           tensio(i,L) = tensio(i,L-1)
647            endif
648    
649      130   continue
650            xtens(i,L) = tensio(i,L)*cos(ang(i))
651            ytens(i,L) = tensio(i,L)*sin(ang(i))
652           enddo
653        enddo        enddo
654    
655  C ******************************************************  C ******************************************************
# Line 626  C       MOMENTUM CHANGE FOR FREE ATMOSPH Line 657  C       MOMENTUM CHANGE FOR FREE ATMOSPH
657  C ******************************************************  C ******************************************************
658    
659        do i = 1,irun        do i = 1,irun
660        do l = nthin(i)+1,lm        do l = nthin(i)+1,Lm
661        coef = -grav*ple(i,lm+1)/dpres(i,lm+1-l)         coef = -grav*ple(i,Lm+1)/dpres(i,Lm+1-L)
662        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))
663        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))
664        enddo        enddo
665        enddo        enddo
666    
667  c Momentum change near the surface  c Momentum change near the surface
668  c --------------------------------  c --------------------------------
669        do i = 1,irun        do i = 1,irun
670        coef = grav*ple(i,lm+1)/(ple(i,lm+1-nthin(i))-ple(i,lm+1))         coef = grav*ple(i,Lm+1)/(ple(i,Lm+1-nthin(i))-ple(i,Lm+1))
671        dudt(i,lm) = coef*(XTENS(i,nthin(i)+1)-XTENS(i,1))         dudt(i,Lm) = coef*(xtens(i,nthin(i)+1)-xtens(i,1))
672        dvdt(i,lm) = coef*(YTENS(i,nthin(i)+1)-YTENS(i,1))         dvdt(i,Lm) = coef*(ytens(i,nthin(i)+1)-ytens(i,1))
673        enddo        enddo
674    
675  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
676  c ----------------------------------------------------------  c ----------------------------------------------------------
677        do i = 1,irun        do i = 1,irun
678        if( nthin(i).gt.1 ) then         if( nthin(i).gt.1 ) then
679        do l = 2,nthin(i)          do l = 2,nthin(i)
680        dudt(i,lm+1-l) = dudt(i,lm)           dudt(i,Lm+1-L) = dudt(i,Lm)
681        dvdt(i,lm+1-l) = dvdt(i,lm)           dvdt(i,Lm+1-L) = dvdt(i,Lm)
682        enddo          enddo
683        endif         endif
684        enddo        enddo
685    
686  c Convert Units to (m/sec**2)  c Convert Units to (m/sec**2)
687  c ---------------------------  c ---------------------------
688        do l = 1,lm        do l = 1,Lm
689        do i = 1,irun        do i = 1,irun
690        dudt(i,l) = - dudt(i,l)/ps(i)*0.01         dudt(i,L) = - dudt(i,L)/ps(i)*0.01
691        dvdt(i,l) = - dvdt(i,l)/ps(i)*0.01         dvdt(i,L) = - dvdt(i,L)/ps(i)*0.01
692        enddo        enddo
693        enddo        enddo
694    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22