Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Data output

macmcmonkey
Beginner
1,099 Views
Hi,

I am trying to output the data from one of my simulations to note pad and to do so i do the following:

1) Create a blank text file in note pad (example: 'inventx')
2) Define the open statement: OPEN (UNIT=10, FILE='inventx.txt', STATUS='REPLACE')
3) Specify the OPEN statement within the WRITE statement (example: WRITE(10, 100) k, v_avg)

The compiler will allow me to build the program no problems but the data is not written to the specified file when the system is run. Can anyone tell me what i am doing wrong?
0 Kudos
1 Reply
mecej4
Honored Contributor III
1,099 Views
>1) Create a blank text file in note pad (example: 'inventx')

Unnecessary. OPEN will create a file if it does not exist, if you use STATUS='REPLACE'.

>3) Specify the OPEN statement within the WRITE statement (example: WRITE(10, 100) k, v_avg)

Cannot do that (OPEN within WRITE). Besides, that is probably not what you meant. You simply use the opened unit number in the WRITE statement.

It is customary to CLOSE the file before exiting the program.

>but the data is not written to the specified file

How do you know that? Did you look for the created file in the default directory where the Fortran program created/replaced the file? Did you perform your step-1 in the same directory as the Fortran executable?
0 Kudos
Reply