#!/usr/bin/perl

$m1 = 1.e-3;
$m2 = 1.e7;
$dm = 10.;

$v1 = 10.;
$v2 = 70.;
$dv = 5.;

$file = "bolid.in";
open(IN, "<$file");
read(IN, $IN, -s $file);
close(IN);

`rm -r [0-9]*_[0-9]*`;

$m = $m1;
while ($m <= $m2) {
  print "m = $m kg\n";
  $M = sprintf("%012.3f", $m);

  $v = $v1;
  while ($v <= $v2) {
    print "v = $v km/s\n";
    $V = sprintf("%03.0f", $v);
    $dir = $V . "_" . $M;
    `mkdir $dir`;

    $OUT = $IN;
    $OUT =~ s/\$V/$v/;
    $OUT =~ s/\$M/$m/;
    open(OUT, ">$dir/$file");
    print(OUT  $OUT);
    close(OUT);

    `cd $dir; ../bolid < bolid.in > bolid.out; cd ..`;

    $v = $v+$dv;
  }
  $m = $m*$dm;
}

exit;


