Skip to main content

3.7) Using 'Open' For Outputting Results


You are going to want to output results to files as well. You’ll learn that now. It can be done with the same type of open statement. Use a different unit number since that is the label or shortcut for the filename and it must be unique for each file.

open(unit=24, file=’outputdata.dat’)

Instead of using print *, which prints to the screen, now you need to use write(24,*) which prints to the output file above called outputdata.dat (the shortcut or nickname of the file is 24). On the next page is an example code that prints the values of a to the file outputdata.dat.