sun.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from numpy.distutils.ccompiler import simple_version_match
  2. from numpy.distutils.fcompiler import FCompiler
  3. compilers = ['SunFCompiler']
  4. class SunFCompiler(FCompiler):
  5. compiler_type = 'sun'
  6. description = 'Sun or Forte Fortran 95 Compiler'
  7. # ex:
  8. # f90: Sun WorkShop 6 update 2 Fortran 95 6.2 Patch 111690-10 2003/08/28
  9. version_match = simple_version_match(
  10. start=r'f9[05]: (Sun|Forte|WorkShop).*Fortran 95')
  11. executables = {
  12. 'version_cmd' : ["<F90>", "-V"],
  13. 'compiler_f77' : ["f90"],
  14. 'compiler_fix' : ["f90", "-fixed"],
  15. 'compiler_f90' : ["f90"],
  16. 'linker_so' : ["<F90>", "-Bdynamic", "-G"],
  17. 'archiver' : ["ar", "-cr"],
  18. 'ranlib' : ["ranlib"]
  19. }
  20. module_dir_switch = '-moddir='
  21. module_include_switch = '-M'
  22. pic_flags = ['-xcode=pic32']
  23. def get_flags_f77(self):
  24. ret = ["-ftrap=%none"]
  25. if (self.get_version() or '') >= '7':
  26. ret.append("-f77")
  27. else:
  28. ret.append("-fixed")
  29. return ret
  30. def get_opt(self):
  31. return ['-fast', '-dalign']
  32. def get_arch(self):
  33. return ['-xtarget=generic']
  34. def get_libraries(self):
  35. opt = []
  36. opt.extend(['fsu', 'sunmath', 'mvec'])
  37. return opt
  38. def runtime_library_dir_option(self, dir):
  39. return '-R%s' % dir
  40. if __name__ == '__main__':
  41. from distutils import log
  42. log.set_verbosity(2)
  43. from numpy.distutils import customized_fcompiler
  44. print(customized_fcompiler(compiler='sun').get_version())