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