Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Sequential File output in Fortran

  1. Apr 22, 2009 #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. jcsd
  3. Apr 23, 2009 #2
    Here's an example:
    Code (Text):

          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
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook