Chris@87: Chris@87: # http://www.absoft.com/literature/osxuserguide.pdf Chris@87: # http://www.absoft.com/documentation.html Chris@87: Chris@87: # Notes: Chris@87: # - when using -g77 then use -DUNDERSCORE_G77 to compile f2py Chris@87: # generated extension modules (works for f2py v2.45.241_1936 and up) Chris@87: from __future__ import division, absolute_import, print_function Chris@87: Chris@87: import os Chris@87: Chris@87: from numpy.distutils.cpuinfo import cpu Chris@87: from numpy.distutils.fcompiler import FCompiler, dummy_fortran_file Chris@87: from numpy.distutils.misc_util import cyg2win32 Chris@87: Chris@87: compilers = ['AbsoftFCompiler'] Chris@87: Chris@87: class AbsoftFCompiler(FCompiler): Chris@87: Chris@87: compiler_type = 'absoft' Chris@87: description = 'Absoft Corp Fortran Compiler' Chris@87: #version_pattern = r'FORTRAN 77 Compiler (?P[^\s*,]*).*?Absoft Corp' Chris@87: version_pattern = r'(f90:.*?(Absoft Pro FORTRAN Version|FORTRAN 77 Compiler|Absoft Fortran Compiler Version|Copyright Absoft Corporation.*?Version))'+\ Chris@87: r' (?P[^\s*,]*)(.*?Absoft Corp|)' Chris@87: Chris@87: # on windows: f90 -V -c dummy.f Chris@87: # 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: Chris@87: # samt5735(8)$ f90 -V -c dummy.f Chris@87: # f90: Copyright Absoft Corporation 1994-2002; Absoft Pro FORTRAN Version 8.0 Chris@87: # Note that fink installs g77 as f77, so need to use f90 for detection. Chris@87: Chris@87: executables = { Chris@87: 'version_cmd' : None, # set by update_executables Chris@87: 'compiler_f77' : ["f77"], Chris@87: 'compiler_fix' : ["f90"], Chris@87: 'compiler_f90' : ["f90"], Chris@87: 'linker_so' : [""], Chris@87: 'archiver' : ["ar", "-cr"], Chris@87: 'ranlib' : ["ranlib"] Chris@87: } Chris@87: Chris@87: if os.name=='nt': Chris@87: library_switch = '/out:' #No space after /out:! Chris@87: Chris@87: module_dir_switch = None Chris@87: module_include_switch = '-p' Chris@87: Chris@87: def update_executables(self): Chris@87: f = cyg2win32(dummy_fortran_file()) Chris@87: self.executables['version_cmd'] = ['', '-V', '-c', Chris@87: f+'.f', '-o', f+'.o'] Chris@87: Chris@87: def get_flags_linker_so(self): Chris@87: if os.name=='nt': Chris@87: opt = ['/dll'] Chris@87: # The "-K shared" switches are being left in for pre-9.0 versions Chris@87: # of Absoft though I don't think versions earlier than 9 can Chris@87: # actually be used to build shared libraries. In fact, version Chris@87: # 8 of Absoft doesn't recognize "-K shared" and will fail. Chris@87: elif self.get_version() >= '9.0': Chris@87: opt = ['-shared'] Chris@87: else: Chris@87: opt = ["-K", "shared"] Chris@87: return opt Chris@87: Chris@87: def library_dir_option(self, dir): Chris@87: if os.name=='nt': Chris@87: return ['-link', '/PATH:"%s"' % (dir)] Chris@87: return "-L" + dir Chris@87: Chris@87: def library_option(self, lib): Chris@87: if os.name=='nt': Chris@87: return '%s.lib' % (lib) Chris@87: return "-l" + lib Chris@87: Chris@87: def get_library_dirs(self): Chris@87: opt = FCompiler.get_library_dirs(self) Chris@87: d = os.environ.get('ABSOFT') Chris@87: if d: Chris@87: if self.get_version() >= '10.0': Chris@87: # use shared libraries, the static libraries were not compiled -fPIC Chris@87: prefix = 'sh' Chris@87: else: Chris@87: prefix = '' Chris@87: if cpu.is_64bit(): Chris@87: suffix = '64' Chris@87: else: Chris@87: suffix = '' Chris@87: opt.append(os.path.join(d, '%slib%s' % (prefix, suffix))) Chris@87: return opt Chris@87: Chris@87: def get_libraries(self): Chris@87: opt = FCompiler.get_libraries(self) Chris@87: if self.get_version() >= '11.0': Chris@87: opt.extend(['af90math', 'afio', 'af77math', 'amisc']) Chris@87: elif self.get_version() >= '10.0': Chris@87: opt.extend(['af90math', 'afio', 'af77math', 'U77']) Chris@87: elif self.get_version() >= '8.0': Chris@87: opt.extend(['f90math', 'fio', 'f77math', 'U77']) Chris@87: else: Chris@87: opt.extend(['fio', 'f90math', 'fmath', 'U77']) Chris@87: if os.name =='nt': Chris@87: opt.append('COMDLG32') Chris@87: return opt Chris@87: Chris@87: def get_flags(self): Chris@87: opt = FCompiler.get_flags(self) Chris@87: if os.name != 'nt': Chris@87: opt.extend(['-s']) Chris@87: if self.get_version(): Chris@87: if self.get_version()>='8.2': Chris@87: opt.append('-fpic') Chris@87: return opt Chris@87: Chris@87: def get_flags_f77(self): Chris@87: opt = FCompiler.get_flags_f77(self) Chris@87: opt.extend(['-N22', '-N90', '-N110']) Chris@87: v = self.get_version() Chris@87: if os.name == 'nt': Chris@87: if v and v>='8.0': Chris@87: opt.extend(['-f', '-N15']) Chris@87: else: Chris@87: opt.append('-f') Chris@87: if v: Chris@87: if v<='4.6': Chris@87: opt.append('-B108') Chris@87: else: Chris@87: # Though -N15 is undocumented, it works with Chris@87: # Absoft 8.0 on Linux Chris@87: opt.append('-N15') Chris@87: return opt Chris@87: Chris@87: def get_flags_f90(self): Chris@87: opt = FCompiler.get_flags_f90(self) Chris@87: opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX", Chris@87: "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"]) Chris@87: if self.get_version(): Chris@87: if self.get_version()>'4.6': Chris@87: opt.extend(["-YDEALLOC=ALL"]) Chris@87: return opt Chris@87: Chris@87: def get_flags_fix(self): Chris@87: opt = FCompiler.get_flags_fix(self) Chris@87: opt.extend(["-YCFRL=1", "-YCOM_NAMES=LCS", "-YCOM_PFX", "-YEXT_PFX", Chris@87: "-YCOM_SFX=_", "-YEXT_SFX=_", "-YEXT_NAMES=LCS"]) Chris@87: opt.extend(["-f", "fixed"]) Chris@87: return opt Chris@87: Chris@87: def get_flags_opt(self): Chris@87: opt = ['-O'] Chris@87: return opt Chris@87: Chris@87: if __name__ == '__main__': Chris@87: from distutils import log Chris@87: log.set_verbosity(2) Chris@87: from numpy.distutils.fcompiler import new_fcompiler Chris@87: compiler = new_fcompiler(compiler='absoft') Chris@87: compiler.customize() Chris@87: print(compiler.get_version())