Chris@87
|
1
|
Chris@87
|
2 # http://www.absoft.com/literature/osxuserguide.pdf
|
Chris@87
|
3 # http://www.absoft.com/documentation.html
|
Chris@87
|
4
|
Chris@87
|
5 # Notes:
|
Chris@87
|
6 # - when using -g77 then use -DUNDERSCORE_G77 to compile f2py
|
Chris@87
|
7 # generated extension modules (works for f2py v2.45.241_1936 and up)
|
Chris@87
|
8 from __future__ import division, absolute_import, print_function
|
Chris@87
|
9
|
Chris@87
|
10 import os
|
Chris@87
|
11
|
Chris@87
|
12 from numpy.distutils.cpuinfo import cpu
|
Chris@87
|
13 from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file
|
Chris@87
|
14 from numpy.distutils.misc_util import cyg2win32
|
Chris@87
|
15
|
Chris@87
|
16 compilers = ['AbsoftFCompiler']
|
Chris@87
|
17
|
Chris@87
|
18 class AbsoftFCompiler(FCompiler):
|
Chris@87
|
19
|
Chris@87
|
20 compiler_type = 'absoft'
|
Chris@87
|
21 description = 'Absoft Corp Fortran Compiler'
|
Chris@87
|
22 #version_pattern = r'FORTRAN 77 Compiler (?P<version>[^\s*,]*).*?Absoft Corp'
|
Chris@87
|
23 version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\
|
Chris@87
|
24 r' (?P<version>[^\s*,]*)(.*?Absoft Corp|)'
|
Chris@87
|
25
|
Chris@87
|
26 # on windows: f90 -V -c dummy.f
|
Chris@87
|
27 # f90: Copyright Absoft Corporation 1994-1998 mV2; Cray Research, Inc. 1994-1996 CF90 (2.x.x.x f36t87) Version 2.3 Wed Apr 19, 2006 13:05:16
|
Chris@87
|
28
|
Chris@87
|
29 # samt5735(8)$ f90 -V -c dummy.f
|
Chris@87
|
30 # f90: Copyright Absoft Corporation 1994-2002; Absoft Pro FORTRAN Version 8.0
|
Chris@87
|
31 # Note that fink installs g77 as f77, so need to use f90 for detection.
|
Chris@87
|
32
|
Chris@87
|
33 executables = {
|
Chris@87
|
34 'version_cmd' : None, # set by update_executables
|
Chris@87
|
35 'compiler_f77' : ["f77"],
|
Chris@87
|
36 'compiler_fix' : ["f90"],
|
Chris@87
|
37 'compiler_f90' : ["f90"],
|
Chris@87
|
38 'linker_so' : ["<F90>"],
|
Chris@87
|
39 'archiver' : ["ar", "-cr"],
|
Chris@87
|
40 'ranlib' : ["ranlib"]
|
Chris@87
|
41 }
|
Chris@87
|
42
|
Chris@87
|
43 if os.name=='nt':
|
Chris@87
|
44 library_switch = '/out:' #No space after /out:!
|
Chris@87
|
45
|
Chris@87
|
46 module_dir_switch = None
|
Chris@87
|
47 module_include_switch = '-p'
|
Chris@87
|
48
|
Chris@87
|
49 def update_executables(self):
|
Chris@87
|
50 f = cyg2win32(dummy_fortran_file())
|
Chris@87
|
51 self.executables['version_cmd'] = ['<F90>', '-V', '-c',
|
Chris@87
|
52 f+'.f', '-o', f+'.o']
|
Chris@87
|
53
|
Chris@87
|
54 def get_flags_linker_so(self):
|
Chris@87
|
55 if os.name=='nt':
|
Chris@87
|
56 opt = ['/dll']
|
Chris@87
|
57 # The "-K shared" switches are being left in for pre-9.0 versions
|
Chris@87
|
58 # of Absoft though I don't think versions earlier than 9 can
|
Chris@87
|
59 # actually be used to build shared libraries. In fact, version
|
Chris@87
|
60 # 8 of Absoft doesn't recognize "-K shared" and will fail.
|
Chris@87
|
61 elif self.get_version() >= '9.0':
|
Chris@87
|
62 opt = ['-shared']
|
Chris@87
|
63 else:
|
Chris@87
|
64 opt = ["-K", "shared"]
|
Chris@87
|
65 return opt
|
Chris@87
|
66
|
Chris@87
|
67 def library_dir_option(self, dir):
|
Chris@87
|
68 if os.name=='nt':
|
Chris@87
|
69 return ['-link', '/PATH:"%s"' % (dir)]
|
Chris@87
|
70 return "-L" + dir
|
Chris@87
|
71
|
Chris@87
|
72 def library_option(self, lib):
|
Chris@87
|
73 if os.name=='nt':
|
Chris@87
|
74 return '%s.lib' % (lib)
|
Chris@87
|
75 return "-l" + lib
|
Chris@87
|
76
|
Chris@87
|
77 def get_library_dirs(self):
|
Chris@87
|
78 opt = FCompiler.get_library_dirs(self)
|
Chris@87
|
79 d = os.environ.get('ABSOFT')
|
Chris@87
|
80 if d:
|
Chris@87
|
81 if self.get_version() >= '10.0':
|
Chris@87
|
82 # use shared libraries, the static libraries were not compiled -fPIC
|
Chris@87
|
83 prefix = 'sh'
|
Chris@87
|
84 else:
|
Chris@87
|
85 prefix = ''
|
Chris@87
|
86 if cpu.is_64bit():
|
Chris@87
|
87 suffix = '64'
|
Chris@87
|
88 else:
|
Chris@87
|
89 suffix = ''
|
Chris@87
|
90 opt.append(os.path.join(d, '%slib%s' % (prefix, suffix)))
|
Chris@87
|
91 return opt
|
Chris@87
|
92
|
Chris@87
|
93 def get_libraries(self):
|
Chris@87
|
94 opt = FCompiler.get_libraries(self)
|
Chris@87
|
95 if self.get_version() >= '11.0':
|
Chris@87
|
96 opt.extend(['af90math', 'afio', 'af77math', 'amisc'])
|
Chris@87
|
97 elif self.get_version() >= '10.0':
|
Chris@87
|
98 opt.extend(['af90math', 'afio', 'af77math', 'U77'])
|
Chris@87
|
99 elif self.get_version() >= '8.0':
|
Chris@87
|
100 opt.extend(['f90math', 'fio', 'f77math', 'U77'])
|
Chris@87
|
101 else:
|
Chris@87
|
102 opt.extend(['fio', 'f90math', 'fmath', 'U77'])
|
Chris@87
|
103 if os.name =='nt':
|
Chris@87
|
104 opt.append('COMDLG32')
|
Chris@87
|
105 return opt
|
Chris@87
|
106
|
Chris@87
|
107 def get_flags(self):
|
Chris@87
|
108 opt = FCompiler.get_flags(self)
|
Chris@87
|
109 if os.name != 'nt':
|
Chris@87
|
110 opt.extend(['-s'])
|
Chris@87
|
111 if self.get_version():
|
Chris@87
|
112 if self.get_version()>='8.2':
|
Chris@87
|
113 opt.append('-fpic')
|
Chris@87
|
114 return opt
|
Chris@87
|
115
|
Chris@87
|
116 def get_flags_f77(self):
|
Chris@87
|
117 opt = FCompiler.get_flags_f77(self)
|
Chris@87
|
118 opt.extend(['-N22', '-N90', '-N110'])
|
Chris@87
|
119 v = self.get_version()
|
Chris@87
|
120 if os.name == 'nt':
|
Chris@87
|
121 if v and v>='8.0':
|
Chris@87
|
122 opt.extend(['-f', '-N15'])
|
Chris@87
|
123 else:
|
Chris@87
|
124 opt.append('-f')
|
Chris@87
|
125 if v:
|
Chris@87
|
126 if v<='4.6':
|
Chris@87
|
127 opt.append('-B108')
|
Chris@87
|
128 else:
|
Chris@87
|
129 # Though -N15 is undocumented, it works with
|
Chris@87
|
130 # Absoft 8.0 on Linux
|
Chris@87
|
131 opt.append('-N15')
|
Chris@87
|
132 return opt
|
Chris@87
|
133
|
Chris@87
|
134 def get_flags_f90(self):
|
Chris@87
|
135 opt = FCompiler.get_flags_f90(self)
|
Chris@87
|
136 opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX",
|
Chris@87
|
137 "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"])
|
Chris@87
|
138 if self.get_version():
|
Chris@87
|
139 if self.get_version()>'4.6':
|
Chris@87
|
140 opt.extend(["-YDEALLOC=ALL"])
|
Chris@87
|
141 return opt
|
Chris@87
|
142
|
Chris@87
|
143 def get_flags_fix(self):
|
Chris@87
|
144 opt = FCompiler.get_flags_fix(self)
|
Chris@87
|
145 opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX",
|
Chris@87
|
146 "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"])
|
Chris@87
|
147 opt.extend(["-f", "fixed"])
|
Chris@87
|
148 return opt
|
Chris@87
|
149
|
Chris@87
|
150 def get_flags_opt(self):
|
Chris@87
|
151 opt = ['-O']
|
Chris@87
|
152 return opt
|
Chris@87
|
153
|
Chris@87
|
154 if __name__ == '__main__':
|
Chris@87
|
155 from distutils import log
|
Chris@87
|
156 log.set_verbosity(2)
|
Chris@87
|
157 from numpy.distutils.fcompiler import new_fcompiler
|
Chris@87
|
158 compiler = new_fcompiler(compiler='absoft')
|
Chris@87
|
159 compiler.customize()
|
Chris@87
|
160 print(compiler.get_version())
|