Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Revision history [back]

EMS global variables are not initialized properly(E+ V23.1)

IDF File Link

I am studying simple EMS script as below.

This is quiet simple script, but there are always EMS errors in the EDD file after complete the run.

The variable 'Var1' is global variable, and I test various EMS calling points for the initialization(see IDF script).

However, the EDD file always tell me that the 'Var1' is not initialized.

How can I fix this?

PROGRAM1,Line 1,IF VAR1 == 0, * Error: EvaluateExpression: Variable = 'VAR1' used in expression has not been initialized! * , During Warmup, Occurrence info=RUN PERIOD 1, 01/01 00:00 - 00:05

PROGRAM1,Line 6,SET VAR1 = VAR1+1, * Error: EvaluateExpression: Variable = 'VAR1' used in expression has not been initialized! * , During Warmup, Occurrence info=RUN PERIOD 1, 01/01 00:00 - 00:05

PROGRAM1,Line 1,IF VAR1 == 0, * Error: EvaluateExpression: Variable = 'VAR1' used in expression has not been initialized! * , During Warmup, Occurrence info=RUN PERIOD 1, 01/01 00:00 - 00:05

PROGRAM1,Line 6,SET VAR1 = VAR1+1, * Error: EvaluateExpression: Variable = 'VAR1' used in expression has not been initialized! * , During Warmup, Occurrence info=RUN PERIOD 1, 01/01 00:00 - 00:05

PROGRAM1,Line 1,IF VAR1 == 0, * Error: EvaluateExpression: Variable = 'VAR1' used in expression has not been initialized! * , During Warmup, Occurrence info=RUN PERIOD 1, 01/01 23:55 - 24:00

PROGRAM1,Line 6,SET VAR1 = VAR1+1, * Error: EvaluateExpression: Variable = 'VAR1' used in expression has not been initialized! * , During Warmup, Occurrence info=RUN PERIOD 1, 01/01 23:55 - 24:00

!- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAMCALLINGMANAGER ===========

EnergyManagementSystem:ProgramCallingManager,

run1,                    !- Name
BeginTimestepBeforePredictor,  !- EnergyPlus Model Calling Point
program1;                !- Program Name 1

EnergyManagementSystem:ProgramCallingManager,

inititate1,              !- Name
AfterComponentInputReadIn,  !- EnergyPlus Model Calling Point
init1;                   !- Program Name 1

EnergyManagementSystem:ProgramCallingManager,

initiate2,               !- Name
BeginNewEnvironment,     !- EnergyPlus Model Calling Point
init1;                   !- Program Name 1

EnergyManagementSystem:ProgramCallingManager,

initiate3,               !- Name
EndOfZoneSizing,         !- EnergyPlus Model Calling Point
init1;                   !- Program Name 1

EnergyManagementSystem:ProgramCallingManager,

initiate4,               !- Name
AfterNewEnvironmentWarmUpIsComplete,  !- EnergyPlus Model Calling Point
init1;                   !- Program Name 1

!- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:PROGRAM ===========

EnergyManagementSystem:Program,

program1,                !- Name
IF var1 == 0,            !- Program Line 1
SET aa = 1,              !- Program Line 2
ELSE,                    !- A4
SET aa = 2,              !- A5
ENDIF,                   !- A6
SET var1 = var1+1;       !- A7

EnergyManagementSystem:Program,

init1,                   !- Name
SET var1 = 0;            !- Program Line 1

!- =========== ALL OBJECTS IN CLASS: ENERGYMANAGEMENTSYSTEM:GLOBALVARIABLE ===========

EnergyManagementSystem:GlobalVariable,

var1;                    !- Erl Variable 1 Name