- #1
Ihatefortran
- 4
- 0
New user's thread moved to the Homework Help forums, so no Template is shown.
Hey guys, new here and was hoping for some help.
Basically I have to use Fortran 77 to complete some questions for an assignment
The first thing to do is, read a bunch of numbers in a list format and then use these numbers to be entered within an equation.
The values I have are listed in a 1 column list eg
4.5252
4.541
5.522
etc
The equation I have is: XYZ (Where Z are the each value from that list, and X/Y are other values). I need to calculate an answer for each Z value.
So far, I'm stuck on even being able to read the file in the first place!
My code:
When I compile the code just reads 0 for some reason.
Someone help?
Basically I have to use Fortran 77 to complete some questions for an assignment
The first thing to do is, read a bunch of numbers in a list format and then use these numbers to be entered within an equation.
The values I have are listed in a 1 column list eg
4.5252
4.541
5.522
etc
The equation I have is: XYZ (Where Z are the each value from that list, and X/Y are other values). I need to calculate an answer for each Z value.
So far, I'm stuck on even being able to read the file in the first place!
My code:
Fortran:
PROGRAM Example
IMPLICIT NONE
INTEGER n
REAL phi(10)
OPEN(10,FILE='data.txt', FORM='FORMATTED', STATUS='OLD')
phi=0.0
n=0
DO
READ(10,*,END=10) phi
n=n+1
ENDDO
10 CONTINUE
PRINT*, phi
END
When I compile the code just reads 0 for some reason.
Someone help?
Last edited by a moderator: