@@ -35,22 +35,23 @@ class GnuFCompiler(FCompiler):
35
35
36
36
def gnu_version_match (self , version_string ):
37
37
"""Handle the different versions of GNU fortran compilers"""
38
- m = re .search (r'GNU Fortran' , version_string )
39
- if not m :
40
- return None
41
- m = re .search (r'GNU Fortran\s+95.*?([0-9-.]+)' , version_string )
42
- if m :
43
- return ('gfortran' , m .group (1 ))
44
- m = re .search (r'GNU Fortran.*?\-?([0-9-.]+)' , version_string )
38
+ # Try to find a valid version string
39
+ m = re .search (r'([0-9.]+)' , version_string )
45
40
if m :
46
- v = m .group (1 )
47
- if v .startswith ('0' ) or v .startswith ('2' ) or v .startswith ('3' ):
48
- # the '0' is for early g77's
49
- return ('g77' , v )
50
- else :
51
- # at some point in the 4.x series, the ' 95' was dropped
52
- # from the version string
53
- return ('gfortran' , v )
41
+ # g77 provides a longer version string that starts with GNU
42
+ # Fortran
43
+ if version_string .startswith ('GNU Fortran' ):
44
+ return ('g77' , m .group (1 ))
45
+
46
+ # gfortran only outputs a version string such as #.#.#, so check
47
+ # if the match is at the start of the string
48
+ elif m .start () == 0 :
49
+ return ('gfortran' , m .group (1 ))
50
+
51
+ # If these checks fail, then raise an error to make the problem easy
52
+ # to find.
53
+ err = 'A valid Fortran verison was not found in this string:\n '
54
+ raise ValueError (err + version_string )
54
55
55
56
def version_match (self , version_string ):
56
57
v = self .gnu_version_match (version_string )
@@ -68,7 +69,7 @@ def version_match(self, version_string):
68
69
69
70
possible_executables = ['g77' , 'f77' ]
70
71
executables = {
71
- 'version_cmd' : [None , "--version " ],
72
+ 'version_cmd' : [None , "-dumpversion " ],
72
73
'compiler_f77' : [None , "-g" , "-Wall" , "-fno-second-underscore" ],
73
74
'compiler_f90' : None , # Use --fcompiler=gnu95 for f90 codes
74
75
'compiler_fix' : None ,
@@ -254,7 +255,7 @@ def version_match(self, version_string):
254
255
255
256
possible_executables
C933
= ['gfortran' , 'f95' ]
256
257
executables = {
257
- 'version_cmd' : ["<F90>" , "--version " ],
258
+ 'version_cmd' : ["<F90>" , "-dumpversion " ],
258
259
'compiler_f77' : [None , "-Wall" , "-g" , "-ffixed-form" ,
259
260
"-fno-second-underscore" ] + _EXTRAFLAGS ,
260
261
'compiler_f90' : [None , "-Wall" , "-g" ,
0 commit comments