def detect_fortran_compiler(self, want_cross):
        evar = 'FC'
        if self.is_cross_build() and want_cross:
            compilers = [self.cross_info['fortran']]
            is_cross = True
            exe_wrap = self.cross_info.get('exe_wrapper', None)
        elif evar in os.environ:
            compilers = os.environ[evar].split()
            is_cross = False
            exe_wrap = None
        else:
            compilers = self.default_fortran
            is_cross = False
            exe_wrap = None
        popen_exceptions = {}
        for compiler in compilers:
            for arg in ['--version', '-V']:
                try:
                    p = subprocess.Popen([compiler, arg],
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.PIPE)
                except __HOLE__ as e:
                    popen_exceptions[' '.join([compiler, arg])] = e
                    continue
                (out, err) = p.communicate()
                out = out.decode(errors='ignore')
                err = err.decode(errors='ignore')

                version = 'unknown version'
                vmatch = re.search(Environment.version_regex, out)
                if vmatch:
                    version = vmatch.group(0)

                if 'GNU Fortran' in out:
                    return GnuFortranCompiler([compiler], version, GCC_STANDARD, is_cross, exe_wrap)

                if 'G95' in out:
                    return G95FortranCompiler([compiler], version, is_cross, exe_wrap)

                if 'Sun Fortran' in err:
                    version = 'unknown version'
                    vmatch = re.search(Environment.version_regex, err)
                    if vmatch:
                        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)

                if 'PathScale EKOPath(tm)' in err:
                    return PathScaleFortranCompiler([compiler], version, is_cross, exe_wrap)

                if 'pgf90' in out:
                    return PGIFortranCompiler([compiler], version, is_cross, exe_wrap)

                if 'Open64 Compiler Suite' in err:
                    return Open64FortranCompiler([compiler], version, is_cross, exe_wrap)

                if 'NAG Fortran' in err:
                    return NAGFortranCompiler([compiler], version, is_cross, exe_wrap)
        errmsg = 'Unknown compiler(s): "' + ', '.join(compilers) + '"'
        if popen_exceptions:
            errmsg += '\nThe follow exceptions were encountered:'
            for (c, e) in popen_exceptions.items():
                errmsg += '\nRunning "{0}" gave "{1}"'.format(c, e)
        raise EnvironmentException(errmsg)
dataset/ETHPy150Open mesonbuild/meson/mesonbuild/environment.py/Environment.detect_fortran_compiler