-
Notifications
You must be signed in to change notification settings - Fork 0
/
fsym
54 lines (51 loc) · 1.63 KB
/
fsym
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
#!/usr/bin/perl
# Search for references in fortran source files.
# Usage: perl fsym [symbol]
$SS=@ARGV[0];
@FNAMES=<src/*.inc include/*.inc src/ness/*.inc >;
push @FNAMES,glob("src/*.f");
push @FNAMES,glob("src/components/*.f");
push @FNAMES,glob("src/components/tof/*.f");
push @FNAMES,glob("src/graphics/*.f");
push @FNAMES,glob("src/instruments/*.f");
push @FNAMES,glob("src/matrix/*.f");
push @FNAMES,glob("src/ness/*.f");
push @FNAMES,glob("src/primitives/*.f");
push @FNAMES,glob("src/tables/*.f");
push @FNAMES,glob("src/xml/*.f");
shift @ARGV;
if (@ARGV < 1) {@ARGVAL=@FNAMES; } else { @ARGVAL=@ARGV};
print "search for $SS: \n";
foreach $infile (@ARGVAL) {
open (INFILE,$infile) || die "could not open input file $infile";
$lino = 0;
$linf=$lino;
while (<INFILE>) {
$lino = $lino + 1;
$LINE=$_;
if ( (! m/^[Cc*!](.*)/) && (! m/^[\s\t]*[!]/)) { # ignore comments
# replace tabelators
if (! s/^\t/ / ) {
if (! s/^(.{1})\t/$1 /) {
if (! s/^(.{2})\t/$1 /) {
if (! s/^(.{3})\t/$1 /) {
if (! s/^(.{4})\t/$1 /) {
if (! s/^(.{5})\t/$1 /) {}}}}}}
s/\t/ /g; # in columns 7pp: TAB replaced by three blanks
$_ = substr $_,5;
if ( m/(.*)[!]/ ) {$_="$1\n";};
s/./ /;
# s/%/!/;
if ( m/([\d ,.()+\*\/\-='\%:;]+)$SS([ ,.()+\*\/\-='\%:;\n]+)/i ) {
# print "$infile $lino $1$SS$2 \n";
print "$infile $lino $_";
$linf=$lino;
}
}
}
close INFILE;
if ($linf != 0) { print " \n";}
}
# ( m/^([A-Za-z]\w*)(.*)/ ) {
#}
exit;