Changeset 853 for codes/icosagcm/devel


Ignore:
Timestamp:
05/05/19 16:17:23 (5 years ago)
Author:
jisesh
Message:

devel: separate module for compute_caldyn_solver and removed Rd duplication in it

Location:
codes/icosagcm/devel/src/dynamics
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/src/dynamics/caldyn_hevi.f90

    r850 r853  
    1010  USE compute_caldyn_slow_hydro_mod, ONLY : compute_caldyn_slow_hydro 
    1111  USE compute_caldyn_slow_NH_mod, ONLY : compute_caldyn_slow_NH 
     12  USE compute_caldyn_solver_mod, ONLY : compute_caldyn_solver 
    1213  IMPLICIT NONE 
    1314  PRIVATE 
  • codes/icosagcm/devel/src/dynamics/caldyn_kernels_hevi.F90

    r850 r853  
    1313  LOGICAL, SAVE :: debug_hevi_solver = .FALSE. 
    1414 
    15   PUBLIC :: compute_caldyn_solver, compute_caldyn_fast 
     15  PUBLIC :: compute_caldyn_fast,compute_NH_geopot 
    1616 
    1717CONTAINS 
     
    183183  END SUBROUTINE compute_NH_geopot 
    184184 
    185   SUBROUTINE compute_caldyn_solver(tau,phis, rhodz,theta,pk, geopot,W, m_il,pres, dPhi,dW,du) 
    186     REAL(rstd),INTENT(IN) :: tau ! "solve" Phi-tau*dPhi/dt = Phi_rhs 
    187     REAL(rstd),INTENT(IN)    :: phis(iim*jjm) 
    188     REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm) 
    189     REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm,nqdyn) 
    190     REAL(rstd),INTENT(OUT)   :: pk(iim*jjm,llm) 
    191     REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) 
    192     REAL(rstd),INTENT(INOUT) :: W(iim*jjm,llm+1) ! OUT if tau>0 
    193     REAL(rstd),INTENT(OUT)   :: m_il(iim*jjm,llm+1)        ! rhodz averaged to interfaces 
    194     REAL(rstd),INTENT(OUT)   :: pres(iim*jjm,llm)          ! pressure 
    195     REAL(rstd),INTENT(OUT)   :: dW(iim*jjm,llm+1) 
    196     REAL(rstd),INTENT(OUT)   :: dPhi(iim*jjm,llm+1) 
    197     REAL(rstd),INTENT(OUT)   :: du(3*iim*jjm,llm) 
    198  
    199     REAL(rstd) :: berni(iim*jjm,llm)         ! (W/m_il)^2 
    200     REAL(rstd) :: berni1(iim*jjm)         ! (W/m_il)^2 
    201     REAL(rstd) :: gamma, rho_ij, T_ij, X_ij, Y_ij, vreff, Rd, Cvd, Rd_preff 
    202     INTEGER    :: ij, l 
    203  
    204     CALL trace_start("compute_caldyn_solver") 
    205  
    206     Rd=cpp*kappa 
    207  
    208     IF(dysl) THEN 
    209  
    210 !$OMP BARRIER 
    211  
    212 #include "../kernels_hex/caldyn_mil.k90" 
    213   IF(tau>0) THEN ! solve implicit problem for geopotential 
    214     CALL compute_NH_geopot(tau,phis, rhodz, m_il, theta, W, geopot) 
    215   END IF 
    216 #define PHI_BOT(ij) phis(ij) 
    217 #include "../kernels_hex/caldyn_solver.k90" 
    218 #undef PHI_BOT 
    219 !$OMP BARRIER 
    220  
    221     ELSE 
    222  
    223 #define BERNI(ij) berni1(ij) 
    224     ! FIXME : vertical OpenMP parallelism will not work 
    225  
    226     ! average m_ik to interfaces => m_il 
    227     !DIR$ SIMD 
    228     DO ij=ij_begin_ext,ij_end_ext 
    229        m_il(ij,1) = .5*rhodz(ij,1) 
    230     ENDDO 
    231     DO l=2,llm 
    232        !DIR$ SIMD 
    233        DO ij=ij_begin_ext,ij_end_ext 
    234           m_il(ij,l) = .5*(rhodz(ij,l-1)+rhodz(ij,l)) 
    235        ENDDO 
    236     ENDDO 
    237     !DIR$ SIMD 
    238     DO ij=ij_begin_ext,ij_end_ext 
    239        m_il(ij,llm+1) = .5*rhodz(ij,llm) 
    240     ENDDO 
    241  
    242     IF(tau>0) THEN ! solve implicit problem for geopotential 
    243        CALL compute_NH_geopot(tau, phis, rhodz, m_il, theta, W, geopot) 
    244     END IF 
    245  
    246     ! Compute pressure, stored temporarily in pk 
    247     ! kappa = R/Cp 
    248     ! 1-kappa = Cv/Cp 
    249     ! Cp/Cv = 1/(1-kappa) 
    250     gamma = 1./(1.-kappa) 
    251     DO l=1,llm 
    252        !DIR$ SIMD 
    253        DO ij=ij_begin_ext,ij_end_ext 
    254           rho_ij = (g*rhodz(ij,l))/(geopot(ij,l+1)-geopot(ij,l)) 
    255           X_ij = (cpp/preff)*kappa*theta(ij,l,1)*rho_ij 
    256           ! kappa.theta.rho = p/exner  
    257           ! => X = (p/p0)/(exner/Cp) 
    258           !      = (p/p0)^(1-kappa) 
    259           pk(ij,l) = preff*(X_ij**gamma) 
    260        ENDDO 
    261     ENDDO 
    262  
    263     ! Update W, compute tendencies 
    264     DO l=2,llm 
    265        !DIR$ SIMD 
    266        DO ij=ij_begin_ext,ij_end_ext 
    267           dW(ij,l)   = (1./g)*(pk(ij,l-1)-pk(ij,l)) - m_il(ij,l) 
    268           W(ij,l)    = W(ij,l)+tau*dW(ij,l) ! update W 
    269           dPhi(ij,l) = g*g*W(ij,l)/m_il(ij,l) 
    270        ENDDO 
    271        !       PRINT *,'Max dPhi', l,ij_begin,ij_end, MAXVAL(abs(dPhi(ij_begin:ij_end,l))) 
    272        !       PRINT *,'Max dW', l,ij_begin,ij_end, MAXVAL(abs(dW(ij_begin:ij_end,l)))  
    273     ENDDO 
    274     ! Lower BC (FIXME : no orography yet !) 
    275     DO ij=ij_begin,ij_end          
    276        dPhi(ij,1)=0 
    277        W(ij,1)=0 
    278        dW(ij,1)=0 
    279        dPhi(ij,llm+1)=0 ! rigid lid 
    280        W(ij,llm+1)=0 
    281        dW(ij,llm+1)=0 
    282     ENDDO 
    283     ! Upper BC p=ptop 
    284     !    DO ij=ij_omp_begin_ext,ij_omp_end_ext 
    285     !       dPhi(ij,llm+1) = W(ij,llm+1)/rhodz(ij,llm) 
    286     !       dW(ij,llm+1) = (1./g)*(pk(ij,llm)-ptop) - .5*rhodz(ij,llm) 
    287     !    ENDDO 
    288      
    289     ! Compute Exner function (needed by compute_caldyn_fast) and du=-g^2.grad(w^2) 
    290     DO l=1,llm 
    291        !DIR$ SIMD 
    292        DO ij=ij_begin_ext,ij_end_ext 
    293           pk(ij,l) = cpp*((pk(ij,l)/preff)**kappa) ! other formulae possible if exponentiation is slow 
    294           BERNI(ij) = (-.25*g*g)*(              & 
    295                  (W(ij,l)/m_il(ij,l))**2       & 
    296                + (W(ij,l+1)/m_il(ij,l+1))**2 ) 
    297        ENDDO 
    298        DO ij=ij_begin,ij_end          
    299           du(ij+u_right,l) = ne_right*(BERNI(ij)-BERNI(ij+t_right)) 
    300           du(ij+u_lup,l)   = ne_lup  *(BERNI(ij)-BERNI(ij+t_lup)) 
    301           du(ij+u_ldown,l) = ne_ldown*(BERNI(ij)-BERNI(ij+t_ldown)) 
    302        ENDDO 
    303     ENDDO 
    304 #undef BERNI 
    305  
    306     END IF ! dysl 
    307  
    308     CALL trace_end("compute_caldyn_solver") 
    309      
    310   END SUBROUTINE compute_caldyn_solver 
    311    
    312185  SUBROUTINE compute_caldyn_fast(tau,u,rhodz,theta,pk,geopot,du) 
    313186    REAL(rstd),INTENT(IN)    :: tau                ! "solve" u-tau*du/dt = rhs 
Note: See TracChangeset for help on using the changeset viewer.