1 subroutine iteration(nnod,dGfile)
2 include 'mpif.h'
3 include 'type'
4 integer nnod,i,j,k,iter
5 real*8 xn(NDIM),xn_temp(NDIM),x(NDIM)
6 real*8 summa,e,eps,ar,epsmax,mflops,temp
7 CHARACTER dGfile*11
8 double precision t
9 2001 format(I5,'|',I10,'|',I10,'|',F10.5,'|',F10.8,'|',F10.6)
10 2002 format('NP','|','Dimension ','|','Iteration ','|',
11 * 'Time ','|','EPS ','|','MFLOPS')
12 e=1d-10
13 call MPI_Barrier(comm,ierr)
14 t=MPI_Wtime()
15 do i=1,i_shag
16 ar=b(i,i+i_step)
17 c(i)=c(i)/ar
18 do j=1,nnod
19 b(i,j)=-b(i,j)/ar
20 end do
21 b(i,i+i_step)=1
22 end do
23 call MPI_Allgather(c,i_shag_const,mpi_real8,
24 * xn,i_shag_const,mpi_real8,comm,ierr)
25 do i=1,nnod
26 x(i)=xn(i)
27 xn_temp(i)=0.d0
28 end do
29 iter=0
30 13 continue
31 iter=iter+1
32 do i=1,i_shag
33 summa=c(i)
34 do j=1,nnod,8
35 summa=summa+xn(j)*b(i,j)+xn(j+1)*b(i,j+1)+
36 * +xn(j+2)*b(i,j+2)+xn(j+3)*b(i,j+3)+
37 * +xn(j+4)*b(i,j+4)+xn(j+5)*b(i,j+5)+
38 * +xn(j+6)*b(i,j+6)+xn(j+7)*b(i,j+7)
39 end do
40 xn_temp(i)=summa-xn(i+i_step)*b(i,i+i_step)
41 end do
42 call MPI_Allgather(xn_temp,i_shag_const,mpi_real8,
43 * x,i_shag_const,mpi_real8,comm,ierr)
44 eps=0.d0
45 do i=1,nnod
46 temp=dabs(x(i)-xn(i))
47 if(temp.gt.eps) then
48 eps=temp
49 end if
50 xn(i)=x(i)
51 end do
52 if (e.le.eps) goto 13
53 do i=1,nnod
54 c(i)=xn(i)
55 end do
56 t=MPI_Wtime()-t
57 mflops=(3*nnod*(nnod-1)*iter)/(t*1000000)
58 if (my_id.eq.0) then
59 OPEN(7,FILE=dGfile(1:10)//'.rez',ACCESS='APPEND')
60 Write (7,2001) np,nnod,iter,t,eps,mflops
61 close(7)
62 Write (*,2001) np,nnod,iter,t,eps,mflops
63 end if
64 return
65 end
Рис. 68. Листинг подпрограммы для реализации алгоритма решения СЛАУ методом простой итерации (общий для стационарной и нестационарной задачи)