c234567
c     This is a shell of a program to demonstrate file input
c     and output in the simplest of cases.
c
      PROGRAM FILEIO
c
c     Variables for input and output
c
      REAL XIN(15), XOUT(15)
      INTEGER N
c
c     Open the files for input and output
c     With STATUS='NEW', you are not allowed to overwrite
c        outfile.txt. You must erase it yourself--this is
c        a safety feature. Change it to 'OLD' if overwriting
c        is allowed.
      OPEN(UNIT=10,FILE='infile.txt',STATUS='OLD')
      OPEN(UNIT=11,FILE='outfile.txt',STATUS='NEW')
c
c     Here is a little housekeeping to make things neat.
      WRITE(*,9) 'How many points should I read? >'
9     FORMAT(X,A32,$)
      READ(*,*) N
c     Read in a data point and write one out.
      DO 100 I=1,N
      READ(10,*) XIN(I)
      XOUT(I)=XIN(I)*XIN(I)
      WRITE(11,*) XOUT(I)
100   CONTINUE
c
c     Always clean up the file status when you are done.
      CLOSE(11)
      CLOSE(10)
      STOP 'Finished with FILEIO'
      END
