Arrays built-in types. Dynamic data structures. Give an example

Arrays built-in types it is are ordered sets of elements of the same type with the same parameter types. Arrays can have a fixed size; the number of elements in the array is given in its description.

Another case is a dynamic array, the number of elements which determined or changed during program execution.

In Fortran 90 came the opportunity to set not only the top, but the lower boundary of an array. The index of the first element - the lower bound, can be any integer including negative:

REAL, DIMENSION (-5:15):: A It means the elements of arrays starts from the index (-5) and lasts to the index (15).

The number of array elements in one dimension is called an extent (length) of the array in this dimension. The size of the array is equal to the product of its extent in all dimensions. The set of extents - integer array whose size is equal to that of the original array - called the shape of the array.

Dynamic data structures

One of the most serious disadvantages of earlier versions of Fortran, including Fortran 77, was the lack of use of dynamic memory.

Memory for the arrays must be allocated at compile time, in fact in the description of arrays in Fortran 90 this lack of was fixed, now in the language allowed dynamic arrays, the size of which, respectively, and the memory area defined in the course of program execution. Dynamic memory can also be allocated under the pointer. The operator ALLOCATE, allocating memory for the object is applicable only to arrays, preceded by the attribute ALLOCATABLE.


Понравилась статья? Добавь ее в закладку (CTRL+D) и не забудь поделиться с друзьями:  



double arrow
Сейчас читают про: