I\'ve noted that if I use integer(16) variables, when I use print, the output contains the exact number of spaces expected. Thus, when I use (some
List-directed output is processor-specific (note that Fortran standard calls "processor" what we'd normally refer to as "compiler"). Here is what the Fortran 90 standard says about list-directed output:
10.8.2 List-directed output
...
Integer output constants are produced with the effect of an
Iwedit descriptor.Real constants are produced with the effect of either an
Fedit descriptor or anEedit descriptor, depending on the magnitudexof the value and a range 10d1 <=x< 10d2, whered1andd2are processor-dependent integers. If the magnitudexis within this range, the constant is produced using0PFw.d; otherwise,1PEw.dEeis used.For numeric output, reasonable processor-dependent values of
w,d, andeare used for each of the numeric constants output.
(emphasis mine)
The same rules are used for numerical values. The text in §10.10.4 of the Fortran 2008 standard copies that from the Fortran 90 standard so no changes in list-directed output were introduced.
As noted already by M. S. B., you can use the I0 edit descriptor to print integer values with the least amount of space necessary:
! Note the space in the string
PRINT '("The difference is ",I0)', diff