free_option Subroutine

private elemental subroutine free_option(self, option_name)

Free an option.

Arguments

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

Section data.

character, intent(in) :: option_name

Option name.


Contents

Source Code


Source Code

  elemental subroutine free_option(self, option_name)
  !< Free an option.
  class(section), intent(inout) :: self        !< Section data.
  character(*),   intent(in)    :: option_name !< Option name.
  type(option), allocatable     :: options(:)  !< Temporary options array.
  integer(I4P)                  :: o           !< Counter.

  if (allocated(self%options)) then
    o = self%index(option_name=option_name)
    if (o>0) then
      allocate(options(1:size(self%options, dim=1)-1))
      if (o==1) then
        options = self%options(2:)
      elseif (o==size(self%options, dim=1)) then
        options = self%options(:o-1)
      else
        options(:o-1) = self%options(:o-1)
        options(o:  ) = self%options(o+1:)
      endif
      call move_alloc(options, self%options)
    endif
  endif
  endsubroutine free_option