>
      %break
    %default
      %assign errTxt = "Invalid location: %<location>"
      %<LibReportError(errTxt)>
  %endswitch
%endfunction

%% DocFunction{Code Configuration Functions}: LibMdlTerminateCustomCode =========
%%
%% Purpose:
%%	Place declaration statements and executable code inside the terminate
%%      function.
%%
%% Syntax:
%%	LibMdlTerminateCustomCode(buffer, location)
%%
%% Arguments:
%%      buffer: String buffer to append to internal cache buffer
%%      location:
%%        "header"      to place buffer at top of function
%%        "declaration" same as specifying header
%%        "execution"   to place buffer at top of function, but after header
%%        "trailer"     to place buffer at bottom of function)
%%
%% Returns:
%%	Nothing
%%
%% Description:
%%	LibMdlTerminateCustomCode places declaration statements and executable
%%	code inside the terminate function.
%%
%%      This code gets output into the following functions depending on
%%      the current code format:
%%
%%      Function Name         Code Format
%%      ---------------------------------
%%      <model>_terminate     Embedded-C
%%      mdlTerminate          S-function
%%      MdlTerminate          RealTime, RealTimeMalloc
%%
%%      Each call to this function appends your buffer to the internal
%%      cache buffer. 
%%
%function LibMdlTerminateCustomCode(buffer, location) void
  %assign ss = System[GetBaseSystemIdx()]
  %switch location
    %case "header"
    %case "declaration"
      %<LibAddToSystemField(ss, "TerminateHeader",  buffer)>
      %break
    %case "execution"
      %<LibAddToSystemField(ss, "TerminateBody",    buffer)>
      %break
    %case "trailer"
      %<LibAddToSystemField(ss, "TerminateTrailer", buffer)>
      %break
    %default
      %assign errTxt = "Invalid location: %<location>"
      %<LibReportError(errTxt)>
  %endswitch
%endfunction

%% DocFunction{Code Configuration Functions}: LibMdlRegCustomCode =============
%%
%% Purpose:
%%	Place declaration statements and executable code inside registrati