advectUpwind1stOrder2dRank2 Function

public pure function advectUpwind1stOrder2dRank2(f, u, v, dx, dy) result(dfdt)

Computes the 2-d advective tendency of an input field f given the advective velocity field u and v [m/s] and grid spacing dx and dy [m], using a first order, positive-definite upwind differencing. Fields f, u, and v are defined on a semi-staggered Arakawa C-grid:

 --+---v---+---v---+---v--
   |       |       |

j+1 u f u f u f | | | --+---v---+---v---+---v-- | | | j u f u f u f | | | --+---v---+---v---+---v-- | | | j-1 u f u f u f | i-1 | i | i+1

The differentiation range is [2:size(f,dim=1)-1,2:size(f,dim=2)-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 advectUpwind1stOrder2d procedure.

Arguments

Type IntentOptional AttributesName
real(kind=rk), intent(in), dimension(:,:,:,:):: f

Input field to be advected

real(kind=rk), intent(in), dimension(:,:,:,:):: u

Advective velocity in x-direction [m/s]

real(kind=rk), intent(in), dimension(:,:,:,:):: v

Advective velocity in y-direction [m/s]

real(kind=rk), intent(in), dimension(:,:):: dx

Grid spacing in x-direction [m]

real(kind=rk), intent(in), dimension(:,:):: dy

Grid spacing in x-direction [m]

Return Value real(kind=rk), dimension(:,:,:,:),allocatable

Advective tendency

Called By

proc~~advectupwind1storder2drank2~~CalledByGraph proc~advectupwind1storder2drank2 advectUpwind1stOrder2dRank2 interface~advectupwind1storder advectUpwind1stOrder interface~advectupwind1storder->proc~advectupwind1storder2drank2
Help


Source Code

pure function advectUpwind1stOrder2dRank2(f,u,v,dx,dy) result(dfdt)

  !! Computes the 2-d advective tendency of an input field f given the advective
  !! velocity field u and v [m/s] and grid spacing dx and dy [m], using a first
  !! order, positive-definite upwind differencing. Fields f, u, and v are
  !! defined on a semi-staggered Arakawa C-grid:
  !!
  !!     --+---v---+---v---+---v--
  !!       |       |       |
  !! j+1   u   f   u   f   u   f
  !!       |       |       |
  !!     --+---v---+---v---+---v--
  !!       |       |       |
  !!  j    u   f   u   f   u   f
  !!       |       |       |
  !!     --+---v---+---v---+---v--
  !!       |       |       |
  !! j-1   u   f   u   f   u   f
  !!       |  i-1  |   i   |  i+1
  !!
  !! The differentiation range is [2:size(f,dim=1)-1,2:size(f,dim=2)-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
  !! `advectUpwind1stOrder2d` procedure.

  real(kind=rk),dimension(:,:,:,:),intent(in) :: f
    !! Input field to be advected
  real(kind=rk),dimension(:,:,:,:),intent(in) :: u
    !! Advective velocity in x-direction [m/s]
  real(kind=rk),dimension(:,:,:,:),intent(in) :: v
    !! Advective velocity in y-direction [m/s]
  real(kind=rk),dimension(:,:),intent(in) :: dx
    !! Grid spacing in x-direction [m]
  real(kind=rk),dimension(:,:),intent(in) :: dy
    !! Grid spacing in x-direction [m]
  real(kind=rk),dimension(:,:,:,:),allocatable :: dfdt
    !! Advective tendency

  integer(kind=ik) :: i,j,m,n
  integer(kind=ik) :: idm,jdm,mdm,ndm

  mdm = size(f,dim=1)
  ndm = size(f,dim=2)
  idm = size(f,dim=3)
  jdm = size(f,dim=4)

  allocate(dfdt(mdm,ndm,2:idm-1,2:jdm-1))
  dfdt = 0

  do concurrent(i = 2:idm-1,j = 2:jdm-1,m = 1:mdm,n = 1:ndm)

    dfdt(m,n,i,j) = - 0.25_rk                                            &
      *((u(m,n,i+1,j)+abs(u(m,n,i+1,j)))*(dy(i,j)+dy(i+1,j))*f(m,n,i,j)  &
      + (u(m,n,i+1,j)-abs(u(m,n,i+1,j)))*(dy(i,j)+dy(i+1,j))*f(m,n,i+1,j)&
      - (u(m,n,i,j)+abs(u(m,n,i,j)))*(dy(i-1,j)+dy(i,j))*f(m,n,i-1,j)    &
      - (u(m,n,i,j)-abs(u(m,n,i,j)))*(dy(i-1,j)+dy(i,j))*f(m,n,i,j)      &
      + (v(m,n,i,j)+abs(v(m,n,i,j)))*(dx(i,j)+dx(i,j+1))*f(m,n,i,j)      &
      + (v(m,n,i,j)-abs(v(m,n,i,j)))*(dx(i,j)+dx(i,j+1))*f(m,n,i+1,j)    &
      - (v(m,n,i,j-1)+abs(v(m,n,i,j-1)))*(dx(i,j-1)+dx(i,j))*f(m,n,i-1,j)&
      - (v(m,n,i,j-1)-abs(v(m,n,i,j-1)))*(dx(i,j-1)+dx(i,j))*f(m,n,i,j)) &
      / (dx(i,j)*dy(i,j))

  enddo

endfunction advectUpwind1stOrder2dRank2


advect1dRank1 advect1dRank2 advect2dRank2 advectCentered2ndOrder advectCentered2ndOrder1dRank0 advectCentered2ndOrder1dRank1 advectCentered2ndOrder1dRank2 advectCentered2ndOrder2dRank0 advectCentered2ndOrder2dRank1 advectCentered2ndOrder2dRank2 advectUpwind1stOrder advectUpwind1stOrder1dRank0 advectUpwind1stOrder1dRank1 advectUpwind1stOrder1dRank2 advectUpwind1stOrder2dRank0 advectUpwind1stOrder2dRank1 advectUpwind1stOrder2dRank2 assign_array_1d assign_array_2d assign_spectrum_array_1d assign_spectrum_array_2d backward_euler backward_euler_domain backward_euler_spectrum constructor constructor constructor_1d constructor_2d diff diff_1d diff_2d diff_periodic diff_periodic_1d diff_periodic_2d domain_add_domain domain_add_real domain_div_domain domain_div_real domain_mult_domain domain_mult_real domain_sub_domain domain_sub_real domain_type domain_unary_minus donelanHamiltonHui donelanHamiltonHuiDirectionalSpectrum donelanHamiltonHuiDirectionalSpreading elevation eq eq exact_exponential exact_exponential_domain exact_exponential_spectrum forward_euler forward_euler_domain forward_euler_spectrum frequencyMoment frequencyMoment ge getAirDensity getAirDensity getAmplitude getAxisX getAxisY getCurrent_u getCurrent_u getCurrent_v getCurrent_v getDepth getDepth getDepthLevels getDirections getDirections getDirections2d getElevation getElevation getFrequency getFrequency getFrequency2d getGravity getGravity getGrid getGridRotation getGridSpacingX getGridSpacingXWithHalo getGridSpacingY getGridSpacingYWithHalo getGroupSpeed getGroupSpeed getGroupSpeed2d getLatitude getLongitude getLowerBounds getLowerBounds getPhaseSpeed getPhaseSpeed getPhaseSpeed2d getSpectrum getSpectrum getSpectrumArray getSurfaceTension getSurfaceTension getUpperBounds getUpperBounds getWaterDensity getWaterDensity getWaveAction getWavelength getWavenumber getWavenumber2d getWavenumberSpacing gravityClairaut grid_type gt horizontalAcceleration horizontalVelocity integrate integrate_domain integrate_spectrum isAllocated isAllocated isMonochromatic isOmnidirectional jonswap jonswapPeakFrequency le lt meanPeriod meanPeriod meanPeriodZeroCrossing meanPeriodZeroCrossing meanSquareSlope meanSquareSlopeDirectional momentum_x momentum_y momentumFlux_xx momentumFlux_xy momentumFlux_yy neq neq nondimensionalDepth nondimensionalEnergy nondimensionalFetch nondimensionalFrequency nondimensionalRoughness_H1986 nondimensionalRoughness_S1974 nondimensionalTime omnidirectionalSpectrum ones ones_int ones_real peakedness peakFrequency peakFrequencyDiscrete phillips piersonMoskowitz piersonMoskowitzPeakFrequency pressure range range_int range_real readJSON real2d_mult_spectrum real_add_domain real_add_spectrum real_div_domain real_div_spectrum real_mult_domain real_mult_spectrum real_sub_domain real_sub_spectrum saturationSpectrum sbf_DCCM2012 sbf_JONSWAP sds_DCCM2012 sdt_DCCM2012 setAirDensity setAirDensity setCurrent1d setCurrent2d setDepth setDepth setElevation setElevation setGravity setGravity setSpectrum1d setSpectrum1d setSpectrum2d setSpectrum2d setSpectrumArray1d1d setSpectrumArray1d2d setSpectrumArray2d2d setSurfaceTension setSurfaceTension setWaterDensity setWaterDensity significantSurfaceOrbitalVelocity significantWaveHeight significantWaveHeight sin_DCCM2012 snl_DCCM2012 spectrum_add_real spectrum_add_spectrum spectrum_div_real spectrum_div_spectrum spectrum_mult_real spectrum_mult_real2d spectrum_mult_spectrum spectrum_sub_real spectrum_sub_spectrum spectrum_type spectrum_unary_minus stokesDrift stokesDrift2d tile tile_1d_int tile_1d_real tile_2d_int tile_2d_real tile_3d_int tile_3d_real ursellNumber verticalAcceleration verticalVelocity waveAge wavenumber wavenumberMoment wavenumberMoment wavenumberSpectrum writeJSON writeJSON zeros zeros_int zeros_real