Fortran Coder

查看: 19744|回复: 3
打印 上一主题 下一主题

[文件读写] fortran怎样判断文件夹是否存在?

[复制链接]

800

帖子

2

主题

0

精华

大宗师

F 币
3801 元
贡献
2272 点
楼主
发表于 2020-4-10 08:40:01 | 显示全部楼层
fortran标准没有判断文件夹的功能,你可以直接open该文件夹中一个文件 open(10,file='2003336\data.txt',iostat=i,iomsg=msg) ,配合iostat 和 iomsg就知道是否存在文件夹。
[Fortran] 纯文本查看 复制代码
program test
  integer i, k
  character(80) msg
  open(10,file='2003336\data.txt',iostat=i,iomsg=msg)
  if(i/=0) then
    call execute_command_line('md 2003336')
    open(10,file='2003336\data.txt',iostat=i,iomsg=msg)
  end if
  if(i/=0) then
    write(*,"(a)") trim(msg)
  end if
  pause
end
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-15 06:12

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表