Returns the length of a keyword vector
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | keyword | Keyword to examine |
||
logical, | intent(out) | :: | found | Is keyword present |
||
integer, | intent(out) | :: | length | length of vector |
subroutine param_get_vector_length(keyword, found, length)
!======================================================!
! !
!! Returns the length of a keyword vector
! !
!======================================================!
use w90_io, only: io_error
implicit none
character(*), intent(in) :: keyword
!! Keyword to examine
logical, intent(out) :: found
!! Is keyword present
integer, intent(out) :: length
!! length of vector
integer :: kl, in, loop, pos
character(len=maxlen) :: dummy
kl = len_trim(keyword)
found = .false.
do loop = 1, num_lines
in = index(in_data(loop), trim(keyword))
if (in == 0 .or. in > 1) cycle
if (found) then
call io_error('Error: Found keyword '//trim(keyword)//' more than once in input file')
endif
found = .true.
dummy = in_data(loop) (kl + 1:)
dummy = adjustl(dummy)
if (dummy(1:1) == '=' .or. dummy(1:1) == ':') then
dummy = dummy(2:)
dummy = adjustl(dummy)
end if
end do
length = 0
if (found) then
if (len_trim(dummy) == 0) call io_error('Error: keyword '//trim(keyword)//' is blank')
length = 1
dummy = adjustl(dummy)
do
pos = index(dummy, ' ')
dummy = dummy(pos + 1:)
dummy = adjustl(dummy)
if (len_trim(dummy) > 0) then
length = length + 1
else
exit
endif
end do
end if
return
end subroutine param_get_vector_length