module solution_9_5
public  ::  get_char
contains
! Solution 9/5
   subroutine get_char(unit_no, gc, ios)
      integer, intent(in)           :: unit_no
      character(len=*), intent(out) :: gc
      integer, intent(out)          :: ios
      integer :: i
    ! Allow one extra attempt to read to handle possible end-of-record,
    ! otherwise exit with error code.
      do i = 1, 2
         read(unit=unit_no, fmt="(a1)", advance="no", iostat=ios) gc
         if (ios == 0 ) then
            exit
         end if
      end do
   end subroutine get_char
end module solution_9_5
