再帰サブルーチンで生成されるファイルに結果を書き込みたいと思いました。また、ファイル内のデータ(読み取り)をfortran90のメインプログラムの配列に割り当てたいと思いました。
program permutations
implicit none
call generate (position_min)
open(unit=20, file="a.dat", status="old")
do i=1,720
read(20,*)(G(i,j),j=1,6)
end do
contains
recursive subroutine generate (position)
implicit none
integer, intent (in) :: position
integer :: value
if (position > position_max) then
open(unit=20, file="a.dat", status="unknown")
write (20, *) permutation
else
call generate(position+1)
end if
end subroutine generate
end program permutations
このプログラムでは、次のランタイム エラーが発生します。
At line 19 of file p2.f90 (unit = 20, file = 'a.dat')
Fortran runtime error: End of file
これを修正するにはどうすればよいですか?