source: codes/icosagcm/trunk/src/etat0.f90 @ 201

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

Simplified etat0 : isothermal, jablonowsky06

File size: 7.6 KB
Line 
1MODULE etat0_mod
2  USE icosa
3  PRIVATE
4
5    CHARACTER(len=255),SAVE :: etat0_type
6!$OMP THREADPRIVATE(etat0_type)
7
8    REAL(rstd) :: etat0_temp
9
10    PUBLIC :: etat0, etat0_type
11
12CONTAINS
13 
14  SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_q)
15    USE mpipara, ONLY : is_mpi_root
16    USE disvert_mod
17    USE etat0_williamson_mod, ONLY : etat0_williamson_new
18    USE etat0_jablonowsky06_mod, ONLY : etat0_jablonowsky06=>etat0
19    USE etat0_academic_mod, ONLY : etat0_academic=>etat0 
20    USE etat0_dcmip1_mod, ONLY : etat0_dcmip1=>etat0
21    USE etat0_dcmip2_mod, ONLY : etat0_dcmip2=>etat0
22    USE etat0_dcmip3_mod, ONLY : etat0_dcmip3=>etat0 
23    USE etat0_dcmip4_mod, ONLY : etat0_dcmip4=>etat0 
24    USE etat0_dcmip5_mod, ONLY : etat0_dcmip5=>etat0 
25    USE etat0_heldsz_mod, ONLY : etat0_heldsz=>etat0 
26    USE dynetat0_gcm_mod, ONLY : dynetat0_start=>etat0 
27    USE dynetat0_hz_mod,  ONLY : dynetat0_hz=>etat0 
28
29    IMPLICIT NONE
30    TYPE(t_field),POINTER :: f_ps(:)
31    TYPE(t_field),POINTER :: f_mass(:)
32    TYPE(t_field),POINTER :: f_phis(:)
33    TYPE(t_field),POINTER :: f_theta_rhodz(:)
34    TYPE(t_field),POINTER :: f_u(:)
35    TYPE(t_field),POINTER :: f_q(:)
36   
37    REAL(rstd),POINTER :: ps(:), mass(:,:)
38    LOGICAL :: init_mass
39    INTEGER :: ind,i,j,ij,l
40
41    ! most etat0 routines set ps and not mass
42    ! in that case and if caldyn_eta == eta_lag
43    ! the initial distribution of mass is taken to be the same
44    ! as what the mass coordinate would dictate
45    ! however if etat0_XXX defines mass then the flag init_mass must be set to .FALSE.
46    ! otherwise mass will be overwritten
47    init_mass = (caldyn_eta == eta_lag)
48
49    etat0_type='jablonowsky06'
50    CALL getin("etat0",etat0_type)
51   
52    SELECT CASE (TRIM(etat0_type))
53    CASE ('isothermal')
54       CALL getin_etat0_isothermal
55       CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
56    CASE ('williamson91.6')
57       init_mass=.FALSE.
58       CALL etat0_williamson_new(f_phis,f_mass,f_theta_rhodz,f_u, f_q)
59    CASE ('jablonowsky06')
60!       CALL etat0_jablonowsky06(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
61       CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
62    CASE ('academic')
63       CALL etat0_academic(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
64    CASE ('held_suarez')
65       PRINT *,"Held & Suarez (1994) test case"
66       CALL etat0_heldsz(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
67    CASE ('dcmip1')
68       CALL etat0_dcmip1(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
69    CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')
70       CALL etat0_dcmip2(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
71    CASE ('dcmip3')
72       CALL etat0_dcmip3(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
73     CASE ('dcmip4')
74        IF(nqtot<2) THEN
75           IF (is_mpi_root)  THEN
76              PRINT *, "nqtot must be at least 2 for test case DCMIP4"
77           END IF
78           STOP
79        END IF
80       CALL etat0_dcmip4(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
81     CASE ('dcmip5')
82       CALL etat0_dcmip5(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
83     CASE ('readnf_start') 
84          print*,"readnf_start used"   
85       CALL dynetat0_start(f_ps,f_phis,f_theta_rhodz,f_u,f_q) 
86        CASE ('readnf_hz') 
87          print*,"readnf_hz used"
88       CALL dynetat0_hz(f_ps,f_phis,f_theta_rhodz,f_u,f_q) 
89   CASE DEFAULT
90       PRINT*, 'Bad selector for variable etat0 <',etat0_type, &
91            '> options are <jablonowsky06>, <academic>, <dcmip[1-4]> '
92       STOP
93    END SELECT
94
95    IF(init_mass) THEN ! initialize mass distribution using ps
96!       !$OMP BARRIER
97       DO ind=1,ndomain
98          IF (.NOT. assigned_domain(ind)) CYCLE
99          CALL swap_dimensions(ind)
100          CALL swap_geometry(ind)
101          mass=f_mass(ind); ps=f_ps(ind)
102          CALL compute_rhodz(.TRUE., ps, mass)
103       END DO
104    END IF
105
106  END SUBROUTINE etat0
107
108  SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
109    USE mpipara
110    IMPLICIT NONE
111    TYPE(t_field),POINTER :: f_ps(:)
112    TYPE(t_field),POINTER :: f_mass(:)
113    TYPE(t_field),POINTER :: f_phis(:)
114    TYPE(t_field),POINTER :: f_theta_rhodz(:)
115    TYPE(t_field),POINTER :: f_u(:)
116    TYPE(t_field),POINTER :: f_q(:)
117 
118    REAL(rstd),POINTER :: ps(:)
119    REAL(rstd),POINTER :: mass(:,:)
120    REAL(rstd),POINTER :: phis(:)
121    REAL(rstd),POINTER :: theta_rhodz(:,:)
122    REAL(rstd),POINTER :: u(:,:)
123    REAL(rstd),POINTER :: q(:,:,:)
124    INTEGER :: ind
125
126    DO ind=1,ndomain
127      IF (.NOT. assigned_domain(ind)) CYCLE
128      CALL swap_dimensions(ind)
129      CALL swap_geometry(ind)
130      ps=f_ps(ind)
131      mass=f_mass(ind)
132      phis=f_phis(ind)
133      theta_rhodz=f_theta_rhodz(ind)
134      u=f_u(ind)
135      q=f_q(ind)
136      CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, q)
137
138    ENDDO
139  END SUBROUTINE etat0_collocated
140
141  SUBROUTINE compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, q)
142    USE disvert_mod
143    USE theta2theta_rhodz_mod
144    USE wind_mod
145    USE etat0_jablonowsky06_mod, ONLY : compute_jablonowsky06 => compute_etat0_new
146    IMPLICIT NONE
147    REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
148    REAL(rstd),INTENT(INOUT) :: mass(iim*jjm,llm)
149    REAL(rstd),INTENT(OUT) :: phis(iim*jjm)
150    REAL(rstd),INTENT(OUT) :: theta_rhodz(iim*jjm,llm)
151    REAL(rstd),INTENT(OUT) :: u(3*iim*jjm,llm)
152    REAL(rstd),INTENT(OUT) :: q(iim*jjm,llm,nqtot)
153
154    REAL(rstd) :: lon_i(iim*jjm)
155    REAL(rstd) :: lat_i(iim*jjm)
156    REAL(rstd) :: temp_i(iim*jjm,llm)
157    REAL(rstd) :: ulon_i(iim*jjm,llm)
158    REAL(rstd) :: ulat_i(iim*jjm,llm)
159
160    REAL(rstd) :: lon_e(3*iim*jjm)
161    REAL(rstd) :: lat_e(3*iim*jjm)
162    REAL(rstd) :: ps_e(3*iim*jjm)
163    REAL(rstd) :: mass_e(3*iim*jjm,llm)
164    REAL(rstd) :: phis_e(3*iim*jjm)
165    REAL(rstd) :: temp_e(3*iim*jjm,llm)
166    REAL(rstd) :: ulon_e(3*iim*jjm,llm)
167    REAL(rstd) :: ulat_e(3*iim*jjm,llm)
168    REAL(rstd) :: q_e(3*iim*jjm,llm,nqtot)
169
170    INTEGER :: l,i,j,ij
171
172    DO l=1,llm
173       DO j=jj_begin-1,jj_end+1
174          DO i=ii_begin-1,ii_end+1
175             ij=(j-1)*iim+i
176             CALL xyz2lonlat(xyz_i(ij,:)/radius,lon_i(ij),lat_i(ij))
177             CALL xyz2lonlat(xyz_e(ij+u_right,:)/radius,lon_e(ij+u_right),lat_e(ij+u_right))
178             CALL xyz2lonlat(xyz_e(ij+u_lup,:)/radius,lon_e(ij+u_lup),lat_e(ij+u_lup))
179             CALL xyz2lonlat(xyz_e(ij+u_ldown,:)/radius,lon_e(ij+u_ldown),lat_e(ij+u_ldown))
180          END DO
181       END DO
182    END DO
183
184    SELECT CASE (TRIM(etat0_type))
185    CASE ('isothermal')
186       CALL compute_etat0_isothermal(iim*jjm, phis, ps, temp_i, ulon_i, ulat_i, q)
187       CALL compute_etat0_isothermal(3*iim*jjm, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
188    CASE('jablonowsky06')
189       CALL compute_jablonowsky06(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i)
190       CALL compute_jablonowsky06(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)
191    END SELECT
192
193    CALL compute_temperature2theta_rhodz(ps,temp_i,theta_rhodz,0)       
194    CALL compute_wind_perp_from_lonlat_compound(ulon_e, ulat_e, u)
195
196  END SUBROUTINE compute_etat0_collocated
197
198!----------------------------- Resting isothermal state --------------------------------
199
200  SUBROUTINE getin_etat0_isothermal
201    etat0_temp=300
202    CALL getin("etat0_isothermal_temp",etat0_temp)
203  END SUBROUTINE getin_etat0_isothermal
204
205  SUBROUTINE compute_etat0_isothermal(ngrid, phis, ps, temp, ulon, ulat, q)
206    IMPLICIT NONE 
207    INTEGER, INTENT(IN)    :: ngrid
208    REAL(rstd),INTENT(OUT) :: phis(ngrid)
209    REAL(rstd),INTENT(OUT) :: ps(ngrid)
210    REAL(rstd),INTENT(OUT) :: temp(ngrid,llm)
211    REAL(rstd),INTENT(OUT) :: ulon(ngrid,llm)
212    REAL(rstd),INTENT(OUT) :: ulat(ngrid,llm)
213    REAL(rstd),INTENT(OUT) :: q(ngrid,llm,nqtot)
214    phis(:)=0
215    ps(:)=preff
216    temp(:,:)=etat0_temp
217    ulon(:,:)=0
218    ulat(:,:)=0
219    q(:,:,:)=0
220  END SUBROUTINE compute_etat0_isothermal
221
222END MODULE etat0_mod
Note: See TracBrowser for help on using the repository browser.