extend_unique_string Subroutine

public subroutine extend_unique_string(nonunique, unique)

Arguments

Type IntentOptional AttributesName
character(len=*), intent(in), dimension(:):: nonunique
character(len=*), intent(inout), dimension(:):: unique

Calls

proc~~extend_unique_string~~CallsGraph proc~extend_unique_string extend_unique_string proc~log_error log_error proc~extend_unique_string->proc~log_error proc~log_message log_message proc~log_error->proc~log_message proc~log_write log_write proc~log_message->proc~log_write proc~log_format_message log_format_message proc~log_message->proc~log_format_message proc~to_string to_string proc~log_write->proc~to_string proc~date_time_str date_time_str proc~log_format_message->proc~date_time_str proc~colourise colourise proc~log_format_message->proc~colourise proc~string_index string_index proc~colourise->proc~string_index

Called by

proc~~extend_unique_string~~CalledByGraph proc~extend_unique_string extend_unique_string proc~output_initialise_user_input output_initialise_user_input proc~output_initialise_user_input->proc~extend_unique_string proc~initialise initialise proc~initialise->proc~output_initialise_user_input program~swim swim program~swim->proc~initialise

Contents

Source Code


Source Code

  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