Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

align to left output data

Status
Not open for further replies.

tuli01

Technical User
Aug 10, 2001
14
US
Hello,

I need to add a routine to an old F77 code. The routine is supposed to write an ASCII file where each line starts at column 1.
The code below does do that for string variables.
I was not able to do that for real and integer numbers.
When I look at the output file, the values printed for real and integer numbers start at column 2, rather than 1.

Any suggestions?

Thanks

================== SOURCE CODE ===============

CHARACTER*128 TXT,AKO
INTEGER I1,I2
REAL*4 F1,F2
DIMENSION TXT(5),AKO(5)
OPEN(6,FILE="AKO.TXT")
TXT(1)="1234567890"
TXT(2)=" 34567890"
TXT(3)=" 45678 "
TXT(4)="1234 890"
TXT(5)="1234567 "
I1=1
I2=3333
F1=23.4
F2=45.567
DO I=1,5
AKO(I)=TRIM(TXT(I))
WRITE(6,101) adjustl(AKO(I))
101 FORMAT(A128)

102 FORMAT(I6)
103 FORMAT(F10.3)
ENDDO
WRITE(6,102) I1
WRITE(6,102) I2
WRITE(6,103) F1
WRITE(6,103) F2
CLOSE(6)
STOP
END

================== OUTPUT FILE ===============

1234567890
34567890
45678
1234 890
1234567
1
3333
23.400
45.567
 
You have to change your format for numerical values. I suggest I0 for integers and F0.3 for real values.

François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top