
      PROGRAM TPK
!     The TPK Algorithm
!     Fortran 90 style
      IMPLICIT NONE
      INTEGER		       :: I
      REAL                     :: Y
      REAL, DIMENSION(0:10)    :: A
      READ (*,*) A
      DO I = 10, 0, -1         ! Backwards
         Y = FUN(A(I))
         IF ( Y < 400.0 ) THEN
            WRITE(*,*) I, Y
         ELSE
            WRITE(*,*) I, ' Too large'
         END IF
      END DO
      CONTAINS                 ! Local function
      FUNCTION FUN(T)
         REAL  :: FUN
         REAL, INTENT(IN) :: T
         FUN = SQRT(ABS(T)) + 5.0*T**3
      END FUNCTION FUN
      END PROGRAM TPK
