assignR Subroutine

private subroutine assignR(buffer, variable, found, keyword, fs)

Assign a real to variable

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(inout) :: buffer

Input buffer

real(kind=real32), 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


Source Code

  subroutine assignR(buffer, variable, found, keyword, fs)
    !! Assign a real to variable
    implicit none

    ! Arguments
    character(*), intent(inout) :: buffer
    !! Input buffer
    real(real32), 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
       read(buffer2, *) variable
    end if
  end subroutine assignR