私は84480行のデータファイルを持っており、それぞれ4224行のサブルーチンで20個のファイルに分割しています。今度は、これらのファイルを別のサブルーチンで1つずつ使用して分析したいと思います。しかし、私が試したとき、私はランタイムエラーを取得しています:ファイルの終わり。ここでランタイムエラー:ファイルの終わり
は、メインプログラムここ
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
です。しかし、次のエラーが表示されます。
どこが間違っていますか?
各ファイルの末尾に空白行を書き込んでください。また、読み取りサイクルで "no"ファイルを閉じます。 –
'@ MichaelO.'いいえ、動作していません。再度同じエラーが表示されます。 – Joe
さて、各ファイルの読み書きのために明示的に名前をつけなければなりません。 –