free_section Subroutine

private elemental subroutine free_section(self, section_name)

Free all options of a section.

Arguments

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

File data.

character, intent(in) :: section_name

Section name.


Contents

Source Code


Source Code

  elemental subroutine free_section(self, section_name)
  !< Free all options of a section.
  class(file_ini), intent(inout) :: self         !< File data.
  character(*),    intent(in)    :: section_name !< Section name.
  type(section), allocatable     :: sections(:)  !< Temporary sections array.
  integer(I4P)                   :: s            !< Counter.

  s = self%index(section_name=section_name)
  if (s>0) then
    allocate(sections(1:size(self%sections, dim=1)-1))
    if (s==1) then
      sections = self%sections(2:)
    elseif (s==size(self%sections, dim=1)) then
      sections = self%sections(:s-1)
    else
      sections(:s-1) = self%sections(:s-1)
      sections(s:  ) = self%sections(s+1:)
    endif
    call move_alloc(sections, self%sections)
    self%Ns = self%Ns - 1
  endif
  endsubroutine free_section