使用fortran open语句时处理语法错误

时间:2021-12-02 15:38:20

I am opening a file which has to be deleted at the end. The following command complains about using dispose.

我正在打开一个必须在最后删除的文件。以下命令抱怨使用dispose。

f = "espy.tmp";  h = "formatted";  r = "read" 
Open (newunit=u, file=f, form=h, action=r,  &
  status="old", dispose="delete")

lib/core.f:177:21:

     status="old", dispose="delete")
                 1
Error: Syntax error in OPEN statement at (1)

1 个解决方案

#1


Dispose is a non-standard compiler extension (and not supported by your compiler). As described in this answer, the standard way to do this is to delete the file on closure:

Dispose是一个非标准的编译器扩展(编译器不支持)。如本回答所述,执行此操作的标准方法是在关闭时删除文件:

f = "espy.tmp";  h = "formatted";  r = "read" 
Open (newunit=u, file=f, form=h, action=r,  &
  status="old")

close(u, status='delete')

Or, you could use temporary/scratch files (no filename):

或者,您可以使用临时/临时文件(无文件名):

f = "espy.tmp";  h = "formatted";  r = "read" 
Open (newunit=u, form=h, action=r,  &
  status="old", status='scratch')

#1


Dispose is a non-standard compiler extension (and not supported by your compiler). As described in this answer, the standard way to do this is to delete the file on closure:

Dispose是一个非标准的编译器扩展(编译器不支持)。如本回答所述,执行此操作的标准方法是在关闭时删除文件:

f = "espy.tmp";  h = "formatted";  r = "read" 
Open (newunit=u, file=f, form=h, action=r,  &
  status="old")

close(u, status='delete')

Or, you could use temporary/scratch files (no filename):

或者,您可以使用临时/临时文件(无文件名):

f = "espy.tmp";  h = "formatted";  r = "read" 
Open (newunit=u, form=h, action=r,  &
  status="old", status='scratch')