Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in), | dimension(:) | :: | nonunique | ||
character(len=*), | intent(inout), | dimension(:) | :: | unique |
subroutine extend_unique_string(nonunique, unique)
! Add entries from nonunique to the next blank of unique unless already present
character(len=*), dimension(:), intent(in) :: nonunique
character(len=*), dimension(:), intent(inout) :: unique
logical add
integer i, ii, iv
iv = 1
! Shift iv counter to allow for already present unique entries
do ii = 1, size(unique)
if (trim(unique(ii)) == "") then
exit
end if
iv = iv + 1
end do
! Add nonunique to unique unless already in unique
do i = 1, size(nonunique)
add = .True.
do ii = 1, size(unique)
if (trim(nonunique(i)) == trim(unique(ii))) then
add = .False.
exit
else if (trim(unique(ii)) == "") then
exit
end if
end do
if (add) then
if (iv > size(unique)) then
call log_error('extend_unique_string', &
"Trying to extend unique array autside size.", i1=iv, int=size(unique))
end if
unique(iv) = nonunique(i)
iv = iv + 1
end if
end do
end subroutine extend_unique_string