Issue #17 resolved

'RET_UNWRITTEN_VARS_NONE = True' broken for floats?

Grant Goodyear
created an issue

Version 0.2.5. I would have expected the two zeroes at the end to be None instead.

>>> import fortranformat as ff
>>> line = '   1.0000       9.0000       105.09       1.0000                   '
>>> fltfmt = ff.FortranRecordReader('(6g13.5)')
>>> ff.config.RET_UNWRITTEN_VARS_NONE = True
>>> data =
>>> print(data)
[1.0, 9.0, 105.09, 1.0, 0.0, 0.0]

Comments (2)

  1. brendanarnold repo owner

    The FORTRAN specification ( specifies that FORTRAN interprets fields of blanks as zeros.

    I'm not clear what the behaviour should be if the final record is too short but full of blanks. There is some suggestion that the record terminator should be considered a blank too. In this case the library just interprets it as a field entirely comprised of blanks and hence a zero.

    To be clear, the RET_UNWRITTEN_VARS_NONE is for the case when FORTRAN variables would not have a value written to them. In this case zero would be written to them so if the variables were initialised to e.g. -1, they would subsequently contain 0. If the format was (7g13.5) then the final variable is not written to. In FORTRAN it would still contain e.g. -1 and in the Python code it would be None

  2. Log in to comment