getting free unit number in fortran

后端 未结 2 782
我在风中等你
我在风中等你 2020-12-10 04:12

I need to develop a library that opens a file and parses the stuff. The unit number, due to fortran IO style, must be decided by me, but I can\'t know what other units are

2条回答
  •  被撕碎了的回忆
    2020-12-10 04:20

    In fortran 2008, there's a newunit clause to open that you can use

       integer :: myunit
    
       ..
       open(newunit=myunit,file='file.dat')
       ...
       close(myunit)
    

    but that's new enough that not all compilers support it yet. If yours doesn't yet, you can mock one up yourself; there's a good example on the fortran wiki.

提交回复
热议问题