Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646

Fortran I/O functions

LRaim
New Contributor I
149 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
New Contributor III
149 Views

You can use

write(unit, pos = ipos) stuff

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

jimdempseyatthecove
Black Belt
149 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

Reply