LoginSignup
0
0

fortranでバイナリファイルを読む方法

Last updated at Posted at 2023-07-07

単純バイナリファイル(gradsなど)を読む際のopen文の書き方

以下の方法で開けば、reclなどを指定しなくても、fortran以外で作成したバイナリファイルが簡単に読み込めます。

1) gfortran

form='unformatted'に加えて、access='stream'を指定

gfortran
open(10,file=...,form='unformatted',access='stream')

バイトオーダーがbig_endianの時はconvert='big_endian'を、読み取り専用で開く時はaction='read'を加える

gfortran (big_endian、読み取り専用)
open(10,file=...,form='unformatted',access='stream',convert='big_endian',action='read')

2) ifort

バイナリファイル専用の形式form='binary'がりよう可能

intel fortran
open(10,file=...,form='binary')
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0