@brief This routine remove not needed spaces from section line @detail This routine used revert reading of lines. Example, that this routine do: > DFTTYP = PBE0 BASNAM=APC4 , ACC5 < DFTTYP=PBE0 BASNAM=APC4,ACC5 @author Igor S. Gerasimov @date Sep, 2019 --Initial release-- @date May, 2021 Moved to strings @param line - (inout) worked line
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=:), | intent(inout), | allocatable | :: | line |
pure subroutine remove_spaces(line) character(len=:), allocatable, intent(inout) :: line ! internal variables character(len=:), allocatable :: tmp_line, res_line integer :: i, ind, ind_end logical :: skip, first tmp_line = line line = "" do res_line = "" ind_end = index(tmp_line, "=") first = .true. skip = .false. ind = ind_end if (ind == 0) ind = len(tmp_line) do i = ind, 1, -1 if (tmp_line(i:i) /= " ") then res_line = tmp_line(i:i)//res_line if (tmp_line(i:i) /= "=" .and. first .and. ind_end /= 0) then skip = .true. first = .false. end if else if (skip) then res_line = " "//res_line skip = .false. end if end do line = line//trim(adjustl(res_line)) if (ind_end == 0) exit tmp_line = tmp_line(ind+1:) end do end subroutine remove_spaces