Ignore:
Timestamp:
10/30/15 15:41:06 (9 years ago)
Author:
dubos
Message:

Progress towards NH

File:
1 edited

Legend:

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

    r362 r366  
    66  PRIVATE 
    77 
    8   PUBLIC :: compute_theta, compute_pvort_only, compute_caldyn_fast, compute_caldyn_slow 
     8  PUBLIC :: compute_theta, compute_pvort_only, compute_caldyn_slow, & 
     9       compute_caldyn_solver, compute_caldyn_fast 
    910 
    1011CONTAINS 
     
    120121  END SUBROUTINE compute_pvort_only 
    121122 
    122   SUBROUTINE compute_caldyn_fast(tau,u,rhodz,theta,pk,geopot, du) 
     123  SUBROUTINE compute_caldyn_solver(tau,rhodz,theta,pk, geopot,W, dPhi,dW) 
     124    USE icosa 
     125    USE disvert_mod 
     126    USE exner_mod 
     127    USE trace 
     128    USE omp_para 
     129    USE disvert_mod 
     130    IMPLICIT NONE 
     131    REAL(rstd),INTENT(IN) :: tau ! "solve" Phi-tau*dPhi/dt = Phi_rhs 
     132    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm) 
     133    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm) 
     134    REAL(rstd),INTENT(OUT)   :: pk(iim*jjm,llm) 
     135    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) 
     136    REAL(rstd),INTENT(INOUT) :: W(iim*jjm,llm+1) ! OUT if tau>0 
     137    REAL(rstd),INTENT(OUT)   :: dW(iim*jjm,llm+1) 
     138    REAL(rstd),INTENT(OUT)   :: dPhi(iim*jjm,llm+1) 
     139 
     140    INTEGER :: ij,l 
     141    INTEGER    :: ij_omp_begin_ext, ij_omp_end_ext 
     142    REAL(rstd) :: gamma, rho_ij, X_ij, Y_ij, m_il 
     143 
     144    CALL trace_start("compute_caldyn_solver") 
     145 
     146    CALL distrib_level(ij_end_ext-ij_begin_ext+1,ij_omp_begin_ext,ij_omp_end_ext) 
     147    ij_omp_begin_ext=ij_omp_begin_ext+ij_begin_ext-1 
     148    ij_omp_end_ext=ij_omp_end_ext+ij_begin_ext-1 
     149 
     150    IF(tau>0) THEN 
     151       PRINT *, 'No implicit solver for NH yet' 
     152       STOP 
     153    END IF 
     154 
     155    ! Compute pressure, stored temporarily in pk 
     156    ! kappa = R/Cp 
     157    ! 1-kappa = Cv/Cp 
     158    ! Cp/Cv = 1/(1-kappa) 
     159    gamma = 1./(1.-kappa) 
     160    DO l=ll_begin,ll_end 
     161       !DIR$ SIMD 
     162       DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     163          rho_ij = (g*rhodz(ij,l))/(geopot(ij,l+1)-geopot(ij,l)) 
     164          X_ij = (cpp/preff)*kappa*theta(ij,l)*rho_ij 
     165          ! kappa.theta.rho = p/exner  
     166          ! => X = (p/p0)/(exner/Cp) 
     167          !      = (p/p0)^(1-kappa) 
     168          pk(ij,l) = preff*(X_ij**gamma) 
     169       ENDDO 
     170    ENDDO 
     171 
     172    ! Compute tendencies for geopotential and vertical momentum 
     173    DO l=ll_beginp1,ll_end 
     174       !DIR$ SIMD 
     175       DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     176          m_il = .5*(rhodz(ij,l)+rhodz(ij,l-1)) 
     177          dW(ij,l) = (1./g)*(pk(ij,l-1)-pk(ij,l)) - m_il 
     178          dPhi(ij,l) = g*g*W(ij,l)/m_il 
     179       ENDDO 
     180       !       PRINT *,'Max dPhi', l,ij_begin,ij_end, MAXVAL(abs(dPhi(ij_begin:ij_end,l))) 
     181       !       PRINT *,'Max dW', l,ij_begin,ij_end, MAXVAL(abs(dW(ij_begin:ij_end,l)))  
     182    ENDDO 
     183    ! Lower BC (FIXME : no orography yet !) 
     184    DO ij=ij_begin,ij_end          
     185       dPhi(ij,1)=0 
     186       W(ij,1)=0 
     187       dW(ij,1)=0 
     188       dPhi(ij,llm+1)=0 ! rigid lid 
     189       W(ij,llm+1)=0 
     190       dW(ij,llm+1)=0 
     191    ENDDO 
     192    ! Upper BC p=ptop 
     193!    DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     194!       dPhi(ij,llm+1) = W(ij,llm+1)/rhodz(ij,llm) 
     195!       dW(ij,llm+1) = (1./g)*(pk(ij,llm)-ptop) - .5*rhodz(ij,llm) 
     196!    ENDDO 
     197     
     198    ! Compute Exner function (needed by compute_caldyn_fast) 
     199    DO l=ll_begin,ll_end 
     200       !DIR$ SIMD 
     201       DO ij=ij_omp_begin_ext,ij_omp_end_ext 
     202          pk(ij,l) = cpp*((pk(ij,l)/preff)**kappa) ! other formulae possible if exponentiation is slow 
     203       ENDDO 
     204    ENDDO 
     205     
     206    CALL trace_end("compute_caldyn_solver") 
     207     
     208  END SUBROUTINE compute_caldyn_solver 
     209   
     210  SUBROUTINE compute_caldyn_fast(tau,u,rhodz,theta,pk,geopot,du) 
    123211    USE icosa 
    124212    USE disvert_mod 
     
    127215    USE omp_para 
    128216    IMPLICIT NONE 
    129     REAL(rstd), INTENT(IN) :: tau ! "solve" u-tau*du/dt = rhs 
    130     REAL(rstd),INTENT(INOUT)  :: u(iim*3*jjm,llm)    ! prognostic "velocity" 
    131     REAL(rstd),INTENT(IN)  :: rhodz(iim*jjm,llm) 
    132     REAL(rstd),INTENT(IN)  :: theta(iim*jjm,llm)  ! potential temperature 
    133     REAL(rstd),INTENT(INOUT) :: pk(iim*jjm,llm) ! Exner function 
    134     REAL(rstd),INTENT(IN)  :: geopot(iim*jjm,llm+1)    ! geopotential 
    135     REAL(rstd),INTENT(OUT) :: du(iim*3*jjm,llm) 
     217    REAL(rstd),INTENT(IN)    :: tau                ! "solve" u-tau*du/dt = rhs 
     218    REAL(rstd),INTENT(INOUT) :: u(iim*3*jjm,llm)   ! OUT if tau>0 
     219    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm) 
     220    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm) 
     221    REAL(rstd),INTENT(INOUT) :: pk(iim*jjm,llm) 
     222    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) 
     223    REAL(rstd),INTENT(OUT)   :: du(iim*3*jjm,llm) 
    136224    REAL(rstd) :: berni(iim*jjm,llm)  ! Bernoulli function 
    137225 
     
    140228 
    141229    CALL trace_start("compute_caldyn_fast") 
    142      
    143     ! Compute bernouilli term 
     230 
     231    ! Compute Bernoulli term 
    144232    IF(boussinesq) THEN 
     233 
    145234       DO l=ll_begin,ll_end 
    146235          !DIR$ SIMD 
Note: See TracChangeset for help on using the changeset viewer.