root / synthbench / euroben-dm / mod2b / .svn / text-base / mod2b.f.svn-base @ 0:839f52ef7657
History | View | Annotate | Download (5.4 kB)
1 |
program mod2b |
---|---|
2 |
! ---------------------------------------------------------------------- |
3 |
! ********************************************************************** |
4 |
! *** This program is part of the Euroben Benchmark *** |
5 |
! *** *** |
6 |
! *** Copyright: EuroBen Group p/o *** |
7 |
! *** Utrecht University, Computational Physics Dept. *** |
8 |
! *** P.O. Box 80.000 *** |
9 |
! *** 3508 TA Utrecht *** |
10 |
! *** The Netherlands *** |
11 |
! *** *** |
12 |
! *** Author of this program: Ruud van der Pas *** |
13 |
! *** Date 11/24/1988 *** |
14 |
! *** Modified by: Peter de Rijk *** |
15 |
! *** Date 02/12/1993 *** |
16 |
! *** Modified by: Gerrit Kolthof *** |
17 |
! *** Date 02/12/1999 (inserted MPI calls) *** |
18 |
! *** Modified by: Aad van der Steen *** |
19 |
! *** Date Autumn 2003 *** |
20 |
! ********************************************************************** |
21 |
! ---------------------------------------------------------------------- |
22 |
! --- Version 1.1 (Parallel, MPI). |
23 |
|
24 |
!- Purpose of program mod2b |
25 |
! ------------------------ |
26 |
! This program solves a linear system Ax = b for a general matrix A |
27 |
! of orders as specified in the input file 'mod2b.in'. |
28 |
|
29 |
! ---------------------------------------------------------------------- |
30 |
Use numerics |
31 |
Use dist_module |
32 |
Implicit None |
33 |
Include 'mpif.h' |
34 |
|
35 |
Integer :: m, n, i, j, lda, nrep, nval, ierr |
36 |
Real(l_) :: bmin, bmax |
37 |
Real(l_), Allocatable :: a(:,:), b(:) |
38 |
Integer, Allocatable :: ipvt(:) |
39 |
Real(l_) :: gltime, gltime1, gltime2, t1, |
40 |
& time1, time2, totime |
41 |
Real(l_) :: start_time, end_time |
42 |
Real(l_) :: ops, speed, comtime |
43 |
Logical :: ok |
44 |
! ----------------------------------------------------------------------- |
45 |
! ---Set up communication and print status information. |
46 |
|
47 |
Call csetup |
48 |
start_time = MPI_Wtime() |
49 |
If ( me == 0 ) Call state( 'mod2b ' ) |
50 |
Open( 1, File = 'mod2b.in' ) |
51 |
If ( me == 0 ) Print 1000, nodes |
52 |
|
53 |
10 Read( 1, *, End = 20 ) n, nrep |
54 |
lda = n + 1 |
55 |
m = n |
56 |
Allocate( a(lda,n), b(n), ipvt(n) ) |
57 |
ops = ((2.0_l_*n)*n*n)/3.0_l_ + (2.0_l_*n)*n |
58 |
time1 = 0.0_l_ |
59 |
time2 = 0.0_l_ |
60 |
Call distribute( n, 8 ) |
61 |
|
62 |
! --- Generate matrix. |
63 |
|
64 |
Do i = 1, nrep |
65 |
Call matgen( m, n, a, lda, b ) |
66 |
|
67 |
! ---Factorise. |
68 |
|
69 |
Call MPI_Barrier( MPI_Comm_World, ierr ) |
70 |
t1 = MPI_Wtime() |
71 |
Call getf2( m, n, a, lda, ipvt, ierr ) |
72 |
time1 = time1 + ( MPI_Wtime() - t1 ) |
73 |
|
74 |
! --- Stop on error. |
75 |
|
76 |
If ( ierr /= 0 ) Then |
77 |
If ( me == 0 ) Print 2000, 'GETF2 ', ierr |
78 |
Call MPI_Finalize( ierr ) |
79 |
Stop |
80 |
End If |
81 |
|
82 |
! --- Solve P*L*U*X=B |
83 |
|
84 |
Call MPI_Barrier( MPI_Comm_World, ierr ) |
85 |
t1 = MPI_Wtime() |
86 |
Call getrs( m, n, a, lda, ipvt, b, ierr ) |
87 |
time2 = time2 + ( MPI_Wtime() - t1 ) |
88 |
|
89 |
! --- Stop on error. |
90 |
|
91 |
If ( ierr /= 0 ) Then |
92 |
If ( me == 0 ) Print 2000, 'GETRS ', ierr |
93 |
Call MPI_Finalize( ierr ) |
94 |
Stop |
95 |
End If |
96 |
End Do |
97 |
|
98 |
Call check( b, n, ok ) |
99 |
time1 = time1/nrep |
100 |
time2 = time2/nrep |
101 |
totime = time1 + time2 |
102 |
|
103 |
! --- Get global wallclock times. |
104 |
|
105 |
Call MPI_Reduce( time1, gltime1, 1, MPI_Real8, MPI_Max, 0, |
106 |
& MPI_Comm_World, ierr ) |
107 |
Call MPI_Reduce( time2, gltime2, 1, MPI_Real8, MPI_Max, 0, |
108 |
& MPI_Comm_World, ierr ) |
109 |
Call MPI_Reduce( totime, gltime, 1, MPI_Real8, MPI_Max, 0, |
110 |
& MPI_Comm_World, ierr ) |
111 |
speed = 1.0e-6_l_*ops/Max( 1.0e-9_l_, gltime ) |
112 |
If ( me == 0 ) Print 1010, n, gltime1, gltime2, gltime, speed, ok |
113 |
Deallocate( a, b, ipvt ) |
114 |
Call cleanup |
115 |
Go To 10 |
116 |
20 If ( me == 0 ) Print 1020 |
117 |
|
118 |
end_time = MPI_Wtime() - start_time |
119 |
If (me == 0) Then |
120 |
Write(6,22) 'Walltime: ', end_time, " s" |
121 |
22 Format(A,F9.3,A) |
122 |
End If |
123 |
Call MPI_Finalize(ierr) |
124 |
! ---------------------------------------------------------------------- |
125 |
1000 Format( 'Full linear solver test, No. of procs = ', i3, ':'/ |
126 |
& '-----------------------------------------------', |
127 |
& '-------------------'/, |
128 |
& ' Order | Factoris. | Solving | Total |', |
129 |
& ' Speed | |'/, |
130 |
& ' n | Time (s) | Time (s) | Time (s) |', |
131 |
& ' (Mflop/s) | OK? |'/, |
132 |
& '-----------------------------------------------', |
133 |
& '-------------------' ) |
134 |
1010 Format( i6, ' |', g11.4, ' |', g11.4, ' |', g11.4,' |', g11.4, |
135 |
& ' |', l3, ' |' ) |
136 |
1020 Format( '-----------------------------------------------', |
137 |
& '-------------------' ) |
138 |
2000 Format( i6 ) |
139 |
! ----------------------------------------------------------------------- |
140 |
End Program mod2b |