Ignore:
Timestamp:
06/08/16 22:24:19 (8 years ago)
Author:
dubos
Message:

Moist dynamics (to be tested)

File:
1 edited

Legend:

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

    r404 r405  
    382382    REAL(rstd),INTENT(INOUT) :: u(iim*3*jjm,llm)   ! OUT if tau>0 
    383383    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm) 
    384     REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm) 
     384    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm,nqdyn) 
    385385    REAL(rstd),INTENT(INOUT) :: pk(iim*jjm,llm) 
    386386    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) 
    387387    REAL(rstd),INTENT(INOUT)   :: du(iim*3*jjm,llm) 
    388388    REAL(rstd) :: berni(iim*jjm,llm)  ! Bernoulli function 
     389    REAL(rstd) :: berniv(iim*jjm,llm)  ! moist Bernoulli function 
    389390 
    390391    INTEGER :: i,j,ij,l 
    391     REAL(rstd) :: due_right, due_lup, due_ldown 
     392    REAL(rstd) :: Rd, qv, temp, chi, nu, due_right, due_lup, due_ldown 
    392393 
    393394    CALL trace_start("compute_caldyn_fast") 
     395 
     396    Rd=cpp*kappa 
    394397 
    395398    ! Compute Bernoulli term 
    396399    IF(boussinesq) THEN 
    397  
    398400       DO l=ll_begin,ll_end 
    399401          !DIR$ SIMD 
     
    417419             DO ij=ij_begin,ij_end          
    418420                berni(ij,l) = .5*(geopot(ij,l)+geopot(ij,l+1)) & 
    419                      + pk(ij,l)*(cpp-theta(ij,l)) ! pk=temperature, theta=entropy 
     421                     + pk(ij,l)*(cpp-theta(ij,l,1)) ! pk=temperature, theta=entropy 
    420422             END DO 
     423          CASE(thermo_moist)  
     424             !DIR$ SIMD 
     425             DO ij=ij_begin,ij_end          
     426                ! du/dt = grad(Bd)+rv.grad(Bv)+s.grad(T) 
     427                ! Bd = Phi + gibbs_d 
     428                ! Bv = Phi + gibbs_v 
     429                ! pk=temperature, theta=entropy 
     430                qv = theta(ij,l,2) 
     431                temp = pk(ij,l) 
     432                chi = log(temp/Treff) 
     433                nu = (chi*(cpp+qv*cppv)-theta(ij,l,1))/(Rd+qv*Rv) ! log(p/preff) 
     434                berni(ij,l) = .5*(geopot(ij,l)+geopot(ij,l+1)) & 
     435                     + temp*(cpp*(1.-chi)+Rd*nu) 
     436                berniv(ij,l) = .5*(geopot(ij,l)+geopot(ij,l+1)) & 
     437                     + temp*(cppv*(1.-chi)+Rv*nu) 
     438            END DO 
    421439          END SELECT 
    422440       END DO 
     
    426444!!! u:=u+tau*du, du = -grad(B)-theta.grad(pi) 
    427445    DO l=ll_begin,ll_end 
    428        !DIR$ SIMD 
    429        DO ij=ij_begin,ij_end          
    430           due_right =  0.5*(theta(ij,l)+theta(ij+t_right,l))  & 
    431                           *(pk(ij+t_right,l)-pk(ij,l))        & 
    432                          +  berni(ij+t_right,l)-berni(ij,l) 
    433           due_lup = 0.5*(theta(ij,l)+theta(ij+t_lup,l))    & 
    434                        *(pk(ij+t_lup,l)-pk(ij,l))          & 
    435                          +  berni(ij+t_lup,l)-berni(ij,l) 
    436           due_ldown = 0.5*(theta(ij,l)+theta(ij+t_ldown,l)) & 
    437                          *(pk(ij+t_ldown,l)-pk(ij,l))      & 
    438                         +   berni(ij+t_ldown,l)-berni(ij,l) 
    439           du(ij+u_right,l) = du(ij+u_right,l) - ne_right*due_right 
    440           du(ij+u_lup,l)   = du(ij+u_lup,l)   - ne_lup*due_lup 
    441           du(ij+u_ldown,l) = du(ij+u_ldown,l) - ne_ldown*due_ldown 
    442           u(ij+u_right,l) = u(ij+u_right,l) + tau*du(ij+u_right,l) 
    443           u(ij+u_lup,l)   = u(ij+u_lup,l)   + tau*du(ij+u_lup,l) 
    444           u(ij+u_ldown,l) = u(ij+u_ldown,l) + tau*du(ij+u_ldown,l) 
    445        ENDDO 
    446     ENDDO 
    447  
     446       IF(caldyn_thermo == thermo_moist) THEN 
     447          !DIR$ SIMD 
     448          DO ij=ij_begin,ij_end          
     449             due_right =  berni(ij+t_right,l)-berni(ij,l)       & 
     450                  + 0.5*(theta(ij,l,1)+theta(ij+t_right,l,1))   & 
     451                       *(pk(ij+t_right,l)-pk(ij,l))             & 
     452                  + 0.5*(theta(ij,l,2)+theta(ij+t_right,l,2))   & 
     453                       *(berniv(ij+t_right,l)-berniv(ij,l)) 
     454              
     455             due_lup = berni(ij+t_lup,l)-berni(ij,l)            & 
     456                  + 0.5*(theta(ij,l,1)+theta(ij+t_lup,l,1))     & 
     457                       *(pk(ij+t_lup,l)-pk(ij,l))               & 
     458                  + 0.5*(theta(ij,l,2)+theta(ij+t_lup,l,2))     & 
     459                       *(berniv(ij+t_lup,l)-berniv(ij,l)) 
     460              
     461             due_ldown = berni(ij+t_ldown,l)-berni(ij,l)        & 
     462                  + 0.5*(theta(ij,l,1)+theta(ij+t_ldown,l,1))   & 
     463                       *(pk(ij+t_ldown,l)-pk(ij,l))             & 
     464                  + 0.5*(theta(ij,l,2)+theta(ij+t_ldown,l,2))   & 
     465                       *(berniv(ij+t_ldown,l)-berniv(ij,l)) 
     466              
     467             du(ij+u_right,l) = du(ij+u_right,l) - ne_right*due_right 
     468             du(ij+u_lup,l)   = du(ij+u_lup,l)   - ne_lup*due_lup 
     469             du(ij+u_ldown,l) = du(ij+u_ldown,l) - ne_ldown*due_ldown 
     470             u(ij+u_right,l) = u(ij+u_right,l) + tau*du(ij+u_right,l) 
     471             u(ij+u_lup,l)   = u(ij+u_lup,l)   + tau*du(ij+u_lup,l) 
     472             u(ij+u_ldown,l) = u(ij+u_ldown,l) + tau*du(ij+u_ldown,l) 
     473          END DO 
     474       ELSE 
     475          !DIR$ SIMD 
     476          DO ij=ij_begin,ij_end          
     477             due_right =  0.5*(theta(ij,l,1)+theta(ij+t_right,l,1))  & 
     478                  *(pk(ij+t_right,l)-pk(ij,l))        & 
     479                  +  berni(ij+t_right,l)-berni(ij,l) 
     480             due_lup = 0.5*(theta(ij,l,1)+theta(ij+t_lup,l,1))    & 
     481                  *(pk(ij+t_lup,l)-pk(ij,l))          & 
     482                  +  berni(ij+t_lup,l)-berni(ij,l) 
     483             due_ldown = 0.5*(theta(ij,l,1)+theta(ij+t_ldown,l,1)) & 
     484                  *(pk(ij+t_ldown,l)-pk(ij,l))      & 
     485                  +   berni(ij+t_ldown,l)-berni(ij,l) 
     486             du(ij+u_right,l) = du(ij+u_right,l) - ne_right*due_right 
     487             du(ij+u_lup,l)   = du(ij+u_lup,l)   - ne_lup*due_lup 
     488             du(ij+u_ldown,l) = du(ij+u_ldown,l) - ne_ldown*due_ldown 
     489             u(ij+u_right,l) = u(ij+u_right,l) + tau*du(ij+u_right,l) 
     490             u(ij+u_lup,l)   = u(ij+u_lup,l)   + tau*du(ij+u_lup,l) 
     491             u(ij+u_ldown,l) = u(ij+u_ldown,l) + tau*du(ij+u_ldown,l) 
     492          END DO 
     493       END IF 
     494    END DO 
     495        
    448496    CALL trace_end("compute_caldyn_fast") 
    449497 
Note: See TracChangeset for help on using the changeset viewer.