! 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.14. Trade the values 1 and 2.
  program D14
    implicit none
    integer :: I
! start program D14
    write (unit = *, fmt = *) " Please enter 1 or 2. "
    read (unit = *, fmt = *) I
    write (unit = *, fmt = *) " Thank you.  You have entered: ", I
     if (I == 1) then
      I = 2
    else if (I == 2) then
      I = 1
    else  ! Leave I value unchanged.
    end if
    write (unit = *, fmt = *) I, " was computed from the value you entered. "
    stop
  end program D14
