REPORTER 22.1

Perl Program/Script

Perl program/script

Perl
# Perl Script to extract the 5 smallest timesteps from otf file
#
# Arguments: 1: otf filename

use strict;

# Test to see if there is an argument
if ($#ARGV < 0)
{
print "No otf filename\n";
exit;
}
# test to see if the otf file exists
if ( !(-e $ARGV[0]) )
{
print "otf file $ARGV[0] does not exist\n";
exit;
}
open (OTF, "< $ARGV[0]");
my $n;
my $t = 1.0e+20;
while ( <OTF>)
{
if (/ (\d+) smallest timesteps/)
{
$n = $1;
if ($n > 5) { $n = 5; }
<OTF>;
<OTF>;
for (my $i=0; $i<$n; $i++)
{
$_ = <OTF>;
print $_;
my @f = split;
if ($f[$#f] < $t) { $t = $f[$#f]; }
}
print "VAR TIMESTEP VALUE=\"$t\"\n";
exit;
}
}
close (OTF);