source: codes/icosagcm/trunk/src/etat0_dcmip3.f90 @ 286

Last change on this file since 286 was 286, checked in by dubos, 10 years ago

Partial etat0 cleanup (removed calls to xyz2lonlat)

File size: 5.8 KB
Line 
1MODULE etat0_dcmip3_mod
2
3! test cases DCMIP 2012, category 3 : Non-hydrostatic gravity waves
4
5! Questions
6! Replace ps0 by preff ??
7
8  USE genmod
9  USE dcmip_initial_conditions_test_1_2_3
10
11  PRIVATE
12
13  PUBLIC  etat0
14
15CONTAINS
16
17
18  SUBROUTINE etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
19  USE icosa
20  IMPLICIT NONE
21    TYPE(t_field),POINTER :: f_ps(:)
22    TYPE(t_field),POINTER :: f_phis(:)
23    TYPE(t_field),POINTER :: f_theta_rhodz(:)
24    TYPE(t_field),POINTER :: f_u(:)
25    TYPE(t_field),POINTER :: f_q(:)
26   
27    REAL(rstd),POINTER :: ps(:)
28    REAL(rstd),POINTER :: phis(:)
29    REAL(rstd),POINTER :: u(:,:)
30    REAL(rstd),POINTER :: theta_rhodz(:,:)
31    REAL(rstd),POINTER :: q(:,:,:)
32
33    INTEGER :: ind
34
35    DO ind=1,ndomain
36      IF (.NOT. assigned_domain(ind)) CYCLE
37      CALL swap_dimensions(ind)
38      CALL swap_geometry(ind)
39
40      ps=f_ps(ind)
41      phis=f_phis(ind)
42      u=f_u(ind)
43      theta_rhodz=f_theta_rhodz(ind)
44      q=f_q(ind)
45      CALL compute_etat0_DCMIP3(ps,phis,u,theta_rhodz,q)
46    ENDDO
47           
48  END SUBROUTINE etat0
49 
50
51  SUBROUTINE compute_etat0_DCMIP3(ps, phis, u, theta_rhodz,q)
52  USE icosa
53  USE pression_mod
54  USE theta2theta_rhodz_mod
55  USE wind_mod
56  IMPLICIT NONE
57  REAL(rstd),PARAMETER :: u0=20.         ! Maximum amplitude of the zonal wind (m.s-1)
58  REAL(rstd),PARAMETER :: N=0.01         ! Brunt-Vaisala frequency (s-1)
59  REAL(rstd),PARAMETER :: Teq=300.       ! Surface temperature at the equator (K)
60  REAL(rstd),PARAMETER :: Peq=1e5        ! Reference surface pressure at the equator (hPa)
61  REAL(rstd),PARAMETER :: d=5000.        ! Witdth parameter for theta
62  REAL(rstd),PARAMETER :: lonc=2*pi/3    ! Longitudinal centerpoint of theta
63  REAL(rstd),PARAMETER :: latc=0         ! Longitudinal centerpoint of theta
64  REAL(rstd),PARAMETER :: dtheta=1.      ! Maximum amplitude of theta (K)
65  REAL(rstd),PARAMETER :: Lz=20000.      ! Vertical wave lenght of the theta perturbation
66
67  REAL(rstd), INTENT(OUT) :: ps(iim*jjm)
68  REAL(rstd), INTENT(OUT) :: phis(iim*jjm)
69  REAL(rstd), INTENT(OUT) :: u(3*iim*jjm,llm)
70  REAL(rstd), INTENT(OUT) :: theta_rhodz(iim*jjm,llm)
71  REAL(rstd), INTENT(OUT) :: q(iim*jjm,llm,nqtot)
72 
73  REAL(rstd) :: Ts(iim*jjm)
74  REAL(rstd) :: s(iim*jjm)
75  REAL(rstd) :: T(iim*jjm,llm)
76  REAL(rstd) :: p(iim*jjm,llm+1)
77  REAL(rstd) :: theta(iim*jjm,llm)
78  REAL(rstd) :: ulon(3*iim*jjm,llm)
79  REAL(rstd) :: ulat(3*iim*jjm,llm)
80 
81 
82  INTEGER :: i,j,l,ij
83  REAL(rstd) :: Rd        ! gas constant of dry air, P=rho.Rd.T
84  REAL(rstd) :: alpha, rm
85  REAL(rstd) :: C0, C1, GG
86  REAL(rstd) :: p0psk, pspsk,r,zz, thetab, thetap
87  REAL(rstd) :: dummy, pp
88  LOGICAL    :: use_dcmip_routine
89 
90  Rd=cpp*kappa
91 
92  GG=(g/N)**2/cpp
93  C0=0.25*u0*(u0+2.*Omega*radius)
94 
95  q(:,:,:)=0
96 
97!  use_dcmip_routine=.TRUE.
98  use_dcmip_routine=.FALSE.
99  dummy=0.
100
101  pp=peq
102  DO j=jj_begin,jj_end
103     DO i=ii_begin,ii_end
104        ij=(j-1)*iim+i
105
106        IF(use_dcmip_routine) THEN
107           CALL test3_gravity_wave(lon_i(ij),lat_i(ij),pp,dummy,0, dummy,dummy,dummy,dummy,phis(ij),ps(ij),dummy,dummy)
108        ELSE
109           C1=C0*(cos(2*lat_i(ij))-1)
110           
111           !--- GROUND GEOPOTENTIAL
112           phis(ij)=0.
113           
114           !--- GROUND TEMPERATURE
115           Ts(ij) = GG+(Teq-GG)*EXP(-C1*(N/g)**2)
116           
117           !--- GROUND PRESSURE
118           Ps(ij) = peq*EXP(C1/GG/Rd)*(Ts(ij)/Teq)**(1/kappa)
119           
120           
121           r=radius*acos(sin(latc)*sin(lat_i(ij))+cos(latc)*cos(lat_i(ij))*cos(lon_i(ij)-lonc))
122           s(ij)= d**2/(d**2+r**2)
123        END IF
124     END DO
125  END DO
126 
127  CALL compute_pression(ps,p,0)
128 
129  DO l=1,llm
130     DO j=jj_begin,jj_end
131        DO i=ii_begin,ii_end
132           ij=(j-1)*iim+i
133           pp=0.5*(p(ij,l+1)+p(ij,l))  ! full-layer pressure
134           IF(use_dcmip_routine) THEN
135              CALL test3_gravity_wave(lon_i(ij),lat_i(ij),pp,dummy,0, &
136                   dummy,dummy,dummy,T(ij,l),dummy,dummy,dummy,dummy)
137           ELSE
138              pspsk=(pp/ps(ij))**kappa
139              p0psk=(Peq/ps(ij))**kappa
140              thetab = Ts(ij)*p0psk / ( Ts(ij) / GG * ( pspsk-1) +1)  ! background pot. temp.
141              zz     = -g/N**2*log( Ts(ij)/GG * (pspsk -1)+1)         ! altitude
142              thetap = dtheta *sin(2*Pi*zz/Lz) * s(ij)                ! perturbation pot. temp.
143              theta(ij,l) = thetab + thetap
144              T(ij,l) = theta(ij,l)* ((pp/peq)**kappa)
145              ! T(ij,l) = Ts(ij)*pspsk / ( Ts(ij) / GG * ( pspsk-1) +1)  ! background temp.
146           END IF
147        ENDDO
148     ENDDO
149  ENDDO
150 
151  IF(use_dcmip_routine) THEN
152     CALL compute_temperature2theta_rhodz(ps,T,theta_rhodz,0)
153  ELSE
154     CALL compute_temperature2theta_rhodz(ps,T,theta_rhodz,0)
155  END IF
156 
157  pp=peq
158  DO l=1,llm
159     DO j=jj_begin-1,jj_end+1
160        DO i=ii_begin-1,ii_end+1
161           ij=(j-1)*iim+i
162           IF(use_dcmip_routine) THEN
163              CALL test3_gravity_wave(lon_e(ij+u_right),lat_e(ij+u_right), &
164                   pp,0.,0, ulon(ij+u_right,l),ulat(ij+u_right,l),&
165                   dummy,dummy,dummy,dummy,dummy,dummy)
166              CALL test3_gravity_wave(lon_e(ij+u_lup),lat_e(ij+u_lup), &
167                   pp,0.,0, ulon(ij+u_lup,l),ulat(ij+u_lup,l),&
168                   dummy,dummy,dummy,dummy,dummy,dummy)
169              CALL test3_gravity_wave(lon_e(ij+u_ldown),lat_e(ij+u_ldown), &
170                   pp,0.,0, ulon(ij+u_ldown,l),ulat(ij+u_ldown,l),&
171                   dummy,dummy,dummy,dummy,dummy,dummy)
172           ELSE
173              ulon(ij+u_right,l) = u0*cos(lat_e(ij+u_right))
174              ulat(ij+u_right,l) = 0
175              ulon(ij+u_lup,l)   = u0*cos(lat_e(ij+u_lup))
176              ulat(ij+u_lup,l)   = 0
177              ulon(ij+u_ldown,l) = u0*cos(lat_e(ij+u_ldown))
178              ulat(ij+u_ldown,l) = 0
179           END IF
180        ENDDO
181     ENDDO
182  ENDDO
183 
184  CALL compute_wind_perp_from_lonlat_compound(ulon,ulat,u)   
185 
186END SUBROUTINE compute_etat0_DCMIP3
187
188
189END MODULE etat0_DCMIP3_mod
Note: See TracBrowser for help on using the repository browser.