127       dtlag, tlag, time_scheme, slag)
 
  130    integer, 
intent(in) :: lxd
 
  131    type(
coef_t), 
target :: coef
 
  132    real(kind=
rp), 
intent(in) :: ctarget
 
  134    real(kind=
rp), 
target, 
intent(in) :: dtlag(10)
 
  135    real(kind=
rp), 
target, 
intent(in) :: tlag(10)
 
  138    integer :: nel, n_GL, n, idx, idy, idz
 
  139    real(kind=
rp) :: max_cfl_rk4
 
  143    this%ntaubd = 
max(int(ctarget/max_cfl_rk4),1)
 
  145    call this%Xh_GL%init(
gl, lxd, lxd, lxd)
 
  146    this%Xh_GLL => coef%Xh
 
  147    this%coef_GLL => coef
 
  148    call this%GLL_to_GL%init(this%Xh_GL, this%Xh_GLL)
 
  150    call this%coef_GL%init(this%Xh_GL, coef%msh)
 
  152    call this%cr_GL%init(coef%msh, this%Xh_GL)
 
  153    call this%cs_GL%init(coef%msh, this%Xh_GL)
 
  154    call this%ct_GL%init(coef%msh, this%Xh_GL)
 
  157    n_gl = nel*this%Xh_GL%lxyz
 
  160    call this%GLL_to_GL%map(this%coef_GL%drdx, coef%drdx, nel, this%Xh_GL)
 
  161    call this%GLL_to_GL%map(this%coef_GL%dsdx, coef%dsdx, nel, this%Xh_GL)
 
  162    call this%GLL_to_GL%map(this%coef_GL%dtdx, coef%dtdx, nel, this%Xh_GL)
 
  163    call this%GLL_to_GL%map(this%coef_GL%drdy, coef%drdy, nel, this%Xh_GL)
 
  164    call this%GLL_to_GL%map(this%coef_GL%dsdy, coef%dsdy, nel, this%Xh_GL)
 
  165    call this%GLL_to_GL%map(this%coef_GL%dtdy, coef%dtdy, nel, this%Xh_GL)
 
  166    call this%GLL_to_GL%map(this%coef_GL%drdz, coef%drdz, nel, this%Xh_GL)
 
  167    call this%GLL_to_GL%map(this%coef_GL%dsdz, coef%dsdz, nel, this%Xh_GL)
 
  168    call this%GLL_to_GL%map(this%coef_GL%dtdz, coef%dtdz, nel, this%Xh_GL)
 
  171    allocate(this%cx(n_gl))
 
  172    allocate(this%cy(n_gl))
 
  173    allocate(this%cz(n_gl))
 
  178    allocate(this%cr_k23)
 
  179    allocate(this%cs_k23)
 
  180    allocate(this%ct_k23)
 
  186    call this%cr_k1%init(coef%msh, this%Xh_GL)
 
  187    call this%cs_k1%init(coef%msh, this%Xh_GL)
 
  188    call this%ct_k1%init(coef%msh, this%Xh_GL)
 
  190    call this%cr_k23%init(coef%msh, this%Xh_GL)
 
  191    call this%cs_k23%init(coef%msh, this%Xh_GL)
 
  192    call this%ct_k23%init(coef%msh, this%Xh_GL)
 
  194    call this%cr_k4%init(coef%msh, this%Xh_GL)
 
  195    call this%cs_k4%init(coef%msh, this%Xh_GL)
 
  196    call this%ct_k4%init(coef%msh, this%Xh_GL)
 
  198    call this%conv_k1%init(3)
 
  199    call this%conv_k23%init(3)
 
  200    call this%conv_k4%init(3)
 
  202    call this%conv_k1%assign(1, this%cr_k1)
 
  203    call this%conv_k1%assign(2, this%cs_k1)
 
  204    call this%conv_k1%assign(3, this%ct_k1)
 
  206    call this%conv_k23%assign(1, this%cr_k23)
 
  207    call this%conv_k23%assign(2, this%cs_k23)
 
  208    call this%conv_k23%assign(3, this%ct_k23)
 
  210    call this%conv_k4%assign(1, this%cr_k4)
 
  211    call this%conv_k4%assign(2, this%cs_k4)
 
  212    call this%conv_k4%assign(3, this%ct_k4)
 
  214    call this%dtime%init(1)
 
  230    call this%GLL_to_GL%map(this%cx, this%ulag%f%x, nel, this%Xh_GL)
 
  231    call this%GLL_to_GL%map(this%cy, this%vlag%f%x, nel, this%Xh_GL)
 
  232    call this%GLL_to_GL%map(this%cz, this%wlag%f%x, nel, this%Xh_GL)
 
  236         this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
 
  239    call this%convr_GL%init(this%cr_GL, 3)
 
  240    call this%convs_GL%init(this%cs_GL, 3)
 
  241    call this%convt_GL%init(this%ct_GL, 3)
 
  244    call this%GLL_to_GL%map(this%cx, this%ulag%lf(1)%x, nel, this%Xh_GL)
 
  245    call this%GLL_to_GL%map(this%cy, this%vlag%lf(1)%x, nel, this%Xh_GL)
 
  246    call this%GLL_to_GL%map(this%cz, this%wlag%lf(1)%x, nel, this%Xh_GL)
 
  249         this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
 
  251    this%convr_GL%lf(1) = this%cr_GL
 
  252    this%convs_GL%lf(1) = this%cs_GL
 
  253    this%convt_GL%lf(1) = this%ct_GL
 
  255    call this%GLL_to_GL%map(this%cx, this%ulag%lf(2)%x, nel, this%Xh_GL)
 
  256    call this%GLL_to_GL%map(this%cy, this%vlag%lf(2)%x, nel, this%Xh_GL)
 
  257    call this%GLL_to_GL%map(this%cz, this%wlag%lf(2)%x, nel, this%Xh_GL)
 
  260         this%cx, this%cy, this%cz, this%Xh_GL, this%coef_GL)
 
  262    this%convr_GL%lf(2) = this%cr_GL
 
  263    this%convs_GL%lf(2) = this%cs_GL
 
  264    this%convt_GL%lf(2) = this%ct_GL
 
  267    if (
present(slag)) 
then 
 
  383  subroutine adv_oifs_compute(this, vx, vy, vz, fx, fy, fz, Xh, coef, n, dt)
 
  386    type(
field_t), 
intent(inout) :: vx, vy, vz
 
  387    type(
field_t), 
intent(inout) :: fx, fy, fz
 
  388    type(
space_t), 
intent(in) :: Xh
 
  389    type(
coef_t), 
intent(in) :: coef
 
  390    integer, 
