compaq.py 3.8 KB

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