yancee
- 5
- 0
I was looking for a fortran code wherein the stored file in DAT file will be stored once I run the program again. My program is just replacing the saved file.
The discussion revolves around a Fortran programming issue related to storing and appending data in a DAT file. Participants explore methods to ensure that new data can be added to an existing file without overwriting previous entries, focusing on file handling techniques in Fortran.
Participants express various approaches to the problem, and while some solutions are proposed, there is no consensus on a single method that resolves all issues. The discussion remains open with multiple competing views on how to handle file operations in Fortran.
Participants mention specific conditions regarding the end of the file and how it affects writing new data. There are also references to the need for clear programming logic when handling user inputs and file reading operations.
What you wrote is not clear. What are you asking?yancee said:I was looking for a fortran code wherein the stored file in DAT file will be stored once I run the program again. My program is just replacing the saved file.
Anna
Abby
Ammy <- end of file is here
Program database
integer reason
character (len=30):: name, a,b,c
open (unit=13, file='rw.dat', status='old', action='readwrite')
do
read(13,'(a)',iostat=reason) a
if (reason < 0) exit
end do
[b]write(13,*)[/b]
print*, 'Input name'
read*, name
write(13,'(a)',[b]advance='no'[/b]) name
close (unit=13)
End program
Anna
Abby
Ammy
<- end of file is here
Program database
integer reason
character (len=30):: name, a,b,c
open (unit=13, file='rw.dat', status='old', action='readwrite')
do
read(13,'(a)',iostat=reason) a
if (reason < 0) exit
end do
print*, 'Input name'
read*, name
write(13,'(a)') name
close (unit=13)
End program