MCPcopy Create free account
hub / github.com/numpy/numpy / is_free_format

Function is_free_format

numpy/f2py/crackfortran.py:332–354  ·  view source on GitHub ↗

Check if file is in free format Fortran.

(fname)

Source from the content-addressed store, hash-verified

330
331
332def 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

Callers 1

readfortrancodeFunction · 0.85

Calls 3

openhookFunction · 0.85
lowerMethod · 0.80
stripMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…