在我正在改進的程序中,我注意到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