program teste
	
	implicit none

	INTEGER*8,PARAMETER:: M=20000, K=2000, N=10000
	real*8::ALPHA, BETA
	INTEGER*8::I, J
	real*8::A(M,K), B(K,N), C(M,N)

	ALPHA = 1.0 
	BETA = 0.0

	!$OMP PARALLEL
		!$OMP WORKSHARE
			forall (I=1:M:1, J=1:K:1)
				A(I,J) = dble((I-1) * K + J)
			end forall
		!$OMP END WORKSHARE
		!$OMP WORKSHARE
			forall (I=1:K:1, J=1:N:1)
				B(I,J) = -dble(((I-1) * N + J))
			end forall
		!$OMP END WORKSHARE
		!$OMP WORKSHARE
			forall (I=1:M:1, J=1:N:1)
				C(I,J) = 0.0d0
			end forall
		!$OMP END WORKSHARE
	!$OMP END PARALLEL

	CALL DGEMM('N','N',M,N,K,ALPHA,A,M,B,K,BETA,C,M)
	
      PRINT *, "Top left corner of matrix A:"
      PRINT 20, ((A(I,J), J = 1,MIN(K,6)), I = 1,MIN(M,6))
      PRINT *, ""

      PRINT *, "Top left corner of matrix B:"
      PRINT 20, ((B(I,J),J = 1,MIN(N,6)), I = 1,MIN(K,6))
      PRINT *, ""

 20   FORMAT(6(F12.0,1x))

      PRINT *, "Top left corner of matrix C:"
      PRINT 30, ((C(I,J), J = 1,MIN(N,6)), I = 1,MIN(M,6))
      PRINT *, ""

 30   FORMAT(6(ES12.4,1x))

      PRINT *, "Example completed."
      
stop
endprogram teste
