Civil Engineering Reference
In-Depth Information
This simple program also illustrates some other very useful features of the standard.
“Whole array” operations are permissible, so that the whole of an array is read in, or the
square root of all its elements computed, by a single statement. The efficiency with which
these features are implemented by practical compilers is variable.
1.9.2 Broadcasting
A feature called broadcasting enables operations on whole arrays by scalars such as two
or d3 in the above example. These scalars are said to be “broadcast” to all the elements
of the array so that what will be printed out are the square roots of all the elements of the
array having been multiplied by 2.0 and added to 3.0.
1.9.3 Constructors
Array elements can be assigned values in the normal way but Fortran 95 also permits the
“construction” of one-dimensional arrays, or vectors, such as the following:
v = (/1.0,2.0,3.0,4.0,5.0/)
which is equivalent to
v(1)=1.0; v(2)=2.0; v(3)=3.0; v(4)=4.0; v(5)=5.0
Array constructors can themselves be arrays, for example
w = (/v, v/)
would have the obvious result for the 10 numbers in w .
1.9.4 Vector subscripts
Integer vectors can be used to define subscripts of arrays, and this is very useful in the
“gather” and “scatter” operations involved in finite element (and other numerical) methods.
Figure 1.2 shows a portion of a finite element mesh of 8-node quadrilaterals with its nodes
numbered “globally” at least up to 106 in the example shown. When “local” calculations
have to be done involving individual elements, for example to determine element strains
or fluxes, a local index vector could hold the node numbers of each element, that is:
82
76
71
72
73
77
84
83
for element 65
93
87
82
83
84
88
95
94
for element 73
and so on. This index or “steering” vector could be called g . When a local vector has to
be gathered from a global one,
local = global(g)
is valid, and for scattering,
global(g) = local
Search WWH ::




Custom Search