%   Terminate integration if ang passes through zero in the decreasing direction
%       or passes through pi in the increasing direction.
    function [value,isterminal,direction]=events(s,y,ipram)
    value=[y(1),y(1)-pi,y(3)-1.e-1];
    isterminal=[1,1,1];
    direction=[-1,+1,-1];