Fortran Sequential File output in Fortran

Click For Summary
The discussion revolves around modifying a Fortran program to output data files during a simulation that involves an explicit differentiation loop. The user seeks assistance in naming these output files in a numerical order at specified time intervals. A code snippet is provided, demonstrating the current setup, which includes a loop for writing file names based on an index variable. The suggested approach involves using the WRITE statement to format the file names correctly. The user is encouraged to adapt the provided code to meet their specific requirements for file output. Additionally, a reference to a related post is included for further guidance.
ugresearcher
Messages
7
Reaction score
0
Hello,
I am currently using a Fortran program to run a simulation which involves an explicit differentiation loop. The program currently plots simulation data at specified time intervals using a subroutine with another program. I'd like to have the program also output data files at these specified times. I'd like to add one set of commands into the loop for the program to output the data files, but I cannot figure out a way for Fortran to name the files in some numerical order. Can anyone help?

Thanks.
 
Technology news on Phys.org
Here's an example:
Code:
      IMPLICIT INTEGER(I-N), REAL*8(A-H,O-Z)
      N=5
      CHARACTER *12 FN
      DO 5 I=1,N
      WRITE(FN,10)I
      WRITE(6,*)FN
      OPEN(1,FILE=FN)
      CLOSE(1)
    5 CONTINUE
   10 FORMAT('INPUT',I3.3,'.FMT')
      STOP
      END
By modifying the code according to your needs, you should be able to achieve what you want to do.

See also post:
https://www.physicsforums.com/showthread.php?t=307970
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
5K
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K