C****************************************************************************** C FILE: arit01.f C DESCRIPTION: C Demonstrates Horner's Rule of Polynomial Evaluation C****************************************************************************** program arit01 IMPLICIT NONE integer ARRAY_SIZE, SEED parameter(ARRAY_SIZE = 10000) parameter(SEED = 1995) integer I, J, K real A(ARRAY_SIZE), AA(ARRAY_SIZE) real B(ARRAY_SIZE), BB(ARRAY_SIZE) real C(ARRAY_SIZE), CC(ARRAY_SIZE) real D(ARRAY_SIZE), DD(ARRAY_SIZE) real E(ARRAY_SIZE), EE(ARRAY_SIZE) real F(ARRAY_SIZE), FF(ARRAY_SIZE) real X, XX integer(8) T1, T2, IRTC C***************************************************************************** C* Untuned Loop * C***************************************************************************** T1 = IRTC() DO I=1, ARRAY_SIZE X = A(I)*X**5 + B(I)*X**4 + C(I)*X**3 + & D(I)*X**2 + E(I)*X + F(I) ENDDO T2 = IRTC() write(*,*)'Untuned loop took', (T2-T1)/1000000, 'msec' C***************************************************************************** C* Tuned Loop * C***************************************************************************** T1 = IRTC() DO I=1, ARRAY_SIZE XX = ((((AA(I)*XX + BB(I)) * XX + CC(I)) * XX + & DD(I)) * XX + EE(I)) * XX + FF(I) ENDDO T2 = IRTC() write(*,*)'Tuned loop took', (T2-T1)/1000000, 'msec' C Need to actually use the results of the calculations or else the C optimizing compiler may just skip doing them...so we'll just C print them. This will force the optimizer to actually do the work. print *, X, XX 999 end