next up previous
Next: Arithmetic Operations Up: Implementation in Fortran Previous: Extensions of the

Assignment Statements

Let's move on to another kind of Fortran program statement: the assignment statements. Once a variable has been declared, it can be given a value by an assignment statement. In Fortran the assignment operator is the = sign. For example, the Fortran statement:

      shoulderx = 0.0

assigns the (floating point) value zero to the (floating point) variable shoulderx. Pause now and locate all of the assignment statements in the program rbtjnts.f.

It is important to remember that assignment is not the same thing as equality or definition. For example, consider the following Fortran statement:

      count = count + 1

As an algebraic equation, that statement is nonsense. If you tried to solve it for the value of count, there would be no solution to the equation. But assignment statements are not algebraic equations. In a Fortran program, the above statement tells the computer to determine the current value of the variable count, add one to that value, and then store that result back in the variable count.


J. C. Diaz