I have an old Fortran program for reading records from text files. The records are of the form:
record_type field1 field2 ... fieldN ;
These records might spread over several lines, the character ; shows that the record has finished. The old code is:
2 read(data,"(a130)",end=3)line
shift=adrec(nbrec)-1
read(line,*,end=1)typrec(nbrec),(field(shift+i),i=1,65)
1 do
do j=shift+1,shift+i-1
k=index(field(j),';')
if(k .ne. 0)then
if(k .eq. 1)then
adrec(nbrec+1)=j
else
field(j)(k:)=''
adrec(nbrec+1)=j+1
endif
go to 2
endif
endo
read(data,"(a130)")line
read(line,*,end=1)(field(shift+i),i=1,65)
enddo
3 continue
This code works with Intel Compiler (ifort) as it is. With gfortran it fails! The first problem is that the implicit read on the third line, with ifort, gives i to be equal to the number of fields actually read, while in gfortran it always gives 65. The second problem is that in the same implicit read, with ifort, the character ; is read as a normal field but with gfortran is skipped.
Anyone can help me solve these two problems? Any other ideas for replacing the code all together are also welcome.