source: codes/icosagcm/trunk/src/etat0_heldsz.f90 @ 526

Last change on this file since 526 was 494, checked in by ymipsl, 8 years ago

Fix held & suarez physic (extra dimansion for theta)

YM

File size: 7.2 KB
Line 
1MODULE etat0_heldsz_mod
2  USE icosa
3  IMPLICIT NONE
4  PRIVATE
5
6  TYPE(t_field),POINTER :: f_theta_eq(:)
7  TYPE(t_field),POINTER :: f_theta(:)
8
9  REAL(rstd),ALLOCATABLE,SAVE :: knewt_t(:),kfrict(:)
10!$OMP THREADPRIVATE(knewt_t,kfrict)
11  LOGICAL, SAVE :: done=.FALSE.
12!$OMP THREADPRIVATE(done)
13
14  REAL(rstd),SAVE :: teta0,ttp,delt_y,delt_z,eps
15!$OMP THREADPRIVATE(teta0,ttp,delt_y,delt_z,eps)
16
17  REAL(rstd),SAVE :: knewt_g, k_f,k_c_a,k_c_s
18!$OMP THREADPRIVATE(knewt_g, k_f,k_c_a,k_c_s)
19
20  PUBLIC :: etat0, held_suarez
21 
22CONTAINS
23
24  SUBROUTINE test_etat0_heldsz
25    USE kinetic_mod
26    TYPE(t_field),POINTER :: f_ps(:)
27    TYPE(t_field),POINTER :: f_phis(:)
28    TYPE(t_field),POINTER :: f_theta_rhodz(:)
29    TYPE(t_field),POINTER :: f_u(:)
30    TYPE(t_field),POINTER :: f_q(:)
31    TYPE(t_field),POINTER :: f_Ki(:)
32
33    REAL(rstd),POINTER :: Ki(:,:)
34    INTEGER :: ind
35
36    CALL allocate_field(f_ps,field_t,type_real)
37    CALL allocate_field(f_phis,field_t,type_real)
38    CALL allocate_field(f_theta_rhodz,field_t,type_real,llm,2)
39    CALL allocate_field(f_u,field_u,type_real,llm)
40    CALL allocate_field(f_Ki,field_t,type_real,llm)
41
42    CALL etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
43    CALL kinetic(f_u,f_Ki)
44
45    CALL writefield('ps',f_ps)
46    CALL writefield('theta',f_theta_rhodz)
47  END SUBROUTINE test_etat0_heldsz
48
49  SUBROUTINE etat0(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
50    USE theta2theta_rhodz_mod
51    IMPLICIT NONE
52    TYPE(t_field),POINTER :: f_ps(:)
53    TYPE(t_field),POINTER :: f_phis(:)
54    TYPE(t_field),POINTER :: f_theta_rhodz(:)
55    TYPE(t_field),POINTER :: f_u(:)
56    TYPE(t_field),POINTER :: f_q(:)
57
58    REAL(rstd),POINTER :: ps(:)
59    REAL(rstd),POINTER :: phis(:)
60    REAL(rstd),POINTER :: theta_rhodz(:,:,:)
61    REAL(rstd),POINTER :: u(:,:)
62    REAL(rstd),POINTER :: q(:,:,:)
63    REAL(rstd),POINTER :: theta_eq(:,:) 
64    REAL(rstd),POINTER :: theta(:,:) 
65
66    INTEGER :: ind
67
68    CALL Init_Teq
69    DO ind=1,ndomain
70       IF (.NOT. assigned_domain(ind)) CYCLE
71       CALL swap_dimensions(ind)
72       CALL swap_geometry(ind)
73
74       theta_eq=f_theta_eq(ind) 
75       CALL compute_Teq(lat_i,theta_eq) ! FIXME : already done by Init_Teq
76
77       ps=f_ps(ind)
78       phis=f_phis(ind)
79       u=f_u(ind)
80       ps(:)=1e5
81       phis(:)=0.
82       u(:,:)=0
83
84       theta_rhodz=f_theta_rhodz(ind)
85       theta=f_theta(ind)
86       CALL compute_etat0_heldsz(theta_eq,theta)
87       CALL compute_theta2theta_rhodz(ps,theta,theta_rhodz(:,:,1),1)
88       IF(nqtot>0) THEN
89          q=f_q(ind)
90          q(:,:,1)=1e-2
91          IF(nqtot>1) q(:,:,2)=0
92          IF(nqtot>2) q(:,:,3:)=1e-2
93       END IF
94    ENDDO
95  END SUBROUTINE etat0
96
97  SUBROUTINE init_Teq
98    USE disvert_mod, ONLY : ap,bp
99    REAL(rstd),POINTER :: clat(:) 
100    REAL(rstd),POINTER :: theta_eq(:,:) 
101    REAL(rstd) :: zsig
102    INTEGER :: ind, l
103
104    IF(.NOT.done) THEN
105       done = .TRUE.
106       
107       CALL allocate_field(f_theta,field_t,type_real,llm)
108       CALL allocate_field(f_theta_eq,field_t,type_real,llm)
109       ALLOCATE(knewt_t(llm)); ALLOCATE( kfrict(llm)) 
110
111       k_f=1.                !friction
112       CALL getin('k_j',k_f)
113       k_f=1./(daysec*k_f)
114       k_c_s=4.  !cooling surface
115       CALL getin('k_c_s',k_c_s)
116       k_c_s=1./(daysec*k_c_s)
117       k_c_a=40. !cooling free atm
118       CALL getin('k_c_a',k_c_a)
119       k_c_a=1./(daysec*k_c_a)
120       ! Constants for Teta equilibrium profile
121       teta0=315.     ! mean Teta (S.H. 315K)
122       CALL getin('teta0',teta0)
123       ttp=200.       ! Tropopause temperature (S.H. 200K)
124       CALL getin('ttp',ttp)
125       eps=0.         ! Deviation to N-S symmetry(~0-20K)
126       CALL getin('eps',eps)
127       delt_y=60.     ! Merid Temp. Gradient (S.H. 60K)
128       CALL getin('delt_y',delt_y)
129       delt_z=10.     ! Vertical Gradient (S.H. 10K)
130       CALL getin('delt_z',delt_z)
131
132       !-----------------------------------------------------------
133       knewt_g=k_c_a 
134       DO l=1,llm
135          zsig=ap(l)/preff+bp(l)
136          knewt_t(l)=(k_c_s-k_c_a)*MAX(0.,(zsig-0.7)/0.3) 
137          kfrict(l)=k_f*MAX(0.,(zsig-0.7)/0.3) 
138       ENDDO
139
140       DO ind=1,ndomain
141          IF (.NOT. assigned_domain(ind)) CYCLE
142          CALL swap_dimensions(ind)
143          CALL swap_geometry(ind)
144          theta_eq=f_theta_eq(ind)
145          CALL compute_Teq(lat_i,theta_eq)
146       ENDDO
147
148    ELSE
149       PRINT *, 'Init_Teq called twice'
150       CALL ABORT
151    END IF
152
153  END SUBROUTINE init_Teq
154
155  SUBROUTINE compute_Teq(lat,theta_eq)
156    USE disvert_mod
157    REAL(rstd),INTENT(IN) :: lat(iim*jjm)
158    REAL(rstd),INTENT(OUT) :: theta_eq(iim*jjm,llm) 
159
160    REAL(rstd) :: r, zsig, ddsin, tetastrat, tetajl
161    INTEGER :: i,j,l,ij
162
163    DO l=1,llm
164       zsig=ap(l)/preff+bp(l)
165       tetastrat=ttp*zsig**(-kappa)
166       DO j=jj_begin-1,jj_end+1
167          DO i=ii_begin-1,ii_end+1
168             ij=(j-1)*iim+i
169             ddsin=SIN(lat(ij)) 
170             tetajl=teta0-delt_y*ddsin*ddsin+eps*ddsin &
171                  -delt_z*(1.-ddsin*ddsin)*log(zsig)
172             theta_eq(ij,l)=MAX(tetajl,tetastrat) 
173          ENDDO
174       ENDDO
175    ENDDO
176  END SUBROUTINE compute_Teq
177
178  SUBROUTINE compute_etat0_heldsz(theta_eq, theta)
179    USE disvert_mod
180    REAL(rstd),INTENT(IN) :: theta_eq(iim*jjm,llm) 
181    REAL(rstd),INTENT(OUT) :: theta(iim*jjm,llm) 
182
183    REAL(rstd) :: r  ! random number
184    INTEGER :: i,j,l,ij
185
186    DO l=1,llm
187       DO j=jj_begin-1,jj_end+1
188          DO i=ii_begin-1,ii_end+1
189             ij=(j-1)*iim+i
190             CALL RANDOM_NUMBER(r); r = 0.0 
191             theta(ij,l)=theta_eq(ij,l)*(1.+0.0005*r)
192          ENDDO
193       ENDDO
194    ENDDO
195
196  END SUBROUTINE compute_etat0_heldsz
197
198
199  SUBROUTINE held_suarez(f_ps,f_theta_rhodz,f_u) 
200    TYPE(t_field),POINTER :: f_theta_rhodz(:)
201    TYPE(t_field),POINTER :: f_u(:)
202    TYPE(t_field),POINTER :: f_ps(:)
203    REAL(rstd),POINTER :: theta_rhodz(:,:,:)
204    REAL(rstd),POINTER :: u(:,:)
205    REAL(rstd),POINTER :: ps(:)
206    REAL(rstd),POINTER :: theta_eq(:,:)
207    REAL(rstd),POINTER :: theta(:,:)
208    REAL(rstd),POINTER :: clat(:)
209    INTEGER::ind
210
211    DO ind=1,ndomain
212       IF (.NOT. assigned_domain(ind)) CYCLE
213       CALL swap_dimensions(ind)
214       CALL swap_geometry(ind)
215       theta_rhodz=f_theta_rhodz(ind)
216       u=f_u(ind)
217       ps=f_ps(ind) 
218       theta_eq=f_theta_eq(ind) 
219       theta=f_theta(ind) 
220       CALL compute_heldsz(ps,theta_eq,lat_i, theta_rhodz(:,:,1),u, theta) 
221    ENDDO
222  END SUBROUTINE held_suarez
223
224  SUBROUTINE compute_heldsz(ps,theta_eq,lat, theta_rhodz,u, theta) 
225    USE theta2theta_rhodz_mod
226    REAL(rstd),INTENT(IN)    :: ps(iim*jjm) 
227    REAL(rstd),INTENT(IN)    :: theta_eq(iim*jjm,llm) 
228    REAL(rstd),INTENT(IN)    :: lat(iim*jjm) 
229    REAL(rstd),INTENT(INOUT) :: theta_rhodz(iim*jjm,llm)
230    REAL(rstd),INTENT(INOUT) :: u(3*iim*jjm,llm)
231    REAL(rstd),INTENT(OUT)   :: theta(iim*jjm,llm) 
232
233    INTEGER :: i,j,l,ij
234
235    CALL compute_theta_rhodz2theta(ps,theta_rhodz,theta,1)
236    DO l=1,llm
237       DO j=jj_begin-1,jj_end+1
238          DO i=ii_begin-1,ii_end+1
239             ij=(j-1)*iim+i
240             theta(ij,l)=theta(ij,l) - dt*(theta(ij,l)-theta_eq(ij,l))* &
241                  (knewt_g+knewt_t(l)*COS(lat(ij))**4 )
242          ENDDO
243       ENDDO
244    ENDDO
245    CALL compute_theta2theta_rhodz(ps,theta,theta_rhodz,1)
246
247    Do l=1,llm
248       u(:,l)=u(:,l)*(1.-dt*kfrict(l))
249    END DO
250
251  END SUBROUTINE compute_heldsz
252
253END MODULE etat0_heldsz_mod
Note: See TracBrowser for help on using the repository browser.