fc_cray.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #! /usr/bin/env python
  2. # encoding: utf-8
  3. # harald at klimachs.de
  4. import re
  5. from waflib.Tools import fc, fc_config, fc_scan
  6. from waflib.Configure import conf
  7. from waflib.Tools.compiler_fc import fc_compiler
  8. fc_compiler['linux'].append('fc_cray')
  9. @conf
  10. def find_crayftn(conf):
  11. """Find the Cray fortran compiler (will look in the environment variable 'FC')"""
  12. fc = conf.find_program(['crayftn'], var='FC')
  13. conf.get_crayftn_version(fc)
  14. conf.env.FC_NAME = 'CRAY'
  15. conf.env.FC_MOD_CAPITALIZATION = 'UPPER.mod'
  16. @conf
  17. def crayftn_flags(conf):
  18. v = conf.env
  19. v['_FCMODOUTFLAGS'] = ['-em', '-J.'] # enable module files and put them in the current directoy
  20. v['FCFLAGS_DEBUG'] = ['-m1'] # more verbose compiler warnings
  21. v['FCFLAGS_fcshlib'] = ['-h pic']
  22. v['LINKFLAGS_fcshlib'] = ['-h shared']
  23. v['FCSTLIB_MARKER'] = '-h static'
  24. v['FCSHLIB_MARKER'] = '-h dynamic'
  25. @conf
  26. def get_crayftn_version(conf, fc):
  27. version_re = re.compile(r"Cray Fortran\s*:\s*Version\s*(?P<major>\d*)\.(?P<minor>\d*)", re.I).search
  28. cmd = fc + ['-V']
  29. out,err = fc_config.getoutput(conf, cmd, stdin=False)
  30. if out:
  31. match = version_re(out)
  32. else:
  33. match = version_re(err)
  34. if not match:
  35. conf.fatal('Could not determine the Cray Fortran compiler version.')
  36. k = match.groupdict()
  37. conf.env['FC_VERSION'] = (k['major'], k['minor'])
  38. def configure(conf):
  39. conf.find_crayftn()
  40. conf.find_ar()
  41. conf.fc_flags()
  42. conf.fc_add_flags()
  43. conf.crayftn_flags()