intent(in) :: n
 
  391    real(kind=
rp), 
intent(in), 
optional :: dt
 
  392    real(kind=
rp) :: tau, tau1, th, dtau
 
  393    integer :: i, ilag, itau, nel, n_GL
 
  396    n_gl = nel * this%Xh_GL%lxyz
 
  398    associate(ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
 
  399         ctlag => this%ctlag, dctlag => this%dctlag, dtime => this%dtime, &
 
  400         xh_gl => this%Xh_GL, coef_gl => this%coef_GL, ntaubd => this%ntaubd, &
 
  401         gll_to_gl => this%GLL_to_GL, oifs_scheme => this%oifs_scheme, &
 
  402         cr_k1 => this%cr_K1, cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, &
 
  403         cr_k23 => this%cr_K23, cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, &
 
  404         cr_k4 => this%cr_K4, cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
 
  405         convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
 
  406         convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
 
  407         conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
 
  409      call dtime%init(oifs_scheme%ndiff)
 
  411      tau = ctlag(oifs_scheme%ndiff)
 
  413      call this%set_conv_velocity_fst(vx, vy, vz)
 
  425      do ilag = oifs_scheme%ndiff, 1, -1
 
  427            if (ilag .eq. 1) 
then 
  429                    oifs_scheme%diffusion_coeffs(2), n)
 
  431                    oifs_scheme%diffusion_coeffs(2), n)
 
  433                    oifs_scheme%diffusion_coeffs(2), n)
 
  436                    oifs_scheme%diffusion_coeffs(ilag+1), n)
 
  438                    oifs_scheme%diffusion_coeffs(ilag+1), n)
 
  440                    oifs_scheme%diffusion_coeffs(ilag+1), n)
 
  443            if (ilag .eq. 1) 
then 
  445                  fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
 
  446                       oifs_scheme%diffusion_coeffs(2) &
 
  447                       * vx%x(i,1,1,1) * coef%B(i,1,1,1)
 
  448                  fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
 
  449                       oifs_scheme%diffusion_coeffs(2) &
 
  450                       * vy%x(i,1,1,1) * coef%B(i,1,1,1)
 
  451                  fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
 
  452                       oifs_scheme%diffusion_coeffs(2) &
 
  453                       * vz%x(i,1,1,1) * coef%B(i,1,1,1)
 
  457                  fx%x(i,1,1,1) = fx%x(i,1,1,1) + &
 
  458                       oifs_scheme%diffusion_coeffs(ilag+1) &
 
  459                       * ulag%lf(ilag-1)%x(i,1,1,1) &
 
  461                  fy%x(i,1,1,1) = fy%x(i,1,1,1) + &
 
  462                       oifs_scheme%diffusion_coeffs(ilag+1) &
 
  463                       * vlag%lf(ilag-1)%x(i,1,1,1) &
 
  465                  fz%x(i,1,1,1) = fz%x(i,1,1,1) + &
 
  466                       oifs_scheme%diffusion_coeffs(ilag+1) &
 
  467                       * wlag%lf(ilag-1)%x(i,1,1,1) &
 
  472         dtau = dctlag(ilag)/
