ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/moreconfigure.pl
Revision: 1.8
Committed: Tue Oct 13 19:22:37 2009 UTC (13 years, 11 months ago) by arta
Content type: text/plain
Branch: MAIN
Changes since 1.7: +55 -0 lines
Log Message:
Add support for ia64 machines, and specific machines (j1, d02, database servers, cluster machines, dcs) to the make/build

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 arta 1.8 # Also, set DEFAULT values for Stanford-specific (if running at Stanford) make variables.
5     # To override the DEFAULT Stanford values, create a config.local file.
6    
7     use Sys::Hostname;
8 arta 1.1
9     use constant ICCMAJOR => 9;
10     use constant ICCMINOR => 0;
11     use constant IFORTMAJOR => 9;
12     use constant IFORTMINOR => 0;
13 arta 1.3 use constant GCCMAJOR => 3;
14 arta 1.1 use constant GCCMINOR => 0;
15     use constant GFORTMAJOR => 4;
16     use constant GFORTMINOR => 2;
17    
18     my($arg);
19     my($pos);
20     my($outfile);
21     my($major);
22     my($minor);
23     my($hasicc);
24     my($hasifort);
25     my($hasgcc);
26     my($hasgfort);
27    
28     while ($arg = shift(@ARGV))
29     {
30     if (($pos = index($arg, "-f", 0)) == 0)
31     {
32     $outfile = substr($arg, 2);
33     }
34     }
35    
36     $hasicc = 0;
37     $hasifort = 0;
38     $hasgcc = 0;
39     $hasgfort = 0;
40    
41     if (defined($outfile))
42     {
43     # Try icc
44 arta 1.2 $ans = `icc -V 2>&1`;
45 arta 1.1
46 arta 1.2 if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
47 arta 1.1 {
48     $major = $1;
49     $minor = $2;
50    
51     if (IsVersion($major, $minor, ICCMAJOR, ICCMINOR))
52     {
53     $hasicc = 1;
54     }
55     }
56    
57     # Try gcc
58     if (!$hasicc)
59     {
60     $ans = `gcc -v 2>&1`;
61 arta 1.2 if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
62 arta 1.1 {
63     $major = $1;
64     $minor = $2;
65    
66     if (IsVersion($major, $minor, GCCMAJOR, GCCMINOR))
67     {
68     $hasgcc = 1;
69     }
70     }
71     }
72    
73     # Try ifort
74     $ans = `ifort -V 2>&1`;
75 arta 1.2 if (defined($ans) && $ans =~ /Version\s+(\d+)\.(\d+)/)
76 arta 1.1 {
77     $major = $1;
78     $minor = $2;
79    
80     if (IsVersion($major, $minor, IFORTMAJOR, IFORTMINOR))
81     {
82     $hasifort = 1;
83     }
84     }
85    
86     # Try gfortran
87     if (!$hasifort)
88     {
89     $ans = `gfortran -v 2>&1`;
90 arta 1.2 if (defined($ans) && $ans =~ /gcc\s+version\s+(\d+)\.(\d+)/)
91 arta 1.1 {
92     $major = $1;
93     $minor = $2;
94    
95     if (IsVersion($major, $minor, GFORTMAJOR, GFORTMINOR))
96     {
97     $hasgfort = 1;
98     }
99     }
100     }
101    
102     open(OUTFILE, ">>$outfile") || die "Couldn't open file $outfile for writing.\n";
103    
104     # Error messages
105     if (!$hasicc && !$hasgcc)
106     {
107 arta 1.7 print "Fatal error: Acceptable C compiler not found! You will be unable to build the DRMS library.\n";
108 arta 1.1 }
109     elsif ($hasicc)
110     {
111 rick 1.4 print OUTFILE "JSOC_AUTOCOMPILER = icc\n";
112 arta 1.1 }
113     else
114     {
115 rick 1.4 print OUTFILE "JSOC_AUTOCOMPILER = gcc\n";
116 arta 1.1 }
117    
118     if (!$hasifort && !$hasgfort)
119     {
120 arta 1.7 print "Warning: Acceptable Fortran compiler not found! Fortran interface will not be built, and you will be unable to build Fortran modules.\n";
121 arta 1.1 }
122     elsif ($hasifort)
123     {
124 rick 1.4 print OUTFILE "JSOC_AUTOFCOMPILER = ifort\n";
125 arta 1.1 }
126     else
127     {
128 rick 1.4 print OUTFILE "JSOC_AUTOFCOMPILER = gfortran\n";
129 arta 1.1 }
130    
131 arta 1.8 # Set DEFAULT values for Stanford-specific (if running at Stanford) make variables.
132     if (-e "suflag.txt")
133     {
134     my($hostname);
135     my($machtype);
136     my($line);
137    
138     if (open(SUFLAG, "<suflag.txt"))
139     {
140     # first figure out what type of Stanford machine this script is running on
141     $hostname = hostname();
142    
143     if ($hostname =~ /j1/)
144     {
145     $machtype = "j1";
146     }
147     elsif ($hostname =~ /d02/)
148     {
149     $machtype = "d02";
150     }
151     elsif ($hostname =~ /hmidb/)
152     {
153     $machtype = "dbserver";
154     }
155     elsif ($hostname =~ /cl1n0/)
156     {
157     $machtype = "cluster";
158     }
159     elsif ($hostname =~ /dcs/)
160     {
161     $machtype = "dcs";
162     }
163    
164     if (defined($machtype))
165     {
166     print OUTFILE "MACHTYPE = $machtype\n";
167     }
168    
169     while (defined($line = <SUFLAG>))
170     {
171     chomp($line);
172     if ($line !~ /^#/ && $line =~ /\S+/)
173     {
174     print OUTFILE "$line\n";
175     }
176     }
177    
178     close(SUFLAG);
179     }
180     }
181    
182 arta 1.1 close(OUTFILE);
183     }
184    
185     sub IsVersion
186     {
187     my($maj1) = $_[0];
188     my($min1) = $_[1];
189     my($maj2) = $_[2];
190     my($min2) = $_[3];
191    
192     my($res) = 0;
193    
194     if ($maj1 > $maj2 || ($maj1 == $maj2 && $min1 >= $min2))
195     {
196     $res = 1;
197     }
198    
199     return $res;
200     }