source: codes/icosagcm/devel/src/dcmip/dcmip_initial_conditions_test_1_2_3_v5.f90 @ 995

Last change on this file since 995 was 995, checked in by jisesh, 4 years ago

devel: Added Teq and h0 as arguments

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