Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how can i convert this formula to fortran?

Status
Not open for further replies.

lemong

Newbie level 1
Joined
Jun 12, 2016
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
9
height of tree.jpg

how can i convert this formula to fortran?

I used print *, Distance(d) and Elevation Angle(theta)
 

Could this be an exercise in learning to co-exist with fussy programming languages? Were you told to use a particular variant?

We learned Fortran programming in school circa 1970. It was fussy about syntax of the PRINT statement. You had to designate the number of columns for integer and fractional portions. (Later Fortran versions are not so fussy.)

When we wrote a single long mathematical calculation, we found it's easy to make a mistake. Therefore it's wise to do a calculation in segments, breaking it up over several lines. Then if we made a mistake, the compiler tells us exactly which line has the error.

- - - Updated - - -

Every line had to be numbered. It's a good idea to do them in increments of 10, because it's inevitable you'll want room to add more lines in between, as you revise your program.
 

Every line had to be numbered. .

This is not correct; we need to label the statement with number (numeric label) if that particular statement is a target.

I learnt FORTRAN around the same time (1974); the only other computer programming languages suitable for scientific computations was ALGOL (that was popular in the Europe). I used FORTRAN till 1984 and then changed over to PASCAL and then to C. I still consider FORTRAN a good programming language for scientific work and even today thousands of scientists use fortran routinely.

- - - Updated - - -

I used print *, Distance(d) and Elevation Angle(theta)

It is D1+D2*TAN(THETA*3.1415/180)
C D1, D2 are in feet; THETA in degrees
 

This is not correct; we need to label the statement with number (numeric label) if that particular statement is a target.

Then I guess I used an earlier version. The punch cards had to be in sequence. Line numbers were essential in case the cards got out of order, which was easy to do.
 

Line numbers were essential in case the cards got out of order, which was easy to do.

Right; the sequence was given in the columns 73-80 that were ignored by the compiler. Column 1 was for comment. Column 6 was for continuation mark.

That was the first programming language I learnt when I joined for Ph.D. - it was good time.
 
try
Code:
  real D1, D2, THETA, result
  D1=4
  D2=50
  THETA=30
  result = D1+D2*TAN(THETA*3.1415/180)
  print *, "result = ", result
when run gives
Code:
 result =    32.8664856
Press any key to continue . . .
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top