I need a format statement that will effectively left justify an integer of an unknown length. In other words, it will print the minimum number of characters required. Right now if I execute:
i=1
write(6,'(a2,i)') 'i=',i
i=12
write(6,'(a2,i)') 'i=',i
I get the following:
i= 1
i= 12
but what I want is:
i=1
i=12
Of course for something as simple as this I could specify "i1" and "i2" respectively but if the number has an unknown content and could be either 1 or 12 then I have to use an IF statement to determine which format to use. This becomes prohibitive when multiple variables are printed on a single line. There has to be a way to do this automatically. Help!
In a related note, are there any recommendations for a VERY good reference on how to format in FORTRAN? Something with lots of examples? If not online then perhaps a good book?
i=1
write(6,'(a2,i)') 'i=',i
i=12
write(6,'(a2,i)') 'i=',i
I get the following:
i= 1
i= 12
but what I want is:
i=1
i=12
Of course for something as simple as this I could specify "i1" and "i2" respectively but if the number has an unknown content and could be either 1 or 12 then I have to use an IF statement to determine which format to use. This becomes prohibitive when multiple variables are printed on a single line. There has to be a way to do this automatically. Help!
In a related note, are there any recommendations for a VERY good reference on how to format in FORTRAN? Something with lots of examples? If not online then perhaps a good book?