나는 84480 라인의 데이터 파일을 가지고 있는데, 각각을 4224 라인을 갖는 서브 루틴에서 20 개의 다른 파일로 나눕니다. 이제이 파일을 다른 서브 루틴에서 하나씩 사용하여 몇 가지 분석을 수행하려고합니다. 하지만 시도했을 때, 런타임 오류가 발생했습니다 : 파일 끝. 여기 런타임 오류 : 파일 끝
메인 프로그램 여기real (kind = 8) :: x(84480),y(84480),x1(4424),y1(4424)
open(1000,file='datafile.txt',status='old')
n = 20 ! number of configurations
m = 84480 ! total number of lines in all configurations
p = 4224 ! number of lines in a single configuration
no = 100 ! starting file number configurations
do i=1,m
read(1000,*) x(i),y(i)
end do
call split(x,y,m,n)
do i = 1,20
open(no)
do j = 1,p
read(no,*) x1(j),y1(j) ! error is occurring in here
end do
no = no + 1
end do
end
의 구조는이 서브 루틴에 fort.119
fort.100
정확하게 출력 파일을 생산
subroutine split(x,y,m,n)
integer , intent (in) :: m,n
real (kind = 8) , intent(in) :: x(m),y(m)
integer :: i,k,j,p
p = 100
do i=0,n-1
k = i*4224
do j = k+1,k+4224
write(p,*) x(j),y(j)
end do
p = p + 1
end do
end subroutine split
에게 서브 루틴이다. 하지만 내가 잘못 가고 다음과 같은 오류
unit = 100, file = 'fort.100' Fortran runtime error: End of file
보여줍니다?
각 파일의 끝에 빈 줄을 쓰십시오. 또한 읽기주기에서 "아니오"파일을 닫으십시오. –
'@ MichaelO.' 아니요, 작동하지 않습니다.같은 오류가 다시 나타납니다. – Joe
그럼 각 파일의 이름을 명시 적으로 지정해야합니다. –