cla_read_str Subroutine

public subroutine cla_read_str(cla_input_str)

Arguments

Type IntentOptional Attributes Name
character(len=*) :: cla_input_str

Source Code

    subroutine cla_read_str(cla_input_str)
      implicit none
      character(len=*) :: cla_input_str
      integer :: i,n,k
      character(CLALEN) :: outs
      cla_cla = trim(adjustl(cla_input_str))
      cla_cla_len = len_trim(cla_cla)
      ! Replace whitespace with single space:
      outs = cla_cla
      n = 0  ; k=cla_cla_len                  ! k=index last non-blank (may be null)
      DO i = 1,k-1                            ! dont process last char yet
         n = n+1 ; outs(n:n) = cla_cla(i:i)
         IF (cla_cla(i:i+1) == '  ') n = n-1  ! backup/discard consecutive output blank
      END DO
      n = n+1  ; outs(n:n)  = cla_cla(k:k)    ! last non-blank char output (may be null)
      IF (n < k) outs(n+1:) = ' '             ! pad trailing blanks
      cla_cla = outs
      cla_cla_len = len_trim(cla_cla)
    end subroutine cla_read_str