以前のリビジョンの文書です


Fortranのtips

連番のファイル名をつける。

ファイル名をcharacter変数に代入して使う。ファイル名の変更にはwrite文を使う。 逐次計算に使える。

character(len=12) filename
...
do i=1,100
  ...
  write(filename,'(a,i4.4,a)') 'hoge',i,'.dat'
  open(10,file=filename)
  ...
    write(10,*) ...
  ...
  close(10)
end do

このファイルをperlに食わせて処理すると便利かも. 以下,サンプル.

#!/usr/bin/perl
$gpfile .= sprintf("%s\n","set terminal gif");
$gpfile .= sprintf("%s\n","set pm3d map");
for($i=1;$i < 30;$i++){
    $file = sprintf("hoge%04d",$i*10);
    $gpfile .= sprintf("%s\n","set output \"$file.gif\"");
    $gpfile .= sprintf("%s\n","splot \"$file.dat\" using 1:2:5");
};
open (GP, "| gnuplot" ) or die "no gnuplot";
print GP "$gpfile";
close GP;
system("gifsicle --delay 50 hoge*gif > anime.gif");

gifsicle はgifアニメを作成するツール.アニメを見るにはgifview.

gifview -a anim.gif
fortran.1243598719.txt.gz · 最終更新: 2009/05/29 21:05 by 10.249.202.233
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0