Ignore:
Timestamp:
02/16/13 17:03:57 (11 years ago)
Author:
dubos
Message:

Transport now working again - tested with dcmip4.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/trunk/src/timeloop_gcm.f90

    r135 r138  
    4646  INTEGER :: it,i,j,n, nb_stage, stage, matsuno_period, scheme 
    4747  CHARACTER(len=255) :: scheme_name 
    48   LOGICAL :: fluxt_zero ! set to .TRUE. to start accumulating fluxes in time 
     48  LOGICAL :: fluxt_zero(ndomain) ! set to .TRUE. to start accumulating fluxes in time 
    4949!  INTEGER :: itaumax 
    5050!  REAL(rstd) ::write_period 
     
    141141     CALL swap_geometry(ind) 
    142142     rhodz=f_rhodz(ind); ps=f_ps(ind) 
    143      CALL compute_rhodz(ps,rhodz) ! save rhodz for transport scheme before dynamics update ps 
     143     CALL compute_rhodz(.TRUE., ps,rhodz) ! save rhodz for transport scheme before dynamics update ps 
    144144  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   
    147157  DO it=0,itaumax 
    148158 
     
    182192 
    183193    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 
    184197       CALL advect_tracer(f_hfluxt,f_wfluxt,f_u, f_q,f_rhodz)  ! update q and rhodz after RK step 
    185198       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 
    186213    END IF 
    187214 
     
    195222    LOGICAL :: with_dps 
    196223    INTEGER :: ind 
    197        
    198224    DO ind=1,ndomain 
     225       CALL swap_dimensions(ind) 
     226       CALL swap_geometry(ind) 
    199227       IF(with_dps) THEN 
    200228          ps=f_ps(ind) ; dps=f_dps(ind) ;  
    201229          ps(:)=ps(:)+dt*dps(:) 
    202230          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)) 
    205233       END IF 
    206234       u=f_u(ind) ; theta_rhodz=f_theta_rhodz(ind) 
     
    221249       
    222250      DO ind=1,ndomain 
     251         CALL swap_dimensions(ind) 
     252         CALL swap_geometry(ind) 
    223253         ps=f_ps(ind)   ; u=f_u(ind)   ; theta_rhodz=f_theta_rhodz(ind) 
    224254         psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) 
     
    234264         IF(stage==nb_stage) THEN ! accumulate mass fluxes at last stage 
    235265            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)) 
    238268         END IF 
    239269      END DO 
     
    245275 
    246276      DO ind=1,ndomain 
     277        CALL swap_dimensions(ind) 
     278        CALL swap_geometry(ind) 
    247279        ps=f_ps(ind)   ; u=f_u(ind)   ; theta_rhodz=f_theta_rhodz(ind) 
    248280        psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) 
     
    277309    tau = dt/nb_stage 
    278310      DO ind=1,ndomain 
     311        CALL swap_dimensions(ind) 
     312        CALL swap_geometry(ind) 
     313 
    279314        ps=f_ps(ind)   ; u=f_u(ind)   ; theta_rhodz=f_theta_rhodz(ind) 
    280315        psm1=f_psm1(ind) ; um1=f_um1(ind) ; theta_rhodzm1=f_theta_rhodzm1(ind) 
     
    320355 
    321356      DO ind=1,ndomain 
     357        CALL swap_dimensions(ind) 
     358        CALL swap_geometry(ind) 
    322359        ps=f_ps(ind)   ; u=f_u(ind)   ; theta_rhodz=f_theta_rhodz(ind) 
    323360        dps=f_dps(ind) ; du=f_du(ind) ; dtheta_rhodz=f_dtheta_rhodz(ind) 
     
    343380  END SUBROUTINE timeloop     
    344381 
    345   SUBROUTINE compute_rhodz(ps, rhodz) 
     382  SUBROUTINE compute_rhodz(comp, ps, rhodz) 
    346383    USE icosa 
    347384    USE disvert_mod 
     385    LOGICAL, INTENT(IN) :: comp ! .TRUE. to compute, .FALSE. to check 
    348386    REAL(rstd), INTENT(IN) :: ps(iim*jjm) 
    349387    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 
    351398    DO l = 1, llm 
    352        DO j=jj_begin-1,jj_end+1 
    353           DO i=ii_begin-1,ii_end+1 
     399       DO j=jj_begin-dd,jj_end+dd 
     400          DO i=ii_begin-dd,ii_end+dd 
    354401             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 
    356408          ENDDO 
    357409       ENDDO 
    358410    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 
    359421  END SUBROUTINE compute_rhodz 
    360422 
    361   SUBROUTINE accumulate_fluxes(hflux,wflux,hfluxt,wfluxt,tau,fluxt_zero) 
     423  SUBROUTINE accumulate_fluxes(hflux,wflux, hfluxt,wfluxt, tau,fluxt_zero) 
    362424    USE icosa 
    363425    REAL(rstd), INTENT(IN)    :: hflux(3*iim*jjm,llm), wflux(iim*jjm,llm+1) 
     
    366428    LOGICAL, INTENT(INOUT) :: fluxt_zero 
    367429    IF(fluxt_zero) THEN 
     430!       PRINT *, 'Accumulating fluxes (first)' 
    368431       fluxt_zero=.FALSE. 
    369432       hfluxt = tau*hflux 
    370433       wfluxt = tau*wflux 
    371434    ELSE 
     435!       PRINT *, 'Accumulating fluxes (next)' 
    372436       hfluxt = hfluxt + tau*hflux 
    373437       wfluxt = wfluxt + tau*wflux 
Note: See TracChangeset for help on using the changeset viewer.