- #1
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.
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][COLOR="Red"]write(13,*)[/COLOR][/b]
print*, 'Input name'
read*, name
write(13,'(a)',[b][COLOR="red"]advance='no'[/COLOR][/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
The purpose of storing data in Fortran is to allow for the efficient manipulation and analysis of large datasets within a scientific or engineering context. Fortran is a high-performance language that is commonly used for numerical and scientific computing, and its data storage capabilities are optimized for this purpose.
There are several methods for storing data in Fortran, including arrays, structures, and variables. Arrays are the most commonly used method and allow for the storage of large amounts of data in a single variable. Structures allow for the grouping of related data, and variables are used for storing single values.
Data in Fortran is declared using the "parameter" keyword, followed by the name and value of the data. For example, "parameter :: pi = 3.14159" declares a constant variable named "pi" with a value of 3.14159. Data can also be initialized using the "data" statement, which assigns values to variables within the program.
Fortran supports a variety of data types, including integers, real numbers, and logical values. Other common data types include character strings, complex numbers, and arrays. Fortran also has specific data types for handling dates and times, as well as for representing units of measurement.
Data in Fortran is stored in memory, and its location can be accessed using its name and the "%" operator. For example, "array(3)%" would access the third element of the array named "array." Data can also be stored and accessed in files using input/output (I/O) operations, which allow for the reading and writing of data to external sources.