在我正在改进的程序中,我注意到Fortran没有检测到文件存在与否。这导致了一个尚未修复的逻辑错误。我非常感谢您能否指出问题或错误,并给我更正。无法检测文件是否存在
open(unit=nhist,file=history,iostat=ierr)!This setting cannot exit program if file does not exist because ierr is always 0
if (ierr /=0) then
write(*,*)'!!! error#',ierr,'- Dump file not found'
stop
endif
!I used below statement, the program exits even though a file is existing
open(unit=nhist,file=history,err=700)
700 ierr=-1
if (ierr /=0) then
write(*,*)'!!! error#',ierr,'- Dump file not found'
stop
endif
亲爱的Francescalus,非常感谢你!是。它在我添加'status = old'时起作用。 – Leon