Variable Initialization

At the beginning of each GPP run, all variables are in a special uninitialized state. Variables are only initialized when assigned a value for the first time, either by GPP or in the GPP program (the first assignment also turns them on).

Each array member needs to be initialized (assigned a value) separately. Consequently, some array members may be initialized while other may stay unused (and hence uninitialized) for the whole duration of the GPP run.

Interaction variables are always initialized, since they are assigned values before the program execution. Consequently, any variable declared as identical to an Interaction variable is also initialized (and assigned the same value). Interaction variables are also set on at the beginning of the program.

Some other variables are initialized with data from the DF2 file. Finally, variables may be initialized through the use of INIT files and the INIT_FILE statement.

Variables should not be used in the GPP program before they are initialized, since the result may seem unpredictable. A runtime warning will be issued in case an uninitialized variable is referred to during the program execution. No compilation-time warning is possible.

If (carelessly!) used in the GPP program, uninitialized variables exhibit the following behavior:

  • They are ignored (not printed) by OUTPUT and PRINT statements.

  • Their set status flags are initially turned off.

  • They can be turned on and off using the explicit SET_ON and SET_OFF statements. This does not make them initialized - they remain uninitialized. It only changes their set status flag.

  • When used in expressions, a runtime warning is issued. The value returned from any uninitialized variable is 0.0 for numeric variables and an empty string for string variables.

If another variable is assigned the value of an uninitialized variable, then the second variable is considered to be initialized (with the value 0.0). For instance, assume A and B are both un-initialized. Executing the statement B = A; will issue a runtime warning (about A) and will make B initialized (A will stay uninitialized).

GPP Compatibility Notes:

In the old GPP, variables seem to start as being on, even if they are not yet initialized. In GPP2, they always start in the off state.

In the old GPP, assigning a value of an uninitialized variable to another variable does not make the second variable initialized.

Some functionality may be dependent on the product package. Contact your Reseller if you require a license.