Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
4 Views

OUTPUT FILE AS A INPUT FILE IN SAME FORTRAN PROGRAM

Jump to solution

Hi, I am a new user of FORTRAN language.  I write a program for index calculation. My program contains with 10 subroutines. First  9 subroutines produced an output file. I want to use first output file as an input file for the last one subroutine in same program.

How can I write this input and read command. 

please, support me.

0 Kudos

Accepted Solutions
Highlighted
Valued Contributor II
4 Views

The simplest way to achieve

Jump to solution

The simplest way to achieve this is:

  • Write all the output to the output file
  • Close the file when you are done (so when the ninth subroutine as finished)
  • Then open it again, now you can read it from the start

Something like:

real :: x
open( 10, file = 'result.out' )
write( 10, * )  cos(1.0)
close( 10 )

open( 10, file = 'result.out' )
read( 10, * )  x
close( 10 )
write( *, * ) 'The number that was produced is ', x

 

View solution in original post

0 Kudos
2 Replies
Highlighted
Valued Contributor II
5 Views

The simplest way to achieve

Jump to solution

The simplest way to achieve this is:

  • Write all the output to the output file
  • Close the file when you are done (so when the ninth subroutine as finished)
  • Then open it again, now you can read it from the start

Something like:

real :: x
open( 10, file = 'result.out' )
write( 10, * )  cos(1.0)
close( 10 )

open( 10, file = 'result.out' )
read( 10, * )  x
close( 10 )
write( *, * ) 'The number that was produced is ', x

 

View solution in original post

0 Kudos
Highlighted
Beginner
4 Views

Many thanks @Arjen Markus. I

Jump to solution

Many thanks @Arjen Markus. I have been solved my problems as per following your guidelines.

0 Kudos