LoginSignup
5
1

More than 5 years have passed since last update.

fortranで変数の値をファイル名に入れる

Last updated at Posted at 2014-12-06
integer :: i !ファイル名に入れたい変数
character :: filename*20

!なんかの処理

write(filename,*) i !i->filename 変換
!read(filename,*) i !ちなみに逆変換も可能

filename='output_'//trim(adjustl(filename))//'.dat' !adjustlで左寄せにしてからtrimで末尾の空白除去,拡張子等をくっつける

print *, filename !表示してみる
open(20,file=filename, status='replace') !使う
5
1
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
5
1