Fortran 文件操作
Open(文件操作)
文件操作表如下:
- Unit = int_value
- 单元号int_value为非负整型,即有定义 integer int_value。
- 注:部分单元号可能被系统或者软件(如Abaqus)独占,请尽量使用100以上的单元号以避免冲突,即int_value>=100。
- File = char_string
- 其中,char_string为包含文件名的完整路径字符串,该字符串也可直接表达。
- Status = char_string
- 其中,char_string 为文件打开状态字符串,其主要含:”Old”、”New”、”Replace”、”Scratch”与”Unknown”。
- Action = char_string
- 其中,char_string指文件读写方式,其主要包含:”read” “write” “readwrite”
- IOStat = int_value
- 其中,inv_value为返回整型值。如果Open成功,则返回值为0,否则为不同错误信息对应数值。
- IOMSG = char_value
- 其中,char_value 为字符串。如果Open成功,该字符值不会发生变化。否则,该字符返回错误信息。
Close(文件操作)
文件操作表如下:
- Unit = int_value
char*256 file1
integer status1
char*10 msg1
write(file1,*) "C:\test1.txt"
Open(Unit=101, File=file1, Status="New", Action="Read", IOStat=status1, IOMSG=msg1)
Open(Unit=102, File="C:\test2.txt")
...
Close(Unit=101)
Close(Unit=102)
近期评论