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

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

Progress towards NH

File size: 10.8 KB
RevLine 
[12]1MODULE etat0_mod
[199]2  USE icosa
[344]3  IMPLICIT NONE         
[199]4  PRIVATE
5
[149]6    CHARACTER(len=255),SAVE :: etat0_type
[186]7!$OMP THREADPRIVATE(etat0_type)
[12]8
[199]9    REAL(rstd) :: etat0_temp
10
11    PUBLIC :: etat0, etat0_type
12
[17]13CONTAINS
14 
[366]15  SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_geopot,f_w, f_q)
[192]16    USE mpipara, ONLY : is_mpi_root
[159]17    USE disvert_mod
[345]18    ! Generic interface
[344]19    USE etat0_dcmip1_mod, ONLY : getin_etat0_dcmip1=>getin_etat0
20    USE etat0_dcmip2_mod, ONLY : getin_etat0_dcmip2=>getin_etat0
[346]21    USE etat0_dcmip4_mod, ONLY : getin_etat0_dcmip4=>getin_etat0
[203]22    USE etat0_dcmip5_mod, ONLY : getin_etat0_dcmip5=>getin_etat0
[204]23    USE etat0_williamson_mod, ONLY : getin_etat0_williamson=>getin_etat0
[327]24    USE etat0_temperature_mod, ONLY: getin_etat0_temperature=>getin_etat0
[345]25    ! Ad hoc interfaces
[54]26    USE etat0_academic_mod, ONLY : etat0_academic=>etat0 
[149]27    USE etat0_heldsz_mod, ONLY : etat0_heldsz=>etat0 
[325]28    USE etat0_venus_mod,  ONLY : etat0_venus=>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(:)
[366]37    TYPE(t_field),POINTER :: f_geopot(:)
38    TYPE(t_field),POINTER :: f_w(:)
[17]39    TYPE(t_field),POINTER :: f_q(:)
[186]40   
[159]41    REAL(rstd),POINTER :: ps(:), mass(:,:)
[366]42    LOGICAL :: autoinit_mass, autoinit_geopot, collocated
[159]43    INTEGER :: ind,i,j,ij,l
44
45    ! most etat0 routines set ps and not mass
46    ! in that case and if caldyn_eta == eta_lag
47    ! the initial distribution of mass is taken to be the same
48    ! as what the mass coordinate would dictate
[366]49    ! however if etat0_XXX defines mass then the flag autoinit_mass must be set to .FALSE.
[159]50    ! otherwise mass will be overwritten
[366]51    autoinit_mass = (caldyn_eta == eta_lag)
[159]52
[17]53    etat0_type='jablonowsky06'
54    CALL getin("etat0",etat0_type)
55   
[345]56    !------------------- Generic interface ---------------------
[344]57    collocated=.TRUE.
[17]58    SELECT CASE (TRIM(etat0_type))
[199]59    CASE ('isothermal')
60       CALL getin_etat0_isothermal
[327]61    CASE ('temperature_profile')
62       CALL getin_etat0_temperature
[203]63    CASE ('jablonowsky06')
[344]64    CASE ('dcmip1')
65        CALL getin_etat0_dcmip1
66    CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')
67       CALL getin_etat0_dcmip2
[345]68    CASE ('dcmip3')
[346]69    CASE ('dcmip4')
70        CALL getin_etat0_dcmip4
[344]71    CASE ('dcmip5')
[203]72        CALL getin_etat0_dcmip5
[168]73    CASE ('williamson91.6')
[366]74       autoinit_mass=.FALSE.
[204]75       CALL getin_etat0_williamson
[344]76    CASE DEFAULT
77       collocated=.FALSE.
[366]78       autoinit_mass = .FALSE.
[344]79    END SELECT
80
[345]81    !------------------- Ad hoc interfaces --------------------
[344]82    SELECT CASE (TRIM(etat0_type))
[266]83    CASE ('start_file')
84       CALL etat0_start_file(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[54]85    CASE ('academic')
86       CALL etat0_academic(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[170]87    CASE ('held_suarez')
88       PRINT *,"Held & Suarez (1994) test case"
[149]89       CALL etat0_heldsz(f_ps,f_phis,f_theta_rhodz,f_u, f_q)
[325]90    CASE ('venus')
91       CALL etat0_venus(f_ps, f_phis, f_theta_rhodz, f_u, f_q)
92       PRINT *, "Venus (Lebonnois et al., 2012) test case"
[62]93   CASE DEFAULT
[344]94      IF(collocated) THEN
[366]95         CALL etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_geopot,f_W, f_q)
[344]96      ELSE
97         PRINT*, 'Bad selector for variable etat0 <',etat0_type, &
98              '> options are <jablonowsky06>, <academic>, <dcmip[1-4]> '
99         STOP
100      END IF
[54]101    END SELECT
[159]102
[186]103!       !$OMP BARRIER
[366]104    IF(autoinit_mass) THEN
[159]105       DO ind=1,ndomain
[186]106          IF (.NOT. assigned_domain(ind)) CYCLE
[159]107          CALL swap_dimensions(ind)
108          CALL swap_geometry(ind)
109          mass=f_mass(ind); ps=f_ps(ind)
[366]110          CALL compute_rhodz(.TRUE., ps, mass) ! initialize mass distribution using ps
[159]111       END DO
112    END IF
[366]113 
[54]114  END SUBROUTINE etat0
[199]115
[366]116  SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_geopot,f_W, f_q)
[295]117    USE theta2theta_rhodz_mod
[199]118    IMPLICIT NONE
119    TYPE(t_field),POINTER :: f_ps(:)
120    TYPE(t_field),POINTER :: f_mass(:)
121    TYPE(t_field),POINTER :: f_phis(:)
122    TYPE(t_field),POINTER :: f_theta_rhodz(:)
123    TYPE(t_field),POINTER :: f_u(:)
[366]124    TYPE(t_field),POINTER :: f_geopot(:)
125    TYPE(t_field),POINTER :: f_W(:)
[199]126    TYPE(t_field),POINTER :: f_q(:)
127 
[321]128    TYPE(t_field),POINTER,SAVE :: f_temp(:)
[199]129    REAL(rstd),POINTER :: ps(:)
130    REAL(rstd),POINTER :: mass(:,:)
131    REAL(rstd),POINTER :: phis(:)
132    REAL(rstd),POINTER :: theta_rhodz(:,:)
[295]133    REAL(rstd),POINTER :: temp(:,:)
[199]134    REAL(rstd),POINTER :: u(:,:)
[366]135    REAL(rstd),POINTER :: geopot(:,:)
136    REAL(rstd),POINTER :: W(:,:)
[199]137    REAL(rstd),POINTER :: q(:,:,:)
138    INTEGER :: ind
139
[321]140    CALL allocate_field(f_temp,field_t,type_real,llm,name='temp')
141
[199]142    DO ind=1,ndomain
143      IF (.NOT. assigned_domain(ind)) CYCLE
144      CALL swap_dimensions(ind)
145      CALL swap_geometry(ind)
146      ps=f_ps(ind)
147      mass=f_mass(ind)
148      phis=f_phis(ind)
149      theta_rhodz=f_theta_rhodz(ind)
[295]150      temp=f_temp(ind)
[199]151      u=f_u(ind)
[366]152      geopot=f_geopot(ind)
153      w=f_w(ind)
[199]154      q=f_q(ind)
[295]155
[366]156      IF( TRIM(etat0_type)=='williamson91.6' ) THEN
157       CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz, u, geopot, W, q)
[295]158      ELSE
[366]159       CALL compute_etat0_collocated(ps,mass, phis, temp, u, geopot, W, q)
[295]160      ENDIF
[199]161    ENDDO
[295]162   
163    IF( TRIM(etat0_type)/='williamson91.6' ) CALL temperature2theta_rhodz(f_ps,f_temp,f_theta_rhodz)
164   
[321]165    CALL deallocate_field(f_temp)
[295]166   
[199]167  END SUBROUTINE etat0_collocated
168
[366]169  SUBROUTINE compute_etat0_collocated(ps,mass,phis,temp_i,u, geopot,W, q)
[199]170    USE wind_mod
[366]171    USE disvert_mod
[203]172    USE etat0_jablonowsky06_mod, ONLY : compute_jablonowsky06 => compute_etat0
[344]173    USE etat0_dcmip1_mod, ONLY : compute_dcmip1 => compute_etat0
174    USE etat0_dcmip2_mod, ONLY : compute_dcmip2 => compute_etat0
[345]175    USE etat0_dcmip3_mod, ONLY : compute_dcmip3 => compute_etat0
[346]176    USE etat0_dcmip4_mod, ONLY : compute_dcmip4 => compute_etat0
[203]177    USE etat0_dcmip5_mod, ONLY : compute_dcmip5 => compute_etat0
[204]178    USE etat0_williamson_mod, ONLY : compute_w91_6 => compute_etat0
[327]179    USE etat0_temperature_mod, ONLY: compute_etat0_temperature => compute_etat0
[199]180    IMPLICIT NONE
181    REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
182    REAL(rstd),INTENT(INOUT) :: mass(iim*jjm,llm)
183    REAL(rstd),INTENT(OUT) :: phis(iim*jjm)
[295]184    REAL(rstd),INTENT(OUT) :: temp_i(iim*jjm,llm)
[199]185    REAL(rstd),INTENT(OUT) :: u(3*iim*jjm,llm)
[366]186    REAL(rstd),INTENT(OUT) :: W(iim*jjm,llm+1)
187    REAL(rstd),INTENT(OUT) :: geopot(iim*jjm,llm+1)
[199]188    REAL(rstd),INTENT(OUT) :: q(iim*jjm,llm,nqtot)
189
190    REAL(rstd) :: ulon_i(iim*jjm,llm)
191    REAL(rstd) :: ulat_i(iim*jjm,llm)
192
193    REAL(rstd) :: ps_e(3*iim*jjm)
194    REAL(rstd) :: mass_e(3*iim*jjm,llm)
195    REAL(rstd) :: phis_e(3*iim*jjm)
196    REAL(rstd) :: temp_e(3*iim*jjm,llm)
[366]197    REAL(rstd) :: geopot_e(3*iim*jjm,llm+1)
[199]198    REAL(rstd) :: ulon_e(3*iim*jjm,llm)
199    REAL(rstd) :: ulat_e(3*iim*jjm,llm)
200    REAL(rstd) :: q_e(3*iim*jjm,llm,nqtot)
201
202    INTEGER :: l,i,j,ij
[366]203    REAL :: p_ik, v_ik, mass_ik
204    LOGICAL :: autoinit_mass, autoinit_NH
[199]205
[366]206    ! For NH geopotential and vertical momentum must be initialized.
207    ! Unless autoinit_mass is set to .FALSE. , they will be initialized
208    ! to hydrostatic geopotential and zero
209    autoinit_mass = .TRUE.
210    autoinit_NH = .NOT. hydrostatic
211    w(:,:) = 0
212
[353]213    !$OMP BARRIER
214
[199]215    SELECT CASE (TRIM(etat0_type))
216    CASE ('isothermal')
[201]217       CALL compute_etat0_isothermal(iim*jjm, phis, ps, temp_i, ulon_i, ulat_i, q)
218       CALL compute_etat0_isothermal(3*iim*jjm, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
[327]219    CASE ('temperature_profile')
220       CALL compute_etat0_temperature(iim*jjm, phis, ps, temp_i, ulon_i, ulat_i, q)
221       CALL compute_etat0_temperature(3*iim*jjm, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
[201]222    CASE('jablonowsky06')
223       CALL compute_jablonowsky06(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i)
224       CALL compute_jablonowsky06(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)
[344]225    CASE('dcmip1')
226       CALL compute_dcmip1(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)
227       CALL compute_dcmip1(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
228    CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')
229       CALL compute_dcmip2(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i)
230       CALL compute_dcmip2(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)     
[345]231    CASE('dcmip3')
[366]232       CALL compute_dcmip3(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, geopot, q)
233       CALL compute_dcmip3(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, geopot_e, q_e)
234       autoinit_NH = .FALSE. ! compute_dcmip3 initializes geopot
[346]235    CASE('dcmip4')
236       CALL compute_dcmip4(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)
237       CALL compute_dcmip4(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
[203]238    CASE('dcmip5')
239       CALL compute_dcmip5(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)
240       CALL compute_dcmip5(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)
[204]241    CASE('williamson91.6')
[295]242       CALL compute_w91_6(iim*jjm,lon_i,lat_i, phis, mass(:,1), temp_i(:,1), ulon_i(:,1), ulat_i(:,1))
[204]243       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))
[366]244       autoinit_mass = .FALSE. ! do not overwrite mass
[199]245    END SELECT
246
[366]247    IF(autoinit_mass) CALL compute_rhodz(.TRUE., ps, mass) ! initialize mass distribution using ps
248    IF(autoinit_NH) THEN
249       geopot(:,1) = phis(:) ! surface geopotential
250       DO l = 1, llm
251          DO ij=1,iim*jjm
252             ! hybrid pressure coordinate
253             p_ik = ptop + mass_ak(l) + mass_bk(l)*ps(ij)
254             mass_ik = (mass_dak(l) + mass_dbk(l)*ps(ij))/g
255             ! v=R.T/p, R=kappa*cpp
256             v_ik = kappa*cpp*temp_i(ij,l)/p_ik
257             geopot(ij,l+1) = geopot(ij,l) + mass_ik*v_ik*g
258          END DO
259       END DO
260    END IF
261
[353]262    !$OMP BARRIER
263
[201]264    CALL compute_wind_perp_from_lonlat_compound(ulon_e, ulat_e, u)
[199]265
[201]266  END SUBROUTINE compute_etat0_collocated
267
[199]268!----------------------------- Resting isothermal state --------------------------------
269
270  SUBROUTINE getin_etat0_isothermal
[201]271    etat0_temp=300
272    CALL getin("etat0_isothermal_temp",etat0_temp)
[199]273  END SUBROUTINE getin_etat0_isothermal
274
275  SUBROUTINE compute_etat0_isothermal(ngrid, phis, ps, temp, ulon, ulat, q)
276    IMPLICIT NONE 
277    INTEGER, INTENT(IN)    :: ngrid
278    REAL(rstd),INTENT(OUT) :: phis(ngrid)
279    REAL(rstd),INTENT(OUT) :: ps(ngrid)
280    REAL(rstd),INTENT(OUT) :: temp(ngrid,llm)
281    REAL(rstd),INTENT(OUT) :: ulon(ngrid,llm)
282    REAL(rstd),INTENT(OUT) :: ulat(ngrid,llm)
283    REAL(rstd),INTENT(OUT) :: q(ngrid,llm,nqtot)
284    phis(:)=0
285    ps(:)=preff
286    temp(:,:)=etat0_temp
287    ulon(:,:)=0
288    ulat(:,:)=0
289    q(:,:,:)=0
290  END SUBROUTINE compute_etat0_isothermal
291
[12]292END MODULE etat0_mod
Note: See TracBrowser for help on using the repository browser.