Check if file is in free format Fortran.
(fname)
| 330 | |
| 331 | |
| 332 | def is_free_format(fname): |
| 333 | """Check if file is in free format Fortran.""" |
| 334 | # f90 allows both fixed and free format, assuming fixed unless |
| 335 | # signs of free format are detected. |
| 336 | result = False |
| 337 | if Path(fname).suffix.lower() in COMMON_FREE_EXTENSIONS: |
| 338 | result = True |
| 339 | with openhook(fname, 'r') as fhandle: |
| 340 | line = fhandle.readline() |
| 341 | n = 15 # the number of non-comment lines to scan for hints |
| 342 | if _has_f_header(line): |
| 343 | n = 0 |
| 344 | elif _has_f90_header(line): |
| 345 | n = 0 |
| 346 | result = True |
| 347 | while n > 0 and line: |
| 348 | if line[0] != '!' and line.strip(): |
| 349 | n -= 1 |
| 350 | if (line[0] != '\t' and _free_f90_start(line[:5])) or line[-2:-1] == '&': |
| 351 | result = True |
| 352 | break |
| 353 | line = fhandle.readline() |
| 354 | return result |
| 355 | |
| 356 | |
| 357 | # Read fortran (77,90) code |
no test coverage detected
searching dependent graphs…