SUBROUTINE FKCVXY
*-- Author : S.Burke
      SUBROUTINE FKCVXY(CPRO,GMES,CFIL,WT,IERR)
**********************************************************************                                        
*                                                                    *                                        
* Calculate filtered covariance for an x/y measurement               *                                        
*                                                                    *                                        
* ERROR CONDITIONS;                                                  *                                        
*       IERR =   0 ; normal termination                              *                                        
*   ->  IERR = 111 ; filtered covariance not positive definite       *                                        
*                                                                    *                                        
*   ->  Fatal error                                                  *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)                               
                                                                        
      PARAMETER (IUTIL=1,IROUT=11)                                      
*KEEP,FKECODE.                                                                                                
      PARAMETER (IWARN=0,IFATAL=1,IFPRO=2,IFFLT=3,IFSMO=4,IFPRS=5,      
     &           IFPAS=6,IFPAF=7)                                       
      PARAMETER (IINF1=1,IINF2=2,IINF3=3,IINV=4,IDONE=5)                
      PARAMETER (IICV=6,IMCV=7,IOCV=11,IRCV=12,IOVCV=13,                
     &           ITHGP2=16,ITHG1=17)                                    
      PARAMETER (IFREE=20,IFREE1=30,IFREE2=40,IFREE3=50)                
*KEND.                                                                                                        
                                                                        
      DIMENSION CPRO(5,5),GMES(2,2),CFIL(5,5),WT(2,5)                   
                                                                        
**********************************************************************                                        
                                                                        
      IERR = 0                                                          
                                                                        
* Calculate the top two rows of G.CPRO + 1 ...                                                                
      GC11 = GMES(1,1)*CPRO(1,1) + GMES(2,1)*CPRO(2,1) + 1.D0           
      GC12 = GMES(1,1)*CPRO(2,1) + GMES(2,1)*CPRO(2,2)                  
      GC13 = GMES(1,1)*CPRO(3,1) + GMES(2,1)*CPRO(3,2)                  
      GC14 = GMES(1,1)*CPRO(4,1) + GMES(2,1)*CPRO(4,2)                  
      GC15 = GMES(1,1)*CPRO(5,1) + GMES(2,1)*CPRO(5,2)                  
                                                                        
      GC21 = GMES(2,1)*CPRO(1,1) + GMES(2,2)*CPRO(2,1)                  
      GC22 = GMES(2,1)*CPRO(2,1) + GMES(2,2)*CPRO(2,2) + 1.D0           
      GC23 = GMES(2,1)*CPRO(3,1) + GMES(2,2)*CPRO(3,2)                  
      GC24 = GMES(2,1)*CPRO(4,1) + GMES(2,2)*CPRO(4,2)                  
      GC25 = GMES(2,1)*CPRO(5,1) + GMES(2,2)*CPRO(5,2)                  
                                                                        
* ... and invert (only the top two rows are non-trivial) ...                                                  
      DET = GC11*GC22 - GC12*GC21                                       
      IF (DET.LE.0.) THEN                                               
         CALL FKERR(IUTIL,IROUT,IFATAL,IOCV,IERR)
         RETURN                                                         
      ENDIF                                                             
      DET = 1.D0/DET                                                    
                                                                        
      GDET22 = GC22*DET                                                 
      GDET12 = GC12*DET                                                 
      WT(1,1) =  GDET22                                                 
      WT(1,2) = -GDET12                                                 
      WT(1,3) =  GDET12*GC23 - GC13*GDET22                              
      WT(1,4) =  GDET12*GC24 - GC14*GDET22                              
      WT(1,5) =  GDET12*GC25 - GC15*GDET22                              
                                                                        
      GDET11 = GC11*DET                                                 
      GDET21 = GC21*DET                                                 
      WT(2,1) = -GDET21                                                 
      WT(2,2) =  GDET11                                                 
      WT(2,3) =  GC13*GDET21 - GDET11*GC23                              
      WT(2,4) =  GC14*GDET21 - GDET11*GC24                              
      WT(2,5) =  GC15*GDET21 - GDET11*GC25                              
                                                                        
* ... and finally, premultiply by CPRO                                                                        
                                                                        
      CFIL(1,1) = CPRO(1,1)*WT(1,1) + CPRO(2,1)*WT(2,1)                 
                                                                        
      CFIL(2,1) = CPRO(2,1)*WT(1,1) + CPRO(2,2)*WT(2,1)                 
      CFIL(2,2) = CPRO(2,1)*WT(1,2) + CPRO(2,2)*WT(2,2)                 
                                                                        
      CFIL(3,1) = CPRO(3,1)*WT(1,1) + CPRO(3,2)*WT(2,1)                 
      CFIL(3,2) = CPRO(3,1)*WT(1,2) + CPRO(3,2)*WT(2,2)                 
      CFIL(3,3) = CPRO(3,1)*WT(1,3) + CPRO(3,2)*WT(2,3) + CPRO(3,3)     
                                                                        
      CFIL(4,1) = CPRO(4,1)*WT(1,1) + CPRO(4,2)*WT(2,1)                 
      CFIL(4,2) = CPRO(4,1)*WT(1,2) + CPRO(4,2)*WT(2,2)                 
      CFIL(4,3) = CPRO(4,1)*WT(1,3) + CPRO(4,2)*WT(2,3) + CPRO(4,3)     
      CFIL(4,4) = CPRO(4,1)*WT(1,4) + CPRO(4,2)*WT(2,4) + CPRO(4,4)     
                                                                        
      CFIL(5,1) = CPRO(5,1)*WT(1,1) + CPRO(5,2)*WT(2,1)                 
      CFIL(5,2) = CPRO(5,1)*WT(1,2) + CPRO(5,2)*WT(2,2)                 
      CFIL(5,3) = CPRO(5,1)*WT(1,3) + CPRO(5,2)*WT(2,3) + CPRO(5,3)     
      CFIL(5,4) = CPRO(5,1)*WT(1,4) + CPRO(5,2)*WT(2,4) + CPRO(5,4)     
      CFIL(5,5) = CPRO(5,1)*WT(1,5) + CPRO(5,2)*WT(2,5) + CPRO(5,5)     
                                                                        
      RETURN                                                            
      END                                                               
*