FUNCTION FKDPHI
*-- Author : S.Burke / J.V. Morris
      DOUBLE PRECISION FUNCTION FKDPHI(PHI1,PHI2)
**********************************************************************                                        
*                                                                    *                                        
* Compute FKDPHI = PHI1-PHI2 , where PHI1 and PHI2 are in the range  *                                        
* zero to twopi.                                                     *                                        
* FKDPHI is between -pi and +pi                                      *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)                               
                                                                        
*KEEP,FKPIDP.                                                                                                 
      DOUBLE PRECISION PI,TWOPI,PIBY2                                   
      PARAMETER (PI=3.141592653589793238)                               
      PARAMETER (TWOPI=PI*2.0D0,PIBY2=PI/2.0D0)                         
*KEND.                                                                                                        
                                                                        
**********************************************************************                                        
                                                                        
      FKDPHI = PHI1 - PHI2                                              
                                                                        
      IF (DABS(FKDPHI).LT.PI) RETURN                                    
                                                                        
      IF (FKDPHI.GT.0.D0) THEN                                          
         FKDPHI = FKDPHI - TWOPI                                        
      ELSE                                                              
         FKDPHI = FKDPHI + TWOPI                                        
      ENDIF                                                             
                                                                        
      RETURN                                                            
      END                                                               
*                                                                                                             
*-----------------------------------------Updates 21/09/92-------                                             
**: FKETOI.......SB. Cope better (?) with zero field.                                                         
*-----------------------------------------Updates----------------