Computes the advective tendency of an input field f given the advective velocity field u [m/s] and grid spacing dx [m], using a first order, positive-definite upwind differencing. Fields f and u are defined on a semi-staggered Arakawa C-grid:
--u---f---u---f---u---f-- | i-1 | i | i+1
The differentiation range is [2,size(f)-1], so 1 halo cell on each end needs to be set priod to calling this function.
This function is for 1-dimensional input arrays. It is overloaded by the
advectUpwind1stOrder1d
procedure.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=rk), | intent(in), | dimension(:) | :: | f | Input field to be advected |
|
real(kind=rk), | intent(in), | dimension(:) | :: | u | Advective velocity [m/s] |
|
real(kind=rk), | intent(in), | dimension(:) | :: | dx | Grid spacing [m] |
Advective tendency
pure function advectUpwind1stOrder1dRank0(f,u,dx) result(dfdt)
!! Computes the advective tendency of an input field f given the advective
!! velocity field u [m/s] and grid spacing dx [m], using a first order,
!! positive-definite upwind differencing. Fields f and u are defined on a
!! semi-staggered Arakawa C-grid:
!!
!! --u---f---u---f---u---f--
!! | i-1 | i | i+1
!!
!! The differentiation range is [2,size(f)-1], so 1 halo cell on each end
!! needs to be set priod to calling this function.
!!
!! This function is for 1-dimensional input arrays. It is overloaded by the
!! `advectUpwind1stOrder1d` procedure.
real(kind=rk),dimension(:),intent(in) :: f
!! Input field to be advected
real(kind=rk),dimension(:),intent(in) :: u
!! Advective velocity [m/s]
real(kind=rk),dimension(:),intent(in) :: dx
!! Grid spacing [m]
real(kind=rk),dimension(:),allocatable :: dfdt
!! Advective tendency
integer(kind=ik) :: i
integer(kind=ik) :: idm
idm = size(f)
allocate(dfdt(2:idm-1))
dfdt = 0
do concurrent(i = 2:idm-1)
dfdt(i) = - 0.5_rk*((u(i+1)+abs(u(i+1)))*f(i) &
+ (u(i+1)-abs(u(i+1)))*f(i+1)&
- (u(i)+abs(u(i)))*f(i-1) &
- (u(i)-abs(u(i)))*f(i)) &
/ dx(i)
enddo
endfunction advectUpwind1stOrder1dRank0