我在调用子程序读入数据赋值到动态数组中时,一赋值就报 访问冲突,一直搞不懂问题的原因是什么,求助
[Fortran] 纯文本查看 复制代码 program main
implicit none
character,allocatable:: A(:,:)
integer:: m,n,nx,ny
character(len=200):: filename
integer:: i,j,iunit,mbc
filename="d:\2.txt"
nx=2
ny=2
allocate(A(nx,ny))
call read_txt(A,1,filename,m,n,nx,ny)
print*,A
end program
subroutine read_txt(input,iunit,filename,m,n,nx,ny)
implicit none
!函数内部变量声明
integer:: iunit,m,n
integer:: nx,ny
character(len=200):: filename
character(len=200):: input(nx,ny)
!局部变量
integer:: i,j
character(len=200):: line
character,allocatable:: temp(:)
open(unit=iunit,file=filename)
read(iunit,"(a)")line
read(line,*)m,n
allocate(temp(n))
do i=1,m
read(iunit,"(a)")line
read(line,*)(temp(j),j=1,n)
do j=1,n
!print*,temp(j)
input(i,j)=temp(j)
enddo
enddo
close(iunit)
end subroutine
|