- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a group of data to be output. Some of the data must be write at the beginning of the file, but the data may be changed after I wrote other data. How can I change the file in Fortran?
integer i, j
integer ij(2, 20)
....
open(1, file='test.txt')
i=10
write(1,*)i
do j=1, 20
write(1,*)ij(:,j)
enddo
...
i=100 ! this means i have changed
! ????????????
! what should I do to modify the beginnig of the file 'test.txt' but need
! notrewrite other data?
! ????????????
close(1)
Thanks,
Zhanghong Tang
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use a direct access file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much!
Can you give more detailed example? or just modify my code given above?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
http://www.navo.hpc.mil/pet/Video/Courses/f90/Extra/dafor.html
Basically, supply the access='direct', form='formatted', and recl=.... keywords in your OPEN(), WRITE the file record by record, and keep track of the specific record numbers which you will want to update. While not the most common form of WRITE, this has been supported for a very long time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Be aware that the file will not be something you can type or print, as it will not have line delimiters. If you want line delimiters, add the /fpscomp:general option.
![](/skins/images/54BF544B471F3F61DFD338F1D58F9426/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page