MeshGrid
Meshgrid generates mesh-grid over a rectangular domain of [xmin, xmax, ymin, ymax]
Calling example
call meshgrid(X, Y, [0.,1.,2.,3.],[5.,6.,7.,8.])
X =
[0.0, 1.0, 2.0, 3.0,
0.0, 1.0, 2.0, 3.0,
0.0, 1.0, 2.0, 3.0,
0.0, 1.0, 2.0, 3.0]
Y =
[ 5.0, 5.0, 5.0, 5.0,
6.0, 6.0, 6.0, 6.0,
7.0, 7.0, 7.0, 7.0,
8.0, 8.0, 8.0, 8.0]
Interface 1
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE SUBROUTINE MeshGrid(x, y, xgv, ygv)
REAL(REAL64), ALLOCATABLE, INTENT(INOUT) :: x(:, :)
!! X and Y are matrix each of size [ny by nx] contains the grid data.
REAL(REAL64), ALLOCATABLE, INTENT(INOUT) :: y(:, :)
!! X and Y are matrix each of size [ny by nx] contains the grid data.
REAL(REAL64), INTENT(IN) :: xgv(:)
!! xgv, ygv are grid vectors in form of full grid data
REAL(REAL64), INTENT(IN) :: ygv(:)
!! xgv, ygv are grid vectors in form of full grid data
END SUBROUTINE MeshGrid
END INTERFACE
- xgv, ygv are grid vectors in form of full grid data
- X and Y are matrix each of size [ny by nx] contains the grid data.
- The coordinates of point (i,j) is [X(i,j), Y(i,j)]
program main
use easifemBase
implicit none
real(dfp), allocatable :: x(:,:), y(:,:)
call meshgrid(x, y, arange(0._dfp,3._dfp), arange(5._dfp, 8._dfp) )
call display(mdencode(x), "x:")
call display(mdencode(y), "y:")
end program main
See results
x:
0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 |
2 | 2 | 2 | 2 |
3 | 3 | 3 | 3 |
y:
5 | 6 | 7 | 8 |
5 | 6 | 7 | 8 |
5 | 6 | 7 | 8 |
5 | 6 | 7 | 8 |
Interface 2
- ܀ Interface
- ️܀ See example
- ↢
INTERFACE
MODULE PURE SUBROUTINE MeshGrid(x, y, z, xgv, ygv, zgv)
REAL(REAL64), ALLOCATABLE, INTENT(INOUT) :: x(:, :, :)
REAL(REAL64), ALLOCATABLE, INTENT(INOUT) :: y(:, :, :)
REAL(REAL64), ALLOCATABLE, INTENT(INOUT) :: z(:, :, :)
REAL(REAL64), INTENT(IN) :: xgv(:)
REAL(REAL64), INTENT(IN) :: ygv(:)
REAL(REAL64), INTENT(IN) :: zgv(:)
END SUBROUTINE MeshGrid
END INTERFACE
program main
use easifemBase
implicit none
real(dfp), allocatable :: x(:,:,:), y(:,:,:), z(:,:,:)
call meshgrid(x, y,z, arange(1._dfp,3._dfp), arange(4._dfp, 5._dfp), arange(6._dfp, 7._dfp) )
call display(mdencode(x), "x:")
call display(mdencode(y), "y:")
call display(mdencode(z), "z:")
end program main
See results
x:( :, :, 1 ) =
1 | 1 |
2 | 2 |
3 | 3 |
( :, :, 2 ) =
1 | 1 |
2 | 2 |
3 | 3 |
y:( :, :, 1 ) =
4 | 5 |
4 | 5 |
4 | 5 |
( :, :, 2 ) =
4 | 5 |
4 | 5 |
4 | 5 |
z:( :, :, 1 ) =
6 | 6 |
6 | 6 |
6 | 6 |
( :, :, 2 ) =
7 | 7 |
7 | 7 |
7 | 7 |