1
# http://developer.intel.com/software/products/compilers/flin/
6
from numpy.distutils.cpuinfo import cpu
7
from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
8
from numpy.distutils.exec_command import find_executable
10
class IntelFCompiler(FCompiler):
12
compiler_type = 'intel'
13
version_pattern = r'Intel\(R\) Fortran Compiler for 32-bit '\
14
'applications, Version (?P<version>[^\s*]*)'
16
for fc_exe in map(find_executable,['ifort','ifc']):
17
if os.path.isfile(fc_exe):
21
'version_cmd' : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
22
% {'fname':dummy_fortran_file()}],
23
'compiler_f77' : [fc_exe,"-72","-w90","-w95"],
24
'compiler_fix' : [fc_exe,"-FI"],
25
'compiler_f90' : [fc_exe],
26
'linker_so' : [fc_exe,"-shared"],
27
'archiver' : ["ar", "-cr"],
32
module_dir_switch = '-module ' # Don't remove ending space!
33
module_include_switch = '-I'
36
opt = self.pic_flags + ["-cm"]
39
def get_flags_free(self):
42
def get_flags_opt(self):
43
return ['-O3','-unroll']
45
def get_flags_arch(self):
47
if cpu.has_fdiv_bug():
48
opt.append('-fdiv_check')
49
if cpu.has_f00f_bug():
50
opt.append('-0f_check')
51
if cpu.is_PentiumPro() or cpu.is_PentiumII() or cpu.is_PentiumIII():
53
elif cpu.is_PentiumM():
54
opt.extend(['-tpp7','-xB'])
55
elif cpu.is_Pentium():
57
elif cpu.is_PentiumIV() or cpu.is_Xeon():
58
opt.extend(['-tpp7','-xW'])
59
if cpu.has_mmx() and not cpu.is_Xeon():
62
opt.append('-arch SSE2')
64
opt.append('-arch SSE')
67
def get_flags_linker_so(self):
68
opt = FCompiler.get_flags_linker_so(self)
69
v = self.get_version()
71
opt.append('-nofor_main')
72
opt.extend(self.get_flags_arch())
75
class IntelItaniumFCompiler(IntelFCompiler):
76
compiler_type = 'intele'
77
version_pattern = r'Intel\(R\) Fortran 90 Compiler Itanium\(TM\) Compiler'\
78
' for the Itanium\(TM\)-based applications,'\
79
' Version (?P<version>[^\s*]*)'
81
for fc_exe in map(find_executable,['ifort','efort','efc']):
82
if os.path.isfile(fc_exe):
86
'version_cmd' : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
87
% {'fname':dummy_fortran_file()}],
88
'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
89
'compiler_fix' : [fc_exe,"-FI"],
90
'compiler_f90' : [fc_exe],
91
'linker_so' : [fc_exe,"-shared"],
92
'archiver' : ["ar", "-cr"],
96
class IntelEM64TFCompiler(IntelFCompiler):
97
compiler_type = 'intelem'
99
version_pattern = r'Intel\(R\) Fortran Compiler for Intel\(R\) EM64T-based '\
100
'applications, Version (?P<version>[^\s*]*)'
102
for fc_exe in map(find_executable,['ifort','efort','efc']):
103
if os.path.isfile(fc_exe):
107
'version_cmd' : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
108
% {'fname':dummy_fortran_file()}],
109
'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
110
'compiler_fix' : [fc_exe,"-FI"],
111
'compiler_f90' : [fc_exe],
112
'linker_so' : [fc_exe,"-shared"],
113
'archiver' : ["ar", "-cr"],
114
'ranlib' : ["ranlib"]
117
class IntelVisualFCompiler(FCompiler):
119
compiler_type = 'intelv'
120
version_pattern = r'Intel\(R\) Fortran Compiler for 32-bit applications, '\
121
'Version (?P<version>[^\s*]*)'
125
if sys.platform=='win32':
126
from distutils.msvccompiler import MSVCCompiler
127
ar_exe = MSVCCompiler().lib
130
'version_cmd' : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
131
% {'fname':dummy_fortran_file()}],
132
'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
133
'compiler_fix' : [fc_exe,"-FI","-4L72","-w"],
134
'compiler_f90' : [fc_exe],
135
'linker_so' : [fc_exe,"-shared"],
136
'archiver' : [ar_exe, "/verbose", "/OUT:"],
140
compile_switch = '/c '
141
object_switch = '/Fo' #No space after /Fo!
142
library_switch = '/OUT:' #No space after /OUT:!
143
module_dir_switch = '/module:' #No space after /module:
144
module_include_switch = '/I'
147
opt = ['/nologo','/MD','/nbs','/Qlowercase','/us']
150
def get_flags_free(self):
153
def get_flags_debug(self):
154
return ['/4Yb','/d2']
156
def get_flags_opt(self):
157
return ['/O3','/Qip','/Qipo','/Qipo_obj']
159
def get_flags_arch(self):
161
if cpu.is_PentiumPro() or cpu.is_PentiumII():
162
opt.extend(['/G6','/Qaxi'])
163
elif cpu.is_PentiumIII():
164
opt.extend(['/G6','/QaxK'])
165
elif cpu.is_Pentium():
167
elif cpu.is_PentiumIV():
168
opt.extend(['/G7','/QaxW'])
173
class IntelItaniumVisualFCompiler(IntelVisualFCompiler):
175
compiler_type = 'intelev'
176
version_pattern = r'Intel\(R\) Fortran 90 Compiler Itanium\(TM\) Compiler'\
177
' for the Itanium\(TM\)-based applications,'\
178
' Version (?P<version>[^\s*]*)'
180
fc_exe = 'efl' # XXX this is a wild guess
181
ar_exe = IntelVisualFCompiler.ar_exe
184
'version_cmd' : [fc_exe, "-FI -V -c %(fname)s.f -o %(fname)s.o" \
185
% {'fname':dummy_fortran_file()}],
186
'compiler_f77' : [fc_exe,"-FI","-w90","-w95"],
187
'compiler_fix' : [fc_exe,"-FI","-4L72","-w"],
188
'compiler_f90' : [fc_exe],
189
'linker_so' : [fc_exe,"-shared"],
190
'archiver' : [ar_exe, "/verbose", "/OUT:"],
194
if __name__ == '__main__':
195
from distutils import log
197
from numpy.distutils.fcompiler import new_fcompiler
198
compiler = new_fcompiler(compiler='intel')
200
print compiler.get_version()