재귀 서브 루틴에서 생성 된 파일에 내 결과를 쓰고 싶었습니다. 또한 파일의 데이터 (읽기)를 fortran90의 메인 프로그램에있는 배열에 할당하려고했습니다.recursive 서브 루틴에서 open 문
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
어떻게 수정합니까?
분명히 파일의 길이가 720 줄이 아니고 한 줄에 6 개의 정수가 있습니다. 그보다 작습니다. 좋아하는 텍스트 편집기를 사용하여 실제로 몇 줄이 있는지 확인하십시오 (그리고 6 개의 정수가 모두있는 경우). 그런 다음 코드를 적절하게 편집하십시오. –
단위 20을 쓰지 않고 닫은 상태입니다. – cup