Write unformatted (binary data) to stdout

后端 未结 2 1010
北海茫月
北海茫月 2021-01-19 21:17

I want to write unformatted (binary) data to STDOUT in a Fortran 90 program. I am using AIX Unix and unfortunately it won\'t let me open unit 6 as \"unformatted\". I thought

2条回答
  •  逝去的感伤
    2021-01-19 21:35

    This is more of a comment/addition to @VladimirF than a new answer, but I can't add those yet. You can first inquire about the location of the preconnected I/O units and then open the unformatted connection:

    character(1024) :: stdout
    inquire(6, name = stdout)
    open(11, file = stdout, access = 'stream', action = 'write')
    

    This is probably the most convenient way, but it uses stream access, a Fortran 2003 feature. Without this, you can only use sequential access (which adds header data to each record) or direct access (which does not add headers but requires a fixed record length).

提交回复
热议问题