! 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 3.9. Trade the values 1 and 2.
  program D09
    implicit none
    integer :: I
! start program D09
    write (unit = *, fmt = *) " Please enter 1 or 2. "
    read (unit = *, fmt = *) I
    write (unit = *, fmt = *) " Thank you.  You have entered: ", I
    if ((I == 1) .or. (I == 2)) then
      if (I == 1) then
        I = 2
      else
        I = 1
      end if
      write (unit = *, fmt = *) " Your value was changed to: ", I
    else
      write (unit = *, fmt = *) " Your value was not 1 or 2; it was: ", I
    end if
    stop
  end program D09
