function push_evt(t,evt_nbr)
%
%  This routine pushes an event onto the event calendar
%    t is the time of occurrence of the new event
%    evt_nbr is the event number (must be a positive integer)
%
%  We start by creating the event calendar if it doesn't exist yet
%
global evt_cal
%
%  Check whether the event calendar is empty
%  If so, insert the event
%
if prod(size(evt_cal)) == 0,
  evt_cal = [ t, evt_nbr ];
  return
end
%
%  The event calendar wasn't empty, hence insert the new event at the
%  right place (we use a simple rather than an efficient implementation
%  of the event calendar)
%
[n,m] = size(evt_cal);
for i=1:n,
  t1 = evt_cal(i,1);
  if t < t1,
    for j=n+1:-1:i+1,
      evt_cal(j,:) = evt_cal(j-1,:);
    end,
    evt_cal(i,:) = [ t, evt_nbr ];
    return
  end,
end
%
%  The new event is the last one in the waiting queue
%
evt_cal(n+1,:) = [ t, evt_nbr ];
%
return