I wanted to use an automatic integer width descriptor in Fortran. I referred to Output formatting: too much whitespace in gfortran
This question says that I can use I0
and F0.0
for "auto" width.
Here is my sample code (complied with GNU Fortran Compiler):
PROGRAM MAIN
IMPLICIT NONE
INTEGER :: i
REAL :: j
WRITE (*,*) 'Enter integer'
READ (*,100) i
100 FORMAT (I0)
WRITE (*,*) 'Enter real'
READ (*,110) j
110 FORMAT (F0.0)
WRITE (*,100) 'Integer = ',i
WRITE (*,110) 'Real = ',j
END PROGRAM
There is runtime error
(unit = 5, file = 'stdin')
Fortran runtime error: Positive width required in format
Am I mis-understanding the auto width descriptor? What option should I use?