Fort 18

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

M.

Sc 1st Semester

Computational techniques
Lecture 1.8
Out of Bound array subscript:

Subscript cannot be more then or less then


the one which is suggested in array
dimension

e.g. in above, while addressing some element


subscript of array a cannot be more then 5
and less then 1
Use of named constants for array declaration:
We should define the size of array by named
Constants.

Helpful for large program. Sizes of arrays


can be changed in code by just changing
named constant at one single place
Using whole array or subset of array as
arithmetic Fortran statement :

Whole array can be used in arithmetic


operation as it is a ordinary variable

If two arrays are of same shape then they can


be used as arithmetic operation. Operation is
applied element to element basis.
Operation is applied using Do Loop and also
direct addition
Two arrays can be used as operands (for
addition, sub etc. ) if they are of same
shape i.e. they have same dimension and
also same number of elements in each
dimension

Two arrays of same shape are known as


conformable.

It is not necessary that the range of


subscripts in two arrays is same
e.g. two array of different range added by
simple arithmetic operation

Scalar values are also conformable


Intrinsic function of Fortran accept the
array as input argument and result in new array

e.g. if we have
Array subset: Subset of array is known as
array section

First last increment


Example:

Array subset

Result:
 Note that all the elements of subscript
triplet are defaulted

If first one is missing, by default it will


consider first element of array

If 2nd one is missing, it will consider last


Element

If last is missing then increment is considered


as one
Different possibilities are :
Example:

1.

2.
3.

4.

5.
6.
Vector subscript is one dimensional integer
array and can choose arbitrary element
from the given array.
Subscript triplet choose only ordered pair

You might also like