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

Last change on this file since 325 was 325, checked in by dubos, 9 years ago

Venus (Lebonnois et al., 2012) test case

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