Finds the values of the required keyword vector
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(settings_type), | intent(inout) | :: | settings | |||
| character(len=*), | intent(in) | :: | keyword |
Keyword to examine |
||
| logical, | intent(inout) | :: | found |
Is keyword present |
||
| integer, | intent(in) | :: | length |
Length of vecotr to read |
||
| type(w90_error_type), | intent(out), | allocatable | :: | error | ||
| type(w90_comm_type), | intent(in) | :: | comm | |||
| character(len=*), | intent(inout), | optional | :: | c_value(length) |
Keyword data |
|
| logical, | intent(inout), | optional | :: | l_value(length) |
Keyword data |
|
| integer, | intent(inout), | optional | :: | i_value(length) |
Keyword data |
|
| real(kind=dp), | intent(inout), | optional | :: | r_value(length) |
Keyword data |
|
| real(kind=dp), | intent(inout), | optional, | allocatable | :: | r2_value(:,:) |
Keyword data |
| character(len=*), | intent(inout), | optional, | allocatable | :: | c2_value(:) |
Keyword data |
subroutine w90_readwrite_get_keyword_vector(settings, keyword, found, length, error, comm, & c_value, l_value, i_value, r_value, r2_value, & c2_value) !================================================! ! !! Finds the values of the required keyword vector ! !================================================! use w90_error, only: w90_error_type, set_error_input, set_error_fatal implicit none type(w90_error_type), allocatable, intent(out) :: error type(w90_comm_type), intent(in) :: comm character(*), intent(in) :: keyword !! Keyword to examine logical, intent(inout) :: found !! Is keyword present integer, intent(in) :: length !! Length of vecotr to read character(*), optional, intent(inout) :: c_value(length) !! Keyword data logical, optional, intent(inout) :: l_value(length) !! Keyword data integer, optional, intent(inout) :: i_value(length) !! Keyword data real(kind=dp), optional, intent(inout) :: r_value(length) !! Keyword data real(kind=dp), allocatable, optional, intent(inout) :: r2_value(:, :) !! Keyword data character(len=*), allocatable, optional, intent(inout) :: c2_value(:) !! Keyword data type(settings_type), intent(inout) :: settings integer :: kl, in, loop, i, itmp character(len=maxlen) :: dummy kl = len_trim(keyword) found = .false. if (allocated(settings%entries) .and. allocated(settings%in_data)) then call set_error_fatal(error, 'Error: (library use) options interface and .win parsing clash.'// & ' See library documentation "setting options." (readwrite.F90)', comm) return elseif (allocated(settings%entries)) then do loop = 1, settings%num_entries ! this means the first occurance of the variable in settings is used ! memory beyond num_entries is not initialised if (settings%entries(loop)%keyword == keyword) then if (present(i_value)) then i_value = settings%entries(loop)%i1d else if (present(r_value)) then r_value = settings%entries(loop)%r1d else if (present(r2_value)) then r2_value = settings%entries(loop)%r2d else if (present(c2_value)) then c2_value = settings%entries(loop)%c2d else call set_error_fatal(error, 'Error: vector sought, but no variable provided to assign to. (readwrite.F90)', comm) return end if found = .true. end if end do else if (allocated(settings%in_data)) then do loop = 1, settings%num_lines in = index(settings%in_data(loop), trim(keyword)) itmp = in + len(trim(keyword)) if (settings%in_data(loop) (itmp:itmp) /= '=' & .and. settings%in_data(loop) (itmp:itmp) /= ':' & .and. settings%in_data(loop) (itmp:itmp) /= ' ') cycle if (in == 0 .or. in > 1) cycle if (found) then call set_error_input(error, 'Error: Found keyword '//trim(keyword)//' more than once in input file', comm) return end if found = .true. dummy = settings%in_data(loop) (kl + 1:) settings%in_data(loop) (1:maxlen) = ' ' dummy = adjustl(dummy) if (dummy(1:1) == '=' .or. dummy(1:1) == ':') then dummy = dummy(2:) dummy = adjustl(dummy) end if end do if (found) then if (present(c_value)) read (dummy, *, err=230, end=230) (c_value(i), i=1, length) if (present(l_value)) then ! I don't think we need this. Maybe read into a dummy charater ! array and convert each element to logical call set_error_input(error, 'w90_readwrite_get_keyword_vector unimplemented for logicals', comm) return end if if (present(i_value)) read (dummy, *, err=230, end=230) (i_value(i), i=1, length) if (present(r_value)) read (dummy, *, err=230, end=230) (r_value(i), i=1, length) end if end if return 230 call set_error_input(error, 'Error: Problem reading keyword '//trim(keyword)//' in w90_readwrite_get_keyword_vector', comm) return end subroutine w90_readwrite_get_keyword_vector