SUBROUTINE FKXYRP
*-- Author : S.Burke / J.V. Morris
      SUBROUTINE FKXYRP(SIN,CIN,SOUT,COUT)
**********************************************************************                                        
*                                                                    *                                        
* Transform a state vector and covariance from (x,y) to (R,PHI)      *                                        
*                                                                    *                                        
* Both are assumed to be at fixed z.                                 *                                        
*                                                                    *                                        
*                        *** NOT TESTED ***                          *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)                               
                                                                        
      DIMENSION SIN(5),CIN(5,5),SOUT(5),COUT(5,5)                       
                                                                        
**********************************************************************                                        
                                                                        
      CALL UCOPY(SIN(3),SOUT(3),6)                                                                     
      CALL UCOPY(CIN(3,3),COUT(3,3),26)                                                                
                                                                        
      X = SIN(1)                                                        
      Y = SIN(2)                                                        
      X2 = X*X                                                          
      Y2 = Y*Y                                                          
      XY = X*Y                                                          
      XI = 1.D0/X                                                       
      X2I = XI*XI                                                       
      YXI = Y*XI                                                        
                                                                        
      SOUT(1) = SQRT(X2 + Y2)                                           
      SOUT(2) = ATAN2(Y,X)                                              
                                                                        
      RI = 1.D0/SOUT(1)                                                 
      R2I = RI*RI                                                       
      CPHI = COS(SOUT(2))                                               
      C2PHI = CPHI*CPHI                                                 
                                                                        
      CXX = CIN(1,1)                                                    
      CYY = CIN(2,2)                                                    
      CXY = CIN(2,1)                                                    
                                                                        
      COUT(1,1) = (X2*CXX + 2.D0*XY*CXY + Y2*CYY)*R2I                   
      COUT(2,1) = (Y*(CXX + CYY) + (X + Y2*XI)*CXY)*CPHI*RI*XI          
      COUT(3,1) = (X*CIN(3,1) + Y*CIN(3,2))*RI                          
      COUT(4,1) = (X*CIN(4,1) + Y*CIN(4,2))*RI                          
      COUT(5,1) = (X*CIN(5,1) + Y*CIN(5,2))*RI                          
                                                                        
      COUT(2,2) = (Y2*X2I*CXX - 2.D0*YXI*CXY + CYY)*C2PHI*X2I           
      COUT(3,2) = (YXI*CIN(3,1) + CIN(3,2))*CPHI*XI                     
      COUT(4,2) = (YXI*CIN(4,1) + CIN(4,2))*CPHI*XI                     
      COUT(5,2) = (YXI*CIN(5,1) + CIN(5,2))*CPHI*XI                     
                                                                        
      RETURN                                                            
      END                                                               
*