Searches the name array for a target name and returns its 1-based index, or 0 if not found.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | names(:) | |||
| integer, | intent(in) | :: | nspecies |
Size of the names array to search. |
||
| character(len=*), | intent(in) | :: | target |
The target name to search for. |
integer function species_index_of(names, nspecies, target) result(idx) character(len=*), intent(in) :: names(:) !< Array of species names. integer, intent(in) :: nspecies !< Number of species to search. character(len=*), intent(in) :: target !< Target name to look up. integer :: k !< Loop counter. idx = 0 if (nspecies <= 0 .or. len_trim(target) == 0) return do k = 1, min(nspecies, size(names)) if (species_names_match(names(k), target)) then idx = k return end if end do end function species_index_of