Changeset 847 for codes/icosagcm/devel
- Timestamp:
- 05/05/19 00:08:28 (5 years ago)
- Location:
- codes/icosagcm/devel/src/initial
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/devel/src/initial/etat0.f90
r732 r847 1 1 MODULE etat0_mod 2 2 USE icosa 3 USE omp_para 4 USE caldyn_vars_mod 3 USE etat0_collocated_mod 5 4 IMPLICIT NONE 6 5 PRIVATE 7 6 8 CHARACTER(len=255),SAVE :: etat0_type 9 !$OMP THREADPRIVATE(etat0_type) 10 11 REAL(rstd) :: etat0_temp 12 13 PUBLIC :: etat0, init_etat0, etat0_type 7 PUBLIC :: etat0, init_etat0 14 8 15 9 ! Important notes for OpenMP … … 67 61 68 62 SUBROUTINE etat0(f_ps,f_mass,f_phis,f_theta_rhodz,f_u, f_geopot,f_w, f_q) 63 USE omp_para, ONLY : is_omp_level_master 69 64 USE mpipara, ONLY : is_mpi_root 70 65 USE disvert_mod 71 66 ! Generic interface 67 USE etat0_isothermal_mod, ONLY : getin_etat0_isothermal=>getin_etat0 72 68 USE etat0_dcmip1_mod, ONLY : getin_etat0_dcmip1=>getin_etat0 73 69 USE etat0_dcmip2_mod, ONLY : getin_etat0_dcmip2=>getin_etat0 … … 183 179 END SUBROUTINE etat0 184 180 185 SUBROUTINE etat0_collocated(f_phis,f_ps,f_mass,f_theta_rhodz,f_u, f_geopot,f_W, f_q)186 USE theta2theta_rhodz_mod187 TYPE(t_field),POINTER :: f_ps(:)188 TYPE(t_field),POINTER :: f_mass(:)189 TYPE(t_field),POINTER :: f_phis(:)190 TYPE(t_field),POINTER :: f_theta_rhodz(:)191 TYPE(t_field),POINTER :: f_u(:)192 TYPE(t_field),POINTER :: f_geopot(:)193 TYPE(t_field),POINTER :: f_W(:)194 TYPE(t_field),POINTER :: f_q(:)195 196 TYPE(t_field),POINTER,SAVE :: f_temp(:)197 REAL(rstd),POINTER :: ps(:)198 REAL(rstd),POINTER :: mass(:,:)199 REAL(rstd),POINTER :: phis(:)200 REAL(rstd),POINTER :: theta_rhodz(:,:,:)201 REAL(rstd),POINTER :: temp(:,:)202 REAL(rstd),POINTER :: u(:,:)203 REAL(rstd),POINTER :: geopot(:,:)204 REAL(rstd),POINTER :: W(:,:)205 REAL(rstd),POINTER :: q(:,:,:)206 INTEGER :: ind207 208 CALL allocate_field(f_temp,field_t,type_real,llm,name='temp')209 210 DO ind=1,ndomain211 IF (.NOT. assigned_domain(ind) .OR. .NOT. is_omp_level_master) CYCLE212 ! IF (.NOT. assigned_domain(ind)) CYCLE213 CALL swap_dimensions(ind)214 CALL swap_geometry(ind)215 ps=f_ps(ind)216 mass=f_mass(ind)217 phis=f_phis(ind)218 theta_rhodz=f_theta_rhodz(ind)219 temp=f_temp(ind)220 u=f_u(ind)221 geopot=f_geopot(ind)222 w=f_w(ind)223 q=f_q(ind)224 225 IF( TRIM(etat0_type)=='williamson91.6' ) THEN226 CALL compute_etat0_collocated(ps,mass, phis, theta_rhodz(:,:,1), u, geopot, W, q)227 ELSE228 CALL compute_etat0_collocated(ps,mass, phis, temp, u, geopot, W, q)229 ENDIF230 231 IF( TRIM(etat0_type)/='williamson91.6' ) CALL compute_temperature2entropy(ps,temp,q,theta_rhodz, 1)232 233 ENDDO234 235 CALL deallocate_field(f_temp)236 237 END SUBROUTINE etat0_collocated238 239 SUBROUTINE compute_temperature2entropy(ps,temp,q,theta_rhodz,offset)240 USE icosa241 USE pression_mod242 USE exner_mod243 USE omp_para244 REAL(rstd),INTENT(IN) :: ps(iim*jjm)245 REAL(rstd),INTENT(IN) :: temp(iim*jjm,llm)246 REAL(rstd),INTENT(IN) :: q(iim*jjm,llm,nqtot)247 REAL(rstd),INTENT(OUT) :: theta_rhodz(iim*jjm,llm)248 INTEGER,INTENT(IN) :: offset249 250 REAL(rstd) :: p(iim*jjm,llm+1)251 REAL(rstd) :: cppd,Rd, mass, p_ij, q_ij,r_ij, chi,nu, entropy, theta252 INTEGER :: i,j,ij,l253 254 cppd=cpp255 Rd=kappa*cppd256 257 CALL compute_pression(ps,p,offset)258 ! flush p259 DO l = ll_begin, ll_end260 DO j=jj_begin-offset,jj_end+offset261 DO i=ii_begin-offset,ii_end+offset262 ij=(j-1)*iim+i263 mass = (p(ij,l)-p(ij,l+1))/g ! dry+moist mass264 p_ij = .5*(p(ij,l)+p(ij,l+1)) ! pressure at full level265 SELECT CASE(caldyn_thermo)266 CASE(thermo_theta)267 theta = temp(ij,l)*(p_ij/preff)**(-kappa)268 theta_rhodz(ij,l) = mass * theta269 CASE(thermo_entropy)270 nu = log(p_ij/preff)271 chi = log(temp(ij,l)/Treff)272 entropy = cppd*chi-Rd*nu273 theta_rhodz(ij,l) = mass * entropy274 ! CASE(thermo_moist)275 ! q_ij=q(ij,l,1)276 ! r_ij=1.-q_ij277 ! mass=mass*(1-q_ij) ! dry mass278 ! nu = log(p_ij/preff)279 ! chi = log(temp(ij,l)/Treff)280 ! entropy = r_ij*(cppd*chi-Rd*nu) + q_ij*(cppv*chi-Rv*nu)281 ! theta_rhodz(ij,l) = mass * entropy282 CASE DEFAULT283 STOP284 END SELECT285 ENDDO286 ENDDO287 ENDDO288 END SUBROUTINE compute_temperature2entropy289 290 SUBROUTINE compute_etat0_collocated(ps,mass,phis,temp_i,u, geopot,W, q)291 USE wind_mod292 USE disvert_mod293 USE etat0_jablonowsky06_mod, ONLY : compute_jablonowsky06 => compute_etat0294 USE etat0_dcmip1_mod, ONLY : compute_dcmip1 => compute_etat0295 USE etat0_dcmip2_mod, ONLY : compute_dcmip2 => compute_etat0296 USE etat0_dcmip3_mod, ONLY : compute_dcmip3 => compute_etat0297 USE etat0_dcmip4_mod, ONLY : compute_dcmip4 => compute_etat0298 USE etat0_dcmip5_mod, ONLY : compute_dcmip5 => compute_etat0299 USE etat0_bubble_mod, ONLY : compute_bubble => compute_etat0300 USE etat0_williamson_mod, ONLY : compute_w91_6 => compute_etat0301 USE etat0_temperature_mod, ONLY: compute_etat0_temperature => compute_etat0302 USE etat0_dcmip2016_baroclinic_wave_mod, ONLY : compute_dcmip2016_baroclinic_wave => compute_etat0303 USE etat0_dcmip2016_cyclone_mod, ONLY : compute_dcmip2016_cyclone => compute_etat0304 USE etat0_dcmip2016_supercell_mod, ONLY : compute_dcmip2016_supercell => compute_etat0305 REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)306 REAL(rstd),INTENT(INOUT) :: mass(iim*jjm,llm)307 REAL(rstd),INTENT(OUT) :: phis(iim*jjm)308 REAL(rstd),INTENT(OUT) :: temp_i(iim*jjm,llm)309 REAL(rstd),INTENT(OUT) :: u(3*iim*jjm,llm)310 REAL(rstd),INTENT(OUT) :: W(iim*jjm,llm+1)311 REAL(rstd),INTENT(OUT) :: geopot(iim*jjm,llm+1)312 REAL(rstd),INTENT(OUT) :: q(iim*jjm,llm,nqtot)313 314 REAL(rstd) :: ulon_i(iim*jjm,llm)315 REAL(rstd) :: ulat_i(iim*jjm,llm)316 317 REAL(rstd) :: ps_e(3*iim*jjm)318 REAL(rstd) :: mass_e(3*iim*jjm,llm)319 REAL(rstd) :: phis_e(3*iim*jjm)320 REAL(rstd) :: temp_e(3*iim*jjm,llm)321 REAL(rstd) :: geopot_e(3*iim*jjm,llm+1)322 REAL(rstd) :: ulon_e(3*iim*jjm,llm)323 REAL(rstd) :: ulat_e(3*iim*jjm,llm)324 REAL(rstd) :: q_e(3*iim*jjm,llm,nqtot)325 326 INTEGER :: l,i,j,ij327 REAL :: p_ik, v_ik, mass_ik328 LOGICAL :: autoinit_mass, autoinit_NH329 330 ! For NH geopotential and vertical momentum must be initialized.331 ! Unless autoinit_NH is set to .FALSE. , they will be initialized332 ! to hydrostatic geopotential and zero333 autoinit_mass = .TRUE.334 autoinit_NH = .NOT. hydrostatic335 w(:,:) = 0336 337 SELECT CASE (TRIM(etat0_type))338 CASE ('isothermal')339 CALL compute_etat0_isothermal(iim*jjm, phis, ps, temp_i, ulon_i, ulat_i, q)340 CALL compute_etat0_isothermal(3*iim*jjm, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)341 CASE ('temperature_profile')342 CALL compute_etat0_temperature(iim*jjm, phis, ps, temp_i, ulon_i, ulat_i, q)343 CALL compute_etat0_temperature(3*iim*jjm, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)344 CASE('jablonowsky06')345 CALL compute_jablonowsky06(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i)346 CALL compute_jablonowsky06(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)347 CASE('dcmip1')348 CALL compute_dcmip1(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)349 CALL compute_dcmip1(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)350 CASE ('dcmip2_mountain','dcmip2_schaer_noshear','dcmip2_schaer_shear')351 CALL compute_dcmip2(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i)352 CALL compute_dcmip2(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e)353 CASE('dcmip3')354 CALL compute_dcmip3(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, geopot, q)355 CALL compute_dcmip3(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, geopot_e, q_e)356 autoinit_NH = .FALSE. ! compute_dcmip3 initializes geopot357 CASE('dcmip4')358 CALL compute_dcmip4(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)359 CALL compute_dcmip4(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)360 CASE('dcmip5')361 CALL compute_dcmip5(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)362 CALL compute_dcmip5(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)363 CASE('bubble')364 CALL compute_bubble(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, geopot, q)365 CALL compute_bubble(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, geopot_e, q_e)366 ! autoinit_NH = .FALSE. ! compute_bubble initializes geopot367 CASE('williamson91.6')368 CALL compute_w91_6(iim*jjm,lon_i,lat_i, phis, mass(:,1), temp_i(:,1), ulon_i(:,1), ulat_i(:,1))369 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))370 autoinit_mass = .FALSE. ! do not overwrite mass371 CASE('dcmip2016_baroclinic_wave')372 CALL compute_dcmip2016_baroclinic_wave(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)373 CALL compute_dcmip2016_baroclinic_wave(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)374 CASE('dcmip2016_cyclone')375 CALL compute_dcmip2016_cyclone(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)376 CALL compute_dcmip2016_cyclone(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)377 CASE('dcmip2016_supercell')378 CALL compute_dcmip2016_supercell(iim*jjm,lon_i,lat_i, phis, ps, temp_i, ulon_i, ulat_i, q)379 CALL compute_dcmip2016_supercell(3*iim*jjm,lon_e,lat_e, phis_e, ps_e, temp_e, ulon_e, ulat_e, q_e)380 END SELECT381 382 IF(autoinit_mass) CALL compute_rhodz(.TRUE., ps, mass) ! initialize mass distribution using ps383 IF(autoinit_NH) THEN384 geopot(:,1) = phis(:) ! surface geopotential385 DO l = 1, llm386 DO ij=1,iim*jjm387 ! hybrid pressure coordinate388 p_ik = ptop + mass_ak(l) + mass_bk(l)*ps(ij)389 mass_ik = (mass_dak(l) + mass_dbk(l)*ps(ij))/g390 ! v=R.T/p, R=kappa*cpp391 v_ik = kappa*cpp*temp_i(ij,l)/p_ik392 geopot(ij,l+1) = geopot(ij,l) + mass_ik*v_ik*g393 END DO394 END DO395 END IF396 397 CALL compute_wind_perp_from_lonlat_compound(ulon_e, ulat_e, u)398 399 END SUBROUTINE compute_etat0_collocated400 401 !----------------------------- Resting isothermal state --------------------------------402 403 SUBROUTINE getin_etat0_isothermal404 etat0_temp=300405 CALL getin("etat0_isothermal_temp",etat0_temp)406 END SUBROUTINE getin_etat0_isothermal407 408 SUBROUTINE compute_etat0_isothermal(ngrid, phis, ps, temp, ulon, ulat, q)409 INTEGER, INTENT(IN) :: ngrid410 REAL(rstd),INTENT(OUT) :: phis(ngrid)411 REAL(rstd),INTENT(OUT) :: ps(ngrid)412 REAL(rstd),INTENT(OUT) :: temp(ngrid,llm)413 REAL(rstd),INTENT(OUT) :: ulon(ngrid,llm)414 REAL(rstd),INTENT(OUT) :: ulat(ngrid,llm)415 REAL(rstd),INTENT(OUT) :: q(ngrid,llm,nqtot)416 phis(:)=0417 ps(:)=preff418 temp(:,:)=etat0_temp419 ulon(:,:)=0420 ulat(:,:)=0421 q(:,:,:)=0422 END SUBROUTINE compute_etat0_isothermal423 424 181 END MODULE etat0_mod
Note: See TracChangeset
for help on using the changeset viewer.