Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28613 Discussions

BACKSPACE statement causes incorrect file position.



Has anyone seen the BACKSPACE statement reset the wrong file position??

Our Fortran program fails to execute properly when performing a BACKSPACE statement. As we process the master file, we have sub file routines that read in the records that correspond with the master key. We collect the data from those that match the master key but upon reading in the first record that corresponds to the next master record, our read subroutines execute a BACKSPACE statement and then exit the subroutine.  The failure happens after we have processed 445074 master file records. One of our sub routine has read in 77 sub file records for that master key and now has executes the BACKSPACE statement. However, instead of resetting the file position to approx. 21474848016, it is set to 4068. 4068 is basically close to the fourth record in the sub file. Now as the program processes the next master record, this sub routine now re-reads 43 million records to get back to where it was previously.  This is about 5-7 minutes of wasted time... Once the routine gets back in synch with the current master key, the routine works flawlessly from that point on. This code is currently on PSXE 2018 update 1 and I went back and tested our version of this program that was on PSXE 2017 update 5 and it has the same problem as well...I've attached a word doc that has screen shots from a debug session that hopefully illustrates the problem...


0 Kudos
0 Replies