Sequential File output in Fortran

  • Fortran
  • Thread starter ugresearcher
  • Start date
  • #1

Main Question or Discussion Point

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.
 

Answers and Replies

  • #2
365
0
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
 

Related Threads for: Sequential File output in Fortran

  • Last Post
Replies
1
Views
5K
  • Last Post
Replies
7
Views
40K
Replies
3
Views
1K
Replies
6
Views
880
Replies
5
Views
3K
Replies
5
Views
2K
Top