Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=dp), | intent(in) | :: | vec(:) | |||
integer, | intent(in), | optional | :: | target_state |
pure integer function my_minloc(vec, target_state)
real(dp), intent(in) :: vec(:)
integer, intent(in), optional :: target_state
logical :: flag(size(vec))
integer :: i
if (present(target_state)) then
flag = .true.
do i = 1, target_state
my_minloc = minloc(vec, dim = 1, mask = flag)
flag(my_minloc) = .false.
end do
else
my_minloc = minloc(vec, 1)
end if
end function my_minloc