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

Fortran I/O functions

LRaim
New Contributor I
325 Views

A trip around Fortran I/O functions.
A Fortran application, launched by a C++ driver, writes a stream file which is later processed by the C++ application.
Now to add a backup feature, the fortran application at a certain point should:
1) find the actual position of the file (INQUIRE   POS=ipos1) 
2)  write additional data, close and copy the file.
3) reopen the file and reposition at ipos1, for continuing the execution.

I am unable to find a fortran statement/specifier to restart writing data at ipos1.

  

 

0 Kudos
2 Replies
Mark_Lewy
Valued Contributor I
325 Views

You can use

write(unit, pos = ipos) stuff

with stream I/O. See Metcalf, Reid & Cohen Modern Fortran Explained 10.16.

0 Kudos
jimdempseyatthecove
Honored Contributor III
325 Views

open output file
open copy file//sequence number
loop:
  ...
  write to output file
  write to copy file
  if(time to close copy file) then
    write additional stuff to copy file
    close copy file
    bump sequence number
    open copy file//sequence number
  end if
end loop

Jim Dempsey

0 Kudos
Reply