real(ntaubd)
 
  476            call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
 
  477            call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
 
  478            call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
 
  479            call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
 
  480            call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
 
  481            call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
 
  482            call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
 
  483            call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
 
  484            call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
 
  485            call runge_kutta(fx, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
 
  486                 coef, coef_gl, gll_to_gl, tau, dtau, &
 
  488            call runge_kutta(fy, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
 
  489                 coef, coef_gl, gll_to_gl, tau, dtau, &
 
  491            call runge_kutta(fz, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
 
  492                 coef, coef_gl, gll_to_gl, tau, dtau, &
 
 
  516    type(field_t), 
intent(inout) :: vx, vy, vz
 
  517    type(field_t), 
intent(inout) :: fs
 
  518    type(field_t), 
intent(inout) :: s
 
  519    type(space_t), 
intent(in) :: Xh
 
  520    type(coef_t), 
intent(in) :: coef
 
  521    integer, 
intent(in) :: n
 
  522    real(kind=rp), 
intent(in), 
optional :: dt
 
  523    real(kind=rp) :: tau, tau1, th, dtau
 
  524    integer :: i, ilag, itau, nel, n_GL
 
  526    n_gl = nel * this%Xh_GL%lxyz
 
  528    associate(slag => this%slag, ctlag => this%ctlag, dctlag => this%dctlag, &
 
  529         dtime => this%dtime, xh_gl => this%Xh_GL, coef_gl => this%coef_GL, &
 
  530         ntaubd => this%ntaubd, gll_to_gl => this%GLL_to_GL, &
 
  531         oifs_scheme => this%oifs_scheme, cr_k1 => this%cr_K1, &
 
  532         cs_k1 => this%cs_K1, ct_k1 => this%ct_K1, cr_k23 => this%cr_K23, &
 
  533         cs_k23 => this%cs_K23, ct_k23 => this%ct_K23, cr_k4 => this%cr_K4, &
 
  534         cs_k4 => this%cs_K4, ct_k4 => this%ct_K4, &
 
  535         convr_gl => this%convr_GL, convs_gl => this%convs_GL, &
 
  536         convt_gl => this%convt_GL, conv_k1 => this%conv_k1, &
 
  537         conv_k23 => this%conv_k23, conv_k4 => this%conv_k4)
 
  539      call dtime%init(oifs_scheme%ndiff)
 
  541      tau = ctlag(oifs_scheme%ndiff)
 
  543      call this%set_conv_velocity_fst(vx, vy, vz)
 
  545      if (neko_bcknd_device .eq. 1) 
then 
  546         call device_rzero(fs%x_d,n)
 
  551      do ilag = oifs_scheme%ndiff, 1, -1
 
  552         if (neko_bcknd_device .eq. 1) 
then 
  553            if (ilag .eq. 1) 
then 
  554               call device_addcol3s2(fs%x_d, s%x_d, coef%B_d, &
 
  555                    oifs_scheme%diffusion_coeffs(2), n)
 
  557               call device_addcol3s2(fs%x_d, slag%lf(ilag-1)%x_d, coef%B_d, &
 
  558                    oifs_scheme%diffusion_coeffs(ilag+1), n)
 
  561            if (ilag .eq. 1) 
then 
  563                  fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
 
  564                       oifs_scheme%diffusion_coeffs(2) &
 
  565                       * s%x(i,1,1,1) * coef%B(i,1,1,1)
 
  569                  fs%x(i,1,1,1) = fs%x(i,1,1,1) + &
 
  570                       oifs_scheme%diffusion_coeffs(ilag+1) &
 
  571                       * slag%lf(ilag-1)%x(i,1,1,1) * coef%B(i,1,1,1)
 
  575         dtau = dctlag(ilag)/
real(ntaubd)
 
  579            call dtime%interpolate_scalar(tau, cr_k1, convr_gl, ctlag, n_gl)
 
  580            call dtime%interpolate_scalar(tau, cs_k1, convs_gl, ctlag, n_gl)
 
  581            call dtime%interpolate_scalar(tau, ct_k1, convt_gl, ctlag, n_gl)
 
  582            call dtime%interpolate_scalar(th, cr_k23, convr_gl, ctlag, n_gl)
 
  583            call dtime%interpolate_scalar(th, cs_k23, convs_gl, ctlag, n_gl)
 
  584            call dtime%interpolate_scalar(th, ct_k23, convt_gl, ctlag, n_gl)
 
  585            call dtime%interpolate_scalar(tau1, cr_k4, convr_gl, ctlag, n_gl)
 
  586            call dtime%interpolate_scalar(tau1, cs_k4, convs_gl, ctlag, n_gl)
 
  587            call dtime%interpolate_scalar(tau1, ct_k4, convt_gl, ctlag, n_gl)
 
  588            call runge_kutta(fs, conv_k1, conv_k23, conv_k4, xh, xh_gl, &
 
  589                 coef, coef_gl, gll_to_gl, tau, dtau, &