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
RevLine 
[12]1MODULE etat0_mod
[199]2  USE icosa
3  PRIVATE
4
[149]5    CHARACTER(len=255),SAVE :: etat0_type
[186]6!$OMP THREADPRIVATE(etat0_type)
[12]7
[199]8    REAL(rstd) :: etat0_temp
9
10    PUBLIC :: etat0, etat0_type
11
[17]12CONTAINS
13 
[159]14  SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_q)
[192]15    USE mpipara, ONLY : is_mpi_root
[159]16    USE disvert_mod
[203]17    ! New interface
18    USE etat0_dcmip5_mod, ONLY : getin_etat0_dcmip5=>getin_etat0
[204]19    USE etat0_williamson_mod, ONLY : getin_etat0_williamson=>getin_etat0
[203]20    ! Old interface
[54]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 
[78]25    USE etat0_dcmip4_mod, ONLY : etat0_dcmip4=>etat0 
[149]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 
[266]29    USE etat0_start_file_mod, ONLY : etat0_start_file=>etat0 
[149]30
[54]31    IMPLICIT NONE
[17]32    TYPE(t_field),POINTER :: f_ps(:)
[159]33    TYPE(t_field),POINTER :: f_mass(:)
[17]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(:)
[186]38   
[159]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
[17]51    etat0_type='jablonowsky06'
52    CALL getin("etat0",etat0_type)
53   
54    SELECT CASE (TRIM(etat0_type))
[203]55       !------------------- New interface ---------------------
[199]56    CASE ('isothermal')
57       CALL getin_etat0_isothermal
[201]58       CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
[203]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)
[168]64    CASE ('williamson91.6')
[199]65       init_mass=.FALSE.
[204]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 --------------------
[266]69    CASE ('start_file')
70       CALL etat0_start_file(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[54]71    CASE ('academic')
72       CALL etat0_academic(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[170]73    CASE ('held_suarez')
74       PRINT *,"Held & Suarez (1994) test case"
[149]75       CALL etat0_heldsz(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[54]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)
[78]82     CASE ('dcmip4')
[192]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
[78]89       CALL etat0_dcmip4(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[149]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) 
[62]96   CASE DEFAULT
[54]97       PRINT*, 'Bad selector for variable etat0 <',etat0_type, &
[67]98            '> options are <jablonowsky06>, <academic>, <dcmip[1-4]> '
[54]99       STOP
100    END SELECT
[159]101
102    IF(init_mass) THEN ! initialize mass distribution using ps
[186]103!       !$OMP BARRIER
[159]104       DO ind=1,ndomain
[186]105          IF (.NOT. assigned_domain(ind)) CYCLE
[159]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
[54]113  END SUBROUTINE etat0
[199]114
[201]115  SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_q)
[199]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)
[201]142      CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, q)
[199]143    ENDDO
144  END SUBROUTINE etat0_collocated
145
[201]146  SUBROUTINE compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, q)
[199]147    USE theta2theta_rhodz_mod
148    USE wind_mod
[203]149    USE etat0_jablonowsky06_mod, ONLY : compute_jablonowsky06 => compute_etat0
150    USE etat0_dcmip5_mod, ONLY : compute_dcmip5 => compute_etat0
[204]151    USE etat0_williamson_mod, ONLY : compute_w91_6 => compute_etat0
[199]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')
[201]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)
[203]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)
[204]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))
[199]187    END SELECT
188
[204]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 
[201]196    CALL compute_wind_perp_from_lonlat_compound(ulon_e, ulat_e, u)
[199]197
[201]198  END SUBROUTINE compute_etat0_collocated
199
[199]200!----------------------------- Resting isothermal state --------------------------------
201
202  SUBROUTINE getin_etat0_isothermal
[201]203    etat0_temp=300
204    CALL getin("etat0_isothermal_temp",etat0_temp)
[199]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
[12]224END MODULE etat0_mod
Note: See TracBrowser for help on using the repository browser.