Computes the advective tendency of an input field f given the advective velocity field u [m/s] and grid spacing dx [m], using a second order centered 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 3-dimensional input arrays. It is overloaded by the
advectCentered2ndOrder1d
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 advectCentered2ndOrder1dRank2(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 second order
!! centered 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 3-dimensional input arrays. It is overloaded by the
!! `advectCentered2ndOrder1d` 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,m,n
integer(kind=ik) :: idm,mdm,ndm
mdm = size(f,dim=1)
ndm = size(f,dim=2)
idm = size(f,dim=3)
allocate(dfdt(mdm,ndm,2:idm-1))
dfdt = 0
do concurrent(i = 2:idm-1,m = 1:mdm,n = 1:ndm)
dfdt(m,n,i) = - 0.5_rk*(u(m,n,i+1)*(f(m,n,i)+f(m,n,i+1))&
- u(m,n,i)*(f(m,n,i-1)+f(m,n,i))) &
/ dx(i)
enddo
endfunction advectCentered2ndOrder1dRank2