-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckTrialIdxGenesisFile
executable file
·63 lines (47 loc) · 1.17 KB
/
checkTrialIdxGenesisFile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/perl -w
## Checks for the existence of a file, given a parameter row on the
## command line.
use strict;
if ($#ARGV < 1) {
&usage;
exit -1;
}
my $num_params = shift;
my @param_names;
my @param_vals;
my $counter = 0;
for ($counter = 0; $counter < $num_params; $counter++) {
$param_names[$counter] = shift;
}
for ($counter = 0; $counter < $num_params; $counter++) {
$param_vals[$counter] = shift;
}
my $prefix = '';
my $suffix = '.bin';
if ($#ARGV >= 0) {
$prefix = shift;
$suffix = shift if ($#ARGV >= 0);
}
my $n=0;
my $j = 0;
my @idx = grep {$n++; $j = $n - 1 if /trial/} @param_names;
#print STDERR "Found: @idx = $param_vals[$j]\n";
# Do it again, because we destroyed it?
my $filename = "${prefix}_trial$param_vals[$j]$suffix";
#print STDERR "$filename\n";
# Do the existence check
if ( -r $filename ) {
exit 0;
} else {
exit -1;
}
sub usage {
print << "END";
Usage:
$0 num_params param_names param_vals [prefix [suffix]]
Given the parameters and values, generates a genesis data file and
checks for its exsitence. optional prefix and suffix strings for the
data file name can be specified.
Cengiz Gunay <cgunay\@emory.edu>, 2005/07/01
END
}