Allocate the arrays.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | xstart | |||
| real(kind=wp), | intent(in) | :: | xstop | |||
| real(kind=wp), | intent(in) | :: | xstep | |||
| real(kind=wp), | intent(in) | :: | ystart | |||
| real(kind=wp), | intent(in) | :: | ystop | |||
| real(kind=wp), | intent(in) | :: | ystep | |||
| real(kind=wp), | intent(out), | dimension(:), allocatable | :: | x | ||
| real(kind=wp), | intent(out), | dimension(:), allocatable | :: | y | ||
| real(kind=wp), | intent(out), | dimension(:,:), allocatable | :: | z | f(x,y) |
subroutine size_arrays(xstart, xstop, xstep, ystart, ystop, ystep, x, y, z)
implicit none
real(wp),intent(in) :: xstart, xstop, xstep, ystart, ystop, ystep
real(wp),dimension(:),allocatable,intent(out) :: x,y
real(wp),dimension(:,:),allocatable,intent(out) :: z !! f(x,y)
integer :: i,j,nx,ny
real(wp) :: tmp
nx = 1
tmp = xstart
x = [tmp]
do
tmp = tmp + xstep
if (tmp>xstop) exit
nx = nx + 1
x = [x,tmp]
end do
ny = 1
tmp = ystart
y = [tmp]
do
tmp = tmp + ystep
if (tmp>ystop) exit
ny = ny + 1
y = [y,tmp]
end do
allocate(z(nx,ny))
z = 0.0_wp
end subroutine size_arrays