1#
2# $Id$
3#
4# perl script searches for both "double" and "single" values of the
5# blas and lapack routines reporting only those files that have a
6# recognized routine.
7#
8# The script is envoked with the command:
9#    perl hasblas.pl file1.f [file2.f ...]
10#
11# This script uses $NWCHEM_TOP/src/config/data.dbl2sngl which is a datafile
12# that containes the specific transliterations for "double" to "single" in
13# simple ascii format.  If you need to add a conversion see the comments in
14# the data file.
15#
16#
17# Written:  3/14/97
18# By:       Ricky A. Kendall
19#           High Performance Computational Chemistry Group
20#           Theory Modeling and Simulation Program
21#           Environmental Molecular Sciences Laboratory
22#           Pacific Northwest National Laboratory
23#           P.O. Box 999
24#           Richland, WA 99352-0999
25#
26#
27$debug = 0;
28@tokens = ();
29$data_path = $ENV{'NWCHEM_TOP'} ;
30if ($data_path eq "") {
31    print "Error: environment variable NWCHEM_TOP is not set\n";
32    print "dbl2sngl: Fatal error\n" ;
33    exit 1;
34}
35if($debug) {print "{$data_path} \n";}
36$data_path = $data_path . "/src/config/data.dbl2sngl";
37if($debug) {print "{$data_path} \n";}
38open (DATA,$data_path) || die " unable to open: $data_path \n";
39while (<DATA>)
40{
41    if (/^[^\#]/) {
42	if($debug) {print $_;}
43	@newtokens = split(' ');
44	$num_tokens = @newtokens ;
45	if($debug){print "tokens: @newtokens $#newtokens $num_tokens \n";}
46	push(@tokens,@newtokens);
47    }
48}
49close (DATA);
50$num_tokens = @tokens;
51if ($debug){
52    print "tokens array @tokens \n";
53    print "number of tokens: $num_tokens\n";
54}
55if ($debug) { print "arguments: @ARGV\n";}
56@found_files = ();
57foreach $file (@ARGV){
58    if ($debug){print "file        : $file\n";}
59    open(FIXEDFILE,$file) || die "Could not open file: $file\n";
60    $found = 0;
61    $lines = 0;
62  FOUNDIT: {
63      while (<FIXEDFILE>) {
64	  $lines ++;
65	  if (/^[ \d]/){
66	      $itok = 0;
67	      while ($itok < $num_tokens && (!($found)))
68	      {
69		  if (/(\W{1})$tokens[$itok](\W{1})/i) {
70		      $found++;
71		      last FOUNDIT;
72		  }
73		  $itok++;
74	      }
75	  }
76      }
77  }
78    if ($found) {push(@found_files,$file);}
79    close(FIXEDFILE);
80}
81$num_found_files = @found_files;
82if ($num_found_files) {
83    print "hasblas: found $num_found_files files: @found_files\n";
84}
85