C   prog2c.f -- Multiply Two Matrices Together
C   Written Sep 1, 2005 by Eric Olson for Mathematics 466 
C
C   Optimized for column-major matrix storage
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

       print *,'prog2c.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 2 j=1,n
           do 1 i=1,n
               C(i,j)=0.0D0
1          continue
2      continue
       do 30 k=1,n
           do 20 j=1,n
               do 10 i=1,n
                   C(i,j)=C(i,j)+A(i,k)*B(k,j)
10             continue
20         continue
30     continue
       call toc(r)
       print *,'n=',n,'    Tn=',r,' seconds'
       stop
       end
