CALL subroutine-name(actual-argument-list)

Any reference to an internal or module subprogram is through an interface that is 'explicit' (that is, the compiler can see all the details). A reference to an external procedure is usually 'implicit' (the compiler assumes the details). However, we can provide an explicit interface in this case too, describing it in the interface unit: INTERFACE

:

END INTERFACE

An interface block is obligatory for:

  • optional and keyword arguments;
  • POINTER and TARGET arguments;
  • POINTER function result;
  • new-style array arguments and array functions.

Initialize variables. Operator DATA. Give an example.

Initialization – it is an assignment of some initial values to variables. In Fortran, there are several ways to initialize variables:

· in sentences description;

· in the operator DATA;

· in assignment statements;

· using input values ​​from the external file;

· using the program unit block data.

Initialization with the assignment operator has a number of drawbacks. First of all, we recall that when the assignment is doing the whole sequence of actions, such as the accessing to a memory, writing to registers, and so on. All of this leads to some consumption of CPU time. In addition, the operator of the form:

variable = constant for storing literal constants used only in one application time, necessary to withdraw a separate memory. Many initialization programs may increase the content of executable file.

When we use the operator DATA the initial values ​​are assigned to the objects already at compile time. Operator DATA has the following form:

DATA object list / list of values ​​/ [a list of objects/ list of values ​​/...]

Here a list of objects is a list of variables and implicit cycles, the list of values ​​- a list of scalar literal constants and constructors structures. The number of elements in the object list must match the number of elements in the list of values.

REAL:: X, Y

INTEGER, DIMENSION(4):: A

DATA X, Y /1.2, -3.12/

DATA A /1, 5, 5, 0/

Here, the variable x is set to 1.2, the variable y - a negative value - 3.12, and to the elements of the array next values:

А(1) = 1

А(2) = 5

А(3) = 5

А(4) = 0


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



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