source: codes/icosagcm/trunk/src/dcmip_initial_conditions_test_1_2_3_v5.f90 @ 48

Last change on this file since 48 was 48, checked in by dubos, 12 years ago

Introduced DCMIP-supplied routines for optional use in test cases 1,2,3.

File size: 47.0 KB
Line 
1MODULE dcmip_initial_conditions_test_1_2_3
2
3  !=======================================================================
4  !
5  !  Functions for setting up initial conditions for the dynamical core tests:
6  !
7  !  11 - Deformational Advection Test
8  !  12 - Hadley Cell Advection Test
9  !  13 - Orography Advection Test
10  !  20 - Impact of orography on a steady-state at rest
11  !  21 and 22 - Non-Hydrostatic Mountain Waves Over A Schaer-Type Mountain without and with vertical wind shear
12  !  31 - Non-Hydrostatic Gravity Waves
13  !
14  !  Given a point specified by:
15  !     lon     longitude (radians)
16  !     lat     latitude (radians)
17  !     p/z     pressure/height
18  !  the functions will return:
19  !     u       zonal wind (m s^-1)
20  !     v       meridional wind (m s^-1)
21  !     w       vertical velocity (m s^-1)
22  !     t       temperature (K)
23  !     phis    surface geopotential (m^2 s^-2)
24  !     ps      surface pressure (Pa)
25  !     rho     density (kj m^-3)
26  !     q       specific humidity (kg/kg)
27  !     qi      tracers (kg/kg)
28  !     p       pressure if height based (Pa)
29  !
30  !
31  !  Authors: James Kent, Paul Ullrich, Christiane Jablonowski
32  !             (University of Michigan, dcmip@ucar.edu)
33  !          version 4
34  !          July/8/2012
35  !
36  ! Change log: (v3, June/8/2012, v4 July/8/2012, v5 July/20/2012)
37  !
38  ! v2: bug fixes in the tracer initialization for height-based models
39  ! v3: test 3-1: the density is now initialized with the unperturbed background temperature (not the perturbed temperature)
40  ! v3: constants converted to double precision
41  ! v4: modified tracers in test 1-1, now with cutoff altitudes. Outside of the vertical domain all tracers are set to 0
42  ! v4: modified cos-term in vertical velocity (now cos(2 pi t/tau)) in test 1-1, now completing one full up and down cycle
43  ! v4: added subroutine test1_advection_orography for test 1-3
44  ! v4: added subroutine test2_steady_state_mountain for test 2-0
45  ! v4: modified parameter list for tests 2-1 and 2-2 (routine test2_schaer_mountain): addition of parameters hybrid_eta, hyam, hybm
46  !     if the logical flag hybrid_eta is true then the pressure in pressure-based model with hybrid sigma-p (eta) coordinates is
47  !     computed internally. In that case the hybrid coefficients hyam and hybm need to be supplied via the parameter list,
48  !     otherwise they are not used.
49  ! v5: Change in test 11 - change to u and w, cutoff altitudes (introduced in v4) are removed again
50  ! v5: Change in test 12 - velocities multiplies by rho0/rho, different w0 and vertical location of the initial tracer
51  !
52  !
53  !=======================================================================
54
55  USE prec
56
57  IMPLICIT NONE
58
59  PRIVATE
60  PUBLIC :: test3_gravity_wave ! (lon,lat,p,z,zcoords,u,v,w,t,phis,ps,rho,q)
61
62!-----------------------------------------------------------------------
63!     Physical Parameters
64!-----------------------------------------------------------------------
65
66  REAL(rstd), parameter ::      &
67       a        = 6371220.0d0,  &       ! Earth's Radius (m)
68       Rd       = 287.0d0,      &       ! Ideal gas const dry air (J kg^-1 K^1)
69       g        = 9.80616d0,    &       ! Gravity (m s^2)
70       cp       = 1004.5d0,     &       ! Specific heat capacity (J kg^-1 K^1)
71       pi       = 4.d0*atan(1.d0)       ! pi
72
73!-----------------------------------------------------------------------
74!     Additional constants
75!-----------------------------------------------------------------------
76
77  real(rstd), parameter ::      p0      = 100000.d0             ! reference pressure (Pa)
78
79
80CONTAINS
81
82!==========================================================================================
83! TEST CASE 11 - PURE ADVECTION - 3D DEFORMATIONAL FLOW
84!==========================================================================================
85
86! The 3D deformational flow test is based on the deformational flow test of Nair and Lauritzen (JCP 2010),
87! with a prescribed vertical wind velocity which makes the test truly 3D. An unscaled planet (with scale parameter
88! X = 1) is selected.
89
90SUBROUTINE test1_advection_deformation (lon,lat,p,z,zcoords,u,v,w,t,phis,ps,rho,q,q1,q2,q3,q4)
91
92IMPLICIT NONE
93!-----------------------------------------------------------------------
94!     input/output params parameters at given location
95!-----------------------------------------------------------------------
96
97        real(rstd), intent(in)  :: lon, &               ! Longitude (radians)
98                                lat, &          ! Latitude (radians)
99                                z               ! Height (m)
100
101        real(rstd), intent(inout) :: p          ! Pressure  (Pa)                               
102
103        integer,  intent(in) :: zcoords         ! 0 or 1 see below
104
105        real(rstd), intent(out) :: u, &                 ! Zonal wind (m s^-1)
106                                v, &            ! Meridional wind (m s^-1)
107                                w, &            ! Vertical Velocity (m s^-1)
108                                t, &            ! Temperature (K)
109                                phis, &         ! Surface Geopotential (m^2 s^-2)
110                                ps, &           ! Surface Pressure (Pa)
111                                rho, &          ! density (kg m^-3)
112                                q, &            ! Specific Humidity (kg/kg)
113                                q1, &           ! Tracer q1 (kg/kg)
114                                q2, &           ! Tracer q2 (kg/kg)
115                                q3, &           ! Tracer q3 (kg/kg)
116                                q4              ! Tracer q4 (kg/kg)
117
118        ! if zcoords = 1, then we use z and output p
119        ! if zcoords = 0, then we use p
120
121!-----------------------------------------------------------------------
122!     test case parameters
123!-----------------------------------------------------------------------
124        real(rstd), parameter ::        tau     = 12.d0 * 86400.d0,     &       ! period of motion 12 days
125                                u0      = (2.d0*pi*a)/tau,      &       ! 2 pi a / 12 days
126                                k0      = (10.d0*a)/tau,        &       ! Velocity Magnitude
127                                omega0  = (23000.d0*pi)/tau,    &       ! Velocity Magnitude
128                                T0      = 300.d0,               &       ! temperature
129                                H       = Rd * T0 / g,          &       ! scale height
130                                RR      = 1.d0/2.d0,            &       ! horizontal half width divided by 'a'
131                                ZZ      = 1000.d0,              &       ! vertical half width
132                                z0      = 5000.d0,              &       ! center point in z
133                                lambda0 = 5.d0*pi/6.d0,         &       ! center point in longitudes
134                                lambda1 = 7.d0*pi/6.d0,         &       ! center point in longitudes
135                                phi0    = 0.d0,                 &       ! center point in latitudes
136                                phi1    = 0.d0                     
137                           
138      real(rstd) :: height                                                      ! The height of the model levels
139      real(rstd) :: ptop                                                        ! Model top in p
140      real(rstd) :: sin_tmp, cos_tmp, sin_tmp2, cos_tmp2                        ! Calculate great circle distances
141      real(rstd) :: d1, d2, r, r2, d3, d4                                       ! For tracer calculations
142      real(rstd) :: s, bs                                                       ! Shape function, and parameter
143      real(rstd) :: lonp                                                        ! Translational longitude, depends on time
144      real(rstd) :: ud                                                  ! Divergent part of u
145      real(rstd) :: time                                                        ! Initially set to zero seconds, needs
146                                                                        ! to be modified when used in dycore
147
148!-----------------------------------------------------------------------
149!    HEIGHT AND PRESSURE
150!-----------------------------------------------------------------------
151       
152        ! Height and pressure are aligned (p = p0 exp(-z/H))
153
154        if (zcoords .eq. 1) then
155
156                height = z
157                p = p0 * exp(-z/H)
158
159        else
160
161                height = H * log(p0/p)
162
163        endif
164
165        ! Model top in p
166
167        ptop    = p0*exp(-12000.d0/H)   
168
169!-----------------------------------------------------------------------
170!    THE VELOCITIES ARE TIME DEPENDENT AND THEREFORE MUST BE UPDATED
171!    IN THE DYNAMICAL CORE
172!-----------------------------------------------------------------------
173
174        ! These are initial conditions hence time = 0
175
176        time = 0.d0
177
178        ! Translational longitude = longitude when time = 0
179
180        lonp = lon - 2.d0*pi*time/tau
181
182        ! Shape function
183!********
184! change in version 5: shape function
185!********
186        bs = 0.2
187        s = 1.0 + exp( (ptop-p0)/(bs*ptop) ) - exp( (p-p0)/(bs*ptop)) - exp( (ptop-p)/(bs*ptop))
188
189        ! Zonal Velocity
190!********
191! change in version 5: ud
192!********
193
194        ud = (omega0*a)/(bs*ptop) * cos(lonp) * (cos(lat)**2.0) * cos(2.0*pi*time/tau) * &
195                ( - exp( (p-p0)/(bs*ptop)) + exp( (ptop-p)/(bs*ptop))  )
196
197        u = k0*sin(lonp)*sin(lonp)*sin(2.d0*lat)*cos(pi*time/tau) + u0*cos(lat) + ud
198
199        ! Meridional Velocity
200
201        v = k0*sin(2.d0*lonp)*cos(lat)*cos(pi*time/tau)
202
203        ! Vertical Velocity - can be changed to vertical pressure velocity by
204        ! omega = -(g*p)/(Rd*T0)*w
205        !
206!********
207! change in version 4: cos(2.0*pi*time/tau) is now used instead of cos(pi*time/tau)
208!********
209!********
210! change in version 5: shape function in w
211!********
212        w = -((Rd*T0)/(g*p))*omega0*sin(lonp)*cos(lat)*cos(2.0*pi*time/tau)*s
213
214!-----------------------------------------------------------------------
215!    TEMPERATURE IS CONSTANT 300 K
216!-----------------------------------------------------------------------
217
218        t = T0
219
220!-----------------------------------------------------------------------
221!    PHIS (surface geopotential)
222!-----------------------------------------------------------------------
223     
224        phis = 0.d0
225
226!-----------------------------------------------------------------------
227!    PS (surface pressure)
228!-----------------------------------------------------------------------
229
230        ps = p0
231
232!-----------------------------------------------------------------------
233!    RHO (density)
234!-----------------------------------------------------------------------
235
236        rho = p/(Rd*t)
237
238!-----------------------------------------------------------------------
239!     initialize Q, set to zero
240!-----------------------------------------------------------------------
241
242        q = 0.d0
243
244!-----------------------------------------------------------------------
245!     initialize tracers
246!-----------------------------------------------------------------------
247
248        ! Tracer 1 - Cosine Bells
249
250                ! To calculate great circle distance
251
252        sin_tmp = sin(lat) * sin(phi0)
253        cos_tmp = cos(lat) * cos(phi0)
254        sin_tmp2 = sin(lat) * sin(phi1)
255        cos_tmp2 = cos(lat) * cos(phi1)
256
257                ! great circle distance without 'a'
258       
259        r  = ACOS (sin_tmp + cos_tmp*cos(lon-lambda0)) 
260        r2  = ACOS (sin_tmp2 + cos_tmp2*cos(lon-lambda1)) 
261        d1 = min( 1.d0, (r/RR)**2 + ((height-z0)/ZZ)**2 )
262        d2 = min( 1.d0, (r2/RR)**2 + ((height-z0)/ZZ)**2 )
263       
264        q1 = 0.5d0 * (1.d0 + cos(pi*d1)) + 0.5d0 * (1.d0 + cos(pi*d2))
265
266        ! Tracer 2 - Correlated Cosine Bells
267
268        q2 = 0.9d0 - 0.8d0*q1**2
269
270        ! Tracer 3 - Slotted Ellipse
271
272                ! Make the ellipse
273
274        if (d1 .le. RR) then
275                q3 = 1.d0
276        elseif (d2 .le. RR) then
277                q3 = 1.d0
278        else
279                q3 = 0.1d0
280        endif
281
282                ! Put in the slot
283       
284        if (height .gt. z0 .and. abs(lat) .lt. 0.125d0) then
285
286                q3 = 0.1d0     
287
288        endif
289
290        ! Tracer 4: q4 is chosen so that, in combination with the other three tracer
291        !           fields with weight (3/10), the sum is equal to one
292
293        q4 = 1.d0 - 0.3d0*(q1+q2+q3)
294
295!************   
296! change in version 4: added cutoff altitudes, tracers are set to zero outside this region
297! prevents tracers from being trapped near the bottom and top of the domain
298!************
299        ! use a cutoff altitude for
300        ! tracer 2 3 and 4
301        ! Set them to zero outside `buffer zone'
302!************   
303! change in version 5: change from v4 reversed, no cutoff altitudes due to continuity equation being satisfied
304!       commented out below
305!************
306
307        !if (height .gt. (z0+1.25*ZZ) .or. height .lt. (z0-1.25*ZZ)) then
308
309        !       q2 = 0.0
310        !       q3 = 0.0
311        !       q4 = 0.0
312
313        !endif
314
315
316
317
318END SUBROUTINE test1_advection_deformation
319
320
321
322
323
324!==========================================================================================
325! TEST CASE 12 - PURE ADVECTION - 3D HADLEY-LIKE FLOW
326!==========================================================================================
327
328SUBROUTINE test1_advection_hadley (lon,lat,p,z,zcoords,u,v,w,t,phis,ps,rho,q,q1)
329
330IMPLICIT NONE
331!-----------------------------------------------------------------------
332!     input/output params parameters at given location
333!-----------------------------------------------------------------------
334
335        real(rstd), intent(in)  :: lon, &               ! Longitude (radians)
336                                lat, &          ! Latitude (radians)
337                                z               ! Height (m)
338
339        real(rstd), intent(inout) :: p          ! Pressure  (Pa)
340                               
341        integer,  intent(in) :: zcoords         ! 0 or 1 see below
342
343        real(rstd), intent(out) :: u, &                 ! Zonal wind (m s^-1)
344                                v, &            ! Meridional wind (m s^-1)
345                                w, &            ! Vertical Velocity (m s^-1)
346                                t, &            ! Temperature (K)
347                                phis, &         ! Surface Geopotential (m^2 s^-2)
348                                ps, &           ! Surface Pressure (Pa)
349                                rho, &          ! density (kg m^-3)
350                                q, &            ! Specific Humidity (kg/kg)
351                                q1              ! Tracer q1 (kg/kg)
352
353        ! if zcoords = 1, then we use z and output p
354        ! if zcoords = 0, then we use p
355
356!-----------------------------------------------------------------------
357!     test case parameters
358!-----------------------------------------------------------------------
359        real(rstd), parameter ::        tau     = 1.d0 * 86400.d0,      &       ! period of motion 1 day (in s)
360                                u0      = 40.d0,                &       ! Zonal velocity magnitude (m/s)
361                                w0      = 0.15d0,               &       ! Vertical velocity magnitude (m/s), changed in v5
362                                T0      = 300.d0,               &       ! temperature (K)
363                                H       = Rd * T0 / g,          &       ! scale height
364                                K       = 5.d0,                 &       ! number of Hadley-like cells
365                                z1      = 2000.d0,              &       ! position of lower tracer bound (m), changed in v5       
366                                z2      = 5000.d0,              &       ! position of upper tracer bound (m), changed in v5       
367                                z0      = 0.5d0*(z1+z2),        &       ! midpoint (m)       
368                                ztop    = 12000.d0                      ! model top (m)       
369                           
370      real(rstd) :: rho0                                                        ! reference density at z=0 m
371      real(rstd) :: height                                                      ! Model level heights
372      real(rstd) :: time                                                        ! Initially set to zero seconds, needs
373                                                                        ! to be modified when used in dycore
374
375!-----------------------------------------------------------------------
376!    HEIGHT AND PRESSURE
377!-----------------------------------------------------------------------
378
379        ! Height and pressure are aligned (p = p0 exp(-z/H))
380
381        if (zcoords .eq. 1) then
382
383                height = z
384                p = p0 * exp(-z/H)
385
386        else
387
388                height = H * log(p0/p)
389
390        endif
391
392!-----------------------------------------------------------------------
393!    TEMPERATURE IS CONSTANT 300 K
394!-----------------------------------------------------------------------
395
396        t = T0
397
398!-----------------------------------------------------------------------
399!    PHIS (surface geopotential)
400!-----------------------------------------------------------------------
401     
402        phis = 0.d0
403
404!-----------------------------------------------------------------------
405!    PS (surface pressure)
406!-----------------------------------------------------------------------
407
408        ps = p0
409
410!-----------------------------------------------------------------------
411!    RHO (density)
412!-----------------------------------------------------------------------
413
414        rho = p/(Rd*t)
415        rho0 = p0/(Rd*t)
416
417!-----------------------------------------------------------------------
418!    THE VELOCITIES ARE TIME DEPENDENT AND THEREFORE MUST BE UPDATED
419!    IN THE DYNAMICAL CORE
420!-----------------------------------------------------------------------
421
422        time = 0.d0
423
424        ! Zonal Velocity
425
426        u = u0*cos(lat)
427
428        ! Meridional Velocity
429
430!************   
431! change in version 5: multiply v and w by rho0/rho
432!************
433
434        v = -(rho0/rho) * (a*w0*pi)/(K*ztop) *cos(lat)*sin(K*lat)*cos(pi*height/ztop)*cos(pi*time/tau)
435
436        ! Vertical Velocity - can be changed to vertical pressure velocity by
437        ! omega = -g*rho*w
438
439        w = (rho0/rho) *(w0/K)*(-2.d0*sin(K*lat)*sin(lat) + K*cos(lat)*cos(K*lat)) &
440                *sin(pi*height/ztop)*cos(pi*time/tau)
441
442
443!-----------------------------------------------------------------------
444!     initialize Q, set to zero
445!-----------------------------------------------------------------------
446
447        q = 0.d0
448
449!-----------------------------------------------------------------------
450!     initialize tracers
451!-----------------------------------------------------------------------
452
453        ! Tracer 1 - Layer
454
455        if (height .lt. z2 .and. height .gt. z1) then
456       
457                q1 = 0.5d0 * (1.d0 + cos( 2.d0*pi*(height-z0)/(z2-z1) ) )
458
459        else
460
461                q1 = 0.d0
462
463        endif
464
465END SUBROUTINE test1_advection_hadley
466
467
468
469!==========================================================================================
470! TEST CASE 13 - HORIZONTAL ADVECTION OF THIN CLOUD-LIKE TRACERS IN THE PRESENCE OF OROGRAPHY
471!==========================================================================================
472
473SUBROUTINE test1_advection_orography (lon,lat,p,z,zcoords,cfv,hybrid_eta,hyam,hybm,gc,u,v,w,t,phis,ps,rho,q,q1,q2,q3,q4)
474
475IMPLICIT NONE
476!-----------------------------------------------------------------------
477!     input/output params parameters at given location
478!-----------------------------------------------------------------------
479
480        real(rstd), intent(in)  :: lon, &               ! Longitude (radians)
481                                lat, &          ! Latitude (radians)
482                                z, &            ! Height (m)
483                                hyam, &         ! A coefficient for hybrid-eta coordinate, at model level midpoint
484                                hybm, &         ! B coefficient for hybrid-eta coordinate, at model level midpoint
485                                gc              ! bar{z} for Gal-Chen coordinate
486
487        logical, intent(in)  :: hybrid_eta      ! flag to indicate whether the hybrid sigma-p (eta) coordinate is used
488                                                ! if set to .true., then the pressure will be computed via the
489                                                !    hybrid coefficients hyam and hybm, they need to be initialized
490                                                ! if set to .false. (for pressure-based models): the pressure is already pre-computed
491                                                !    and is an input value for this routine
492                                                ! for height-based models: pressure will always be computed based on the height and
493                                                !    hybrid_eta is not used
494
495        ! Note that we only use hyam and hybm for the hybrid-eta coordiantes, and we only use
496        ! gc for the Gal-Chen coordinates. If not required then they become dummy variables
497
498        real(rstd), intent(inout) :: p          ! Pressure  (Pa)
499                               
500        integer,  intent(in) :: zcoords         ! 0 or 1 see below
501        integer,  intent(in) :: cfv             ! 0, 1 or 2 see below
502
503        real(rstd), intent(out) :: u, &                 ! Zonal wind (m s^-1)
504                                v, &            ! Meridional wind (m s^-1)
505                                w, &            ! Vertical Velocity (m s^-1)
506                                t, &            ! Temperature (K)
507                                phis, &         ! Surface Geopotential (m^2 s^-2)
508                                ps, &           ! Surface Pressure (Pa)
509                                rho, &          ! density (kg m^-3)
510                                q, &            ! Specific Humidity (kg/kg)
511                                q1, &           ! Tracer q1 (kg/kg)
512                                q2, &           ! Tracer q2 (kg/kg)
513                                q3, &           ! Tracer q3 (kg/kg)
514                                q4              ! Tracer q4 (kg/kg)
515
516        ! if zcoords = 1, then we use z and output p
517        ! if zcoords = 0, then we use p
518
519        ! if cfv = 0 we assume that our horizontal velocities are not coordinate following
520        ! if cfv = 1 then our velocities follow hybrid eta coordinates and we need to specify w
521        ! if cfv = 2 then our velocities follow Gal-Chen coordinates and we need to specify w
522
523        ! In hybrid-eta coords: p = hyam p0 + hybm ps
524        ! In Gal-Chen coords: z = zs + (gc/ztop)*(ztop - zs)
525
526        ! if other orography-following coordinates are used, the w wind needs to be newly derived for them
527
528!-----------------------------------------------------------------------
529!     test case parameters
530!-----------------------------------------------------------------------
531        real(rstd), parameter ::        tau     = 12.d0 * 86400.d0,     &       ! period of motion 12 days (s)
532                                u0      = 2.d0*pi*a/tau,        &       ! Velocity Magnitude (m/s)
533                                T0      = 300.d0,               &       ! temperature (K)
534                                H       = Rd * T0 / g,          &       ! scale height (m)
535                                alpha   = pi/6.d0,              &       ! rotation angle (radians), 30 degrees   
536                                lambdam = 3.d0*pi/2.d0,         &       ! mountain longitude center point (radians)   
537                                phim    = 0.d0,                 &       ! mountain latitude center point (radians)   
538                                h0      = 2000.d0,              &       ! peak height of the mountain range (m)
539                                Rm      = 3.d0*pi/4.d0,         &       ! mountain radius (radians)
540                                zetam   = pi/16.d0,             &       ! mountain oscillation half-width (radians)
541                                lambdap = pi/2.d0,              &       ! cloud-like tracer longitude center point (radians)
542                                phip    = 0.d0,                 &       ! cloud-like tracer latitude center point (radians)   
543                                Rp      = pi/4.d0,              &       ! cloud-like tracer radius (radians)   
544                                zp1     = 3050.d0,              &       ! midpoint of first (lowermost) tracer (m)           
545                                zp2     = 5050.d0,              &       ! midpoint of second tracer (m)         
546                                zp3     = 8200.d0,              &       ! midpoint of third (topmost) tracer (m)   
547                                dzp1    = 1000.d0,              &       ! thickness of first (lowermost) tracer (m)           
548                                dzp2    = 1000.d0,              &       ! thickness of second tracer (m)
549                                dzp3    = 400.d0,               &       ! thickness of third (topmost) tracer (m)       
550                                ztop    = 12000.d0                      ! model top (m)         
551                           
552      real(rstd) :: height                                                      ! Model level heights (m)
553      real(rstd) :: r                                                   ! Great circle distance (radians)
554      real(rstd) :: rz                                                  ! height differences
555      real(rstd) :: zs                                                  ! Surface elevation (m)
556
557
558
559!-----------------------------------------------------------------------
560!    PHIS (surface geopotential)
561!-----------------------------------------------------------------------
562     
563        r = acos( sin(phim)*sin(lat) + cos(phim)*cos(lat)*cos(lon - lambdam) )
564
565        if (r .lt. Rm) then
566
567                zs = (h0/2.d0)*(1.d0+cos(pi*r/Rm))*cos(pi*r/zetam)**2.d0
568
569        else
570
571                zs = 0.d0
572
573        endif
574
575        phis = g*zs
576
577!-----------------------------------------------------------------------
578!    PS (surface pressure)
579!-----------------------------------------------------------------------
580
581        ps = p0 * exp(-zs/H)
582
583
584!-----------------------------------------------------------------------
585!    HEIGHT AND PRESSURE
586!-----------------------------------------------------------------------
587
588        ! Height and pressure are aligned (p = p0 exp(-z/H))
589
590        if (zcoords .eq. 1) then
591
592                height = z
593                p = p0 * exp(-z/H)
594
595        else
596
597                if (hybrid_eta) p = hyam*p0 + hybm*ps   ! compute the pressure based on the surface pressure and hybrid coefficients
598                height = H * log(p0/p)
599
600        endif
601
602!-----------------------------------------------------------------------
603!    THE VELOCITIES ARE TIME INDEPENDENT
604!-----------------------------------------------------------------------
605
606        ! Zonal Velocity
607
608        u = u0*(cos(lat)*cos(alpha)+sin(lat)*cos(lon)*sin(alpha))
609
610        ! Meridional Velocity
611
612        v = -u0*(sin(lon)*sin(alpha))
613
614!-----------------------------------------------------------------------
615!    TEMPERATURE IS CONSTANT 300 K
616!-----------------------------------------------------------------------
617
618        t = T0
619
620!-----------------------------------------------------------------------
621!    RHO (density)
622!-----------------------------------------------------------------------
623
624        rho = p/(Rd*t)
625
626!-----------------------------------------------------------------------
627!     initialize Q, set to zero
628!-----------------------------------------------------------------------
629
630        q = 0.d0
631
632!-----------------------------------------------------------------------
633!    VERTICAL VELOCITY IS TIME INDEPENDENT
634!-----------------------------------------------------------------------
635
636        ! Vertical Velocity - can be changed to vertical pressure velocity by
637        ! omega = -(g*p)/(Rd*T0)*w
638
639        ! NOTE that if orography-following coordinates are used then the vertical
640        ! velocity needs to be translated into the new coordinate system due to
641        ! the variation of the height along coordinate surfaces
642        ! See section 1.3 and the appendix of the test case document
643
644        if (cfv .eq. 0) then
645
646                ! if the horizontal velocities do not follow the vertical coordinate
647
648                w = 0.d0
649
650        elseif (cfv .eq. 1) then
651
652                ! if the horizontal velocities follow hybrid eta coordinates then
653                ! the perceived vertical velocity is
654
655                call test1_advection_orograph_hybrid_eta_velocity(w)
656
657        elseif (cfv .eq. 2) then
658
659                ! if the horizontal velocities follow Gal Chen coordinates then
660                ! the perceived vertical velocity is   
661
662                call test1_advection_orograph_Gal_Chen_velocity(w)     
663
664!        else
665!               compute your own vertical velocity if other orography-following
666!               vertical coordinate is used
667!
668        endif
669
670
671
672!-----------------------------------------------------------------------
673!     initialize tracers
674!-----------------------------------------------------------------------
675
676        ! Tracer 1 - Cloud Layer
677     
678        r = acos( sin(phip)*sin(lat) + cos(phip)*cos(lat)*cos(lon - lambdap) )
679
680        rz = abs(height - zp1)
681
682        if (rz .lt. 0.5d0*dzp1 .and. r .lt. Rp) then
683
684                q1 = 0.25d0*(1.d0+cos(2.d0*pi*rz/dzp1))*(1.d0+cos(pi*r/Rp))
685
686        else
687
688                q1 = 0.d0
689
690        endif
691
692        rz = abs(height - zp2)
693
694        if (rz .lt. 0.5d0*dzp2 .and. r .lt. Rp) then
695
696                q2 = 0.25d0*(1.d0+cos(2.d0*pi*rz/dzp2))*(1.d0+cos(pi*r/Rp))
697
698        else
699
700                q2 = 0.d0
701
702        endif
703
704        rz = abs(height - zp3)
705
706        if (rz .lt. 0.5d0*dzp3 .and. r .lt. Rp) then
707
708                q3 = 1.d0
709
710        else
711
712                q3 = 0.d0
713
714        endif
715
716        q4 = q1 + q2 + q3
717
718
719        CONTAINS
720
721        !-----------------------------------------------------------------------
722        !    SUBROUTINE TO CALCULATE THE PERCEIVED VERTICAL VELOCITY
723        !               UNDER HYBRID-ETA COORDINATES
724        !-----------------------------------------------------------------------
725
726        SUBROUTINE test1_advection_orograph_hybrid_eta_velocity(w)
727        IMPLICIT NONE
728        real(rstd), intent(out) ::      w
729
730        real(rstd) ::   press, &                ! hyam *p0 + hybm *ps
731                        r, &                    ! Great Circle Distance
732                        dzsdx, &                ! Part of surface height derivative
733                        dzsdlambda, &           ! Derivative of zs w.r.t lambda
734                        dzsdphi, &              ! Derivative of zs w.r.t phi
735                        dzdlambda, &            ! Derivative of z w.r.t lambda
736                        dzdphi, &               ! Derivative of z w.r.t phi
737                        dpsdlambda, &           ! Derivative of ps w.r.t lambda
738                        dpsdphi                 ! Derivative of ps w.r.t phi
739
740                ! Calculate pressure and great circle distance to mountain center
741
742                press = hyam*p0 + hybm*ps
743
744                r = acos( sin(phim)*sin(lat) + cos(phim)*cos(lat)*cos(lon - lambdam) )
745
746                ! Derivatives of surface height
747
748                if (r .lt. Rm) then
749                        dzsdx = -h0*pi/(2.d0*Rm)*sin(pi*r/Rm)*cos(pi*r/zetam)**2 - &
750                                (h0*pi/zetam)*(1.d0+cos(pi*r/Rm))*cos(pi*r/zetam)*sin(pi*r/zetam)
751                else
752                        dzsdx = 0.d0
753                endif
754
755                ! Prevent division by zero
756
757                if (1.d0-cos(r)**2 .gt. 0.d0) then
758                        dzsdlambda = dzsdx * (cos(phim)*cos(lat)*sin(lon-lambdam)) &
759                                        /sqrt(1.d0-cos(r)**2)
760                        dzsdphi    = dzsdx * (-sin(phim)*cos(lat) + cos(phim)*sin(lat)*cos(lon-lambdam)) & 
761                                        /sqrt(1.d0-cos(r)**2)
762                else
763                        dzsdlambda = 0.d0
764                        dzsdphi    = 0.d0
765                endif
766
767                ! Derivatives of surface pressure
768
769                dpsdlambda = -(g*p0/(Rd*T0))*exp(-g*zs/(Rd*T0))*dzsdlambda
770                dpsdphi    = -(g*p0/(Rd*T0))*exp(-g*zs/(Rd*T0))*dzsdphi
771
772                ! Derivatives of coordinate height
773
774                dzdlambda = -(Rd*T0/(g*press))*hybm*dpsdlambda
775                dzdphi    = -(Rd*T0/(g*press))*hybm*dpsdphi
776
777                ! Prevent division by zero
778
779                if (abs(lat) .lt. pi/2.d0) then
780                        w = - (u/(a*cos(lat)))*dzdlambda - (v/a)*dzdphi
781                else
782                        w = 0.d0
783                endif
784
785        END SUBROUTINE test1_advection_orograph_hybrid_eta_velocity
786
787
788
789        !-----------------------------------------------------------------------
790        !    SUBROUTINE TO CALCULATE THE PERCEIVED VERTICAL VELOCITY
791        !               UNDER GAL-CHEN COORDINATES
792        !-----------------------------------------------------------------------
793
794        SUBROUTINE test1_advection_orograph_Gal_Chen_velocity(w)
795        IMPLICIT NONE
796        real(rstd), intent(out) ::      w
797
798        real(rstd) ::   r, &                    ! Great Circle Distance
799                        dzsdx, &                ! Part of surface height derivative
800                        dzsdlambda, &           ! Derivative of zs w.r.t lambda
801                        dzsdphi, &              ! Derivative of zs w.r.t phi
802                        dzdlambda, &            ! Derivative of z w.r.t lambda
803                        dzdphi                  ! Derivative of z w.r.t phi
804
805                ! Calculate great circle distance to mountain center
806
807                r = acos( sin(phim)*sin(lat) + cos(phim)*cos(lat)*cos(lon - lambdam) )
808
809                ! Derivatives of surface height
810
811                if (r .lt. Rm) then
812                        dzsdx = -h0*pi/(2.d0*Rm)*sin(pi*r/Rm)*cos(pi*r/zetam)**2 - &
813                                (h0*pi/zetam)*(1.d0+cos(pi*r/Rm))*cos(pi*r/zetam)*sin(pi*r/zetam)
814                else
815                        dzsdx = 0.d0
816                endif
817
818                ! Prevent division by zero
819
820                if (1.d0-cos(r)**2 .gt. 0.d0) then
821                        dzsdlambda = dzsdx * (cos(phim)*cos(lat)*sin(lon-lambdam)) &
822                                        /sqrt(1.d0-cos(r)**2)
823                        dzsdphi    = dzsdx * (-sin(phim)*cos(lat) + cos(phim)*sin(lat)*cos(lon-lambdam)) & 
824                                        /sqrt(1.d0-cos(r)**2)
825                else
826                        dzsdlambda = 0.d0
827                        dzsdphi    = 0.d0
828                endif
829
830                ! Derivatives of coordinate height
831
832                dzdlambda = (1.d0-gc/ztop)*dzsdlambda
833                dzdphi    = (1.d0-gc/ztop)*dzsdphi
834
835                ! Prevent division by zero
836
837                if (abs(lat) .lt. pi/2.d0) then
838                        w = - (u/(a*cos(lat)))*dzdlambda - (v/a)*dzdphi
839                else
840                        w = 0.d0
841                endif
842
843        END SUBROUTINE test1_advection_orograph_Gal_Chen_velocity
844
845END SUBROUTINE test1_advection_orography
846
847
848
849
850!==========================================================================================
851! TEST CASE 2X - IMPACT OF OROGRAPHY ON A NON-ROTATING PLANET
852!==========================================================================================
853! The tests in section 2-x examine the impact of 3D Schaer-like circular mountain profiles on an
854! atmosphere at rest (2-0), and on flow fields with wind shear (2-1) and without vertical wind shear (2-2). 
855! A non-rotating planet is used for all configurations. Test 2-0 is conducted on an unscaled regular-size
856! planet and primarily examines the accuracy of the pressure gradient calculation in a steady-state
857! hydrostatically-balanced atmosphere at rest. This test is especially appealing for models with
858! orography-following vertical coordinates. It increases the complexity of test 1-3, that investigated
859! the impact of the same Schaer-type orographic profile on the accuracy of purely-horizontal passive
860! tracer advection.
861!
862! Tests 2-1 and 2-2 increase the complexity even further since non-zero flow fields are now prescribed
863! with and without vertical wind shear. In order to trigger non-hydrostatic responses the two tests are
864! conducted on a reduced-size planet with reduction factor $X=500$ which makes the horizontal and
865! vertical grid spacing comparable. This test clearly discriminates between non-hydrostatic and hydrostatic
866! models since the expected response is in the non-hydrostatic regime. Therefore, the flow response is
867! captured differently by hydrostatic models.
868
869
870
871
872!=========================================================================
873! Test 2-0:  Steady-State Atmosphere at Rest in the Presence of Orography
874!=========================================================================
875SUBROUTINE test2_steady_state_mountain (lon,lat,p,z,zcoords,hybrid_eta,hyam,hybm,u,v,w,t,phis,ps,rho,q)
876
877IMPLICIT NONE
878!-----------------------------------------------------------------------
879!     input/output params parameters at given location
880!-----------------------------------------------------------------------
881
882        real(rstd), intent(in)  :: lon, &               ! Longitude (radians)
883                                lat, &          ! Latitude (radians)
884                                z, &            ! Height (m)
885                                hyam, &         ! A coefficient for hybrid-eta coordinate, at model level midpoint
886                                hybm            ! B coefficient for hybrid-eta coordinate, at model level midpoint
887
888        logical, intent(in)  :: hybrid_eta      ! flag to indicate whether the hybrid sigma-p (eta) coordinate is used
889                                                ! if set to .true., then the pressure will be computed via the
890                                                !    hybrid coefficients hyam and hybm, they need to be initialized
891                                                ! if set to .false. (for pressure-based models): the pressure is already pre-computed
892                                                !    and is an input value for this routine
893                                                ! for height-based models: pressure will always be computed based on the height and
894                                                !    hybrid_eta is not used
895
896        real(rstd), intent(inout) :: p          ! Pressure  (Pa)
897                               
898        integer,  intent(in) :: zcoords         ! 0 or 1 see below
899
900        real(rstd), intent(out) :: u, &                 ! Zonal wind (m s^-1)
901                                v, &            ! Meridional wind (m s^-1)
902                                w, &            ! Vertical Velocity (m s^-1)
903                                t, &            ! Temperature (K)
904                                phis, &         ! Surface Geopotential (m^2 s^-2)
905                                ps, &           ! Surface Pressure (Pa)
906                                rho, &          ! density (kg m^-3)
907                                q               ! Specific Humidity (kg/kg)
908
909        ! if zcoords = 1, then we use z and output p
910        ! if zcoords = 0, then we compute or use p
911        !
912        ! In hybrid-eta coords: p = hyam p0 + hybm ps
913        !
914        ! The grid-point based initial data are computed in this routine.
915
916!-----------------------------------------------------------------------
917!     test case parameters
918!-----------------------------------------------------------------------
919        real(rstd), parameter ::        T0      = 300.d0,               &       ! temperature (K)
920                                gamma   = 0.0065d0,             &       ! temperature lapse rate (K/m)     
921                                lambdam = 3.d0*pi/2.d0,         &       ! mountain longitude center point (radians)   
922                                phim    = 0.d0,                 &       ! mountain latitude center point (radians)   
923                                h0      = 2000.d0,              &       ! peak height of the mountain range (m)
924                                Rm      = 3.d0*pi/4.d0,         &       ! mountain radius (radians)
925                                zetam   = pi/16.d0,             &       ! mountain oscillation half-width (radians)
926                                ztop    = 12000.d0                      ! model top (m)         
927                           
928      real(rstd) :: height                                                      ! Model level heights (m)
929      real(rstd) :: r                                                   ! Great circle distance (radians)
930      real(rstd) :: zs                                                  ! Surface elevation (m)
931      real(rstd) :: exponent                                               ! exponent: g/(Rd * gamma)
932      real(rstd) :: exponent_rev                                           ! reversed exponent
933
934
935!-----------------------------------------------------------------------
936!    compute exponents
937!-----------------------------------------------------------------------
938     exponent     = g/(Rd*gamma)
939     exponent_rev = 1.d0/exponent
940
941!-----------------------------------------------------------------------
942!    PHIS (surface geopotential)
943!-----------------------------------------------------------------------
944     
945        r = acos( sin(phim)*sin(lat) + cos(phim)*cos(lat)*cos(lon - lambdam) )
946
947        if (r .lt. Rm) then
948
949                zs = (h0/2.d0)*(1.d0+cos(pi*r/Rm))*cos(pi*r/zetam)**2.d0   ! mountain height
950
951        else
952
953                zs = 0.d0
954
955        endif
956
957        phis = g*zs
958
959!-----------------------------------------------------------------------
960!    PS (surface pressure)
961!-----------------------------------------------------------------------
962
963        ps = p0 * (1.d0 - gamma/T0*zs)**exponent
964
965
966!-----------------------------------------------------------------------
967!    HEIGHT AND PRESSURE
968!-----------------------------------------------------------------------
969
970        ! Height and pressure are aligned (p = p0 * (1.d0 - gamma/T0*z)**exponent)
971
972        if (zcoords .eq. 1) then
973
974                height = z
975                p = p0 * (1.d0 - gamma/T0*z)**exponent
976
977        else
978
979                if (hybrid_eta) p = hyam*p0 + hybm*ps              ! compute the pressure based on the surface pressure and hybrid coefficients
980                height = T0/gamma * (1.d0 - (p/p0)**exponent_rev)  ! compute the height at this pressure
981
982        endif
983
984!-----------------------------------------------------------------------
985!    THE VELOCITIES ARE ZERO (STATE AT REST)
986!-----------------------------------------------------------------------
987
988        ! Zonal Velocity
989
990        u = 0.d0
991
992        ! Meridional Velocity
993
994        v = 0.d0
995
996        ! Vertical Velocity
997
998        w = 0.d0
999
1000!-----------------------------------------------------------------------
1001!    TEMPERATURE WITH CONSTANT LAPSE RATE
1002!-----------------------------------------------------------------------
1003
1004        t = T0 - gamma*height
1005
1006!-----------------------------------------------------------------------
1007!    RHO (density)
1008!-----------------------------------------------------------------------
1009
1010        rho = p/(Rd*t)
1011
1012!-----------------------------------------------------------------------
1013!     initialize Q, set to zero
1014!-----------------------------------------------------------------------
1015
1016        q = 0.d0
1017
1018END SUBROUTINE test2_steady_state_mountain
1019
1020
1021
1022!=====================================================================================
1023! Tests 2-1 and 2-2:  Non-hydrostatic Mountain Waves over a Schaer-type Mountain
1024!=====================================================================================
1025
1026SUBROUTINE test2_schaer_mountain (lon,lat,p,z,zcoords,hybrid_eta,hyam,hybm,shear,u,v,w,t,phis,ps,rho,q)
1027
1028IMPLICIT NONE
1029!-----------------------------------------------------------------------
1030!     input/output params parameters at given location
1031!-----------------------------------------------------------------------
1032
1033        real(rstd), intent(in)  :: lon, &               ! Longitude (radians)
1034                                lat, &          ! Latitude (radians)
1035                                z,   &          ! Height (m)
1036                                hyam, &         ! A coefficient for hybrid-eta coordinate, at model level midpoint
1037                                hybm            ! B coefficient for hybrid-eta coordinate, at model level midpoint
1038
1039        logical, intent(in)  :: hybrid_eta      ! flag to indicate whether the hybrid sigma-p (eta) coordinate is used
1040                                                ! if set to .true., then the pressure will be computed via the
1041                                                !    hybrid coefficients hyam and hybm, they need to be initialized
1042                                                ! if set to .false. (for pressure-based models): the pressure is already pre-computed
1043                                                !    and is an input value for this routine
1044                                                ! for height-based models: pressure will always be computed based on the height and
1045                                                !    hybrid_eta is not used
1046
1047        real(rstd), intent(inout) :: p          ! Pressure  (Pa)
1048                               
1049
1050        integer,  intent(in) :: zcoords, &      ! 0 or 1 see below
1051                                shear           ! 0 or 1 see below
1052
1053        real(rstd), intent(out) :: u, &                 ! Zonal wind (m s^-1)
1054                                v, &            ! Meridional wind (m s^-1)
1055                                w, &            ! Vertical Velocity (m s^-1)
1056                                t, &            ! Temperature (K)
1057                                phis, &         ! Surface Geopotential (m^2 s^-2)
1058                                ps, &           ! Surface Pressure (Pa)
1059                                rho, &          ! density (kg m^-3)
1060                                q               ! Specific Humidity (kg/kg)
1061
1062        ! if zcoords = 1, then we use z and output p
1063        ! if zcoords = 0, then we either compute or use p
1064
1065        ! if shear = 1, then we use shear flow
1066        ! if shear = 0, then we use constant u
1067
1068!-----------------------------------------------------------------------
1069!     test case parameters
1070!-----------------------------------------------------------------------
1071        real(rstd), parameter ::        X       = 500.d0,               &       ! Reduced Earth reduction factor
1072                                Om      = 0.d0,                 &       ! Rotation Rate of Earth
1073                                as      = a/X,                  &       ! New Radius of small Earth     
1074                                ueq     = 20.d0,                &       ! Reference Velocity
1075                                Teq     = 300.d0,               &       ! Temperature at Equator   
1076                                Peq     = 100000.d0,            &       ! Reference PS at Equator
1077                                ztop    = 30000.d0,             &       ! Model Top       
1078                                lambdac = pi/4.d0,              &       ! Lon of Schar Mountain Center
1079                                phic    = 0.d0,                 &       ! Lat of Schar Mountain Center
1080                                h0      = 250.d0,               &       ! Height of Mountain
1081                                d       = 5000.d0,              &       ! Mountain Half-Width
1082                                xi      = 4000.d0,              &       ! Mountain Wavelength
1083                                cs      = 0.00025d0                     ! Wind Shear (shear=1)
1084                           
1085      real(rstd) :: height                                                      ! Model level heights
1086      real(rstd) :: sin_tmp, cos_tmp                                    ! Calculation of great circle distance
1087      real(rstd) :: r                                                   ! Great circle distance
1088      real(rstd) :: zs                                                  ! Surface height
1089      real(rstd) :: c                                                   ! Shear
1090
1091!-----------------------------------------------------------------------
1092!    PHIS (surface geopotential)
1093!-----------------------------------------------------------------------
1094
1095        sin_tmp = sin(lat) * sin(phic)
1096        cos_tmp = cos(lat) * cos(phic)
1097       
1098        ! great circle distance with 'a/X' 
1099
1100        r  = as * ACOS (sin_tmp + cos_tmp*cos(lon-lambdac))     
1101        zs   = h0 * exp(-(r**2)/(d**2))*(cos(pi*r/xi)**2)
1102        phis = g*zs
1103
1104!-----------------------------------------------------------------------
1105!    SHEAR FLOW OR CONSTANT FLOW
1106!-----------------------------------------------------------------------
1107
1108        if (shear .eq. 1) then
1109
1110                c = cs
1111
1112        else
1113
1114                c = 0.d0
1115
1116        endif
1117
1118!-----------------------------------------------------------------------
1119!    TEMPERATURE
1120!-----------------------------------------------------------------------
1121
1122        t = Teq *(1.d0 - (c*ueq*ueq/(g))*(sin(lat)**2) )
1123
1124!-----------------------------------------------------------------------
1125!    PS (surface pressure)
1126!-----------------------------------------------------------------------
1127
1128        ps = peq*exp( -(ueq*ueq/(2.d0*Rd*Teq))*(sin(lat)**2) - phis/(Rd*t)    )
1129
1130!-----------------------------------------------------------------------
1131!    HEIGHT AND PRESSURE
1132!-----------------------------------------------------------------------
1133
1134        if (zcoords .eq. 1) then
1135
1136                height = z
1137                p = peq*exp( -(ueq*ueq/(2.d0*Rd*Teq))*(sin(lat)**2) - g*height/(Rd*t)    )
1138
1139        else
1140                if (hybrid_eta) p = hyam*p0 + hybm*ps ! compute the pressure based on the surface pressure and hybrid coefficients
1141                height = (Rd*t/(g))*log(peq/p) - (t*ueq*ueq/(2.d0*Teq*g))*(sin(lat)**2)
1142
1143        endif
1144
1145!-----------------------------------------------------------------------
1146!    THE VELOCITIES
1147!-----------------------------------------------------------------------
1148
1149        ! Zonal Velocity
1150
1151        u = ueq * cos(lat) * sqrt( (2.d0*Teq/(t))*c*height + t/(Teq) )
1152
1153        ! Meridional Velocity
1154
1155        v = 0.d0
1156
1157        ! Vertical Velocity = Vertical Pressure Velocity = 0
1158
1159        w = 0.d0
1160
1161!-----------------------------------------------------------------------
1162!    RHO (density)
1163!-----------------------------------------------------------------------
1164
1165        rho = p/(Rd*t)
1166
1167!-----------------------------------------------------------------------
1168!     initialize Q, set to zero
1169!-----------------------------------------------------------------------
1170
1171        q = 0.d0
1172
1173END SUBROUTINE test2_schaer_mountain
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184!==========================================================================================
1185! TEST CASE 3 - GRAVITY WAVES
1186!==========================================================================================
1187
1188! The non-hydrostatic gravity wave test examines the response of models to short time-scale wavemotion
1189! triggered by a localized perturbation. The formulation presented in this document is new,
1190! but is based on previous approaches by Skamarock et al. (JAS 1994), Tomita and Satoh (FDR 2004), and
1191! Jablonowski et al. (NCAR Tech Report 2008)
1192
1193
1194!==========
1195! Test 3-1
1196!==========
1197SUBROUTINE test3_gravity_wave (lon,lat,p,z,zcoords,u,v,w,t,phis,ps,rho,q)
1198
1199IMPLICIT NONE
1200!-----------------------------------------------------------------------
1201!     input/output params parameters at given location
1202!-----------------------------------------------------------------------
1203
1204        real(rstd), intent(in)  :: lon, &               ! Longitude (radians)
1205                                lat, &          ! Latitude (radians)
1206                                z               ! Height (m)
1207
1208        real(rstd), intent(inout) :: p          ! Pressure  (Pa)
1209                               
1210
1211        integer,  intent(in) :: zcoords         ! 0 or 1 see below
1212
1213        real(rstd), intent(out) :: u, &                 ! Zonal wind (m s^-1)
1214                                v, &            ! Meridional wind (m s^-1)
1215                                w, &            ! Vertical Velocity (m s^-1)
1216                                t, &            ! Temperature (K)
1217                                phis, &         ! Surface Geopotential (m^2 s^-2)
1218                                ps, &           ! Surface Pressure (Pa)
1219                                rho, &          ! density (kg m^-3)
1220                                q               ! Specific Humidity (kg/kg)
1221
1222        ! if zcoords = 1, then we use z and output z
1223        ! if zcoords = 0, then we use p
1224
1225!-----------------------------------------------------------------------
1226!     test case parameters
1227!-----------------------------------------------------------------------
1228        real(rstd), parameter ::        X       = 125.d0,               &       ! Reduced Earth reduction factor
1229                                Om      = 0.d0,                 &       ! Rotation Rate of Earth
1230                                as      = a/X,                  &       ! New Radius of small Earth     
1231                                u0      = 20.d0,                &       ! Reference Velocity
1232                                Teq     = 300.d0,               &       ! Temperature at Equator   
1233                                Peq     = 100000.d0,            &       ! Reference PS at Equator
1234                                ztop    = 10000.d0,             &       ! Model Top       
1235                                lambdac = 2.d0*pi/3.d0,         &       ! Lon of Pert Center
1236                                d       = 5000.d0,              &       ! Width for Pert
1237                                phic    = 0.d0,                 &       ! Lat of Pert Center
1238                                delta_theta = 1.d0,             &       ! Max Amplitude of Pert
1239                                Lz      = 20000.d0,             &       ! Vertical Wavelength of Pert
1240                                N       = 0.01d0,               &       ! Brunt-Vaisala frequency
1241                                N2      = N*N,                  &       ! Brunt-Vaisala frequency Squared
1242                                bigG    = (g*g)/(N2*cp)                 ! Constant
1243                           
1244      real(rstd) :: height                                                      ! Model level height
1245      real(rstd) :: sin_tmp, cos_tmp                                    ! Calculation of great circle distance
1246      real(rstd) :: r, s                                                        ! Shape of perturbation
1247      real(rstd) :: TS                                                  ! Surface temperature
1248      real(rstd) :: t_mean, t_pert                                              ! Mean and pert parts of temperature
1249      real(rstd) :: theta_pert                                          ! Pot-temp perturbation
1250
1251!-----------------------------------------------------------------------
1252!    THE VELOCITIES
1253!-----------------------------------------------------------------------
1254
1255        ! Zonal Velocity
1256
1257        u = u0 * cos(lat)
1258
1259        ! Meridional Velocity
1260
1261        v = 0.d0
1262
1263        ! Vertical Velocity = Vertical Pressure Velocity = 0
1264
1265        w = 0.d0
1266
1267!-----------------------------------------------------------------------
1268!    PHIS (surface geopotential)
1269!-----------------------------------------------------------------------
1270
1271        phis = 0.d0
1272
1273!-----------------------------------------------------------------------
1274!    SURFACE TEMPERATURE
1275!-----------------------------------------------------------------------
1276
1277        TS = bigG + (Teq-bigG)*exp( -(u0*N2/(4.d0*g*g))*(u0+2.d0*om*as)*(cos(2.d0*lat)-1.d0)    ) 
1278
1279!-----------------------------------------------------------------------
1280!    PS (surface pressure)
1281!-----------------------------------------------------------------------
1282
1283        ps = peq*exp( (u0/(4.0*bigG*Rd))*(u0+2.0*Om*as)*(cos(2.0*lat)-1.0)  ) &
1284                * (TS/Teq)**(cp/Rd)
1285
1286!-----------------------------------------------------------------------
1287!    HEIGHT AND PRESSURE AND MEAN TEMPERATURE
1288!-----------------------------------------------------------------------
1289
1290        if (zcoords .eq. 1) then
1291
1292                height = z
1293                p = ps*( (bigG/TS)*exp(-N2*height/g)+1.d0 - (bigG/TS)  )**(cp/Rd)
1294
1295        else
1296
1297                height = (-g/N2)*log( (TS/bigG)*( (p/ps)**(Rd/cp) - 1.d0  ) + 1.d0 )
1298
1299        endif
1300
1301        t_mean = bigG*(1.d0 - exp(N2*height/g))+ TS*exp(N2*height/g)
1302
1303!-----------------------------------------------------------------------
1304!    rho (density), unperturbed using the background temperature t_mean
1305!-----------------------------------------------------------------------
1306
1307!***********
1308!       change in version 3: density is now initialized with unperturbed background temperature,
1309!                            temperature perturbation is added afterwards
1310!***********
1311        rho = p/(Rd*t_mean)
1312
1313!-----------------------------------------------------------------------
1314!    POTENTIAL TEMPERATURE PERTURBATION,
1315!    here: converted to temperature and added to the temperature field
1316!    models with a prognostic potential temperature field can utilize
1317!    the potential temperature perturbation theta_pert directly and add it
1318!    to the background theta field (not included here)
1319!-----------------------------------------------------------------------
1320
1321        sin_tmp = sin(lat) * sin(phic)
1322        cos_tmp = cos(lat) * cos(phic)
1323
1324                ! great circle distance with 'a/X'
1325
1326        r  = as * ACOS (sin_tmp + cos_tmp*cos(lon-lambdac)) 
1327
1328        s = (d**2)/(d**2 + r**2)
1329
1330        theta_pert = delta_theta*s*sin(2.d0*pi*height/Lz)
1331
1332        t_pert = theta_pert*(p/p0)**(Rd/cp)
1333
1334        t = t_mean + t_pert
1335
1336!-----------------------------------------------------------------------
1337!     initialize Q, set to zero
1338!-----------------------------------------------------------------------
1339
1340        q = 0.d0
1341
1342END SUBROUTINE test3_gravity_wave
1343
1344
1345END MODULE dcmip_initial_conditions_test_1_2_3
1346
Note: See TracBrowser for help on using the repository browser.