Information Technology Reference
In-Depth Information
utilized. Our mathematical model is an integral,
I D Z b
a
f.x/dx;
and the purpose is to compute an approximation of I . In a program we need to
1. Initialize input data: a , b ,and n
2. Specify a function f.x/
3. Call a program module that implements Algorithm 6.2
4. Write out the value of I
The input data are normally provided by the user of the program at run time, but
for simplicity, we shall explicitly set a D 0 , b D 2 ,and n D 1;000 in our sample
codes.
The function f.x/ is selected as e x 2 log .1 C x sin x/ and implemented with
the name f1 . Most codes also have a simple linear function 1 C x , called f2 and
used for checking that the numerical results are correct. Since 1 C x is integrated
without numerical errors, when using the trapezoidal rule, we should expect I D
R 0 .1 C x/dx D 4 to machine precision. If the program works for f2 , we expect it
to work for f1 .
Algorithm 6.2 is more or less directly translated to a function. The main differ-
ence between the various implementations is how f.x/ is technically treated as an
argument in this function.
6.3.2
Fortran 77
The Fortran language was designed in the 1950s as a high-level alternative to assem-
bly programming. With Fortran, scientists could express mathematical formulas in a
program using a syntax close to the syntax of mathematics. Since the 1950s, Fortran
has been improved several times, resulting in Fortran IV, Fortran 66, Fortran 77,
Fortran 90, Fortran 95, and Fortran 2000. The latter three versions are very different
from the former ones, so it makes sense to talk about two families of Fortran, before
and after Fortran 90.
Fortran 77 is a quite primitive language in the sense that there are few variable
types (only integer, real, complex, array, and string), few keywords, few control
structures, and a strict layout of the code. These limitations are not significant until
one tries to build fairly large codes. Fortran IV and Fortran 66 are even more primi-
tive and are of no significance today, except that there is lots of legacy code written
in these languages.
Fortran 77 is without competition the most widespread programming language
for scientific computing applications. The reasons for this are simplicity, tradition,
and high performance. The newer versions, Fortran 90, 95, and 2000, support pro-
gramming with objects (called modules), and have modernized Fortran, to some
Search WWH ::




Custom Search