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

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

Partial fix for etat0 : W91 works again

File size: 7.8 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_start_file_mod, ONLY : etat0_start_file=>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       !------------------- New interface ---------------------
54    CASE ('isothermal')
55       CALL getin_etat0_isothermal
56       CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
57    CASE ('jablonowsky06')
58       CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
59     CASE ('dcmip5')
60        CALL getin_etat0_dcmip5
61        CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
62    CASE ('williamson91.6')
63       init_mass=.FALSE.
64       CALL getin_etat0_williamson
65       CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
66       !------------------- Old interface --------------------
67    CASE ('start_file')
68       CALL etat0_start_file(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
69    CASE ('academic')
70       CALL etat0_academic(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
71    CASE ('held_suarez')
72       PRINT *,"Held & Suarez (1994) test case"
73       CALL etat0_heldsz(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
74    CASE ('dcmip1')
75       CALL etat0_dcmip1(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
76    CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')
77       CALL etat0_dcmip2(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
78    CASE ('dcmip3')
79       CALL etat0_dcmip3(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
80    CASE ('dcmip4')
81        IF(nqtot<2) THEN
82           IF (is_mpi_root)  THEN
83              PRINT *, "nqtot must be at least 2 for test case DCMIP4"
84           END IF
85           STOP
86        END IF
87        CALL etat0_dcmip4(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
88   CASE DEFAULT
89       PRINT*, 'Bad selector for variable etat0 <',etat0_type, &
90            '> options are <jablonowsky06>, <academic>, <dcmip[1-4]> '
91       STOP
92    END SELECT
93
94    IF(init_mass) THEN ! initialize mass distribution using ps
95!       !$OMP BARRIER
96       DO ind=1,ndomain
97          IF (.NOT. assigned_domain(ind)) CYCLE
98          CALL swap_dimensions(ind)
99          CALL swap_geometry(ind)
100          mass=f_mass(ind); ps=f_ps(ind)
101          CALL compute_rhodz(.TRUE., ps, mass)
102       END DO
103    END IF
104
105  END SUBROUTINE etat0
106
107  SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
108    USE theta2theta_rhodz_mod
109    IMPLICIT NONE
110    TYPE(t_field),POINTER :: f_ps(:)
111    TYPE(t_field),POINTER :: f_mass(:)
112    TYPE(t_field),POINTER :: f_phis(:)
113    TYPE(t_field),POINTER :: f_theta_rhodz(:)
114    TYPE(t_field),POINTER :: f_u(:)
115    TYPE(t_field),POINTER :: f_q(:)
116 
117    TYPE(t_field),POINTER,SAVE :: f_temp(:)
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 :: temp(:,:)
123    REAL(rstd),POINTER :: u(:,:)
124    REAL(rstd),POINTER :: q(:,:,:)
125    INTEGER :: ind
126
127    CALL allocate_field(f_temp,field_t,type_real,llm,name='temp')
128
129    DO ind=1,ndomain
130      IF (.NOT. assigned_domain(ind)) CYCLE
131      CALL swap_dimensions(ind)
132      CALL swap_geometry(ind)
133      ps=f_ps(ind)
134      mass=f_mass(ind)
135      phis=f_phis(ind)
136      theta_rhodz=f_theta_rhodz(ind)
137      temp=f_temp(ind)
138      u=f_u(ind)
139      q=f_q(ind)
140
141      IF( TRIM(etat0_type)=='williamson91.6' ) THEN
142       CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, q)
143      ELSE
144       CALL compute_etat0_collocated(ps,mass, phis, temp, u, q)
145      ENDIF
146    ENDDO
147   
148    IF( TRIM(etat0_type)/='williamson91.6' ) CALL temperature2theta_rhodz(f_ps,f_temp,f_theta_rhodz)
149   
150    CALL deallocate_field(f_temp)
151   
152  END SUBROUTINE etat0_collocated
153
154  SUBROUTINE compute_etat0_collocated(ps,mass, phis, temp_i, u, q)
155    USE wind_mod
156    USE etat0_jablonowsky06_mod, ONLY : compute_jablonowsky06 => compute_etat0
157    USE etat0_dcmip5_mod, ONLY : compute_dcmip5 => compute_etat0
158    USE etat0_williamson_mod, ONLY : compute_w91_6 => compute_etat0
159    IMPLICIT NONE
160    REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
161    REAL(rstd),INTENT(INOUT) :: mass(iim*jjm,llm)
162    REAL(rstd),INTENT(OUT) :: phis(iim*jjm)
163    REAL(rstd),INTENT(OUT) :: temp_i(iim*jjm,llm)
164    REAL(rstd),INTENT(OUT) :: u(3*iim*jjm,llm)
165    REAL(rstd),INTENT(OUT) :: q(iim*jjm,llm,nqtot)
166
167    REAL(rstd) :: ulon_i(iim*jjm,llm)
168    REAL(rstd) :: ulat_i(iim*jjm,llm)
169
170    REAL(rstd) :: ps_e(3*iim*jjm)
171    REAL(rstd) :: mass_e(3*iim*jjm,llm)
172    REAL(rstd) :: phis_e(3*iim*jjm)
173    REAL(rstd) :: temp_e(3*iim*jjm,llm)
174    REAL(rstd) :: ulon_e(3*iim*jjm,llm)
175    REAL(rstd) :: ulat_e(3*iim*jjm,llm)
176    REAL(rstd) :: q_e(3*iim*jjm,llm,nqtot)
177
178    INTEGER :: l,i,j,ij
179
180    SELECT CASE (TRIM(etat0_type))
181    CASE ('isothermal')
182       CALL compute_etat0_isothermal(iim*jjm, phis, ps, temp_i, ulon_i, ulat_i, q)
183       CALL compute_etat0_isothermal(3*iim*jjm, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
184    CASE('jablonowsky06')
185       CALL compute_jablonowsky06(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i)
186       CALL compute_jablonowsky06(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)
187    CASE('dcmip5')
188       CALL compute_dcmip5(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)
189       CALL compute_dcmip5(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
190    CASE('williamson91.6')
191       CALL compute_w91_6(iim*jjm,lon_i,lat_i, phis, mass(:,1), temp_i(:,1), ulon_i(:,1), ulat_i(:,1))
192       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))
193    END SELECT
194
195    CALL compute_wind_perp_from_lonlat_compound(ulon_e, ulat_e, u)
196
197  END SUBROUTINE compute_etat0_collocated
198
199!----------------------------- Resting isothermal state --------------------------------
200
201  SUBROUTINE getin_etat0_isothermal
202    etat0_temp=300
203    CALL getin("etat0_isothermal_temp",etat0_temp)
204  END SUBROUTINE getin_etat0_isothermal
205
206  SUBROUTINE compute_etat0_isothermal(ngrid, phis, ps, temp, ulon, ulat, q)
207    IMPLICIT NONE 
208    INTEGER, INTENT(IN)    :: ngrid
209    REAL(rstd),INTENT(OUT) :: phis(ngrid)
210    REAL(rstd),INTENT(OUT) :: ps(ngrid)
211    REAL(rstd),INTENT(OUT) :: temp(ngrid,llm)
212    REAL(rstd),INTENT(OUT) :: ulon(ngrid,llm)
213    REAL(rstd),INTENT(OUT) :: ulat(ngrid,llm)
214    REAL(rstd),INTENT(OUT) :: q(ngrid,llm,nqtot)
215    phis(:)=0
216    ps(:)=preff
217    temp(:,:)=etat0_temp
218    ulon(:,:)=0
219    ulat(:,:)=0
220    q(:,:,:)=0
221  END SUBROUTINE compute_etat0_isothermal
222
223END MODULE etat0_mod
Note: See TracBrowser for help on using the repository browser.