
November 25th, 2007, 09:28 PM
|
|
Contributing User
|
|
Join Date: Nov 2007
Posts: 35
Time spent in forums: 10 h 43 m 45 sec
Reputation Power: 1
|
|
Quote: | Originally Posted by TimA Hi folks
I'm a physics student doing a project that requires me to program in fortran90/95. I have a very basic question; I'm really a beginner at programming.
In my program I create a 3-dimensional real array called field(i,j,k).
All I need to be able to do is store this array in a file. A .dat file would be good, something I can open in matlab or IDL and visualise. I think my problem is that my programming book is written for programmers and not physicists...
Sorry for the simplistic question. Many thanks for your help
Tim. |
Tim
I haven't programmed Fortran for years. However, I did look for an answer to your post and found this sample code.
Here DATA01.TXT is the name of the file to be written. You must OPEN the file, write the data , then CLOSE the file.
Hopefully this may help
Code:
C Create an external data file
OPEN (7, FILE = 'DATA01.TXT', ACCESS = 'APPEND',STATUS = 'NEW')
C Write some values to the file
DO 10 I=1,100
WRITE(7,*) I
10 CONTINUE
C Close the external file
CLOSE(7)
STOP
END
I found this at : Here the link:
http://www.livephysics.com/computational-physics/fortran/fortran-file-handling.html
|