Skip to content

Commit

Permalink
Only run finalize model code if model is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
BSchilperoort committed Jan 3, 2024
1 parent f7b61dd commit 1601040
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/STEMMUS_SCOPE_exe.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ function STEMMUS_SCOPE_exe(config_file, runMode)
'TT' ... % Soil temperature over depth
}; %#ok

% Variables for tracking the state of the model initialization:
isInitialized = false;
isUpdated = false;

% ...until finalize has been run, at which point it quits.
while ~strcmp(bmiMode, "finalize")
Expand All @@ -49,12 +51,13 @@ function STEMMUS_SCOPE_exe(config_file, runMode)
if isInitialized
% The 'initialize', 'update' and 'finalize' run modes are dispatched to the model.
run STEMMUS_SCOPE;
isUpdated = true;
else
disp("First initialize the model before calling 'update'");
end

elseif strcmp(bmiMode, "finalize")
if isInitialized
if isInitialized & isUpdated
run STEMMUS_SCOPE;
end

Expand Down

0 comments on commit 1601040

Please sign in to comment.