Changeset 138 for codes/icosagcm/trunk/src/timeloop_gcm.f90
- Timestamp:
- 02/16/13 17:03:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
codes/icosagcm/trunk/src/timeloop_gcm.f90
r135 r138 46 46 INTEGER :: it,i,j,n, nb_stage, stage, matsuno_period, scheme 47 47 CHARACTER(len=255) :: scheme_name 48 LOGICAL :: fluxt_zero ! set to .TRUE. to start accumulating fluxes in time48 LOGICAL :: fluxt_zero(ndomain) ! set to .TRUE. to start accumulating fluxes in time 49 49 ! INTEGER :: itaumax 50 50 ! REAL(rstd) ::write_period … … 141 141 CALL swap_geometry(ind) 142 142 rhodz=f_rhodz(ind); ps=f_ps(ind) 143 CALL compute_rhodz( ps,rhodz) ! save rhodz for transport scheme before dynamics update ps143 CALL compute_rhodz(.TRUE., ps,rhodz) ! save rhodz for transport scheme before dynamics update ps 144 144 END DO 145 fluxt_zero=.FALSE. 146 145 fluxt_zero=.TRUE. 146 147 ! check that rhodz is consistent with ps 148 CALL transfert_request(f_rhodz,req_i1) 149 CALL transfert_request(f_ps,req_i1) 150 DO ind=1,ndomain 151 CALL swap_dimensions(ind) 152 CALL swap_geometry(ind) 153 rhodz=f_rhodz(ind); ps=f_ps(ind) 154 CALL compute_rhodz(.FALSE., ps, rhodz) 155 END DO 156 147 157 DO it=0,itaumax 148 158 … … 182 192 183 193 IF(MOD(it+1,itau_adv)==0) THEN 194 CALL transfert_request(f_wfluxt,req_i1) ! FIXME 195 ! CALL transfert_request(f_hfluxt,req_e1) ! FIXME 196 184 197 CALL advect_tracer(f_hfluxt,f_wfluxt,f_u, f_q,f_rhodz) ! update q and rhodz after RK step 185 198 fluxt_zero=.TRUE. 199 200 ! FIXME : check that rhodz is consistent with ps 201 CALL transfert_request(f_rhodz,req_i1) 202 CALL transfert_request(f_ps,req_i1) 203 CALL transfert_request(f_dps,req_i1) ! FIXME 204 CALL transfert_request(f_wflux,req_i1) ! FIXME 205 DO ind=1,ndomain 206 CALL swap_dimensions(ind) 207 CALL swap_geometry(ind) 208 rhodz=f_rhodz(ind); ps=f_ps(ind); dps=f_dps(ind); 209 wflux=f_wflux(ind); wfluxt=f_wfluxt(ind) 210 CALL compute_rhodz(.FALSE., ps, rhodz) 211 END DO 212 186 213 END IF 187 214 … … 195 222 LOGICAL :: with_dps 196 223 INTEGER :: ind 197 198 224 DO ind=1,ndomain 225 CALL swap_dimensions(ind) 226 CALL swap_geometry(ind) 199 227 IF(with_dps) THEN 200 228 ps=f_ps(ind) ; dps=f_dps(ind) ; 201 229 ps(:)=ps(:)+dt*dps(:) 202 230 hflux=f_hflux(ind); hfluxt=f_hfluxt(ind) 203 wflux=f_ hflux(ind); wfluxt=f_wfluxt(ind)204 CALL accumulate_fluxes(hflux,wflux,hfluxt,wfluxt,dt,fluxt_zero )231 wflux=f_wflux(ind); wfluxt=f_wfluxt(ind) 232 CALL accumulate_fluxes(hflux,wflux,hfluxt,wfluxt,dt,fluxt_zero(ind)) 205 233 END IF 206 234 u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) … … 221 249 222 250 DO ind=1,ndomain 251 CALL swap_dimensions(ind) 252 CALL swap_geometry(ind) 223 253 ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) 224 254 psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) … … 234 264 IF(stage==nb_stage) THEN ! accumulate mass fluxes at last stage 235 265 hflux=f_hflux(ind); hfluxt=f_hfluxt(ind) 236 wflux=f_ hflux(ind); wfluxt=f_wfluxt(ind)237 CALL accumulate_fluxes(hflux,wflux, hfluxt,wfluxt,dt,fluxt_zero)266 wflux=f_wflux(ind); wfluxt=f_wfluxt(ind) 267 CALL accumulate_fluxes(hflux,wflux, hfluxt,wfluxt, dt,fluxt_zero(ind)) 238 268 END IF 239 269 END DO … … 245 275 246 276 DO ind=1,ndomain 277 CALL swap_dimensions(ind) 278 CALL swap_geometry(ind) 247 279 ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) 248 280 psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) … … 277 309 tau = dt/nb_stage 278 310 DO ind=1,ndomain 311 CALL swap_dimensions(ind) 312 CALL swap_geometry(ind) 313 279 314 ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) 280 315 psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) … … 320 355 321 356 DO ind=1,ndomain 357 CALL swap_dimensions(ind) 358 CALL swap_geometry(ind) 322 359 ps=f_ps(ind) ; u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) 323 360 dps=f_dps(ind) ; du=f_du(ind) ; dtheta_rhodz=f_dtheta_rhodz(ind) … … 343 380 END SUBROUTINE timeloop 344 381 345 SUBROUTINE compute_rhodz( ps, rhodz)382 SUBROUTINE compute_rhodz(comp, ps, rhodz) 346 383 USE icosa 347 384 USE disvert_mod 385 LOGICAL, INTENT(IN) :: comp ! .TRUE. to compute, .FALSE. to check 348 386 REAL(rstd), INTENT(IN) :: ps(iim*jjm) 349 387 REAL(rstd), INTENT(OUT) :: rhodz(iim*jjm,llm) 350 INTEGER :: l,i,j,ij 388 REAL(rstd) :: m, err 389 INTEGER :: l,i,j,ij,dd 390 err=0. 391 IF(comp) THEN 392 dd=1 393 ELSE 394 ! dd=-1 395 dd=0 396 END IF 397 351 398 DO l = 1, llm 352 DO j=jj_begin- 1,jj_end+1353 DO i=ii_begin- 1,ii_end+1399 DO j=jj_begin-dd,jj_end+dd 400 DO i=ii_begin-dd,ii_end+dd 354 401 ij=(j-1)*iim+i 355 rhodz(ij,l) = (ap(l) - ap(l+1) + (bp(l)-bp(l+1))*ps(ij))/g 402 m = ( ap(l) - ap(l+1) + (bp(l)-bp(l+1))*ps(ij) )/g 403 IF(comp) THEN 404 rhodz(ij,l) = m 405 ELSE 406 err = MAX(err,abs(m-rhodz(ij,l))) 407 END IF 356 408 ENDDO 357 409 ENDDO 358 410 ENDDO 411 412 IF(.NOT. comp) THEN 413 IF(err>1e-10) THEN 414 PRINT *, 'Discrepancy between ps and rhodz detected', err 415 STOP 416 ELSE 417 ! PRINT *, 'No discrepancy between ps and rhodz detected' 418 END IF 419 END IF 420 359 421 END SUBROUTINE compute_rhodz 360 422 361 SUBROUTINE accumulate_fluxes(hflux,wflux, hfluxt,wfluxt,tau,fluxt_zero)423 SUBROUTINE accumulate_fluxes(hflux,wflux, hfluxt,wfluxt, tau,fluxt_zero) 362 424 USE icosa 363 425 REAL(rstd), INTENT(IN) :: hflux(3*iim*jjm,llm), wflux(iim*jjm,llm+1) … … 366 428 LOGICAL, INTENT(INOUT) :: fluxt_zero 367 429 IF(fluxt_zero) THEN 430 ! PRINT *, 'Accumulating fluxes (first)' 368 431 fluxt_zero=.FALSE. 369 432 hfluxt = tau*hflux 370 433 wfluxt = tau*wflux 371 434 ELSE 435 ! PRINT *, 'Accumulating fluxes (next)' 372 436 hfluxt = hfluxt + tau*hflux 373 437 wfluxt = wfluxt + tau*wflux
Note: See TracChangeset
for help on using the changeset viewer.