Changeset 4435 for LMDZ6/branches


Ignore:
Timestamp:
Feb 13, 2023, 4:45:52 PM (15 months ago)
Author:
Laurent Fairhead
Message:

Routines adapted to GPU. Speed-up is some 200 w.r.t. 1 CPU as measured by SYSTEM_CLOCK calls
around the call to the routine, CPU takes .14 (seconds?), GPU around 6E-004 (s?) at a resolution of 144x142x95.
Comparison of the netcdf result files output with the replay method yields no difference between the
two runs

Location:
LMDZ6/branches/Portage_acc/libf/phylmd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_env.F90

    r4185 r4435  
    4040  !$acc kernels default(none) async
    4141   mask(:,:)=.true.
    42    !$acc end kernels
    43    
     42  !$acc end kernels
    4443!
    4544! calcul des caracteristiques de l environnement
     
    5756!---------------
    5857! Calcul de l'humidite a saturation et de la condensation
    59 
    6058   call thermcell_qsat(ngrid*nlay,mask,pplev,pt,po,pqsat)
    6159  !$acc kernels default(none) async
     
    9290!!! temporary for GPU port !!!$acc update self(zo, zl, zh, ztv, zthl,zpspsk, zu, zv, pqsat)
    9391!!! temporary for GPU port include "dump_param.h" ! replay automatic include
    94   !$acc end data
     92!!! !$acc update self(zo, zl, zh, ztv, zthl,zpspsk, zu, zv, pqsat)
     93   !$acc end data
    9594   RETURN
    9695   END
  • LMDZ6/branches/Portage_acc/libf/phylmd/thermcell_qsat.F90

    r3035 r4435  
    11subroutine thermcell_qsat(klon,active,pplev,ztemp,zqta,zqsat)
    2 implicit none
     2  USE thermcell_ini_mod, ONLY : RLvCp,RETV, RCPD, RLVTT, RTT
     3  implicit none
    34
    4 #include "YOMCST.h"
     5!!#include "YOMCST.h"
    56#include "YOETHF.h"
    67#include "FCTTRE.h"
     
    1213
    1314! Arguments
    14 INTEGER klon
    15 REAL zpspsk(klon),pplev(klon)
    16 REAL ztemp(klon),zqta(klon),zqsat(klon)
    17 LOGICAL active(klon)
     15INTEGER, INTENT(IN) :: klon
     16!REAL zpspsk(klon),pplev(klon)
     17!REAL ztemp(klon),zqta(klon),zqsat(klon)
     18REAL, INTENT(IN) :: pplev(klon)
     19REAL, INTENT(IN) :: ztemp(klon),zqta(klon)
     20REAL, INTENT(OUT) :: zqsat(klon)
     21LOGICAL, INTENT(IN) :: active(klon)
    1822
    1923! Variables locales
     
    2226REAL tdelta,qsatbef,zcor,qlbef,zdelta,zcvm5,dqsat,num,denom,dqsat_dT
    2327logical Zsat
    24 REAL RLvCp
     28!REAL RLvCp
    2529
    2630REAL, SAVE :: DDT0=.01
    2731!$OMP THREADPRIVATE(DDT0)
    2832
    29 LOGICAL afaire(klon),tout_converge
     33     !$acc data create (dt, tbef) &
     34     !$acc present(pplev, ztemp, zqta, active) &
     35     !$acc present(zqsat) &
     36     !$acc &
    3037
    3138!====================================================================
     
    3340!====================================================================
    3441
    35 RLvCp = RLVTT/RCPD
    36 tout_converge=.false.
    37 afaire(:)=.false.
     42!RLvCp = RLVTT/RCPD
     43!$acc kernels default(none)
    3844DT(:)=0.
    39 
     45!!LF !$acc end kernels
    4046
    4147!====================================================================
     
    4551!====================================================================
    4652
     53!!LF   !$acc kernels default(none)
    4754do ig=1,klon
    4855   if (active(ig)) then
     
    5865     endif
    5966enddo
     67!!LF   !$acc end kernels
    6068
    6169! Traitement du cas ou il y a condensation mais faible
    6270! On ne condense pas mais on dit que le qsat est le qta
     71!!LF    !$acc kernels default(none)
    6372do ig=1,klon
    6473   if (active(ig)) then
     
    6877   endif
    6978enddo
     79!!LF   !$acc end kernels
    7080
     81!!LF   !$acc kernels default(none)
     82!!   !$acc parallel loop private(tbef,dt,zqsat)
    7183do iter=1,10
    72     afaire(:)=abs(DT(:)).gt.DDT0
    7384    do ig=1,klon
    74                if (afaire(ig)) then
    75                  Tbef(ig)=Tbef(ig)+DT(ig)
    76                  zdelta=MAX(0.,SIGN(1.,RTT-Tbef(ig)))
    77                  qsatbef= R2ES * FOEEW(Tbef(ig),zdelta)/pplev(ig)
    78                  qsatbef=MIN(0.5,qsatbef)
    79                  zcor=1./(1.-retv*qsatbef)
    80                  qsatbef=qsatbef*zcor
    81                  qlbef=zqta(ig)-qsatbef
    82                  zdelta=MAX(0.,SIGN(1.,RTT-Tbef(ig)))
    83                  zcvm5=R5LES*(1.-zdelta) + R5IES*zdelta
    84                  zcor=1./(1.-retv*qsatbef)
    85                  dqsat_dT=FOEDE(Tbef(ig),zdelta,zcvm5,qsatbef,zcor)
    86                  num=-Tbef(ig)+ztemp(ig)+RLvCp*qlbef
    87                  denom=1.+RLvCp*dqsat_dT
    88                  zqsat(ig) = qsatbef
    89                  DT(ig)=num/denom
    90                endif
     85       if (abs(DT(ig)).gt.DDT0) then
     86          Tbef(ig)=Tbef(ig)+DT(ig)
     87          zdelta=MAX(0.,SIGN(1.,RTT-Tbef(ig)))
     88          qsatbef= R2ES * FOEEW(Tbef(ig),zdelta)/pplev(ig)
     89          qsatbef=MIN(0.5,qsatbef)
     90          zcor=1./(1.-retv*qsatbef)
     91          qsatbef=qsatbef*zcor
     92          qlbef=zqta(ig)-qsatbef
     93          zdelta=MAX(0.,SIGN(1.,RTT-Tbef(ig)))
     94          zcvm5=R5LES*(1.-zdelta) + R5IES*zdelta
     95          zcor=1./(1.-retv*qsatbef)
     96          dqsat_dT=FOEDE(Tbef(ig),zdelta,zcvm5,qsatbef,zcor)
     97          num=-Tbef(ig)+ztemp(ig)+RLvCp*qlbef
     98          denom=1.+RLvCp*dqsat_dT
     99          zqsat(ig) = qsatbef
     100          DT(ig)=num/denom
     101       endif
    91102    enddo
    92103enddo
     104   !$acc end kernels
     105
     106
     107   !$acc end data
    93108
    94109return
Note: See TracChangeset for help on using the changeset viewer.