(file) Return to moreconfigure.pl CVS log (file) (dir) Up to [Development] / JSOC

  1 arta  1.1 #!/usr/bin/perl -w 
  2           
  3           # Determine which compilers are installed; then set make variables to indicate that
  4           
  5           use constant ICCMAJOR => 9;
  6           use constant ICCMINOR => 0;
  7           use constant IFORTMAJOR => 9;
  8           use constant IFORTMINOR => 0;
  9 arta  1.3 use constant GCCMAJOR => 3;
 10 arta  1.1 use constant GCCMINOR => 0;
 11           use constant GFORTMAJOR => 4;
 12           use constant GFORTMINOR => 2;
 13           
 14           my($arg);
 15           my($pos);
 16           my($outfile);
 17           my($major);
 18           my($minor);
 19           my($hasicc);
 20           my($hasifort);
 21           my($hasgcc);
 22           my($hasgfort);
 23           
 24           while ($arg = shift(@ARGV))
 25           {
 26               if (($pos = index($arg, "-f", 0)) == 0)
 27               {
 28           	$outfile = substr($arg, 2);
 29               }
 30           }
 31 arta  1.1 
 32           $hasicc = 0;
 33           $hasifort = 0;
 34           $hasgcc = 0;
 35           $hasgfort = 0;
 36           
 37           if (defined($outfile))
 38           {
 39               # Try icc
 40 arta  1.2     $ans = `icc -V 2>&1`;      
 41 arta  1.1 
 42 arta  1.2     if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
 43 arta  1.1     {
 44                   $major = $1;
 45                   $minor = $2;
 46           
 47                   if (IsVersion($major, $minor, ICCMAJOR, ICCMINOR))
 48                   {
 49                       $hasicc = 1;
 50                   }
 51               }
 52           
 53               # Try gcc
 54               if (!$hasicc)
 55               {
 56                   $ans = `gcc -v 2>&1`;
 57 arta  1.2         if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
 58 arta  1.1         {
 59                       $major = $1;
 60                       $minor = $2;
 61           
 62                       if (IsVersion($major, $minor, GCCMAJOR, GCCMINOR))
 63                       {
 64                           $hasgcc = 1;
 65                       }
 66                   }
 67               }
 68           
 69               # Try ifort
 70               $ans = `ifort -V 2>&1`;
 71 arta  1.2     if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
 72 arta  1.1     {
 73                   $major = $1;
 74                   $minor = $2;
 75           
 76                   if (IsVersion($major, $minor, IFORTMAJOR, IFORTMINOR))
 77                   {
 78                       $hasifort = 1;
 79                   }
 80               }
 81           
 82               # Try gfortran
 83               if (!$hasifort)
 84               {
 85                   $ans = `gfortran -v 2>&1`;
 86 arta  1.2         if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
 87 arta  1.1         {
 88                       $major = $1;
 89                       $minor = $2;
 90           
 91                       if (IsVersion($major, $minor, GFORTMAJOR, GFORTMINOR))
 92                       {
 93                           $hasgfort = 1;
 94                       }
 95                   }
 96               }
 97           
 98               open(OUTFILE, ">>$outfile") || die "Couldn't open file $outfile for writing.\n";
 99           
100               # Error messages
101               if (!$hasicc && !$hasgcc)
102               {
103                   print "ERROR: Acceptable C compiler not found!\n";
104               }
105               elsif ($hasicc)
106               {
107 rick  1.4         print OUTFILE "JSOC_AUTOCOMPILER = icc\n";
108 arta  1.1     }
109               else
110               {
111 rick  1.4         print OUTFILE "JSOC_AUTOCOMPILER = gcc\n";
112 arta  1.1     }
113           
114               if (!$hasifort && !$hasgfort)
115               {
116                   print "ERROR: Acceptable Fortran compiler not found!\n";
117               }
118               elsif ($hasifort)
119               {
120 rick  1.4         print OUTFILE "JSOC_AUTOFCOMPILER = ifort\n";
121 arta  1.1     }
122               else
123               {
124 rick  1.4         print OUTFILE "JSOC_AUTOFCOMPILER = gfortran\n";
125 arta  1.1     }
126           
127               close(OUTFILE);
128           }
129           
130           sub IsVersion
131           {
132               my($maj1) = $_[0];
133               my($min1) = $_[1];
134               my($maj2) = $_[2];
135               my($min2) = $_[3];
136           
137               my($res) = 0;
138               
139               if ($maj1 > $maj2 || ($maj1 == $maj2 && $min1 >= $min2))
140               {
141                   $res = 1;
142               }
143               
144               return $res;
145           }

Karen Tian
Powered by
ViewCVS 0.9.4