The short program below is abbreviated from a fixed format read routine from a program that was written many years ago but is still used regularly.
PROGRAM READCARD
CHARACTER*80 CARD,CODE1*1,CENDR*3,CW2*2
CHARACTER CFORM1*26,CFORM2*29
DIMENSION XP(3),XI(3)
CFORM1= '(A1,A3,A2,I4,I5,I5,6F10.0)'
CFORM2='(1X,A1,A3,A2,I4,I5,I5,6F10.3)'
OPEN(16,FILE='CARD.DAT')
OPEN(17,FILE='CARD.OUT')
C READ CARD READ(16,1020,END=9999)CARD 1020 FORMAT(A)
C READ AS NODE READ(CARD,CFORM1,ERR=35)CODE1,CENDR,CW2,NODE,NUMN,NODEIN,XP,XI
C CARD ECHO WRITE(17,CFORM2)CODE1,CENDR,CW2,NODE,NUMN,NODEIN,XP,XI GOTO 9999
35 WRITE(17,1001) 1001 FORMAT('DATA ERROR')
9999 STOP END
When the input line is 019004 -200.975 -150.0 -300.0
The program correctly writes 'DATA ERROR'. Note that the value -200.975 is in the ‘wrong’ columns. (How do I use a fixed width font here?)
When the value -150.0 is replaced by an integer -150, the program writes 019004 0 0 -200.970 0.000 -300.000 0.000 0.000 0.000
Not only does it read 0.000 incorrectly, it appears to set an error flag somewhere not related to this routine at all, so that we later get a Floating Point Overflow error. (I tried to paste the error message here but it doesn't work).
Richard May