-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lapack.f90
85 lines (85 loc) · 1.71 KB
/
test_lapack.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
73
74
75
76
77
78
79
80
81
82
83
84
85
SUBROUTINE test_lapack_real(ndim,mat)
!
IMPLICIT NONE
!
INTEGER, PARAMETER :: DP = SELECTED_REAL_KIND(14,200)
!
INTEGER, INTENT(IN) :: ndim
REAL(DP), INTENT(INOUT) :: mat(ndim,ndim)
!
INTEGER :: lwork
INTEGER :: ierr
INTEGER :: cr
INTEGER :: t1
INTEGER :: t2
INTEGER, ALLOCATABLE :: ipiv(:)
!
REAL(DP), ALLOCATABLE :: work(:)
!
ALLOCATE(ipiv(ndim))
ALLOCATE(work(1))
!
CALL SYSTEM_CLOCK(COUNT_RATE=cr)
CALL SYSTEM_CLOCK(t1)
!
CALL DGETRF(ndim,ndim,mat,ndim,ipiv,ierr)
CALL DGETRI(ndim,mat,ndim,ipiv,work,-1,ierr)
!
lwork = CEILING(work(1))
!
DEALLOCATE(work)
ALLOCATE(work(lwork))
!
CALL DGETRI(ndim,mat,ndim,ipiv,work,lwork,ierr)
!
CALL SYSTEM_CLOCK(t2)
!
PRINT *,"time1:",REAL(t2-t1)/REAL(cr)
!
DEALLOCATE(ipiv)
DEALLOCATE(work)
!
END SUBROUTINE
!
SUBROUTINE test_lapack_cmplx(ndim,mat)
!
IMPLICIT NONE
!
INTEGER, PARAMETER :: DP = SELECTED_REAL_KIND(14,200)
!
INTEGER, INTENT(IN) :: ndim
COMPLEX(DP), INTENT(INOUT) :: mat(ndim,ndim)
!
INTEGER :: lwork
INTEGER :: ierr
INTEGER :: cr
INTEGER :: t1
INTEGER :: t2
INTEGER, ALLOCATABLE :: ipiv(:)
!
COMPLEX(DP), ALLOCATABLE :: work(:)
!
ALLOCATE(ipiv(ndim))
ALLOCATE(work(1))
!
CALL SYSTEM_CLOCK(COUNT_RATE=cr)
CALL SYSTEM_CLOCK(t1)
!
CALL ZGETRF(ndim,ndim,mat,ndim,ipiv,ierr)
CALL ZGETRI(ndim,mat,ndim,ipiv,work,-1,ierr)
!
lwork = CEILING(REAL(work(1)))
!
DEALLOCATE(work)
ALLOCATE(work(lwork))
!
CALL ZGETRI(ndim,mat,ndim,ipiv,work,lwork,ierr)
!
CALL SYSTEM_CLOCK(t2)
!
PRINT *,"time1:",REAL(t2-t1)/REAL(cr)
!
DEALLOCATE(ipiv)
DEALLOCATE(work)
!
END SUBROUTINE