program main !*****************************************************************************80 ! !! MAIN is the main program for SUM_MILLION. ! ! Discussion: ! ! SUM_MILLION is a sketch of a program to generate the numbers ! from 1 to 1,000,000, add them, and print the result. ! ! This program is only a sketch. Your job is to finish it, ! debug it, and get it to run. ! ! Read the CPU clock this way: ! ! call cpu_time ( ctime1 ) ! integer, parameter :: n = 1000000 double precision ctime double precision ctime1 double precision ctime2 double precision error; double precision, parameter :: exact = 500000500000.0D+00 integer flops integer i double precision mflops double precision total double precision x(n) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'SUM_MILLION:' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' ' write ( *, '(a,i8)' ) ' Task: add the numbers from 1 to ', n ! ! Step 1: ! Load the array X with the values. ! do i = 1, n x(i) = i end do ! ! Step 2: ! Start the clock. ! Add up the entries in X. ! Stop the clock. ! Compute elapsed CPU time; ! Set the number of FLOPs. (how many additions are being done?) ! Compute the MFLOPS rate. ! Compute the error. ! MISSING CODE ! ! Step 3: ! Print results. ! write ( *, * ) ' ' write ( *, * ) ' Total = ', total write ( *, * ) ' Error = ', error write ( *, * ) ' CPU time = ', ctime write ( *, * ) ' MegaFlops = ', mflops stop end