Custom implementation of the findloc intrinsic (with somewhat reduced functionality) as it requires fortran2008 support and is thus not available for some relevant compilers
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int64), | intent(in) | :: | arr(:) | |||
integer(kind=int64), | intent(in) | :: | val | |||
logical, | intent(in), | optional | :: | back |
pure function custom_findloc_integer_int64(arr, val, back) result(loc)
integer(int64), intent(in) :: arr(:)
integer(int64), intent(in) :: val
logical, intent(in), optional :: back
integer :: loc
integer :: i, first, last, step
logical :: back_
def_default(back_, back, .false.)
if(back_) then
first = size(arr)
last = 1
step = -1
else
first = 1
last = size(arr)
step = 1
end if
loc = 0
do i = first, last, step
if(arr(i) == val) then
loc = i
return
endif
end do
end function custom_findloc_integer_int64