Returns an array of integers given start, end, and increment values. If the
increment argument is not passed, default increment is 1. This procedure is
overloaded by the generic procedure range
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ik), | intent(in) | :: | start | Start value of the array |
||
integer(kind=ik), | intent(in) | :: | end | End value of the array |
||
integer(kind=ik), | intent(in), | optional | :: | increment | Array increment |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module.
pure function range_int(start,end,increment) result(range)
!! Returns an array of integers given start, end, and increment values. If the
!! increment argument is not passed, default increment is 1. This procedure is
!! overloaded by the generic procedure `range`.
integer(kind=ik),intent(in) :: start
!! Start value of the array
integer(kind=ik),intent(in) :: end
!! End value of the array
integer(kind=ik),intent(in),optional :: increment
!! Array increment
integer(kind=ik),dimension(:),allocatable :: range
integer(kind=ik) :: i
integer(kind=ik) :: increment_
integer(kind=ik) :: length
if(present(increment))then
increment_ = increment
else
increment_ = 1
endif
length = (end-start)/increment_+1
allocate(range(length))
do concurrent(i = 1:length)
range(i) = start+(i-1)*increment_
enddo
endfunction range_int