Search the first 20 lines of fortran 77 code for line pattern `CF77FLAGS( )= ` Return a dictionary { : }.
(src)
| 1011 | |
| 1012 | _f77flags_re = re.compile(r'(c|)f77flags\s*\(\s*(?P<fcname>\w+)\s*\)\s*=\s*(?P<fflags>.*)', re.I) |
| 1013 | def get_f77flags(src): |
| 1014 | """ |
| 1015 | Search the first 20 lines of fortran 77 code for line pattern |
| 1016 | `CF77FLAGS(<fcompiler type>)=<f77 flags>` |
| 1017 | Return a dictionary {<fcompiler type>:<f77 flags>}. |
| 1018 | """ |
| 1019 | flags = {} |
| 1020 | with open(src, encoding='latin1') as f: |
| 1021 | i = 0 |
| 1022 | for line in f: |
| 1023 | i += 1 |
| 1024 | if i>20: break |
| 1025 | m = _f77flags_re.match(line) |
| 1026 | if not m: continue |
| 1027 | fcname = m.group('fcname').strip() |
| 1028 | fflags = m.group('fflags').strip() |
| 1029 | flags[fcname] = split_quoted(fflags) |
| 1030 | return flags |
| 1031 | |
| 1032 | # TODO: implement get_f90flags and use it in _compile similarly to get_f77flags |
| 1033 |