rd2 Function

function rd2(a, b, x, y)

Read one number from each of two tokens.

False, w/ need two numbers printed, if either fails to parse.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: a

First token.

character(len=*), intent(in) :: b

Second token.

real(kind=8), intent(out) :: x

Number read from a.

real(kind=8), intent(out) :: y

Number read from b.

Return Value logical


Source Code

   logical function rd2(a, b, x, y)
      !! Read one number from each of two tokens.
      !!
      !! False, w/ `need two numbers` printed, if either fails to parse.
      ! Arguments
      character(len=*), intent(in) :: a
         !! First token.
      character(len=*), intent(in) :: b
         !! Second token.
      real(8), intent(out) :: x
         !! Number read from `a`.
      real(8), intent(out) :: y
         !! Number read from `b`.
      integer :: e1, e2
      rd2 = .false.
      read (a, *, iostat=e1) x
      read (b, *, iostat=e2) y
      if (e1 /= 0 .or. e2 /= 0) then
         print *, 'need two numbers'
         return
      end if
      rd2 = .true.
   end function rd2