Sequential File output in Fortran

  • #1
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.
 
  • #2
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
 

Suggested for: Sequential File output in Fortran

Replies
12
Views
1K
Replies
2
Views
649
Replies
3
Views
895
Replies
10
Views
925
2
Replies
60
Views
2K
Replies
1
Views
165
Replies
8
Views
937
Replies
9
Views
1K
Back
Top