Allcoate 3-Dimensional array of type: integer
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout), | dimension(:, :, :), allocatable | :: | var | Variable to which memory is allocated |
|
integer, | intent(in) | :: | start1 | Starting index of Var array's dimension |
||
integer, | intent(in) | :: | stop1 | Last index of Var array's dimension |
||
integer, | intent(in) | :: | start2 | Starting index of Var array's dimension |
||
integer, | intent(in) | :: | stop2 | Last index of Var array's dimension |
||
integer, | intent(in) | :: | start3 | Starting index of Var array's dimension |
||
integer, | intent(in) | :: | stop3 | Last index of Var array's dimension |
||
character(len=*), | intent(in), | optional | :: | errmsg | Error message to print if mem_stat is not 0(successful) |
subroutine alloc_rank3_integer(var, start1, stop1, start2, stop2, &
start3, stop3, errmsg)
!< Allcoate 3-Dimensional array of type: integer
implicit none
integer, dimension(:, :, :), intent(inout), allocatable :: var
!< Variable to which memory is allocated
integer, intent(in) :: start1, start2, start3
!< Starting index of Var array's dimension
integer, intent(in) :: stop1, stop2, stop3
!< Last index of Var array's dimension
integer :: mem_stat
!< Status of the memory allocation process
character(len=*), intent(in), optional :: errmsg
!< Error message to print if mem_stat is not 0(successful)
allocate(var(start1:stop1, start2:stop2, start3:stop3), &
stat=mem_stat)
if (mem_stat /= 0) then
if (present(errmsg)) then
print *, errmsg
else
print *, 'Error: Could not allocate memory.'
end if
print *, 'Required extent: ', stop1 - start1 + 1, &
stop2 - start2 + 1, stop3 - start3 + 1
stop
end if
end subroutine alloc_rank3_integer