From 36d6fc47b3be6bee0742ce1040dacc9c8df17500 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Mon, 8 Sep 2014 23:06:49 +0300 Subject: [PATCH] Fortran compiler fixes from Peter Koval. --- environment.py | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/environment.py b/environment.py index cf32d5e2d0fd..8fd5429dca51 100644 --- a/environment.py +++ b/environment.py @@ -1159,7 +1159,7 @@ def needs_static_linker(self): return True def sanity_check(self, work_dir): - source_name = os.path.join(work_dir, 'sanitycheckf.f95') + source_name = os.path.join(work_dir, 'sanitycheckf.f90') binary_name = os.path.join(work_dir, 'sanitycheckf') ofile = open(source_name, 'w') ofile.write('''program prog @@ -1190,7 +1190,7 @@ def get_linker_always_args(self): return [] def get_std_warn_args(self): - return GnuFortranCompiler.std_warn_args + return FortranCompiler.std_warn_args def get_buildtype_args(self, buildtype): return gnulike_buildtype_args[buildtype] @@ -1257,6 +1257,9 @@ def __init__(self, exelist, version, is_cross, exe_wrapper=None): super().__init__(exelist, version, is_cross, exe_wrapper=None) self.id = 'g95' + def get_module_outdir_args(self, path): + return ['-fmod='+path] + class SunFortranCompiler(FortranCompiler): def __init__(self, exelist, version, is_cross, exe_wrapper=None): super().__init__(exelist, version, is_cross, exe_wrapper=None) @@ -1266,7 +1269,35 @@ def get_dependency_gen_args(self, outtarget, outfile): return ['-fpp'] def get_always_args(self): - return [''] + return [] + + def get_std_warn_args(self): + return [] + + def get_module_outdir_args(self, path): + return ['-moddir='+path] + +class IntelFortranCompiler(FortranCompiler): + std_warn_args = ['-warn', 'all'] + + def __init__(self, exelist, version, is_cross, exe_wrapper=None): + super().__init__(exelist, version, is_cross, exe_wrapper=None) + self.id = 'intel' + + def get_module_outdir_args(self, path): + return ['-module', path] + + def get_always_args(self): + return [] + + def can_compile(self, src): + suffix = os.path.splitext(src)[1].lower() + if suffix == '.f' or suffix == '.f90': + return True + return False + + def get_std_warn_args(self): + return IntelFortranCompiler.std_warn_args class VisualStudioLinker(): always_args = ['/NOLOGO'] @@ -1580,6 +1611,9 @@ def detect_fortran_compiler(self, want_cross): version = vmatch.group(0) return SunFortranCompiler([compiler], version, is_cross, exe_wrap) + if 'ifort (IFORT)' in out: + return IntelFortranCompiler([compiler], version, is_cross, exe_wrap) + raise EnvironmentException('Unknown compiler(s): "' + ', '.join(compilers) + '"') def get_scratch_dir(self):