Error: Nonnegative width required in format string at (1)

前端 未结 2 1648
南方客
南方客 2020-11-30 13:17

I\'m trying to compile a piece of code with gfortran and it\'s failing with the following error:

Error: Nonnegative width required in format string at (1)
..         


        
相关标签:
2条回答
  • 2020-11-30 13:34

    Try changing the format string I to Iw where w is a positive number. Same with E, only use Ew.d.
    For explanation see, for example, this link: http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/chap05/format.html

    Beware though: using, say, I3 for writing out 1234 might print ***, so make sure your formats are wide enough.

    EDIT: See @M.S.B.'s answer on how to avoid problems with integer formats.

    0 讨论(0)
  • 2020-11-30 13:41

    As already answered, you need to specify widths. Something like ES14.5 might work well for the floating point format. There is a short cut for the integer format: I0 will cause the compiler to use the number of digits needed.

    0 讨论(0)
提交回复
热议问题