Civil Engineering Reference
In-Depth Information
(iii) The loop
FOR i TO n
Until some
condition is satisfied
ACTION
TO BE
REPEATED
n TIMES
or
ACTION
TO BE
REPEATED
This comes in various forms, but we shall usually be concerned with DO -loops, either
for a fixed number of repetitions or “forever” (so called because of the danger of the loop
never being completed).
In particular, the structure chart notation discourages the use of GOTO statements. Using
this notation, a matrix multiplication program would be represented as shown in Figure 1.4.
The nested nature of a typical program can be seen quite clearly.
Initialise variables and
arrays a(l,m), b(m,n) and c(l,n)
FOR i TO l
FOR k TO n
sum = 0.0
FOR j TO m
sum = sum + a(i,j)*b(j,k)
Set c(i,k) = sum
Do something with c
Figure 1.4 Structure chart for matrix multiplication
1.10 Conclusions
Computers on which finite element computations can be done vary widely in their capa-
bilities and architecture. Because of its entrenched position FORTRAN is the language
in which computer programs for engineering applications had best be written in order to
assure maximum readership and portability. Using Fortran 95, a library of subroutines can
be created which is held in compiled form and accessed by programs in just the way that
Search WWH ::




Custom Search