SUBROUTINE FKDMQD
*-- Author : S.Burke / J.V. Morris
      SUBROUTINE FKDMQD(DINV,QGAIN,AGAIN)
**********************************************************************                                        
*                                                                    *                                        
* Calculate the smoother gain matrix                                 *                                        
*                                                                    *                                        
* Output is AGAIN = DINV.(1 - QGAIN)                                 *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      IMPLICIT DOUBLE PRECISION (A-H,O-Z)                               
                                                                        
      DIMENSION DINV(5,5),QGAIN(5,5),AGAIN(5,5)                         
                                                                        
**********************************************************************                                        
                                                                        
      AGAIN(1,1) = 1.D0      - QGAIN(1,1) - DINV(1,4)*QGAIN(4,1)        
     &                                    - DINV(1,5)*QGAIN(5,1)        
      AGAIN(1,2) =           - QGAIN(1,2) - DINV(1,4)*QGAIN(4,2)        
     &                                    - DINV(1,5)*QGAIN(5,2)        
      AGAIN(1,3) = DINV(1,3) - QGAIN(1,3) - DINV(1,4)*QGAIN(4,3)        
     &                                    - DINV(1,5)*QGAIN(5,3)        
      AGAIN(1,4) = DINV(1,4) - QGAIN(1,4) - DINV(1,4)*QGAIN(4,4)        
     &                                    - DINV(1,5)*QGAIN(5,4)        
      AGAIN(1,5) = DINV(1,5) - QGAIN(1,5) - DINV(1,4)*QGAIN(4,5)        
     &                                    - DINV(1,5)*QGAIN(5,5)        
                                                                        
      AGAIN(2,1) =           - QGAIN(2,1) - DINV(2,4)*QGAIN(4,1)        
     &                                    - DINV(2,5)*QGAIN(5,1)        
      AGAIN(2,2) = 1.D0      - QGAIN(2,2) - DINV(2,4)*QGAIN(4,2)        
     &                                    - DINV(2,5)*QGAIN(5,2)        
      AGAIN(2,3) = DINV(2,3) - QGAIN(2,3) - DINV(2,4)*QGAIN(4,3)        
     &                                    - DINV(2,5)*QGAIN(5,3)        
      AGAIN(2,4) = DINV(2,4) - QGAIN(2,4) - DINV(2,4)*QGAIN(4,4)        
     &                                    - DINV(2,5)*QGAIN(5,4)        
      AGAIN(2,5) = DINV(2,5) - QGAIN(2,5) - DINV(2,4)*QGAIN(4,5)        
     &                                    - DINV(2,5)*QGAIN(5,5)        
                                                                        
      AGAIN(3,3) = 1.D0                                                 
                                                                        
      AGAIN(4,1) =      - QGAIN(4,1)                                    
      AGAIN(4,2) =      - QGAIN(4,2)                                    
      AGAIN(4,3) =      - QGAIN(4,3)                                    
      AGAIN(4,4) = 1.D0 - QGAIN(4,4)                                    
      AGAIN(4,5) =      - QGAIN(4,5)                                    
                                                                        
      AGAIN(5,1) =           - DINV(5,4)*QGAIN(4,1) - QGAIN(5,1)        
      AGAIN(5,2) =           - DINV(5,4)*QGAIN(4,2) - QGAIN(5,2)        
      AGAIN(5,3) = DINV(5,3) - DINV(5,4)*QGAIN(4,3) - QGAIN(5,3)        
      AGAIN(5,4) = DINV(5,4) - DINV(5,4)*QGAIN(4,4) - QGAIN(5,4)        
      AGAIN(5,5) = 1.D0      - DINV(5,4)*QGAIN(4,5) - QGAIN(5,5)        
                                                                        
      RETURN                                                            
      END                                                               
*