! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example 4.7. Compute Fibonacci sequence; exit to avoid overflow.
  program E07
    implicit none
    integer :: FI, FJ, Next
! start program E07
    FI = 1
    FJ = 1
    write (unit = *, fmt = *) FI
    write (unit = *, fmt = *) FJ
    do
      if (FJ > huge (1) - FI) then
        exit
      end if
      Next = FI + FJ
      FI = FJ
      FJ = Next
      write (unit = *, fmt = *) FJ
    end do
    stop
  end program E07
