我在运行时收到此错误:
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"inMAIN才能完成这项工作?
经过一些运行时,我也得到了severe (9): permission to access file denied,对这些错误感到困惑。感谢任何帮助谢谢