ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/moreconfigure.pl
Revision: 1.1
Committed: Fri Jun 5 21:03:51 2009 UTC (14 years, 3 months ago) by arta
Content type: text/plain
Branch: MAIN
Log Message:
Modify make system to accommodate non-ifort fortran compiler. All the flags previously defined were specific to ifort. I also added a script that determines which C and Fortran compilers are installed, and then sets those in the make system. You can override the compilers with environment variables - CUSTOM_COMPILER and CUSTOM_FCOMPILER.; Also fix broken gcc build in proj/lev0

File Contents

# User Rev Content
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     use constant GCCMAJOR => 4;
10     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    
32     $hasicc = 0;
33     $hasifort = 0;
34     $hasgcc = 0;
35     $hasgfort = 0;
36    
37     if (defined($outfile))
38     {
39     # Try icc
40     $ans = `icc -V 2>&1`;
41    
42     if ($ans =~ /Version\s+(\d+)\.(\d+)/)
43     {
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     if ($ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
58     {
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     if ($ans =~ /Version\s+(\d+)\.(\d+)/)
72     {
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     if ($ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
87     {
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     print OUTFILE "AUTOCOMPILER = icc\n";
108     }
109     else
110     {
111     print OUTFILE "AUTOCOMPILER = gcc\n";
112     }
113    
114     if (!$hasifort && !$hasgfort)
115     {
116     print "ERROR: Acceptable Fortran compiler not found!\n";
117     }
118     elsif ($hasifort)
119     {
120     print OUTFILE "AUTOFCOMPILER = ifort\n";
121     }
122     else
123     {
124     print OUTFILE "AUTOFCOMPILER = gfortran\n";
125     }
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     }