I have included one variable in one of the fortran functions. I use it in another function. But the meaning does not remain the same. In another function call, I get the garbage value. How to save the initialized value.
Example:
entry a () num_calls = 0 entry b () num_calls = num_calls + 1
From the entry "b" I get num_calls as some trash
In classic Fortran (Fortran 77 or earlier), you need to make sure that num_calls is defined in a common block - perhaps a named common block.
COMMON /magic/ num_calls
Fortran 90, , . , , , , - .
. :
INTEGER*4 num_calls COMMON /magic/ num_calls
FORTRAN 77 , , Fortran 90 COMMON. , Fortran 90/Fortran 2003, COMMON - GOTO ENTRY.
COMMON
GOTO
ENTRY
Fortran 90 ( ) COMMON, a MODULE. :
MODULE
module count_calls integer :: num_calls = 0 end module count_calls
, num_calls,
use count_calls
, ( a program MODULE).
program
num_calls , . -, FORTRAN, ...
num_calls
"save". , . , "", .
integer*4, save :: num_calls
This is a standard feature in most languages when local variables go undefined when they go out of scope.
Source: https://habr.com/ru/post/1713124/More articles:Allocator Slab - performance comparisonQt: add user interface elements with Qt Script - c ++Common Data in ASP.NET MVC Views - asp.net-mvcInteraction with external SQLite databases from Android. - androidRails Nested route for a unique resource - ruby-on-rails.net exception pool - .netWebSphere 6.1: Cannot start admin console after installing SSL-cert - sslCalling a method from a class - methodsDiscard a problem in a console application (Linux) - c ++Ruby to_yaml utf8 string - ruby | fooobar.comAll Articles