C   prog2a.f -- Multiply Two Matrices Together
C   Written Sep 1, 2005 by Eric Olson for Mathematics 466
C
C   Naive implementation
C
C   For more information see the lecture notes at
C   http://fractal.math.unr.edu/~ejolson/466/notes/lect01.html
C
       implicit none
       integer n,i,j,k
       parameter(n=1024)
       real*8 A(n,n),B(n,n),C(n,n)
       real*8 r,sum

       print *,'prog2a.f -- Multiply Two Matrices Together'

       do 101 j=1,n
           do 100 i=1,n
               A(i,j)=rand(0)
100        continue
101    continue
       do 103 j=1,n
           do 102 i=1,n
               B(i,j)=rand(0)
102        continue
103    continue

       call tic
       do 30 i=1,n
           do 20 j=1,n
               sum=0.0D0
               do 10 k=1,n
                   sum=sum+A(i,k)*B(k,j)
10             continue
               C(i,j)=sum
20         continue
30     continue
       call toc(r)
       print *,'n=',n,'    Tn=',r,' seconds'
       stop
       end
