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
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