Assign a logical to variable (T/t/1 and F/f/0 accepted)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(inout) | :: | buffer |
Input buffer |
||
| logical, | intent(out) | :: | variable |
Variable to assign data to |
||
| integer, | intent(inout) | :: | found |
Count for finding variable |
||
| character(len=*), | intent(in), | optional | :: | keyword |
Keyword to start from |
|
| character(len=1), | intent(in), | optional | :: | fs |
Field separator |
subroutine assignL(buffer, variable, found, keyword, fs) !! Assign a logical to variable (T/t/1 and F/f/0 accepted) implicit none ! Arguments character(*), intent(inout) :: buffer !! Input buffer logical, intent(out) :: variable !! Variable to assign data to integer, intent(inout) :: found !! Count for finding variable character(*), optional, intent(in) :: keyword !! Keyword to start from character(1), optional, intent(in) :: fs !! Field separator ! Local variables character(1024) :: buffer2 !! Temporary buffer character(1) :: fs_ !! Field separator fs_ = '=' if(present(fs)) fs_ = fs if(present(keyword)) buffer = buffer(index(buffer, keyword):) if(scan(buffer, fs_) .ne. 0) buffer2 = get_val(buffer, fs_) if(trim(adjustl(buffer2)) .ne. '')then found = found + 1 if( & index(buffer2, "T") .ne. 0 .or. & index(buffer2, "t") .ne. 0 .or. & index(buffer2, "1") .ne. 0 & )then variable = .TRUE. end if if( & index(buffer2, "F") .ne. 0 .or. & index(buffer2, "f") .ne. 0 .or. & index(buffer2, "0") .ne. 0 & )then variable = .FALSE. end if end if end subroutine assignL