Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

initialize Variable in declaration section of a Subroutine

$
0
0
When I initialize a Variable in a Subroutine within the declaration section, the initialization is just executed in the first run of the Subroutine. In the second run, the old (saved?) value is used.
As a minimal example I have the following code with the output 1 and 5 instead of two times the 1.
Does someone understand this feature?



Program Test
Implicit none

Call Sub1( )
Call Sub1( )

contains

   Subroutine Sub1( )
   Implicit None
   Integer*4 :: j1=1
   Print*, j1
   j1=5
   End Subroutine Sub1

End Program Test

 

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>