Ignore:
Timestamp:
06/09/17 16:13:47 (7 years ago)
Author:
dubos
Message:

devel : macro-generated kernels for caldyn_coriolis, compute_NH_geopot, caldyn_solver, caldyn_vert_NH

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

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/src/dynamics/caldyn_kernels_base.F90

    r537 r538  
    4949 
    5050#ifdef CPP_DYSL 
     51!#if 0 
    5152#include "../kernels/compute_geopot.k90" 
    5253#else 
     
    303304    REAL(rstd),INTENT(INOUT) :: dW(iim*jjm,llm+1) 
    304305    ! local arrays 
    305     REAL(rstd) :: eta_dot(iim*jjm) ! eta_dot in full layers 
    306     REAL(rstd) :: wcov(iim*jjm) ! covariant vertical momentum in full layers 
     306    REAL(rstd) :: eta_dot(iim*jjm, llm) ! eta_dot in full layers 
     307    REAL(rstd) :: wcov(iim*jjm,llm) ! covariant vertical momentum in full layers 
    307308    REAL(rstd) :: W_etadot(iim*jjm,llm) ! vertical flux of vertical momentum 
    308309    ! indices and temporary values 
     
    312313    CALL trace_start("compute_caldyn_vert_nh") 
    313314 
     315#ifdef CPP_DYSL 
     316!#if 0 
     317#include "../kernels/caldyn_vert_NH.k90" 
     318#else 
     319#define ETA_DOT(ij) eta_dot(ij,1) 
     320#define WCOV(ij) wcov(ij,1) 
     321 
    314322    DO l=ll_begin,ll_end 
    315323       ! compute the local arrays 
     
    319327          w_ij = .5*(W(ij,l)+W(ij,l+1))/mass(ij,l) 
    320328          W_etadot(ij,l) = wflux_ij*w_ij 
    321           eta_dot(ij) = wflux_ij / mass(ij,l) 
    322           wcov(ij) = w_ij*(geopot(ij,l+1)-geopot(ij,l)) 
     329          ETA_DOT(ij) = wflux_ij / mass(ij,l) 
     330          WCOV(ij) = w_ij*(geopot(ij,l+1)-geopot(ij,l)) 
    323331       ENDDO 
    324332       ! add NH term to du 
     
    326334      DO ij=ij_begin,ij_end 
    327335          du(ij+u_right,l) = du(ij+u_right,l) & 
    328                - .5*(wcov(ij+t_right)+wcov(ij)) & 
    329                *ne_right*(eta_dot(ij+t_right)-eta_dot(ij)) 
     336               - .5*(WCOV(ij+t_right)+WCOV(ij)) & 
     337               *ne_right*(ETA_DOT(ij+t_right)-ETA_DOT(ij)) 
    330338          du(ij+u_lup,l) = du(ij+u_lup,l) & 
    331                - .5*(wcov(ij+t_lup)+wcov(ij)) & 
    332                *ne_lup*(eta_dot(ij+t_lup)-eta_dot(ij)) 
     339               - .5*(WCOV(ij+t_lup)+WCOV(ij)) & 
     340               *ne_lup*(ETA_DOT(ij+t_lup)-ETA_DOT(ij)) 
    333341          du(ij+u_ldown,l) = du(ij+u_ldown,l) & 
    334                - .5*(wcov(ij+t_ldown)+wcov(ij)) & 
    335                *ne_ldown*(eta_dot(ij+t_ldown)-eta_dot(ij)) 
     342               - .5*(WCOV(ij+t_ldown)+WCOV(ij)) & 
     343               *ne_ldown*(ETA_DOT(ij+t_ldown)-ETA_DOT(ij)) 
    336344       END DO 
    337345    ENDDO 
     
    352360       END DO 
    353361    END DO 
     362 
     363#undef ETA_DOT 
     364#undef WCOV 
     365#endif 
     366 
    354367    CALL trace_end("compute_caldyn_vert_nh") 
    355368 
  • codes/icosagcm/devel/src/dynamics/caldyn_kernels_hevi.F90

    r537 r538  
    1111  REAL(rstd), PARAMETER :: pbot=1e5, Phi_bot=0., rho_bot=1e6 ! FIXME 
    1212 
    13   LOGICAL, PARAMETER :: debug_hevi_solver = .FALSE. 
     13  LOGICAL, SAVE :: debug_hevi_solver = .FALSE. 
     14  LOGICAL, PARAMETER :: rigid=.TRUE. 
    1415 
    1516  PUBLIC :: compute_theta, compute_pvort_only, compute_caldyn_Coriolis, & 
     
    117118    REAL(rstd) :: wil, tau2_g, g2, gm2, ml_g2, c2_mik 
    118119 
    119     INTEGER    :: iter, ij, l 
     120    INTEGER    :: iter, ij, l, ij_omp_begin_ext, ij_omp_end_ext 
     121 
     122    CALL distrib_level(ij_end_ext-ij_begin_ext+1,ij_omp_begin_ext,ij_omp_end_ext) 
     123    ij_omp_begin_ext=ij_omp_begin_ext+ij_begin_ext-1 
     124    ij_omp_end_ext=ij_omp_end_ext+ij_begin_ext-1 
     125 
     126#ifdef CPP_DYSL 
     127!#if 0 
     128#include "../kernels/compute_NH_geopot.k90" 
     129#else 
    120130 
    121131!    FIXME : vertical OpenMP parallelism will not work 
     
    251261 
    252262    END DO ! Newton-Raphson 
     263 
     264#endif 
    253265     
    254266  END SUBROUTINE compute_NH_geopot 
     
    257269    REAL(rstd),INTENT(IN) :: tau ! "solve" Phi-tau*dPhi/dt = Phi_rhs 
    258270    REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm) 
    259     REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm) 
     271    REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm,nqdyn) 
    260272    REAL(rstd),INTENT(OUT)   :: pk(iim*jjm,llm) 
    261273    REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) 
     
    266278 
    267279    REAL(rstd) :: m_il(iim*jjm,llm+1)        ! rhodz averaged to interfaces 
    268     REAL(rstd) :: berni(iim*jjm)             ! (W/m_il)^2 
    269     REAL(rstd) :: gamma, rho_ij, X_ij, Y_ij 
     280    REAL(rstd) :: pres(iim*jjm,llm)          ! pressure 
     281    REAL(rstd) :: berni(iim*jjm,llm)             ! (W/m_il)^2 
     282    REAL(rstd) :: gamma, rho_ij, T_ij, X_ij, Y_ij, vreff, Rd, Cvd 
    270283    INTEGER    :: ij, l 
    271284 
    272285    CALL trace_start("compute_caldyn_solver") 
    273286 
     287    Rd=cpp*kappa 
     288 
     289#ifdef CPP_DYSL 
     290!#if 0 
     291#include "../kernels/caldyn_solver.k90" 
     292#else 
     293#define BERNI(ij) berni(ij,1) 
    274294    ! FIXME : vertical OpenMP parallelism will not work 
    275295 
     
    303323       DO ij=ij_begin_ext,ij_end_ext 
    304324          rho_ij = (g*rhodz(ij,l))/(geopot(ij,l+1)-geopot(ij,l)) 
    305           X_ij = (cpp/preff)*kappa*theta(ij,l)*rho_ij 
     325          X_ij = (cpp/preff)*kappa*theta(ij,l,1)*rho_ij 
    306326          ! kappa.theta.rho = p/exner  
    307327          ! => X = (p/p0)/(exner/Cp) 
     
    342362       DO ij=ij_begin_ext,ij_end_ext 
    343363          pk(ij,l) = cpp*((pk(ij,l)/preff)**kappa) ! other formulae possible if exponentiation is slow 
    344           berni(ij) = (-.25*g*g)*(              & 
     364          BERNI(ij) = (-.25*g*g)*(              & 
    345365                 (W(ij,l)/m_il(ij,l))**2       & 
    346366               + (W(ij,l+1)/m_il(ij,l+1))**2 ) 
    347367       ENDDO 
    348368       DO ij=ij_begin,ij_end          
    349           du(ij+u_right,l) = ne_right*(berni(ij)-berni(ij+t_right)) 
    350           du(ij+u_lup,l)   = ne_lup  *(berni(ij)-berni(ij+t_lup)) 
    351           du(ij+u_ldown,l) = ne_ldown*(berni(ij)-berni(ij+t_ldown)) 
     369          du(ij+u_right,l) = ne_right*(BERNI(ij)-BERNI(ij+t_right)) 
     370          du(ij+u_lup,l)   = ne_lup  *(BERNI(ij)-BERNI(ij+t_lup)) 
     371          du(ij+u_ldown,l) = ne_ldown*(BERNI(ij)-BERNI(ij+t_ldown)) 
    352372       ENDDO 
    353373    ENDDO 
    354      
     374#undef BERNI 
     375#endif 
     376 
    355377    CALL trace_end("compute_caldyn_solver") 
    356378     
     
    488510    REAL(rstd),INTENT(INOUT) :: du(3*iim*jjm,llm) 
    489511     
    490     REAL(rstd) :: Ftheta(3*iim*jjm)  ! potential temperature flux 
    491     REAL(rstd) :: uu_right, uu_lup, uu_ldown 
     512    REAL(rstd) :: Ftheta(3*iim*jjm,llm)  ! potential temperature flux 
     513    REAL(rstd) :: uu_right, uu_lup, uu_ldown, du_trisk, divF 
    492514    INTEGER :: ij,iq,l,kdown 
    493515 
    494516    CALL trace_start("compute_caldyn_Coriolis") 
     517 
     518#ifdef CPP_DYSL 
     519!#if 0 
     520#include "../kernels/coriolis.k90" 
     521#else 
     522#define FTHETA(ij) Ftheta(ij,1) 
    495523 
    496524    DO l=ll_begin, ll_end 
     
    499527       !DIR$ SIMD 
    500528          DO ij=ij_begin_ext,ij_end_ext       
    501              Ftheta(ij+u_right) = 0.5*(theta(ij,l,iq)+theta(ij+t_right,l,iq)) & 
     529             FTHETA(ij+u_right) = 0.5*(theta(ij,l,iq)+theta(ij+t_right,l,iq)) & 
    502530                                  * hflux(ij+u_right,l) 
    503              Ftheta(ij+u_lup)   = 0.5*(theta(ij,l,iq)+theta(ij+t_lup,l,iq)) & 
     531             FTHETA(ij+u_lup)   = 0.5*(theta(ij,l,iq)+theta(ij+t_lup,l,iq)) & 
    504532                  * hflux(ij+u_lup,l) 
    505              Ftheta(ij+u_ldown) = 0.5*(theta(ij,l,iq)+theta(ij+t_ldown,l,iq)) & 
     533             FTHETA(ij+u_ldown) = 0.5*(theta(ij,l,iq)+theta(ij+t_ldown,l,iq)) & 
    506534                  * hflux(ij+u_ldown,l) 
    507535          END DO 
     
    511539             ! dtheta_rhodz =  -div(flux.theta) 
    512540             dtheta_rhodz(ij,l,iq)= & 
    513                   -1./Ai(ij)*(ne_right*Ftheta(ij+u_right)    +  & 
    514                   ne_rup*Ftheta(ij+u_rup)        +  &   
    515                   ne_lup*Ftheta(ij+u_lup)        +  &   
    516                   ne_left*Ftheta(ij+u_left)      +  &   
    517                   ne_ldown*Ftheta(ij+u_ldown)    +  & 
    518                   ne_rdown*Ftheta(ij+u_rdown) ) 
     541                  -1./Ai(ij)*(ne_right*FTHETA(ij+u_right)    +  & 
     542                  ne_rup*FTHETA(ij+u_rup)        +  &   
     543                  ne_lup*FTHETA(ij+u_lup)        +  &   
     544                  ne_left*FTHETA(ij+u_left)      +  &   
     545                  ne_ldown*FTHETA(ij+u_ldown)    +  & 
     546                  ne_rdown*FTHETA(ij+u_rdown) ) 
    519547          END DO 
    520548       END DO 
     
    626654       STOP 
    627655    END SELECT 
     656#undef FTHETA 
     657#endif 
    628658 
    629659    CALL trace_end("compute_caldyn_Coriolis") 
     
    645675 
    646676#ifdef CPP_DYSL 
     677!#if 0 
    647678#define BERNI(ij,l) berni(ij,l) 
    648679#include "../kernels/caldyn_slow_hydro.k90" 
     680#undef BERNI 
    649681#else 
    650682#define BERNI(ij) berni(ij,1) 
     
    696728       END IF 
    697729    END DO 
     730#undef BERNI 
    698731#endif 
    699 #undef BERNI 
    700732    CALL trace_end("compute_caldyn_slow_hydro")     
    701733  END SUBROUTINE compute_caldyn_slow_hydro 
Note: See TracChangeset for help on using the changeset viewer.