我在运行时遇到此错误:
forrtl: severe (10): Cannot overwrite existing file, unit
27, file C:\Abaqus_JOBS\w.txt
错误发生在分析开始时。
在开始时,文件w.txt
已创建,但最初为空。然后1
写入w.txt
并在我收到上述错误后。
我的代码是:
SUBROUTINE MAIN(....)
C
C UPDATE w counter
C
flag = 0
OPEN(2700, action = "READWRITE", FILE = "C:/Abaqus_JOBS/w.txt", status = "UNKNOWN")
C
READ(2700, *, iostat=stat) w
CALL del_file(2700, stat, flag)
C
w = w + 1
IF (w.GT.nELEM) THEN
nInc = KINC !Update nInc: to check IF failure occurred
ELSE
nInc = 0
ENDIF
C
OPEN(2700, FILE = "C:/Abaqus_JOBS/w.txt",
1 action = "READWRITE", status = "new")
C If I change ´status = "new"´ to `status = "unknown"´ it works...
WRITE(2700,*) w
CLOSE(2700)
C
C computations
C
RETURN
END
SUBROUTINE WMOD(....)
C Subroutine WMOD is called at the end of subroutine MAIN
C
C UPDATE w
OPEN(27, FILE = "C:/Abaqus_JOBS/w.txt",
1 action = "READWRITE", status = "UNKNOWN")
w1 = 0.D0
WRITE(27,*) w1
CLOSE(27)
C
RETURN
END
SUBROUTINE del_file(uFile, stat, flag)
C
IMPLICIT NONE
INTEGER uFile, stat, flag
IF (stat.NE.0 .OR. flag.EQ.1) THEN
C If the unit is not open, stat will be non-zero
CLOSE(unit=uFile, status='delete', iostat=stat)
ELSE
CLOSE(unit=uFile, iostat=stat)
ENDIF
C
END SUBROUTINE
我的问题是为什么我必须在status = "new"
中将status = "unknown"
更改为MAIN
才能使其发挥作用?
经过一段时间运行后,我也得到severe (9): permission to access file denied
,对这些错误感到困惑。任何帮助表示赞赏
感谢
答案 0 :(得分:3)
您告诉代码它已被格式化(FORM
语句中OPEN
的隐式定义),但您尝试使用READ(27)
将其作为无格式文本读取。
这应该是
OPEN(UNIT = 27, FILE = "C:/Abaqus_JOBS/w.txt", status = "UNKNOWN")
READ(27, *, iostat=stat) w