constructor_2d Function

private function constructor_2d(lb, ub, x, y, dx, dy, lon, lat) result(grid)

Arguments

Type IntentOptional AttributesName
integer(kind=intkind), intent(in), dimension(:):: lb

Lower bound indices of the grid array

integer(kind=intkind), intent(in), dimension(:):: ub

Upper bound indices of the grid array

real(kind=realkind), intent(in), optional dimension(:,:):: x

Distance in x-direction [m]

real(kind=realkind), intent(in), optional dimension(:,:):: y

Distance in y-direction [m]

real(kind=realkind), intent(in), optional dimension(:,:):: dx

Grid spacing in x-direction [m]

real(kind=realkind), intent(in), optional dimension(:,:):: dy

Grid spacing in y-direction [m]

real(kind=realkind), intent(in), optional dimension(:,:):: lon

Longitude [rad]

real(kind=realkind), intent(in), optional dimension(:,:):: lat

Latitude [rad]

Return Value type(grid_type)

Calls

proc~~constructor_2d~~CallsGraph proc~constructor_2d constructor_2d interface~diff diff proc~constructor_2d->interface~diff proc~diff_1d diff_1d interface~diff->proc~diff_1d proc~diff_2d diff_2d interface~diff->proc~diff_2d
Help

Called By

proc~~constructor_2d~~CalledByGraph proc~constructor_2d constructor_2d interface~grid_type grid_type interface~grid_type->proc~constructor_2d
Help

Source Code


Source Code

type(grid_type) function constructor_2d(lb,ub,x,y,dx,dy,lon,lat) result(grid)

  integer(kind=intkind),dimension(:),intent(in) :: lb
    !! Lower bound indices of the grid array
  integer(kind=intkind),dimension(:),intent(in) :: ub
    !! Upper bound indices of the grid array
  real(kind=realkind),dimension(:,:),intent(in),optional :: x
    !! Distance in x-direction [m]
  real(kind=realkind),dimension(:,:),intent(in),optional :: y
    !! Distance in y-direction [m]
  real(kind=realkind),dimension(:,:),intent(in),optional :: dx
    !! Grid spacing in x-direction [m]
  real(kind=realkind),dimension(:,:),intent(in),optional :: dy
    !! Grid spacing in y-direction [m]
  real(kind=realkind),dimension(:,:),intent(in),optional :: lon
    !! Longitude [rad]
  real(kind=realkind),dimension(:,:),intent(in),optional :: lat
    !! Latitude [rad]

  integer(kind=intkind) :: grid_rank
  integer(kind=intkind) :: idm,jdm
  integer(kind=intkind) :: i,j

  ! Raise error if lb and ub are not of matching ranks
  if(.not. size(lb) == size(ub))then
    write(unit=stderr,fmt='(a)')'Error in grid constructor: size(lb) must == '&
      //'size(ub)'
    stop 1
  endif

  grid % lb = lb
  grid % ub = ub

  allocate(grid % x(grid % lb(1):grid % ub(1),grid % lb(2):grid % ub(2)))
  allocate(grid % y(grid % lb(1):grid % ub(1),grid % lb(2):grid % ub(2)))
  allocate(grid % dx(grid % lb(1):grid % ub(1),grid % lb(2):grid % ub(2)))
  allocate(grid % dy(grid % lb(1):grid % ub(1),grid % lb(2):grid % ub(2)))

  if(present(x) .and. present(y))then

    ! x and y are given as input arguments
    grid % x = x
    grid % y = y

    ! Compute dx and dy using centered differences
    grid % dx = diff(x,dim=1)
    grid % dy = diff(y,dim=2)

  elseif(present(dx) .and. present(dy))then

    ! dx and dy are given as input arguments
    grid % dx = dx
    grid % dy = dy

    ! Compute x using dx provided as input argument
    grid % x(1,:) = 0
    do i = grid % lb(1)+1,grid % ub(1)
      grid % x(i,:) = grid % x(i-1,:) + grid % dx(i,:)
    enddo

    ! Compute y using dy provided as input argument
    grid % y(:,1) = 0
    do j = grid % lb(2)+1,grid % ub(2)
      grid % y(:,j) = grid % y(:,j-1) + grid % dy(:,j)
    enddo

  endif

endfunction constructor_2d


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