Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Best way to set up "once only" code ?

$
0
0

I have a subroutine where I only want to execute a block of statements the FIRST time it's called.

I tried to do it this way:

INTEGER  Once

DATA once/0/

IF(ONCE == 0)THEN

!  EXECUTES A BLOCK OF STATEMENTS

 

...

...

...

ONCE =1

ENDIF

For some reason, the compiler set it to Zero every time it was called.

How do I tell the compiler that an item is NOT supposed to be reinitialized every time?

I am not sure that the standard really addresses this issue.


Viewing all articles
Browse latest Browse all 5691

Trending Articles