brendanarnold / py-fortranformat

MIT License
31 stars 8 forks source link

Error when a == b or b == 0 in FortranRecordWriter('Fa.b') #18

Closed Kayya886 closed 2 years ago

Kayya886 commented 3 years ago
import fortranformat as ff
reader = ff.FortranRecordReader('F5.5')
writer = ff.FortranRecordWriter('F5.5')
reader.read('123456')  # result: [0.12345]
writer.write([0.12345])  # result: '*****' 
brendanarnold commented 3 years ago

Hi @Kayya886

Fortran formats are not symmetric - valid read formats are not always valid write formats

In this case, the write format is invalid - you have asked for 5 decimal places plus a . character in 5 spaces which is impossible!