SUBROUTINE FKDIFF
*-- Author : S.Burke / J.V. Morris
      SUBROUTINE FKDIFF(S1,S2,S3)
**********************************************************************                                        
*                                                                    *                                        
*  S3 = S1 - S2 (takes care of phi range)                            *                                        
*                                                                    *                                        
*  Delta phi is in the range -pi to pi                               *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)                               
                                                                        
      DIMENSION S1(5),S2(5),S3(5)                                       
                                                                        
*KEEP,FKPIDP.                                                                                                 
      DOUBLE PRECISION PI,TWOPI,PIBY2                                   
      PARAMETER (PI=3.141592653589793238)                               
      PARAMETER (TWOPI=PI*2.0D0,PIBY2=PI/2.0D0)                         
*KEND.                                                                                                        
                                                                        
**********************************************************************                                        
                                                                        
      S3(1) = S1(1) - S2(1)                                             
      S3(2) = S1(2) - S2(2)                                             
      S3(3) = S1(3) - S2(3)                                             
      S3(4) = S1(4) - S2(4)                                             
      S3(5) = S1(5) - S2(5)                                             
                                                                        
      IF (DABS(S3(5)).LT.PI) RETURN                                     
                                                                        
      IF (S3(5).GT.0.D0) THEN                                           
         S3(5) = S3(5) - TWOPI                                          
      ELSE                                                              
         S3(5) = S3(5) + TWOPI                                          
      ENDIF                                                             
                                                                        
      RETURN                                                            
      END                                                               
*