set_a_option Subroutine

private pure subroutine set_a_option(self, option_name, val, delimiter, error)

Set option value (array).

Arguments

TypeIntentOptionalAttributesName
class(section), intent(inout) :: self

Section data.

character, intent(in) :: option_name

Option name.

class(*), intent(in) :: val(:)

Value.

character, intent(in), optional :: delimiter

Delimiter used for separating values.

integer(kind=I4P), intent(out), optional :: error

Error code.


Contents

Source Code


Source Code

  pure subroutine set_a_option(self, option_name, val, delimiter, error)
  !< Set option value (array).
  class(section), intent(inout)         :: self        !< Section data.
  character(*),   intent(in)            :: option_name !< Option name.
  class(*),       intent(in)            :: val(:)      !< Value.
  character(*),   intent(in),  optional :: delimiter   !< Delimiter used for separating values.
  integer(I4P),   intent(out), optional :: error       !< Error code.
  integer(I4P)                          :: errd        !< Error code.
  character(len=:), allocatable         :: dlm         !< Dummy string for delimiter handling.
  integer(I4P)                          :: o           !< Counter.

  dlm = ' ' ; if (present(delimiter)) dlm = delimiter
  errd = ERR_SECTION_OPTIONS
  if (allocated(self%options)) then
    do o=1, size(self%options, dim=1)
      if (self%options(o) == trim(adjustl(option_name))) then
        call self%options(o)%set(delimiter=dlm, val=val)
        errd = 0
        exit
      endif
    enddo
  endif
  if (present(error)) error = errd
  endsubroutine set_a_option