SUBROUTINE FKLPRO
*-- Author : S.Burke / J.V. Morris
      SUBROUTINE FKLPRO(JPL,IERR)
**********************************************************************                                        
*                                                                    *                                        
* Project the state vector and its covariance from plane JPL to      *                                        
* plane JPL+1, including multiple scattering.                        *                                        
*                                                                    *                                        
* ERROR CONDITIONS;                                                  *                                        
*       IERR =   0 ; normal termination                              *                                        
*   ->  IERR = 101 ; no filtered vector at JPL                       *                                        
*       IERR =   5 ; projection to JPL+1 already done                *                                        
*   ->  IERR = 111 ; failure to invert projected covariance          *                                        
*                                                                    *                                        
*   ->  Fatal errors                                                 *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)                               
                                                                        
      PARAMETER (IUTIL=0,IROUT=2)                                       
*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.                                                                                                        
                                                                        
*                                                                                                             
* Common block definitions                                                                                    
*                                                                                                             
*KEEP,FKNPL.                                                                                                  
      CHARACTER*5 CKDBG                                                 
      PARAMETER (CKDBG='FKDBG')                                         
      PARAMETER (NPL=72)                                                
      LOGICAL LTRUE,LFIRST,LTRPL,LTRPLD                                 
      DOUBLE PRECISION TRUE,RTRUE,CHITRU,SPRO,CPRO,SFIL,CFIL            
     &,                SSMT,CSMT,SSMTR,CSMTR,DPRO,CBPRO,QPRO,QGAIN      
     &,                RPRO,CRPRO,RFIL,CRFIL,RSMT,CRSMT,CHIFIL,CHISMT   
*                                                                                                             
* Per-track values can go in H1WORK; note that LTRUE and LFIRST must                                          
* be set at least per event.                                                                                  
*                                                                                                             
* This is about 36k words long; the remaining common blocks are                                               
* about 3.6k in total. Some of this could be in /H1WORK/, but the                                             
* blocks would have to be reorganised.                                                                        
*                                                                                                             
      COMMON /H1WORK/                                                   
* /FKPROJ/                                                                                                    
     &                SPRO(5,NPL),CPRO(5,5,NPL)                         
* /FKFILT/                                                                                                    
     &,               SFIL(5,NPL),CFIL(5,5,NPL)                         
* /FKSMTH/                                                                                                    
     &,               SSMT(5,NPL),CSMT(5,5,NPL)                         
     &,               SSMTR(5,NPL),CSMTR(5,5,NPL)                       
* /FKINT/                                                                                                     
     &,               DPRO(5,5,NPL),CBPRO(5,5,NPL),QPRO(5,5,NPL)        
     &,               QGAIN(5,5,NPL),IAPROX,LFIRST                      
* /FKRSID/                                                                                                    
     &,               RPRO(2,NPL),CRPRO(2,2,NPL),RFIL(2,NPL)            
     &,               CRFIL(2,2,NPL),RSMT(2,NPL),CRSMT(2,2,NPL)         
     &,               CHIFIL(NPL),CHISMT(NPL)                           
* /FKTRUE/                                                                                                    
     &,               TRUE(5,NPL),RTRUE(5,NPL),CHITRU(NPL),LTRUE        
* /FKDBG/                                                                                                     
     &,               LTRPL(NPL),LTRPLD(NPL)                            
*KEEP,FKCNTL.                                                                                                 
      COMMON /FKCNTL/ LUN,IPR,ITR,IPL,JSTART,JSTOP,JLAST,JSTEP          
*KEEP,FKCONS.                                                                                                 
      DOUBLE PRECISION ZPL,DZPL,RADL                                    
      COMMON /FKCONS/ ZPL(NPL),DZPL(NPL),RADL(NPL)                      
*KEEP,FKFLAG.                                                                                                 
      LOGICAL LPRO,LFIL,LSMT,LMES,LRAD,LRPRO,LRFIL,LRSMT,LPOINT,LBLOCK  
      COMMON /FKFLAG/ LPRO(NPL),LFIL(NPL),LSMT(NPL),LMES(NPL)           
     &,               LRAD(NPL),LRPRO,LRFIL,LRSMT,LPOINT,LBLOCK         
*KEEP,FKPROJ.                                                                                                 
*KEEP,FKFILT.                                                                                                 
*KEEP,FKINT.                                                                                                  
*KEND.                                                                                                        
                                                                        
**********************************************************************                                        
*                                                                                                             
* Local arrays etc ...                                                                                        
*                                                                                                             
      DIMENSION D(5,5)                                                  
                                                                        
**********************************************************************                                        
*                                                                                                             
* Initialisation and checks ....                                                                              
*                                                                                                             
      IERR = 0                                                          
                                                                        
      IF (.NOT.LFIL(JPL)) THEN                                          
* no filtered data at plane JPL ... terminate!                                                                
         CALL FKERR(IUTIL,IROUT,IFATAL,IINF1,IERR)
         RETURN                                                         
      ENDIF                                                             
                                                                        
* Number of next plane                                                                                        
      JPLN = JPL + JSTEP                                                
                                                                        
* Projection has already been made .... but do it anyway!                                                     
      IF (LPRO(JPLN)) CALL FKERR(IUTIL,IROUT,IWARN,IDONE,IERR)
                                                                        
**********************************************************************                                        
                                                                        
* Transform the state vector and covariance from JPL to JPL+1 ...                                             
      CALL FKTRAN(DZPL(JPL),ZPL(JPL),SFIL(1,JPL),SPRO(1,JPLN),D)
      CALL FKMUL(CFIL(1,1,JPL),D,CPRO(1,1,JPLN))
                                                                        
* RADL and LRAD are defined in an asymmetrical way                                                            
      JPLR = JPL + (JSTEP-1)/2                                          
                                                                        
      IF (LRAD(JPLR)) THEN                                              
* Compute the MS matrix                                                                                       
         CALL FKSCAT(DZPL(JPL),SFIL(1,JPL),RADL(JPLR),D,QPRO(1,1,JPL))
* ... and add to the projected error matrix                                                                   
         CALL FKQADD(CPRO(1,1,JPLN),QPRO(1,1,JPL))
* Calculate QGAIN for the smoother                                                                            
         CALL FKQG(CPRO(1,1,JPLN),QPRO(1,1,JPL),QGAIN(1,1,JPL),IFAIL)
         IF (IFAIL.NE.0) THEN                                           
            CALL FKERR(IUTIL,IROUT,IFATAL,IOCV,IERR)
            RETURN                                                      
         ENDIF                                                          
      ENDIF                                                             
                                                                        
* Projection is complete                                                                                      
      LPRO(JPLN) = .TRUE.                                               
                                                                        
      RETURN                                                            
      END                                                               
*