How to read data from files and process it?

AI Thread Summary
The discussion centers around a Fortran program designed to read data from a file with four columns and process it for calculations. The user encounters an issue where the output consistently returns 0.00000. Key points include the structure of the code, which involves opening a file, reading data into arrays, and attempting to write output. A critical suggestion is to specify the file format in the OPEN statements. If the data is in a human-readable format, the option FORM=FORMATTED should be added. Conversely, for binary data, FORM=UNFORMATTED and RECL=xxx are necessary. Understanding the data file's format is essential for resolving the output issue.
ade_tokunbo
Messages
2
Reaction score
0
Dear all,

I want to read data from a file which has four column and process the data for further calculation. After running the code it keeps given me 0.00000 as output. What do i do? Here is the structure of the code

program new

Implicit none
integer,parameter ::Nmax=1000
Integer :: i,io,max,t
Real*8,Dimension(Nmax) :: Ev,X,Y,Z
Real*8, Dimension(Nmax)::Evr,Xr,Yr,Zr


open(1, File='si.dat',status='old')

open(16,file='cal.dat',status='unknown')

max=0
do i=1,Nmax
read(1,*,IOSTAT = io)Ev(i),X(i),Y(i),Z(i)
if (io.eq.0) then
max = max+1
else
goto 677
endif
enddo


677 close(1)

do t=1,Nmax
open(1, file='si.dat',status='old')
do i=1,max

read(1,*,iostat=io)Ev(i),X(i),Y(i),Z(i)
enddo
write(6,*)Ev(t),X(t),Y(t),Z(t)
enddo
close(16)

end program
 
Technology news on Phys.org
On the OPEN statements, if the data is in human readable form (i.e. text), add the additional option FORM=FORMATTED. If the data is binary, then FORM=UNFORMATTED and RECL=xxx should be added, but in any event, you'll need to know what form the data files are in.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
2
Views
2K
Replies
12
Views
3K
Replies
1
Views
3K
Replies
5
Views
2K
Replies
8
Views
4K
Replies
10
Views
25K
Replies
5
Views
5K
Back
Top