! Printing Left-Justified Values in Fortran ! https://jblevins.org/log/leftjust program leftjust integer :: i = 42 real :: r = 46.2 ! Method 3 and 4 variables character(len=8), dimension(3) :: header = (/ 'String ', 'Integer', 'Real ' /) character(len=8) :: c = 'Label' ! Method 4 variables character(len=8) :: i_char, r_char ! Method 1 print '(/,"Method 1",/)' print '(3a8)', 'String', 'Integer', 'Real' print '(a8,i8,f8.2)', 'Label', i, r ! Method 2 print '(/,"Method 2",/)' print '(3a8)', 'String ', 'Integer ', 'Real ' print '(a8,i8,f8.2)', 'Label ', i, r ! Method 3 print '(/,"Method 3",/)' print '(3a8)', header print '(a8,i8,f8.2)', c, i, r ! Method 4 print '(/,"Method 4",/)' write (i_char, '(i8)') i write (r_char, '(f8.2)') r print '(3a8)', header print '(3a8)', c, adjustl(i_char), adjustl(r_char) end program leftjust