Closed arporter closed 5 years ago
I thought this might have been something to do with whether or not the reader thought it was free-form source but I've tried explicitly setting the mode to free-form and that didn't alter the behaviour.
I can reproduce this error in fparser and confirm that it compiles fine with gfortran
rupert@ubuntu:~/proj/fparser/src/fparser/two$ cat tmp.f90
program just_a_test
100 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)
end program just_a_test
rupert@ubuntu:~/proj/fparser/src/fparser/two$ ../scripts/fparser2.py tmp.f90
Syntax error: at line 2
>>>100 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)
at line 2
>>>100 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)
parsing 'tmp.f90' failed at line #2 100 'FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)'
started at line #1'program just_a_test'
rupert@ubuntu:~/proj/fparser/src/fparser/two$ gfortran tmp.f90
rupert@ubuntu:~/proj/fparser/src/fparser/two$
Created branch format_error
If you check the return value from
reader = get_reader( ' 100 FORMAT(a19,3(a18,"=",es14.7,x,a2,:,","),a12,i8)')
ast = Format_Stmt(reader)
you should see that ast is None
so it does not match and is consistent with the reported syntax error.
I've found the root of the problem. fparser2 does not like the x
in the format statement. If we remove it then the line is parsed, whereas this simple example fails ...
program just_a_test
100 FORMAT(x)
end program just_a_test
Reading the spec for fortran2003 and fortran2008 it seems to me that fparser2 is correct. The use of x must be preceded by a positive integer.
In f2003
R1013 position-edit-desc is T n
or TL n
or TR n
or n X
In f2008
R1015 position-edit-desc is T n
or TL n
or TR n
or n X
And here we have it ...
rupert@ubuntu:~/proj/fparser/src/fparser/two$ gfortran -std=f2003 tmp.f90
tmp.f90:5:12:
100 FORMAT(X)
1
Error: GNU Extension: X descriptor requires leading space count at (1)
Created PR #141 from format_error branch to address this issue.
PR #141 has been merged. Closing issue.
This can be reproduced with the following test code:
For which fparser reports a syntax error with the format statement. Strangely, if I just do:
then everything is fine.