compaq.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #http://www.compaq.com/fortran/docs/
  2. from __future__ import division, absolute_import, print_function
  3. import os
  4. import sys
  5. from numpy.distutils.fcompiler import FCompiler
  6. from numpy.distutils.compat import get_exception
  7. from distutils.errors import DistutilsPlatformError
  8. compilers = ['CompaqFCompiler']
  9. if os.name != 'posix' or sys.platform[:6] == 'cygwin' :
  10. # Otherwise we'd get a false positive on posix systems with
  11. # case-insensitive filesystems (like darwin), because we'll pick
  12. # up /bin/df
  13. compilers.append('CompaqVisualFCompiler')
  14. class CompaqFCompiler(FCompiler):
  15. compiler_type = 'compaq'
  16. description = 'Compaq Fortran Compiler'
  17. version_pattern = r'Compaq Fortran (?P<version>[^\s]*).*'
  18. if sys.platform[:5]=='linux':
  19. fc_exe = 'fort'
  20. else:
  21. fc_exe = 'f90'
  22. executables = {
  23. 'version_cmd' : ['<F90>', "-version"],
  24. 'compiler_f77' : [fc_exe, "-f77rtl", "-fixed"],
  25. 'compiler_fix' : [fc_exe, "-fixed"],
  26. 'compiler_f90' : [fc_exe],
  27. 'linker_so' : ['<F90>'],
  28. 'archiver' : ["ar", "-cr"],
  29. 'ranlib' : ["ranlib"]
  30. }
  31. module_dir_switch = '-module ' # not tested
  32. module_include_switch = '-I'
  33. def get_flags(self):
  34. return ['-assume no2underscore', '-nomixed_str_len_arg']
  35. def get_flags_debug(self):
  36. return ['-g', '-check bounds']
  37. def get_flags_opt(self):
  38. return ['-O4', '-align dcommons', '-assume bigarrays',
  39. '-assume nozsize', '-math_library fast']
  40. def get_flags_arch(self):
  41. return ['-arch host', '-tune host']
  42. def get_flags_linker_so(self):
  43. if sys.platform[:5]=='linux':
  44. return ['-shared']
  45. return ['-shared', '-Wl,-expect_unresolved,*']
  46. class CompaqVisualFCompiler(FCompiler):
  47. compiler_type = 'compaqv'
  48. description = 'DIGITAL or Compaq Visual Fortran Compiler'
  49. version_pattern = (r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'
  50. r' Version (?P<version>[^\s]*).*')
  51. compile_switch = '/compile_only'
  52. object_switch = '/object:'
  53. library_switch = '/OUT:' #No space after /OUT:!
  54. static_lib_extension = ".lib"
  55. static_lib_format = "%s%s"
  56. module_dir_switch = '/module:'
  57. module_include_switch = '/I'
  58. ar_exe = 'lib.exe'
  59. fc_exe = 'DF'
  60. if sys.platform=='win32':
  61. from numpy.distutils.msvccompiler import MSVCCompiler
  62. try:
  63. m = MSVCCompiler()
  64. m.initialize()
  65. ar_exe = m.lib
  66. except DistutilsPlatformError:
  67. pass
  68. except AttributeError:
  69. msg = get_exception()
  70. if '_MSVCCompiler__root' in str(msg):
  71. print('Ignoring "%s" (I think it is msvccompiler.py bug)' % (msg))
  72. else:
  73. raise
  74. except IOError:
  75. e = get_exception()
  76. if not "vcvarsall.bat" in str(e):
  77. print("Unexpected IOError in", __file__)
  78. raise e
  79. except ValueError:
  80. e = get_exception()
  81. if not "'path'" in str(e):
  82. print("Unexpected ValueError in", __file__)
  83. raise e
  84. executables = {
  85. 'version_cmd' : ['<F90>', "/what"],
  86. 'compiler_f77' : [fc_exe, "/f77rtl", "/fixed"],
  87. 'compiler_fix' : [fc_exe, "/fixed"],
  88. 'compiler_f90' : [fc_exe],
  89. 'linker_so' : ['<F90>'],
  90. 'archiver' : [ar_exe, "/OUT:"],
  91. 'ranlib' : None
  92. }
  93. def get_flags(self):
  94. return ['/nologo', '/MD', '/WX', '/iface=(cref,nomixed_str_len_arg)',
  95. '/names:lowercase', '/assume:underscore']
  96. def get_flags_opt(self):
  97. return ['/Ox', '/fast', '/optimize:5', '/unroll:0', '/math_library:fast']
  98. def get_flags_arch(self):
  99. return ['/threads']
  100. def get_flags_debug(self):
  101. return ['/debug']
  102. if __name__ == '__main__':
  103. from distutils import log
  104. log.set_verbosity(2)
  105. from numpy.distutils import customized_fcompiler
  106. print(customized_fcompiler(compiler='compaq').get_version())