-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdgemm.F90
72 lines (65 loc) · 2.01 KB
/
dgemm.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
program dgemm_example
!!!!!!!!!!!!!!!!
!Brock Palen
!
!Example Callding DGEMM from Fortran
!See:
!
!http://www.netlib.org/blas/dgemm.f
!!!!!!!!!!!!!!!!
#define WHERESTR "[file %s, line %d]"
#define WHEREARG __FILE__,__LINE__
#ifdef _OPENMP
use omp_lib
#endif
implicit none
EXTERNAL DGEMM
INTEGER I, J
DOUBLE PRECISION, ALLOCATABLE :: a(:,:)
DOUBLE PRECISION, ALLOCATABLE :: b(:,:)
DOUBLE PRECISION, ALLOCATABLE :: c(:,:)
INTEGER M ! Number of rows of matrix op(a)
INTEGER N ! Number of columns of matrix op(b)
INTEGER K ! Number of columns of matrix op(a) and rows op(b)
INTEGER lda ! n entry, LDA specifies the first dimension of A as declared
! in the calling (sub) program. When TRANSA = 'N' or 'n' then
! LDA must be at least max( 1, m ), otherwise LDA must be at
! least max( 1, k ).
INTEGER ldb ! On entry, LDB specifies the first dimension of B as declared
! in the calling (sub) program. When TRANSB = 'N' or 'n' then
! LDB must be at least max( 1, k ), otherwise LDB must be at
! least max( 1, n ).
INTEGER ldc ! On entry, LDC specifies the first dimension of C as declared
! in the calling (sub) program. LDC must be at least
! max( 1, m ).
DOUBLE PRECISION alpha, beta
#define WHERESTR "[file %s, line %d]"
#define WHEREARG __FILE__,__LINE__
#ifdef _OPENMP
write(*,*)"Will use: ", omp_get_num_procs(), " of ", &
omp_get_max_threads(), " available"
#endif
M=3
N=M
K=M
lda=M
ldb=M
ldc=M
alpha=1.0
beta=0.0
! allocate arrays
ALLOCATE(a(lda,K), b(ldb,N), c(ldc,N))
a=RESHAPE((/ 0.0, 1.0, 2.0, &
3.0, 4.0, 5.0, &
6.0, 7.0, 8.0 /), &
(/lda,K/))
b=RESHAPE((/ 0.0, 1.0, 2.0, &
3.0, 4.0, 5.0, &
6.0, 7.0, 8.0 /), &
(/ldb,N/))
CALL DGEMM('N','N',M,N,K,alpha,a,lda,b,ldb,beta,c,ldc)
DO I = LBOUND(c,1), UBOUND(c,1)
WRITE(*,*) (c(I,J), J=LBOUND(c,2), UBOUND(c,2))
END DO
end program dgemm_example