我用visual studio2013 +intel fortran2013来编写openmp的程序,
调试结果为哦错误,0警告,但是就是运行出错,说是遇到程序断点,错误出现在刚刚读入数据的地方
研究了很久都没结果,求路过的大神指点一二,拜谢!!!
程序如下(求解系数矩阵):
c************************************************************
c 求解大型稠密系数矩阵
c 应用于有限元刚度系数矩阵求解问题
c 采用openmp+fortran进行编译
c 采用无带回的高斯消去法
c************************************************************
program coefficientmatrix
use omp_lib
implicit none
integer,parameter::row=3
integer,parameter::col=3
integer my_id,i,j,k,nth,chunk
real*8 buffer
real*8 A(row,col),x(row),y(row)
chunk=1
c 读入矩阵A和向量y
open(unit=1,file='A_data.txt')
do i=1,row
do j=1,col
read(1,*) A(i,j)
end do
end do
close(1)
open(2,file='y_data.txt')
do i=1,row
read(2,*) y(i)
end do
close(2)
c 输出矩阵A和y的十行十列
print *,'Check the file'
print *,'The matrix A is:'
do i=1,3
print *,(A(i,j),j=1,3)
end do
print *,'The matrix y is:'
do i=1,3
print *,y(i)
end do
c 进入并行区域
c 开始查看所有的线程
!$OMP PARALLEL SHARED(A,X,Y,NTH,CHUNK) PRIVATE(MY_ID,I,J,K,buffer)
my_id=OMP_GET_THREAD_NUM()
!$OMP MASTER
nth=OMP_GET_NUM_THREADS()
print *,'Compute the coefficient matrix with',nth,'threads'
!$OMP END MASTER
print *,'Thread',my_id,'is already'
c 开始进行计算,首先消去下三角
do k=1,row-1
!$OMP DO SCHEDULE(DYNAMIC,chunk)
do i=k+1,row
do j=k,col
buffer=A(i,k)/A(k,k)
A(i,j)=A(i,j)-buffer*A(k,j)
y(i)=y(i)-buffer*y(k)
end do
end do
!$OMP END DO
end do
c 接下来消去上三角
do k=row,2
!$OMP DO SCHEDULE(DYNAMIC,chunk)
do i=k-1,1
do j=i,col
buffer=A(i,k)/A(k,k)
A(i,j)=A(i,j)-buffer*A(k,j)
y(i)=y(i)-buffer*y(k)
end do
end do
!$OMP END DO
end do
c 系数矩阵运算完成,求解矩阵x
!$OMP DO SCHEDULE(DYNAMIC,chunk)
do i=1,row
x(i)=y(i)/A(i,i)
end do
!$OMP END DO
!$OMP END PARALLEL
c 运算结束,关闭并行区域,处理结果
c 初步检查运算结果
print *,'**************************************************'
print *,'The result Matrix x is:'
do i=1,3
print *,x(i)
end do
open(3,file='x_data.txt')
do i=1,row
write(3,10) x(i)
10 FORMAT(2x,f8.0)
end do
close(3)
print *,'**************************************************'
print *,'Done'
end program coefficientmatrix