                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     MAIN : DRIVER FOR FORTRAN TRACKER                                 
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                    
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      PROGRAM TRACK                                                     
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES      : NUMBER OF LAUNCH SITES                              
C     NFSITE(I)   : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)   : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)   : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP      : TIME STEP BETWEEN DATA SCANS                        
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS      : SENSOR LONGITUDE (RADIANS)                          
C     MAXTHR      : MAXIMUM THREAT SIZE (400, SET IN MAIN )             
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)   : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)    : DATA USE COUNTERS FOR EXTEND, BATCH                 
C     SIGMES      : RMS MEASUREMENT RESOLUTION                          
C     SIGMS2      : MEASUREMENT VARIANCE                                
C     ITROLD(I)   : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ     : BATCH INITIATION DATA STORAGE                       
C                                                                       
C     NNSJ        : FIRST HIT FROM SITE COUNTERS                        
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C                   SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED    
C                   CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE    
C                   ARE AS FOLLOWS:                                     
C                                                                       
C                   400 -> MAXTHR                                       
C                    10 -> MAXSIT                                       
C                    11 -> MAXSIT+1                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TRACK STORAGE FOR FORTRAN TRACKER                                 
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TIMING VARIABLES                                                  
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TIMERC/ TSBI,TABI,TSKF,TAKF,TSPR,TAPR,TSTH,TATH           
                                                                        
C     TSBI : STEP TIME, BATCH INITIATION                                
C     TABI : TOTAL TIME, BATCH INITIATION                               
C     TSKF : STEP TIME, FOCAL PLANE FILTER                              
C     TAKF : TOTAL TIME, FOCAL PLANE FILTER                             
C     TSPR : STEP TIME, PRECISION TRACKER                               
C     TAPR : TOTAL TIME, PRECISION TRACKER                              
C     TSTH : STEP TIME, SENSOR DATA GENERATION                          
C     TATH : TOTAL TIME, SENSOR DATA GENERATION                         
                                                                        
      DOUBLE PRECISION Z,R,VZ,VR,AZ,AR,TDUM                             
      REAL T1,T2,T3,T4                                                  
      DIMENSION SIG0(4)                                                 
C-----------------------------------------------------------------------
CX00001 CALL MAINIX (1)                                                 
CY00001 CALL MAINIY (1)                                                 
CX60000 CALL CNTINX ()                                                  
CY60000 CALL CNTINY ()                                                  
C---- OPEN INPUT FILES -------------------------------------------------
C-----------------------------------------------------------------------
      OPEN(5,FILE='MTI5',STATUS='OLD')                                  
      OPEN(15,FILE='MTI15',STATUS='OLD')                                
      OPEN(16,FILE='MTI16',STATUS='OLD')                                
      OPEN(4,FILE='MTV',STATUS='UNKNOWN')                               
      OPEN(6,FILE='MTO6',STATUS='UNKNOWN')                              
C                                                                       
      CALL CPUTIM(T1)                                                   
      CALL ELAPSE(T2)                                                   
C                                                                       
C **********************************************************************
C *** THE FOLLOWING LIMITS MUST AGREE WITH DIMENSIONS   ****************
C *** IN THDAT.INC AND TRAXCM.INC                       ****************
C **********************************************************************
                                                                        
      MAXTRK=1600                                                       
      MAXTHR=500                                                        
      MAXSIT=15                                                         
                                                                        
C ----------------------------------------------------------------------
C --- PROGRAM INITIALIZATIONS ------------------------------------------
C ----------------------------------------------------------------------
                                                                        
C     T1=CPUTYM(1.0)                                                    
      CALL CPUTIM(T11)                                                  
      TAKF=0.0                                                          
      TABI=0.0                                                          
      TAPR=0.0                                                          
      TATH=0.0                                                          
      TATOT=0.0                                                         
C                                       LINEAR FILTER INITIALIZATION ---
      READ(5,*) DT,WB,CELL,FACM,IPFL                                    
      READ(5,*) SIG0                                                    
      CALL FINIT4(DT,WB,CELL,FACM,SIG0,IPFL)                            
C                                       BOOSTER PROFILE INITIALIZATION -
      TDUM=123.45                                                       
      CALL PROFYL(TDUM,Z,R,VZ,VR,AZ,AR)                                 
C                                       THREAT INITIALIZATION ----------
      READ(5,*) IPFL                                                    
      CALL THINIT(IPFL)                                                 
C                                       SENSOR INITIALIZATION ----------
      READ(5,*) PHSD,IPFL                                               
      CALL SENINT(PHSD,IPFL)                                            
C                                       BATCH INITIATOR INITIALIZATION -
      READ(5,*) VVMIN,FRVC,FRXZ,NHL,THMX,IPFL                           
      CALL MSINIT(VVMIN,FRVC,FRXZ,NHL,THMX,IPFL)                        
C                                       FOCAL PLANE FILTER INITS. ------
      READ(5,*) GATE1,GATE2,NEQQ,ALVNEW,IPFL                            
      CALL EXTINT(GATE1,GATE2,NEQQ,ALVNEW,IPFL)                         
C                                       PRECISION FILTER INITIALIZATIONS
      READ(5,*) NPRNEW,EXTNEW,IGOCH2,CH2NEW,MAXNEW,IPFL                 
      CALL NLINIT(NPRNEW,EXTNEW,IGOCH2,CH2NEW,MAXNEW,IPFL)              
C                                       GET SIMULATION LIMITS ----------
      READ(5,*) TNOW,NSTEP,IPRANS                                       
                                                                        
C     TINIT=CPUTYM(2.0)-T1                                              
C                                                                       
      CALL CPUTIM(T12)                                                  
      TINIT=T12-T11                                                     
      WRITE(6,900) NSTEP,TNOW,TINIT                                     
      WRITE(6,901)                                                      
      CALL CPUTIM(TSTART)                                               
C     TSTART=CPUTYM(1.0)                                                
                                                                        
                                                                        
C ----------------------------------------------------------------------
C --- MAIN SIMULATION LOOP ---------------------------------------------
C ----------------------------------------------------------------------
                                                                        
      TNOW=TNOW-TISTEP                                                  
CX10501 CALL DOINX( 501 )                                               
CY10501 CALL DOINY( 501 )                                               
      DO 400 KSTEP=1,NSTEP                                              
C                                       GENERATE SENSOR DATA -----------
      TNOW=TNOW+TISTEP                                                  
      CALL GETDAT(TNOW)                                                 
C                                       LINEAR TRACKING OPERATIONS -----
      CALL FPTRAK(NNEW,ISTAT)                                           
      IF( ISTAT.GE.0 ) GO TO 200                                        
      WRITE(6,990) ISTAT                                                
      CALL TERMN8                                                       
C                                       PRECISION TRACKING -------------
  200 CALL NLFILT(NPREC,NRJCT)                                          
C                                       STEP OUTPUT SUMMARY ------------
      TSTOT=TSBI+TSKF+TSPR                                              
      TATOT=TATOT+TSTOT                                                 
      NOUSED=0                                                          
      IF( LSTDAT.LT.1) GO TO 204                                        
      DO 202 K=1,LSTDAT                                                 
      IF( NUSED(K).EQ.0 ) NOUSED=NOUSED+1                               
  202 CONTINUE                                                          
  204 CONTINUE                                                          
                                                                        
      WRITE(6,902) KSTEP,TNOW,LSTDAT,NOUSED,LSTTRK,NNEW,NPREC,          
     +          TSBI,TSKF,TSPR,TSTOT                                    
      WRITE(6,903) TABI,TAKF,TAPR,TATOT                                 
                                                                        
  400 CONTINUE                                                          
CX20502 CALL DOOUTX( 502 )                                              
CY20502 CALL DOOUTY( 502 )                                              
                                                                        
C                                                                       
C ----------------------------------------------------------------------
C --- PRINT FINAL TIMING SUMMARIES -------------------------------------
C ----------------------------------------------------------------------
                                                                        
      CALL CPUTIM(T13)                                                  
      TIMBIG=T13-TSTART                                                 
C                                                                       
      WRITE(4,301)                                                      
301   FORMAT(1X,
     * 'OUTPUT FOR PERFECT CLUB BENCHMARK: TRACK INSTRUMENTED VERSION'/
     *       1X,'$Revision: 1.A.1 $ $Author: psharma $'/)
      WRITE(4,302)                                                      
302   FORMAT(1X,'VALIDATION PARAMETERS:'/)                              
C                                                                       
      WRITE(6,904) TABI,TAKF,TAPR,TATOT,TATH,TIMBIG                     
      IF( IPRANS.LT.1 ) GOTO 99                                         
      CALL TRUTHP                                                       
      IF( IPRANS.LT.2 ) GOTO 99                                         
      CALL PRSCOR                                                       
      IF( IPRANS.LT.3 ) GOTO 99                                         
      CALL PRPARM                                                       
      IF( IPRANS.GT.3 ) CALL PRTRAX                                     
C                                                                       
99    CALL CPUTIM(T3)                                                   
      CALL ELAPSE(T4)                                                   
C                                                                       
      WRITE(4,*)                                                        
C MFLOPS = MFLOP 1 CPU CRAY X-MP/CPU TIME                               
      WRITE(4,*) 'ELAPSED CPU TIME IN SECONDS: ',T3-T1                  
      WRITE(4,*) 'MFLOPS RATE: ', 81.624/(T3-T1)                        
      WRITE(4,*) 'ELAPSED WALLCLOCK TIME IN SECONDS: ',                 
     *            MOD(T4-T2+1000000.0,1000000.0)                        
CX70000 CALL CNTOTX ()                                                  
CY70000 CALL CNTOTY ()                                                  
CX50000 CALL MAINOX ()                                                  
CY50000 CALL MAINOY ()                                                  
C                                                                       
      STOP                                                              
C                                                                       
  900 FORMAT(/2X,I8,' : NUMBER OF SCANS TO BE PROCESSED'/               
     +2X,F8.2,' : TIME OF FIRST SENSOR DATA'//                          
     +2X,F8.2,' : TOTAL CPU TIME FOR INITIALIZATIONS'//                 
     +' INITIALIZATIONS COMPLETED --------------------------'/)         
  901 FORMAT(/                                                          
     +'             DATA FILE     TRACK FILES   ',                      
     +'   TIMING (STEP/CUMULATIVE) [SEC]'/                              
     +'  NS  TIME   TOTL  NEW   TOTL  NEW   PREC',                      
     +'   BATCH   FILTER  PRECIS  TOTAL '/                              
     +'  --  -----  ----  ----  ----  ----  ----',                      
     +'   ------  ------  ------  ------')                              
  902 FORMAT(2X,I2,2X,F5.1,2X,I4,2X,I4,2X,I4,2X,I4,2X,I4,               
     +3X,F7.2,2X,F7.2,2X,F7.2,2X,F7.2)                                  
  903 FORMAT(44X,F7.2,2X,F7.2,2X,F7.2,2X,F7.2/)                         
  904 FORMAT(//' FINAL TIMING SUMMARY'/1X,50('-')/                      
     +2X,F7.2,' : BATCH MODE TRACK INITIATION'/                         
     +2X,F7.2,' : FOCAL PLANE LINEAR FILTERING'/                        
     +2X,F7.2,' : PRECISION PARAMETER FILTER'/                          
     +2X,F7.2,' : TOTAL TRACKING COMPUTATION TIME'/                     
     +2X,F7.2,' : SENSOR DATA GENERATION'/                              
     +2X,F7.2,' : TOTAL RUN TIME, EXCLUDING INITIALIZATIONS'//)         
  990 FORMAT(/1X,50('*')/                                               
     +' FPTRAK ERROR STATUS ',I3/1X,50('*')/)                           
CX70000 CALL CNTOTX ()                                                  
CY70000 CALL CNTOTY ()                                                  
CX50000 CALL MAINOX ()                                                  
CY50000 CALL MAINOY ()                                                  
      END                                                               
                                                                        
      SUBROUTINE TERMN8                                                 
CX30003 CALL SBINX (3)                                                  
CY30003 CALL SBINY (3)                                                  
      WRITE(6,999)                                                      
  999 FORMAT(//' *** PROGRAM CRASH AND BURN *****'/)                    
CX40004 CALL SBOUTX (4)                                                 
CY40004 CALL SBOUTY (4)                                                 
      STOP                                                              
      END                                                               
C***********************************************************************
C                                                                       
C     FOCAL-PLANE KALMAN FILTER PACKAGE                                 
C                                                                       
C     ROUTINES IN THIS FILE ------------------------------------------- 
C       FINIT4 : FILTER INITIALIZATIONS                                 
C        FPRED : STATE VECTOR PREDICTION                                
C       FILTR4 : STATE VECTOR FILTERING                                 
C                                                                       
C***********************************************************************
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     FINIT4 : INITIALIZATION FOR 4-STATE KINEMATIC FILTER MODEL        
C                                                                       
C      USAGE : CALL FINIT4(DT,WB,CELL,FACM,SIG0,IPFL)                   
C         DT : TIME STEP BETWEEN DATA (SEC)                             
C         WB : STOCHASTIC PARAMETER (KM/(SEC^7/2))                      
C       CELL : SENSOR PIXEL SIZE (KM)                                   
C       FACM : MEASUREMENT UNCERTAINTY ENHANCEMENT                      
C       SIG0 : VECTOR OF INITIAL, DIAGONAL COVARIANCES                  
C            : ( PXX, PVV, PAA, PJJ ) (KM,SEC UNITS)                    
C       IPFL : PRINT FLAG, LIST INITIALIZATIONS IF POSITIVE             
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE FINIT4(DT,WB,CELL,FACM,SIG0,IPFL)                      
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C       THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                  
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES      : NUMBER OF LAUNCH SITES                              
C     NFSITE(I)   : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)   : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)   : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP      : TIME STEP BETWEEN DATA SCANS                        
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS      : SENSOR LONGITUDE (RADIANS)                          
C     MAXTHR      : MAXIMUM THREAT SIZE (400, SET IN MAIN )             
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)   : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)    : DATA USE COUNTERS FOR EXTEND, BATCH                 
C     SIGMES      : RMS MEASUREMENT RESOLUTION                          
C     SIGMS2      : MEASUREMENT VARIANCE                                
C     ITROLD(I)   : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ     : BATCH INITIATION DATA STORAGE                       
C                                                                       
C     NNSJ        : FIRST HIT FROM SITE COUNTERS                        
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C                   SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED    
C                   CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE    
C                   ARE AS FOLLOWS:                                     
C                                                                       
C                   400 -> MAXTHR                                       
C                    10 -> MAXSIT                                       
C                    11 -> MAXSIT+1                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      COMMON /FIL4CM/ PM(4,4,15),PP(4,4,15),AK(4,15),                   
     +                DELTAT,PHI(4,4)                                   
      DOUBLE PRECISION P0(4,4),TM1(4,4),TM2(4,4),Q(4,4)                 
      DOUBLE PRECISION PHIT(4,4)                                        
      DIMENSION SIG0(4)                                                 
      DOUBLE PRECISION PM,PP,AK,DELTAT,PHI                              
      DOUBLE PRECISION SIGM,T,T2,T3,T4,Q0,BOT                           
CX30005 CALL SBINX (5)                                                  
CY30005 CALL SBINY (5)                                                  
                                                                        
      CELSIZ=CELL                                                       
      SIGM=FACM*CELL*CELL/12.                                           
      SIGMS2=SIGM                                                       
      SIGMES=SQRT(SIGMS2)                                               
      TISTEP=DT                                                         
C                                                                       
C     INITIALIZE MODEL COVARIANCE MATRIX                                
C                                                                       
      T=DT                                                              
      DELTAT=T                                                          
      T2=T*T                                                            
      T3=T2*T                                                           
      T4=T3*T                                                           
      Q0=WB*WB                                                          
      Q(1,1)=Q0*T3*T4/252.                                              
      Q(1,2)=Q0*T3*T3/72.                                               
      Q(1,3)=Q0*T2*T3/30.                                               
      Q(1,4)=Q0*T4/24.                                                  
      Q(2,1)=Q(1,2)                                                     
      Q(2,2)=Q0*T3*T2/20.                                               
      Q(2,3)=Q0*T4/8.                                                   
      Q(2,4)=Q0*T3/6.                                                   
      Q(3,1)=Q(1,3)                                                     
      Q(3,2)=Q(2,3)                                                     
      Q(3,3)=Q0*T3/3.                                                   
      Q(3,4)=Q0*T2/2.                                                   
      Q(4,1)=Q(1,4)                                                     
      Q(4,2)=Q(2,4)                                                     
      Q(4,3)=Q(3,4)                                                     
      Q(4,4)=Q0*T                                                       
CX10503 CALL DOINX( 503 )                                               
CY10503 CALL DOINY( 503 )                                               
C                                                                       
C     EVALUATE INITIAL COVARIANCE, STATE TRANSITION MATRIX              
C                                                                       
      DO 110 K=1,4                                                      
      DO 100 J=1,4                                                      
      PHI(K,J)=0.0                                                      
  100 P0(K,J)=0.0                                                       
      PHI(K,K)=1.0                                                      
  110 P0(K,K)=SIG0(K)*SIG0(K)                                           
CX20504 CALL DOOUTX( 504 )                                              
CY20504 CALL DOOUTY( 504 )                                              
      PHI(1,2)=T                                                        
      PHI(1,3)=T2/2.                                                    
      PHI(1,4)=T3/6.                                                    
      PHI(2,3)=T                                                        
      PHI(2,4)=T2/2.                                                    
      PHI(3,4)=T                                                        
CX10505 CALL DOINX( 505 )                                               
CY10505 CALL DOINY( 505 )                                               
      DO 130 K=1,4                                                      
      DO 130 J=1,4                                                      
      PHIT(K,J)=PHI(J,K)                                                
  130 CONTINUE                                                          
CX20506 CALL DOOUTX( 506 )                                              
CY20506 CALL DOOUTY( 506 )                                              
CX10507 CALL DOINX( 507 )                                               
CY10507 CALL DOINY( 507 )                                               
C                                                                       
C     SET UP FIXED FILTER COEFFICIENTS FOR 15 TIME STEPS                
C                                                                       
      DO 160 KS=1,15                                                    
      KSM=KS-1                                                          
      IF(KS.EQ.1) CALL MATMLT(P0,PHIT,TM1,4,4,4)                        
      IF(KS.GT.1) CALL MATMLT(PP(1,1,KSM),PHIT,TM1,4,4,4)               
      CALL MATMLT(PHI,TM1,TM2,4,4,4)                                    
      CALL MATADD(TM2,Q,PM(1,1,KS),4,4,1.0D0,1.0D0)                     
      BOT=PM(1,1,KS)+SIGM                                               
      DO 140 K=1,4                                                      
  140 AK(K,KS)=PM(K,1,KS)/BOT                                           
      DO 150 K=1,4                                                      
      DO 150 J=1,4                                                      
      TM1(K,J)=0.0                                                      
      IF(K.EQ.J) TM1(K,J)=1.0                                           
      IF(J.EQ.1) TM1(K,J)=TM1(K,J)-AK(K,KS)                             
  150 CONTINUE                                                          
      CALL MATMLT(TM1,PM(1,1,KS),PP(1,1,KS),4,4,4)                      
  160 CONTINUE                                                          
CX20508 CALL DOOUTX( 508 )                                              
CY20508 CALL DOOUTY( 508 )                                              
C                                                                       
      IF(IPFL.LE.0) THEN                                                
CX40006 CALL SBOUTX (6)                                                 
CY40006 CALL SBOUTY (6)                                                 
      RETURN                                                            
      ENDIF                                                             
C                                                                       
      WRITE(6,900) DT,WB,CELL,FACM,SIGM,SIG0                            
      IF(IPFL.LT.2) THEN                                                
CX40006 CALL SBOUTX (6)                                                 
CY40006 CALL SBOUTY (6)                                                 
      RETURN                                                            
      ENDIF                                                             
      WRITE(6,902)                                                      
CX10509 CALL DOINX( 509 )                                               
CY10509 CALL DOINY( 509 )                                               
      DO 170 K=1,15                                                     
      PXX=PM(1,1,K)                                                     
      SIGX=SQRT(ABS(PXX))                                               
  170 WRITE(6,901) K,PXX,SIGX                                           
CX20510 CALL DOOUTX( 510 )                                              
CY20510 CALL DOOUTY( 510 )                                              
      IF(IPFL.LT.3) THEN                                                
CX40006 CALL SBOUTX (6)                                                 
CY40006 CALL SBOUTY (6)                                                 
      RETURN                                                            
      ENDIF                                                             
      WRITE(6,903)                                                      
CX10511 CALL DOINX( 511 )                                               
CY10511 CALL DOINY( 511 )                                               
      DO 180 K=1,15                                                     
  180 WRITE(6,901) K,AK(1,K),AK(2,K),AK(3,K),AK(4,K)                    
CX20512 CALL DOOUTX( 512 )                                              
CY20512 CALL DOOUTY( 512 )                                              
      WRITE(6,904)                                                      
CX10513 CALL DOINX( 513 )                                               
CY10513 CALL DOINY( 513 )                                               
      DO 190 K=1,15                                                     
      SSX=SQRT(ABS(PP(1,1,K)))                                          
      SSV=SQRT(ABS(PP(2,2,K)))                                          
  190 WRITE(6,901) K,PP(1,1,K),PP(1,2,K),PP(2,2,K),SSX,SSV              
CX20514 CALL DOOUTX( 514 )                                              
CY20514 CALL DOOUTY( 514 )                                              
      IF( IPFL.LT.4 ) THEN                                              
CX40006 CALL SBOUTX (6)                                                 
CY40006 CALL SBOUTY (6)                                                 
      RETURN                                                            
      ENDIF                                                             
      CALL MATPRT(PHI,4,4,'TRANSITION  ')                               
      CALL MATPRT(Q,4,4,'DYNAMIC COV.')                                 
CX40006 CALL SBOUTX (6)                                                 
CY40006 CALL SBOUTY (6)                                                 
      RETURN                                                            
C                                                                       
  900 FORMAT(/' FOCAL-PLANE FILTER INITIALIZATIONS ',                   
     +35('-')/                                                          
     +2X,F10.2,' : TIME STEP [SEC]'/                                    
     +2X,G10.3,' : MODEL NOISE TERM [KM/SEC^4]'/                        
     +2X,F10.4,' : RESOLUTION CELL SIZE [KM]'/                          
     +2X,F10.2,' : MEASUREMENT COVARIANCE ENHANCEMENT'/                 
     +2X,G10.4,' : MEASUREMENT COVARIANCE [KM^2]'/                      
     +2X,G10.4,' : INITIAL POSITION UNCERTAINTY [KM]'/                  
     +2X,G10.4,' : INITIAL VELOCITY UNCERTAINTY [KM/S]'/                
     +2X,G10.4,' : INITIAL ACCELERATION UNCERTAINTY [KM/S^2]'/          
     +2X,G10.4,' : INITIAL DA/DT UNCERTAINTY [KM/S^3]')                 
  901 FORMAT(3X,I2,1X,5(2X,G10.4))                                      
  902 FORMAT(/' PREDICTION CHARACTERISTICS'/                            
     +'  STEP   P[XX,-]     SIGMA(X) '/                                 
     +'  ----  ----------  ----------')                                 
  903 FORMAT(/' KALMAN GAINS'/                                          
     +'  STEP     K[X]        K[V]        K[A]      K[DA/DT]'/          
     +'  ----  ----------  ----------  ----------  ----------')         
  904 FORMAT(/' FILTERED COVARIANCES'/                                  
     +'  STEP   P[XX,+]     P[XV,+]     P[VV,+]  ',                     
     +'   SIGMA[X]    SIGMA[V] '/'  ----',5('  ----------'))            
CX40006 CALL SBOUTX (6)                                                 
CY40006 CALL SBOUTY (6)                                                 
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C      FPRED : STATE VECTOR PREDICTION ROUTINE                          
C                                                                       
C      USAGE : CALL FPRED(KT,GATE,IOK)                                  
C         KT : INDEX OF STATE IN /TRAXCM/                               
C       GATE : ASSOCIATION GATE (KM^2) [OUTPUT]                         
C        IOK : STATUS FLAG                                              
C               0 : SUCCESSFUL EXTENSION                                
C              -1 : INVALID POINTER (KT) ON ENTRY                       
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE FPRED(KT,GATE,IOK)                                     
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C       THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                  
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES      : NUMBER OF LAUNCH SITES                              
C     NFSITE(I)   : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)   : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)   : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP      : TIME STEP BETWEEN DATA SCANS                        
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS      : SENSOR LONGITUDE (RADIANS)                          
C     MAXTHR      : MAXIMUM THREAT SIZE (400, SET IN MAIN )             
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)   : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)    : DATA USE COUNTERS FOR EXTEND, BATCH                 
C     SIGMES      : RMS MEASUREMENT RESOLUTION                          
C     SIGMS2      : MEASUREMENT VARIANCE                                
C     ITROLD(I)   : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ     : BATCH INITIATION DATA STORAGE                       
C                                                                       
C     NNSJ        : FIRST HIT FROM SITE COUNTERS                        
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C                   SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED    
C                   CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE    
C                   ARE AS FOLLOWS:                                     
C                                                                       
C                       400 -> MAXTHR                                   
C                        10 -> MAXSIT                                   
C                        11 -> MAXSIT+1                                 
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TRACK STORAGE FOR FORTRAN TRACKER                                 
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
      COMMON /FIL4CM/ PM(4,4,15),PP(4,4,15),AK(4,15),                   
     +               DT,PHI(4,4)                                        
      DOUBLE PRECISION GATE,PM,PP,AK,DT,PHI                             
CX30007 CALL SBINX (7)                                                  
CY30007 CALL SBINY (7)                                                  
C                                                                       
      IOK=-1                                                            
      IF(KT.LT.1.OR.KT.GT.LSTTRK) THEN                                  
CX40008 CALL SBOUTX (8)                                                 
CY40008 CALL SBOUTY (8)                                                 
      RETURN                                                            
      ENDIF                                                             
      IOK=0                                                             
      KG=NMHITS(KT)                                                     
      IF(KG.GT.15) KG=15                                                
      XH2(1,KT)=XH1(1,KT)+DT*(XH1(2,KT)+DT*(XH1(3,KT)/2.                
     +         +DT*XH1(4,KT)/6.))                                       
      XH2(2,KT)=XH1(2,KT)+DT*(XH1(3,KT)+DT*XH1(4,KT)/2.)                
      XH2(3,KT)=XH1(3,KT)+DT*XH1(4,KT)                                  
      XH2(4,KT)=XH1(4,KT)                                               
      XH2(5,KT)=XH1(5,KT)+DT*(XH1(6,KT)+DT*(XH1(7,KT)/2.                
     +         +DT*XH1(8,KT)/6.))                                       
      XH2(6,KT)=XH1(6,KT)+DT*(XH1(7,KT)+DT*XH1(8,KT)/2.)                
      XH2(7,KT)=XH1(7,KT)+DT*XH1(8,KT)                                  
      XH2(8,KT)=XH1(8,KT)                                               
      GATE=PM(1,1,KG)+SIGMS2                                            
CX40008 CALL SBOUTX (8)                                                 
CY40008 CALL SBOUTY (8)                                                 
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     FILTR4 : FILTER EXISTING STATE VECTOR BY SPECIFIED DATA           
C                                                                       
C      USAGE : CALL FILTR4(KT,KN,Y,IOK)                                 
C         KT : POINTER TO (PREDICTED) ENTRY IN /TRAXCM/                 
C         KN : LOCATION IN /TRAXCM/ FPR NEW, FILTERED STATE             
C          Y : INNOVATIONS VECTOR {Y.X,Y.Z} FOR FILTERING               
C        IOK : STATUS FLAG                                              
C               0 : SUCCESSFUL STATE FILTERING                          
C              -1 : UNACCEPTABLE POINTERS (KT OR KN)                    
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE FILTR4(KT,KN,Y,IOK)                                    
      DOUBLE PRECISION Y(2)                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                    
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES      : NUMBER OF LAUNCH SITES                              
C     NFSITE(I)   : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)   : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)   : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP      : TIME STEP BETWEEN DATA SCANS                        
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS      : SENSOR LONGITUDE (RADIANS)                          
C     MAXTHR      : MAXIMUM THREAT SIZE (400, SET IN MAIN )             
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)   : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)    : DATA USE COUNTERS FOR EXTEND, BATCH                 
C     SIGMES      : RMS MEASUREMENT RESOLUTION                          
C     SIGMS2      : MEASUREMENT VARIANCE                                
C     ITROLD(I)   : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ     : BATCH INITIATION DATA STORAGE                       
C                                                                       
C     NNSJ        : FIRST HIT FROM SITE COUNTERS                        
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C                   SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED    
C                   CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE    
C                   ARE AS FOLLOWS:                                     
C                                                                       
C                       400 -> MAXTHR                                   
C                        10 -> MAXSIT                                   
C                        11 -> MAXSIT+1                                 
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TRACK STORAGE FOR FORTRAN TRACKER                                 
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
      COMMON /FIL4CM/ PM(4,4,15),PP(4,4,15),AK(4,15),                   
     +                DT,PHI(4,4)                                       
      DOUBLE PRECISION PM,PP,AK,DT,PHI                                  
CX30009 CALL SBINX (9)                                                  
CY30009 CALL SBINY (9)                                                  
                                                                        
      IOK=-1                                                            
      IF(KT.LT.1.OR.KT.GT.LSTTRK) THEN                                  
CX40010 CALL SBOUTX (10)                                                
CY40010 CALL SBOUTY (10)                                                
      RETURN                                                            
      ENDIF                                                             
      IF(KN.LT.1.OR.KN.GT.MAXTRK) THEN                                  
CX40010 CALL SBOUTX (10)                                                
CY40010 CALL SBOUTY (10)                                                
      RETURN                                                            
      ENDIF                                                             
      IOK=0                                                             
                                                                        
      IF(KN.NE.KT) CALL COPYTR(KT,KN)                                   
      KG=NMHITS(KT)                                                     
      IF(KG.LT.1) KG=1                                                  
      IF(KG.GT.15) KG=15                                                
CX10515 CALL DOINX( 515 )                                               
CY10515 CALL DOINY( 515 )                                               
                                                                        
      DO 100 I=1,4                                                      
      J=4+I                                                             
      XH1(I,KN)=XH2(I,KT)+Y(1)*AK(I,KG)                                 
      XH1(J,KN)=XH2(J,KT)+Y(2)*AK(I,KG)                                 
  100 CONTINUE                                                          
CX20516 CALL DOOUTX( 516 )                                              
CY20516 CALL DOOUTY( 516 )                                              
CX10517 CALL DOINX( 517 )                                               
CY10517 CALL DOINY( 517 )                                               
                                                                        
      DO 110 I=1,4                                                      
      IN=6-I                                                            
      IT=5-I                                                            
      IHITS(IN,KN)=IHITS(IT,KT)                                         
  110 CONTINUE                                                          
CX20518 CALL DOOUTX( 518 )                                              
CY20518 CALL DOOUTY( 518 )                                              
CX40010 CALL SBOUTX (10)                                                
CY40010 CALL SBOUTY (10)                                                
      RETURN                                                            
      END                                                               
                                                                        
C***********************************************************************
C                                                                       
C       FOCAL PLANE TRACKING PACKAGE                                    
C                                                                       
C     ROUTINES IN THIS FILE ------------------------------------------- 
C       FPTRAK : TRACKING DRIVER AND BATCH MODE INITIATOR               
C       MSINIT : BATCH INITIATION PARAMETER SETTING                     
C       EXTEND : TRACK SPLITTING FILTER FOR EXISTING TRACKS             
C       EXTINI : TRACK SPLIT PARAMETER INITIATION                       
C                                                                       
C***********************************************************************
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     FPTRAK : FOCAL-PLANE TRACKING DRIVER                              
C                                                                       
C      USAGE : CALL FPTRAK(NNEW,ISTAT)                                  
C       NNEW : NUMBER OF NEWLY INITIATED TRACK CANDIIDATES              
C      ISTAT : STATUS FLAG                                              
C              0 : NORMAL TERMINATION                                   
C             -1 : EXCEED TRACK STORAGE DURING BATCH INITIATION         
C             -3 : FPRED ERROR DURING BATCH INITIATION                  
C             -4 : FILTR4 ERROR DURING BATCH INITIATION                 
C             -6 : EXCEED TRACK STORAGE DURING FOCAL PLANE FILTERING    
C             -7 : GENERATE NEGATIVE ASSOCIAYION GATE DURING FP-FILTER  
C             -8 : FPRED ERROR DURING FOCAL PLANE FILTERING             
C             -9 : FILTR4 ERROR DURING FOCAL PLANE FILTERING            
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE FPTRAK(NNEW,ISTAT)                                     
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C       THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                  
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES      : NUMBER OF LAUNCH SITES                              
C     NFSITE(I)   : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)   : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)   : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP      : TIME STEP BETWEEN DATA SCANS                        
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS      : SENSOR LONGITUDE (RADIANS)                          
C     MAXTHR      : MAXIMUM THREAT SIZE (400, SET IN MAIN )             
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)   : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)    : DATA USE COUNTERS FOR EXTEND, BATCH                 
C     SIGMES      : RMS MEASUREMENT RESOLUTION                          
C     SIGMS2      : MEASUREMENT VARIANCE                                
C     ITROLD(I)   : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ     : BATCH INITIATION DATA STORAGE                       
C                                                                       
C     NNSJ        : FIRST HIT FROM SITE COUNTERS                        
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C                   SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED    
C                   CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE    
C                   ARE AS FOLLOWS:                                     
C                                                                       
C                        400 -> MAXTHR                                  
C                         10 -> MAXSIT                                  
C                         11 -> MAXSIT+1                                
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TRACK STORAGE FOR FORTRAN TRACKER                                 
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TIMING VARIABLES                                                  
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TIMERC/ TSBI,TABI,TSKF,TAKF,TSPR,TAPR,TSTH,TATH           
                                                                        
C     TSBI : STEP TIME, BATCH INITIATION                                
C     TABI : TOTAL TIME, BATCH INITIATION                               
C     TSKF : STEP TIME, FOCAL PLANE FILTER                              
C     TAKF : TOTAL TIME, FOCAL PLANE FILTER                             
C     TSPR : STEP TIME, PRECISION TRACKER                               
C     TAPR : TOTAL TIME, PRECISION TRACKER                              
C     TSTH : STEP TIME, SENSOR DATA GENERATION                          
C     TATH : TOTAL TIME, SENSOR DATA GENERATION                         
                                                                        
      DOUBLE PRECISION Y(2),VIMIN,FRVCUT,FRVXVZ,CTHMIN,THIMAX           
      DOUBLE PRECISION DELX,VIMAX,RADIAN,FRXZ2,VIMAXN,DELXN             
      DOUBLE PRECISION VZ2,VX2,V2SQ,VZ1,VX1,V1SQ,DOT,CTHSQ,GATE         
      SAVE VIMIN2, FRXZ2, CTHMIN, CTHSQ, VIMAX, VIMAXN,                 
     *     DELXN, NM1, NM2, NM3                                         
      DOUBLE PRECISION VIMIN2                                           
      SAVE VIMIN, FRVCUT, FRVXVZ, NHOLDT                                
      SAVE THIMAX, DELX                                                 
      SAVE ISINIT                                                       
      PARAMETER (RADIAN = 57.2957795)                                   
                                                                        
      DATA VIMIN,FRVCUT,FRVXVZ,NHOLDT /0.4,0.15,0.4,7/                  
      DATA THIMAX,DELX,VIMAX /15.0,1.4,3.0/                             
      DATA ISINIT /1/                                                   
CX30011 CALL SBINX (11)                                                 
CY30011 CALL SBINY (11)                                                 
                                                                        
C --- INITIALIZATIONS ON FIRST ENTRY -----------------------------------
                                                                        
      IF( ISINIT.LT.0 ) GO TO 100                                       
      VIMIN2=VIMIN*VIMIN                                                
      FRXZ2=FRVXVZ*FRVXVZ                                               
      CTHMIN=COS(THIMAX/RADIAN)                                         
      CTHSQ=CTHMIN*CTHMIN                                               
      VIMAX=VIMAX*TISTEP                                                
      VIMAXN=-VIMAX                                                     
      DELXN=-DELX                                                       
      NM1=0                                                             
      NM2=0                                                             
      NM3=0                                                             
      LSTTRK=0                                                          
      ISINIT=-1                                                         
                                                                        
C --- ROLL BACK EXISTING DATA, GET/SAVE NEW DATA -----------------------
                                                                        
  100 NM3=NM2                                                           
      IF( NM3.LT.1 ) GO TO 104                                          
CX10519 CALL DOINX( 519 )                                               
CY10519 CALL DOINY( 519 )                                               
      DO 102 K=1,NM3                                                    
      XX3(K)=XX2(K)                                                     
  102 ZZ3(K)=ZZ2(K)                                                     
CX20520 CALL DOOUTX( 520 )                                              
CY20520 CALL DOOUTY( 520 )                                              
  104 NM2=NM1                                                           
      IF( NM2.LT.1 ) GO TO 108                                          
CX10521 CALL DOINX( 521 )                                               
CY10521 CALL DOINY( 521 )                                               
      DO 106 K=1,NM2                                                    
      XX2(K)=XX1(K)                                                     
  106 ZZ2(K)=ZZ1(K)                                                     
CX20522 CALL DOOUTX( 522 )                                              
CY20522 CALL DOOUTY( 522 )                                              
  108 NM1=LSTDAT                                                        
      IF( NM1.LT.1 ) GO TO 112                                          
CX10523 CALL DOINX( 523 )                                               
CY10523 CALL DOINY( 523 )                                               
      DO 110 K=1,NM1                                                    
      ITROLD(K)=0                                                       
      NUSED(K)=0                                                        
      XX1(K)=THDATA(1,K)                                                
  110 ZZ1(K)=THDATA(2,K)                                                
CX20524 CALL DOOUTX( 524 )                                              
CY20524 CALL DOOUTY( 524 )                                              
  112 KMAX=NSITES+1                                                     
CX10525 CALL DOINX( 525 )                                               
CY10525 CALL DOINY( 525 )                                               
      DO 114 K=1,KMAX                                                   
      NNS3(K)=NNS2(K)                                                   
      NNS2(K)=NNS1(K)                                                   
  114 NNS1(K)=NFLAUN(K)                                                 
CX20526 CALL DOOUTX( 526 )                                              
CY20526 CALL DOOUTY( 526 )                                              
                                                                        
C ----------------------------------------------------------------------
C --- EXTEND EXISTING TRACKS USING FOCAL PLANE FILTER ------------------
C ----------------------------------------------------------------------
                                                                        
      TSKF=0.0                                                          
      IF( LSTTRK.LT.1 ) GO TO 150                                       
      CALL CPUTIM(T1)                                                   
C     T1=CPUTYM(1.0)                                                    
      CALL EXTEND(JSTAT)                                                
      CALL CPUTIM(T2)                                                   
C     TSKF=CPUTYM(2.0)-T1                                               
      TSKF=T2-T1                                                        
      TAKF=TAKF+TSKF                                                    
      IF( JSTAT.GE.0 ) GO TO 150                                        
      NNEW=0                                                            
      ISTAT=JSTAT                                                       
CX40012 CALL SBOUTX (12)                                                
CY40012 CALL SBOUTY (12)                                                
      RETURN                                                            
                                                                        
C --- NO INITIATION IF ANY SCAN IS EMPTY -------------------------------
                                                                        
  150 NNEW=0                                                            
      ISTAT=0                                                           
      TSBI=0.0                                                          
      IF( NM1.LT.1 .OR. NM2.LT.1 .OR. NM3.LT.1 ) THEN                   
CX40012 CALL SBOUTX (12)                                                
CY40012 CALL SBOUTY (12)                                                
      RETURN                                                            
      ENDIF                                                             
                                                                        
C --- MARK ESTABLISHED TRACKS IN PRESENT TRACK FILE --------------------
                                                                        
C     T1=CPUTYM(1.0)                                                    
      CALL CPUTIM(T1)                                                   
      IF( LSTTRK.LT.1 ) GO TO 170                                       
CX10527 CALL DOINX( 527 )                                               
CY10527 CALL DOINY( 527 )                                               
      DO 160 KT=1,LSTTRK                                                
      IF( NMHITS(KT).LT.NHOLDT ) GO TO 160                              
      ID=IHITS(1,KT)                                                    
      ITROLD(ID)=1                                                      
  160 CONTINUE                                                          
CX20528 CALL DOOUTX( 528 )                                              
CY20528 CALL DOOUTY( 528 )                                              
  170 NTROLD=LSTTRK                                                     
CX10529 CALL DOINX( 529 )                                               
CY10529 CALL DOINY( 529 )                                               
                                                                        
C ----------------------------------------------------------------------
C --- MAIN BATCH INITIATION CODE ---------------------------------------
C ----------------------------------------------------------------------
                                                                        
C ------------------------------------- LOOP : PRESENT DATA SCAN -------
                                                                        
      DO 300 K1=1,NM1                                                   
C                                       SKIP DATUM WITH ESTABLISHED TRAC
      IF( ITROLD(K1).GT.0 ) GO TO 300                                   
C                                       GET BACK-SCAN SEARCH LIMITS     
      ISITE=ITHSIT(K1)                                                  
      IS2=ISITE+1                                                       
      K2MIN=NNS2(ISITE)                                                 
      K2MAX=NNS2(IS2)-1                                                 
      IF( K2MIN.GT.K2MAX ) GO TO 300                                    
      K3MIN=NNS3(ISITE)                                                 
      K3MAX=NNS3(IS2)-1                                                 
      IF( K3MIN.GT.K3MAX ) GO TO 300                                    
                                                                        
C ------------------------------------- LOOP : ONE SCAN BACK -----------
                                                                        
      DO 290 K2=K2MIN,K2MAX                                             
                                                                        
C                                       FIRST VELOCITY TESTS            
      VZ2 = ZZ1(K1)-ZZ2(K2)                                             
      IF( VZ2.LE.0.0 ) GO TO 290                                        
      VX2 = XX1(K1)-XX2(K2)                                             
      IF( VX2.GT.VIMAX.OR.VX2.LT.VIMAXN ) GO TO 290                     
      VZ2=VZ2/TISTEP                                                    
      VX2=VX2/TISTEP                                                    
      V2SQ=VX2*VX2+VZ2*VZ2                                              
      IF( V2SQ.LT.VIMIN2 ) GO TO 290                                    
      IF( VX2*VX2/V2SQ.GT.FRXZ2 ) GO TO 290                             
                                                                        
C ------------------------------------- LOOP : TWO SCANS BACK ----------
                                                                        
      DO 280 K3=K3MIN,K3MAX                                             
                                                                        
C                                       SECOND VELOCITY TESTS           
      VZ1 = ZZ2(K2)-ZZ3(K3)                                             
      IF( VZ1.LE.0.0 ) GO TO 280                                        
      VX1 = XX2(K2)-XX3(K3)                                             
      IF( VX1.GT.VIMAX.OR.VX1.LT.VIMAXN ) GO TO 280                     
      VZ1=VZ1/TISTEP                                                    
      VX1=VX1/TISTEP                                                    
      V1SQ=VX1*VX1+VZ1*VZ1                                              
      IF( ABS(V1SQ-V2SQ).GT.2.*FRVCUT*V2SQ ) GO TO 280                  
      DOT=VX1*VX2+VZ1*VZ2                                               
      IF( DOT*DOT.LT.CTHSQ*V1SQ*V2SQ ) GO TO 280                        
                                                                        
C                                      SEARCH FOR TRACK DUPLICATION     
      IF( NTROLD.LT.1 ) GO TO 210                                       
      DO 200 KT=1,NTROLD                                                
      IF( K1.NE.IHITS(1,KT) ) GO TO 200                                 
      IF( K2.NE.IHITS(2,KT) ) GO TO 200                                 
      IF( K3.NE.IHITS(3,KT) ) GO TO 200                                 
      GO TO 280                                                         
  200 CONTINUE                                                          
                                                                        
C --- INITIATE A NEW TRACK ---------------------------------------------
                                                                        
  210 LSTTRK=LSTTRK+1                                                   
      IF( LSTTRK.LE.MAXTRK ) GO TO 212                                  
C                                      ERROR: EXCEED STORAGE LIMITS     
      ISTAT=-1                                                          
CX40012 CALL SBOUTX (12)                                                
CY40012 CALL SBOUTY (12)                                                
      RETURN                                                            
                                                                        
  212 CONTINUE                                                          
      DO 214 J=1,8                                                      
  214 XH1(J,LSTTRK) = 0.0                                               
      DO 216 J=1,4                                                      
  216 PRMTRK(J,LSTTRK) = 0.0                                            
      DO 218 J=1,16                                                     
  218 COVTRK(J,LSTTRK) = 0.0                                            
      XH1(1,LSTTRK) = XX2(K2)                                           
      XH1(2,LSTTRK) = VX1                                               
      XH1(5,LSTTRK) = ZZ2(K2)                                           
      XH1(6,LSTTRK) = VZ1                                               
      IDDSIT(LSTTRK) = ISITE                                            
      ISPREC(LSTTRK) = 0                                                
      NMHITS(LSTTRK) = 2                                                
      SCORE1(LSTTRK) = 0.0                                              
      SCORE2(LSTTRK) = 0.0                                              
      IHITS(1,LSTTRK) = K2                                              
      IHITS(2,LSTTRK) = K3                                              
      IHITS(3,LSTTRK) = 0                                               
      IHITS(4,LSTTRK) = 0                                               
      IHITS(5,LSTTRK) = 0                                               
      CALL FPRED(LSTTRK,GATE,JSTAT)                                     
      IF( JSTAT.GE.0 ) GO TO 220                                        
C                                      ERROR : PREDICTION FAILURE       
      ISTAT=-3                                                          
CX40012 CALL SBOUTX (12)                                                
CY40012 CALL SBOUTY (12)                                                
      RETURN                                                            
  220 Y(1)=XX1(K1)-XH2(1,LSTTRK)                                        
      Y(2)=ZZ1(K1)-XH2(5,LSTTRK)                                        
      CALL FILTR4(LSTTRK,LSTTRK,Y,JSTAT)                                
      IF( JSTAT.GE.0 ) GO TO 230                                        
C                                      ERROR : FILTER FAILURE           
      ISTAT=-4                                                          
CX40012 CALL SBOUTX (12)                                                
CY40012 CALL SBOUTY (12)                                                
      RETURN                                                            
  230 IHITS(1,LSTTRK)=K1                                                
      NMHITS(LSTTRK)=3                                                  
      SCORE1(LSTTRK)=(Y(1)*Y(1)+Y(2)*Y(2))/(2.0*GATE)                   
      NUSED(K1)=NUSED(K1)+1                                             
                                                                        
C ------------------------------------- END LOOP : TWO SCANS BACK ------
                                                                        
  280 CONTINUE                                                          
                                                                        
C ------------------------------------- END LOOP : ONE SCAN BACK -------
                                                                        
  290 CONTINUE                                                          
                                                                        
C ------------------------------------- END LOOP : PRESENT DATA SCAN ---
                                                                        
  300 CONTINUE                                                          
CX20530 CALL DOOUTX( 530 )                                              
CY20530 CALL DOOUTY( 530 )                                              
                                                                        
C --- COUNT NEW TRACKS AND RETURN --------------------------------------
                                                                        
      NNEW=LSTTRK-NTROLD                                                
      CALL CPUTIM(T2)                                                   
C     TSBI=CPUTYM(2.0)-T1                                               
      TSBI=T2-T1                                                        
      TABI=TABI+TSBI                                                    
      ISTAT=0                                                           
CX40012 CALL SBOUTX (12)                                                
CY40012 CALL SBOUTY (12)                                                
      RETURN                                                            
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     MSINIT : INITIALIZE BATCH INITIATOR PARAMETERS                    
C                                                                       
C      USAGE : CALL MSINIT(VVMIN,FRVC,FRXZ,NHL,IPR)                     
C      VVMIN : MINIMUM SPEED FOR INITIATION                             
C       FRVC : MAX{ |V1-V2|/|V2| }                                      
C       FRXZ : MAX{ |VX(2)|/|V2| }                                      
C        NHL : MINIMUM AGE FOR ESTABLISHED TRACKS                       
C        IPR : PRINT FLAG, LIST PARAMETERS IF POSITIVE                  
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      ENTRY MSINIT(VVMIN,FRVC,FRXZ,NHL,THMX,IPR)                        
CX30013 CALL SBINX (13)                                                 
CY30013 CALL SBINY (13)                                                 
                                                                        
      VIMIN=VVMIN                                                       
      FRVCUT=FRVC                                                       
      FRVXVZ=FRXZ                                                       
      NHOLDT=NHL                                                        
      THIMAX=THMX                                                       
      ISINIT=1                                                          
      IF(IPR.GT.0) WRITE(6,900) VIMIN,FRVCUT,FRVXVZ,THIMAX,NHOLDT       
CX40014 CALL SBOUTX (14)                                                
CY40014 CALL SBOUTY (14)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(/' RESET BATCH PARAMETERS -----------------------------'/  
     +2X,F8.3,' : MINIMUM SPEED CUT [KM/S]'/                            
     +2X,F8.3,' : MAX[ |V1-V2|/V2 ]'/                                   
     +2X,F8.3,' : MAX[ |VX(2)|/V2 ]'/                                   
     +2X,F8.3,' : MAXIMUM NON-LINEARITY [DEG]'/                         
     +2X,I8,' : COUNTS REQUIRED FOR ESTABLISHED TRACKS'/)               
CX40014 CALL SBOUTX (14)                                                
CY40014 CALL SBOUTY (14)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     EXTEND : DRIVER FOR LINEAR, TRACK-SPLIT PROCESSOR                 
C                                                                       
C      USAGE : CALL EXTEND(ISTAT)                                       
C      ISTAT : STATUS FLAG                                              
C               SUCCESS : ISTAT=0                                       
C                ERRORS : ISTAT= -6,-7,-8,-9, AS DOCUMENTED ABOVE       
C                         FOR FPTRAK                                    
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE EXTEND(ISTAT)                                          
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C        THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                 
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES      : NUMBER OF LAUNCH SITES                              
C     NFSITE(I)   : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)   : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)   : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP      : TIME STEP BETWEEN DATA SCANS                        
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS      : SENSOR LONGITUDE (RADIANS)                          
C     MAXTHR      : MAXIMUM THREAT SIZE (400, SET IN MAIN )             
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)   : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)    : DATA USE COUNTERS FOR EXTEND, BATCH                 
C     SIGMES      : RMS MEASUREMENT RESOLUTION                          
C     SIGMS2      : MEASUREMENT VARIANCE                                
C     ITROLD(I)   : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ     : BATCH INITIATION DATA STORAGE                       
C                                                                       
C     NNSJ        : FIRST HIT FROM SITE COUNTERS                        
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C                   SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED    
C                   CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE    
C                   ARE AS FOLLOWS:                                     
C                                                                       
C                       400 -> MAXTHR                                   
C                        10 -> MAXSIT                                   
C                        11 -> MAXSIT+1                                 
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     TRACK STORAGE FOR FORTRAN TRACKER                                 
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
      COMMON /FIL4CM/ PMKAL(16,15),DUMMY(300),DELTAT,PHI(16)            
      DOUBLE PRECISION Y(2),GATEF,GATVEL,ALVERT,FADE                    
      DOUBLE PRECISION PMKAL,DUMMY,DELTAT,PHI,DELX,DELXN                
      DOUBLE PRECISION XDAT,ZDAT,Y0,Y1,ZZMIN,G2,G2RAT                   
      DOUBLE PRECISION VX,VZ,TEMP,VMAG,SCORE,GATE                       
      SAVE GATEF, NEQUIV, GATVEL, ALVERT, FADE                          
      PARAMETER (DELX = 1.4, DELXN = -1.4)                              
                                                                        
      DATA GATEF,NEQUIV,GATVEL,ALVERT,FADE /18.0,4,0.5,0.5,0.5/         
CX30015 CALL SBINX (15)                                                 
CY30015 CALL SBINY (15)                                                 
                                                                        
      ISTAT=0                                                           
      IF(LSTTRK.LT.1) THEN                                              
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
      ENDIF                                                             
      IF(LSTDAT.GT.0) GO TO 100                                         
      LSTTRK=0                                                          
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
                                                                        
C --- EXTEND EXISTING TRACKS -------------------------------------------
                                                                        
  100 CONTINUE                                                          
CX10531 CALL DOINX( 531 )                                               
CY10531 CALL DOINY( 531 )                                               
      DO 110 KT=1,LSTTRK                                                
      CALL FPRED(KT,GATE,IOK)                                           
      IF(IOK.GE.0) GO TO 110                                            
      ISTAT=-8                                                          
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
  110 CONTINUE                                                          
CX20532 CALL DOOUTX( 532 )                                              
CY20532 CALL DOOUTY( 532 )                                              
                                                                        
C --- SEARCH FOR TRACK<->HIT ASSOCIATIONS ------------------------------
                                                                        
      LSTOLD=LSTTRK                                                     
CX10533 CALL DOINX( 533 )                                               
CY10533 CALL DOINY( 533 )                                               
                                                                        
C --- LOOP ON SENSOR REPORTS -------------------------------------------
                                                                        
      DO 400 KD=1,LSTDAT                                                
      ISITE=ITHSIT(KD)                                                  
      XDAT=THDATA(1,KD)                                                 
      ZDAT=THDATA(2,KD)                                                 
      IFDATA=LSTTRK+1                                                   
      NTRFST(KD)=IFDATA-LSTOLD                                          
                                                                        
C --- LOOP ON ORIGINAL TRACKS ------------------------------------------
                                                                        
      DO 300 KT=1,LSTOLD                                                
C                                               CRUDE ASSOCIATION TESTS 
      IF(IDDSIT(KT).NE.ISITE) GO TO 300                                 
      Y0=XDAT-XH2(1,KT)                                                 
      IF(Y0.GT.DELX.OR.Y0.LT.DELXN) GO TO 300                           
      Y1=ZDAT-XH2(5,KT)                                                 
      IF(Y1.GT.DELX.OR.Y1.LT.DELXN) GO TO 300                           
      ZZMIN=ALVERT*XH1(5,KT)+(1.-ALVERT)*XH2(5,KT)                      
      IF(ZDAT.LT.ZZMIN) GO TO 300                                       
C                                               NOMINAL GATING TEST     
      IOK=1                                                             
      IG=NMHITS(KT)                                                     
      IF(IG.LT.1) IG=1                                                  
      IF(IG.GT.15) IG=15                                                
      GATE=PMKAL(1,IG)+SIGMS2                                           
      IF(GATE.GT.0.0) GO TO 200                                         
      ISTAT=-7                                                          
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
  200 G2=Y0*Y0+Y1*Y1                                                    
      G2RAT=G2/GATE                                                     
      IF( G2RAT.GT.GATEF ) GO TO 300                                    
C                                               VELOCITY GATE TEST      
      VX=XH1(2,KT)                                                      
      VZ=XH1(6,KT)                                                      
      TEMP=DELTAT*GATVEL                                                
      VMAG=TEMP*TEMP*(VX*VX+VZ*VZ)                                      
      IF( G2.GT.VMAG ) GO TO 300                                        
C                                               CREATE PROVISIONAL TRACK
      Y(1)=Y0                                                           
      Y(2)=Y1                                                           
      NEXTRK=LSTTRK+1                                                   
C                                        TEST: STORAGE OVERFLOW --------
      IF( NEXTRK.LE.MAXTRK ) GO TO 201                                  
      ISTAT=-6                                                          
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
                                                                        
  201 CALL FILTR4(KT,NEXTRK,Y,IOK)                                      
      IF( IOK.GE.0 ) GO TO 202                                          
      ISTAT=-9                                                          
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
  202 IHITS(1,NEXTRK)=KD                                                
      SCORE=G2/(2.0*GATE)                                               
      SCORE1(NEXTRK)=FADE*SCORE+(1.0-FADE)*SCORE1(NEXTRK)               
      NMHITS(NEXTRK)=NMHITS(NEXTRK)+1                                   
C                                               BEGIN UNIQUENESS TESTS  
      ISSAME=0                                                          
      IF( NMHITS(NEXTRK).LT.NEQUIV .OR. IFDATA.GT.LSTTRK )              
     +    GO TO 250                                                     
      DO 230 JT=IFDATA,LSTTRK                                           
      IF( NMHITS(JT).LT.NEQUIV) GO TO 230                               
      DO 220 J=2,NEQUIV                                                 
      IF(IHITS(J,JT).NE.IHITS(J,NEXTRK)) GO TO 230                      
  220 CONTINUE                                                          
      ISSAME=1                                                          
      JTSAME=JT                                                         
      GO TO 232                                                         
  230 CONTINUE                                                          
  232 CONTINUE                                                          
      IF( ISSAME.EQ.0 ) GO TO 250                                       
C                                              CHOOSE EQUIVALENT TRACK  
      NH1=NMHITS(NEXTRK)                                                
      NH2=NMHITS(JTSAME)                                                
      IF( NH1.GT.NH2 .OR.                                               
     +  ( NH1.EQ.NH2.AND.SCORE1(NEXTRK).LT.SCORE1(JTSAME)) )            
     +     CALL COPYTR(NEXTRK,JTSAME)                                   
      GO TO 300                                                         
C                                              EXTEND THE TRACK FILE    
  250 CONTINUE                                                          
      NUSED(KD)=NUSED(KD)+1                                             
      LSTTRK=NEXTRK                                                     
                                                                        
C --- END: LOOP ON ORIGINAL TRACKS -------------------------------------
                                                                        
  300 CONTINUE                                                          
                                                                        
C --- END: LOOP ON SENSOR REPORTS --------------------------------------
                                                                        
  400 CONTINUE                                                          
CX20534 CALL DOOUTX( 534 )                                              
CY20534 CALL DOOUTY( 534 )                                              
                                                                        
C --- COMPRESS THE TRACK FILE ------------------------------------------
                                                                        
      NEWTRK=LSTTRK-LSTOLD                                              
CX10535 CALL DOINX( 535 )                                               
CY10535 CALL DOINY( 535 )                                               
      DO 410 K=1,NEWTRK                                                 
      CALL COPYTR(K+LSTOLD,K)                                           
  410 CONTINUE                                                          
CX20536 CALL DOOUTX( 536 )                                              
CY20536 CALL DOOUTY( 536 )                                              
      LSTTRK=NEWTRK                                                     
      ISTAT=0                                                           
CX40016 CALL SBOUTX (16)                                                
CY40016 CALL SBOUTY (16)                                                
      RETURN                                                            
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     EXTINT : FOCAL PLANE TRACKER INITIALIZATIONS                      
C                                                                       
C      USAGE : CALL EXTINT(GATE1,GATE2,NEQQ,ALVNEW,IPRT)                
C      GATE1 : STANDARD COVARIANCE GATING CUTOFF (IN SIGMAS)            
C      GATE2 : VELOCITY GATING CUTOFF (FRACTION OF MAX DISTANCE)        
C       NEQQ : NUMBER OF IDENTICAL HITS FOR TRACK EQUIVALENCE           
C     ALVNEW : VERTICAL MOTION CUTOFF                                   
C       IPRT : PRINT FLAG, LIST NEW PARAMETERS IF POSITIVE              
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      ENTRY EXTINT(GATE1,GATE2,NEQQ,ALVNEW,IPRT)                        
CX30017 CALL SBINX (17)                                                 
CY30017 CALL SBINY (17)                                                 
                                                                        
      GATEF=GATE1                                                       
      GATVEL=GATE2                                                      
      NEQUIV=NEQQ                                                       
      ALVERT=ALVNEW                                                     
      IF(IPRT.LT.1) THEN                                                
CX40018 CALL SBOUTX (18)                                                
CY40018 CALL SBOUTY (18)                                                
      RETURN                                                            
      ENDIF                                                             
      WRITE(6,900) GATEF,GATVEL,NEQQ,ALVERT                             
CX40018 CALL SBOUTX (18)                                                
CY40018 CALL SBOUTY (18)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(/' RESET EXTEND PARAMETERS ----------------------------'/  
     +2X,F8.3,' : GATE G1 : Y^2 < G1*[ PXX+SIGM2 ]'/                    
     +2X,F8.3,' : GATE G2 : |Y| < G2*|V|*DT'/                           
     +2X,I8,' : NUMBER OF IDENTICAL HITS FOR EQUIVALENCE'/              
     +2X,F8.3,' : VERTICAL MOTION CUTOFF'/)                             
CX40018 CALL SBOUTX (18)                                                
CY40018 CALL SBOUTY (18)                                                
      END                                                               
                                                                        
                                                                        
C **********************************************************************
C                                                                       
C       PRECISION LAUNCH PARAMETER ESTIMATION PACKAGE                   
C                                                                       
C     ROUTINES IN THIS FILE ------------------------------------------- 
C       NLFILT : PRECISION TRACKING DRIVER                              
C       NLINIT : PRECISION TRACKING PARAMETER INITIALIZATIONS           
C       FITPAR : NEWTON-RAPHSON PARAMETER VECTOR ESTIMATION             
C       FITSET : N-R PARAMETER INITIALIZATION                           
C       FIJGET : LINEARIZED TRANSFORMATION MATRIX EVALUATION            
C       COMCOV : PARAMETER ESTIMATE COMBINATION FILTER                  
C       GETOBS : FP-STATE FROM PARAMETERS UTILITY                       
C       CHIFIT : CHI^2 EVALUATION UTILITY                               
C                                                                       
C **********************************************************************
                                                                        
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C     NLFILT : PRECISION PARAMETER ESTIMATION DRIVER                    
C                                                                       
C      USAGE : CALL NLFILT(NPREC,NRJCT)                                 
C      NPREC : TOTAL PRECISION TRACKS       [OUTPUT]                    
C      NRJCT : NUMBER OF TRACKS DISCARDED   [OUTPUT]                    
C                                                                       
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE NLFILT(NPREC,NRJCT)                                    
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C                                                                       
C       THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER                  
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TIMING VARIABLES 							+                                         
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TIMERC/ TSBI,TABI,TSKF,TAKF,TSPR,TAPR,TSTH,TATH           
                                                                        
C     TSBI : STEP TIME, BATCH INITIATION                                
C     TABI : TOTAL TIME, BATCH INITIATION                               
C     TSKF : STEP TIME, FOCAL PLANE FILTER                              
C     TAKF : TOTAL TIME, FOCAL PLANE FILTER                             
C     TSPR : STEP TIME, PRECISION TRACKER                               
C     TAPR : TOTAL TIME, PRECISION TRACKER                              
C     TSTH : STEP TIME, SENSOR DATA GENERATION                          
C     TATH : TOTAL TIME, SENSOR DATA GENERATION                         
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRACK STORAGE FOR FORTRAN TRACKER					+                           
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
                                                                        
      DOUBLE PRECISION P1(4),P2(4),P(4)                                 
      DOUBLE PRECISION PP1(16),PP2(16),PP(16)                           
      DOUBLE PRECISION XSD(4),SCORE,RMP,FACTOR,FADE,TT1                 
      SAVE NPRMND, MAXEND, CH2CUT                                       
                                                                        
      DATA NPRMND,MAXEND,CH2CUT /6,3,0.01/                              
CX30019 CALL SBINX (19)                                                 
CY30019 CALL SBINY (19)                                                 
                                                                        
C --- TEST FOR ANYTHING TO DO ------------------------------------------
                                                                        
      TSPR=0.0                                                          
      NPREC=0                                                           
      NRJCT=0                                                           
      IF( LSTTRK.LT.1 ) THEN                                            
CX40020 CALL SBOUTX (20)                                                
CY40020 CALL SBOUTY (20)                                                
      RETURN                                                            
      ENDIF                                                             
                                                                        
C ----------------------------------------------------------------------
C --- MAIN LOOP THROUGH EXISTING TRACKS --------------------------------
C ----------------------------------------------------------------------
                                                                        
C     T1=CPUTYM(1.0)                                                    
      CALL CPUTIM(T1)                                                   
CX10537 CALL DOINX( 537 )                                               
CY10537 CALL DOINY( 537 )                                               
                                                                        
      DO 300 KT=1,LSTTRK                                                
                                                                        
      NMP = ISPREC(KT)                                                  
      IF( NMP.LT.0 ) ISPREC(KT)=0                                       
      IF( NMP.LT.1 ) GO TO 200                                          
                                                                        
C --- PROCESS/UPDATE EXISTING PRECISION TRACKS -------------------------
                                                                        
      DO 100 I=1,4                                                      
      P1(I)=PRMTRK(I,KT)                                                
  100 P2(I)=P1(I)                                                       
      DO 102 I=1,16                                                     
  102 PP2(I)=COVTRK(I,KT)                                               
C					GET ESTIMATED FP VECTOR                                           
      XSD(1)=XH1(1,KT)                                                  
      XSD(2)=XH1(5,KT)                                                  
      XSD(3)=XH1(2,KT)                                                  
      XSD(4)=XH1(6,KT)                                                  
C					GET NEW PARAMETER ESTIMATE                                        
      IG=NMHITS(KT)                                                     
      CALL FITPAR(P1,XSD,IG,PP1,CHIVAL,IOK)                             
      IF( CHIVAL.LE.CH2CUT .AND. IOK.GE.0 ) GO TO 120                   
C					NOMINALLY BAD FIT                                                 
C					DISCARD TRACK IF NOT UNIQUE                                       
      JOK=IHITS(1,KT)                                                   
      IF( NUSED(JOK).LE.1 ) GO TO 140                                   
      NRJCT=NRJCT+1                                                     
      ISPREC(KT)=-2                                                     
      NUSED(JOK)=NUSED(JOK)-1                                           
      GO TO 300                                                         
                                                                        
C					UPDATE PARAMETER/COVARIANCE ESTIMATES                             
  120 ID=IHITS(1,KT)                                                    
      IF( NUSED(ID).LE.1 ) GO TO 140                                    
C					ENHANCE PRESENT COVARIANCE ESTIMATE                               
C					FOR MULTIPLE TRACKS TO DATUM                                      
      FACTOR=NUSED(ID)                                                  
      DO 130 J=1,16                                                     
  130 PP1(J)=PP1(J)*FACTOR                                              
C					COMPUTE FADING MEMORY FACTOR                                      
  140 RMP=NMP                                                           
      FADE=1.0+3.0/SQRT(RMP)                                            
C					COMBINE/SAVE PARAMETER/COVARIANCE                                 
      CALL COMCOV(P1,PP1,P2,PP2,P,PP,SCORE,FADE,JSTAT)                  
      IF( JSTAT.LT.0 ) GO TO 300                                        
      ISPREC(KT)=NMP+1                                                  
      SCORE2(KT)=((RMP-1.0)*SCORE2(KT)+SCORE)/RMP                       
      DO 150 J=1,4                                                      
  150 PRMTRK(J,KT)=P(J)                                                 
      DO 160 J=1,16                                                     
  160 COVTRK(J,KT)=PP(J)                                                
      NPREC=NPREC+1                                                     
      GO TO 300                                                         
                                                                        
C --- ATTEMPT TO FORM A NEW PRECISION TRACK ----------------------------
                                                                        
  200 NEND=IHITS(1,KT)                                                  
      NN=NMHITS(KT)                                                     
      IF( NN.LT.NPRMND ) GO TO 300                                      
      IF( NUSED(NEND).GT.MAXEND .AND. NN.LT.NPRMND+3 ) GO TO 300        
                                                                        
C					GET FP STATE VECTOR                                               
      XSD(1)=XH1(1,KT)                                                  
      XSD(2)=XH1(5,KT)                                                  
      XSD(3)=XH1(2,KT)                                                  
      XSD(4)=XH1(6,KT)                                                  
C					NOMINAL INITIAL PARAMETER GUESS                                   
      I=IDDSIT(KT)                                                      
      IF( I.LT.1 .OR. I.GT.NSITES ) I=1                                 
      P1(1)=SITLAT(I)                                                   
      P1(2)=SITLON(I)                                                   
      P1(3)=0.0                                                         
      TT1=40+5*NN                                                       
      P1(4)=TIMDAT-TT1                                                  
C					TRY HARD TO GET INITIAL FIT                                       
      DO 210 JTRY=1,3                                                   
      CALL FITPAR(P1,XSD,NN,PP1,CHIVAL,ISTAT)                           
      IF( ISTAT.NE.3 ) GO TO 220                                        
  210 CONTINUE                                                          
  220 CONTINUE                                                          
                                                                        
C					REJECT BAD INITIAL FITS                                           
C					(IF MULTIPLE TRACKS TO DATUM)                                     
                                                                        
      IF( ISTAT.GE.0 .AND. CHIVAL.LT.CH2CUT ) GO TO 240                 
      JOK=IHITS(1,KT)                                                   
      IF( NUSED(JOK).LE.1 ) GO TO 300                                   
      ISPREC(KT)=-2                                                     
      NUSED(JOK)=NUSED(JOK)-1                                           
      NRJCT=NRJCT+1                                                     
      GO TO 300                                                         
C					INITIATE NEW PRECISION TRACK                                      
  240 ID=IHITS(1,KT)                                                    
      FACTOR=1.0                                                        
      IF( NUSED(ID).GT.1 ) FACTOR=NUSED(ID)                             
      DO 250 I=1,4                                                      
  250 PRMTRK(I,KT)=P1(I)                                                
      DO 260 I=1,16                                                     
  260 COVTRK(I,KT)=PP1(I)*FACTOR                                        
      ISPREC(KT)=1                                                      
      SCORE2(KT)=0.0                                                    
      NPREC=NPREC+1                                                     
                                                                        
C					END: LOOP ON EXISTING TRACKS                                      
  300 CONTINUE                                                          
CX20538 CALL DOOUTX( 538 )                                              
CY20538 CALL DOOUTY( 538 )                                              
                                                                        
                                                                        
C --- REMOVE DELETED TRACKS FROM FILE ----------------------------------
                                                                        
      IF( NRJCT.LT.1 ) GO TO 410                                        
      KT=0                                                              
CX10539 CALL DOINX( 539 )                                               
CY10539 CALL DOINY( 539 )                                               
      DO 400 I=1,LSTTRK                                                 
      IF( ISPREC(I).LT.0 ) GO TO 400                                    
      KT=KT+1                                                           
      IF( KT.LT.I ) CALL COPYTR(I,KT)                                   
  400 CONTINUE                                                          
CX20540 CALL DOOUTX( 540 )                                              
CY20540 CALL DOOUTY( 540 )                                              
      LSTTRK=KT                                                         
C 410 TSPR = CPUTYM(2.0)-T1                                             
  410 CALL CPUTIM(T2)                                                   
      TSPR = T2-T1                                                      
      TAPR = TAPR+TSPR                                                  
CX40020 CALL SBOUTX (20)                                                
CY40020 CALL SBOUTY (20)                                                
      RETURN                                                            
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     NLINIT : INITIALIZE PRECISION ESTIMATION PARAMETERS		+            
C									+                                                             
C      USAGE : CALL NLINIT(NPRNEW,EXTNEW,IGOCH2,CH2NEW,MAXNEW,IPR)	+    
C     NPRNEW : NEW VALUE FOR NPRMND					+                               
C     EXTNEW : NEW VALUE FOR EXTERR (ROUTINE FIJGET)			+                
C     IGOCH2 : DUMMY PARAMETER (COMPATABILITY WITH C-PROGRAM)		+        
C     CH2NEW : NEW VALUE FOR CH2CUT					+                               
C     MAXNEW : NEW VALUE FOR MAXEND					+                               
C        IPR : PRINT FLAG, LIST NEW VALUES IF POSITIVE			+              
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      ENTRY NLINIT(NPRNEW,EXTNEW,IGOCH2,CH2NEW,MAXNEW,IPR)              
CX30021 CALL SBINX (21)                                                 
CY30021 CALL SBINY (21)                                                 
                                                                        
      NPRMND=NPRNEW                                                     
      CALL FITSET(EXTNEW)                                               
      CH2CUT=CH2NEW                                                     
      MAXEND=MAXNEW                                                     
      IF( IPR.GT.0 ) WRITE(6,900) NPRMND,MAXEND,EXTNEW,CH2CUT           
CX40022 CALL SBOUTX (22)                                                
CY40022 CALL SBOUTY (22)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(/' RESET PRECISION ESTIMATION PARAMETERS ',25('-')/        
     +2X,I8,' : MINIMUM HITS TO INITIATE PRECISION TRACKING'/           
     +2X,I8,' : MAX TRACKS TO DATUM FOR EARLY INITIATION'/              
     +2X,F8.2,' : FP-FILTER ERROR ENHANCEMENT'/                         
     +2X,F8.5,' : MAXIMUM CHI^2 FOR PRECISION TRACK INITIATION'/)       
CX40022 CALL SBOUTX (22)                                                
CY40022 CALL SBOUTY (22)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     FITPAR : NEWTON-RAPHSON LAUNCH PARAMATER ESTIMATION		+            
C									+                                                             
C      USAGE : CALL FITPAR(P,XSD,IDSTEP,PP,CHIVAL,ISTAT)		+             
C	   P : PARAMETER VECTOR ESTIMATE	[OUTPUT/INPUT]		+                    
C	 XSD : FOCAL PLANE STATE VECTOR					+                                 
C     IDSTEP : FOCAL PLANE TRACK AGE					+                              
C     CHIVAL : CHI^2 FOR DEDUCED FIT		[OUTPUT]		+                       
C      ISTAT : STATUS FLAG						+                                       
C	       -2 : FAIL TO INVERT GRADIENT MATRIX			+                        
C	       -1 : FAIL TO EVALUATE GRADIENT MATRIX			+                      
C	        1 : SUCCESSFUL SOLUTION					+                                 
C	        2 : FAIL TO REDUCE CHI^2 TO SPECIFIED LIMIT		+                
C	        3 : EXCEED MAXIMUM NUMBER OF ALLOWED ITERATIONS		+            
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE FITPAR(P,XSD,IDSTEP,PP,CHIVAL,ISTAT)                   
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      COMMON /FIL4CM/ PMKAL(16,15),PPKAL(16,15),DUMMY(77)               
      DOUBLE PRECISION PMKAL,PPKAL,DUMMY                                
      DOUBLE PRECISION P(4),XSD(4),PP(16)                               
      DOUBLE PRECISION WGTS(4),EXTERR,DXX,DXV,DVV                       
      DOUBLE PRECISION PNEW(4),DEL(4),DELP(4),PTRY(4)                   
      DOUBLE PRECISION CHISUM,T,TERM,FACTOR,F(16),FIN(16),XSNEW(4)      
      SAVE EXTERR                                                       
      PARAMETER (CHICUT = 0.0005, NTRYMX = 6)                           
                                                                        
      DATA EXTERR /2.2/                                                 
CX30023 CALL SBINX (23)                                                 
CY30023 CALL SBINY (23)                                                 
                                                                        
C					SET UP ERROR ENTRIES, WEIGHTS                                     
      T=TIMDAT                                                          
      IG=IDSTEP+1                                                       
      IF(IG.LT.1) IG=1                                                  
      IF(IG.GT.15) IG=15                                                
      DXX=EXTERR*PPKAL(1,IG)                                            
      DXV=EXTERR*PPKAL(2,IG)                                            
      DVV=EXTERR*PPKAL(6,IG)                                            
CX10541 CALL DOINX( 541 )                                               
CY10541 CALL DOINY( 541 )                                               
      DO 50 K=1,4                                                       
   50 PNEW(K)=P(K)                                                      
CX20542 CALL DOOUTX( 542 )                                              
CY20542 CALL DOOUTY( 542 )                                              
      WGTS(1)=1.0/SQRT(DXX)                                             
      WGTS(2)=WGTS(1)                                                   
      WGTS(3)=1.0/SQRT(DVV)                                             
      WGTS(4)=WGTS(3)                                                   
CX10543 CALL DOINX( 543 )                                               
CY10543 CALL DOINY( 543 )                                               
                                                                        
C --- MAIN CHI^2 REDUCTION LOOP ----------------------------------------
                                                                        
      DO 300 NTRY=1,NTRYMX                                              
C					GET/INVERT LOCAL GRADIENT MATRIX                                  
      CALL FIJGET(PNEW,F,IOK)                                           
      IF(IOK.GE.0) GO TO 100                                            
C					ERROR : IMPROPER PARAMETERS                                       
      ISTAT=-1                                                          
CX40024 CALL SBOUTX (24)                                                
CY40024 CALL SBOUTY (24)                                                
      RETURN                                                            
  100 CALL INV4(F,FIN,IOK)                                              
      IF(IOK.GE.0) GO TO 110                                            
C					ERROR : SINGULAR F                                                
      ISTAT=-2                                                          
CX40024 CALL SBOUTX (24)                                                
CY40024 CALL SBOUTY (24)                                                
      RETURN                                                            
                                                                        
C					GET PREDICTED STATE, RESIDUALS                                    
  110 CALL GETOBS(PNEW,T,XSNEW)                                         
      CHISUM=0.0                                                        
      DO 120 K=1,4                                                      
      DEL(K)=XSD(K)-XSNEW(K)                                            
      TERM=DEL(K)*WGTS(K)                                               
  120 CHISUM=CHISUM+TERM*TERM                                           
      CHI2=CHISUM                                                       
      ISDONE=1                                                          
C					TEST FOR CONVERGENCE                                              
      IF( CHI2.LE.CHICUT ) GO TO 310                                    
                                                                        
C					GET NOMINAL PARAMETER STEP                                        
      DO 140 I=1,4                                                      
      DELP(I)=0.0                                                       
      DO 130 J=1,4                                                      
      K=I+4*(J-1)                                                       
  130 DELP(I)=DELP(I)+DEL(J)*FIN(K)                                     
  140 CONTINUE                                                          
                                                                        
C					LOOP ON SCALED PARAMETER STEPS                                    
      ISDONE=2                                                          
      FACTOR=2.0                                                        
      DO 200 ITRY=1,10                                                  
      FACTOR=FACTOR/2.0                                                 
      DO 150 I=1,4                                                      
  150 PTRY(I)=PNEW(I)+FACTOR*DELP(I)                                    
      CHINEW=CHIFIT(PTRY,XSD,WGTS)                                      
      IF( CHINEW.GT.CHI2 ) GO TO 200                                    
      CHI2=CHINEW                                                       
C					SAVE NEW PARAMETER ESTIMATE                                       
      DO 160 I=1,4                                                      
  160 PNEW(I)=PTRY(I)                                                   
      ISDONE=0                                                          
C					SET CONVERGENCE FLAG                                              
      IF( CHI2.LT.CHICUT ) ISDONE=1                                     
C					TERMINATE STEP LOOP                                               
      GO TO 210                                                         
  200 CONTINUE                                                          
  210 CONTINUE                                                          
C					TEST FOR CONVERGENCE                                              
      IF( ISDONE.NE.0 ) GO TO 310                                       
  300 CONTINUE                                                          
CX20544 CALL DOOUTX( 544 )                                              
CY20544 CALL DOOUTY( 544 )                                              
      ISDONE=3                                                          
  310 ISTAT=ISDONE                                                      
                                                                        
C					SAVE FINAL PARAMETERS, CHI^2                                      
      CHIVAL=CHI2                                                       
CX10545 CALL DOINX( 545 )                                               
CY10545 CALL DOINY( 545 )                                               
      DO 320 K=1,4                                                      
  320 P(K)=PNEW(K)                                                      
CX20546 CALL DOOUTX( 546 )                                              
CY20546 CALL DOOUTY( 546 )                                              
                                                                        
C					COMPUTE PARAMETER COVARIANCE MATRIX                               
      PP(1) = DXX*(FIN(1)*FIN(1)+FIN(5)*FIN(5))                         
     +      + DVV*(FIN(9)*FIN(9)+FIN(13)*FIN(13))                       
     +      + 2.*DXV*(FIN(1)*FIN(9)+FIN(5)*FIN(13))                     
      PP(2) = DXX*(FIN(1)*FIN(2)+FIN(5)*FIN(6))                         
     +      + DVV*(FIN(9)*FIN(10)+FIN(13)*FIN(14))                      
     +      + DXV*(FIN(1)*FIN(10)+FIN(5)*FIN(14)+                       
     +        FIN(2)*FIN(9)+FIN(6)*FIN(13))                             
      PP(5) = PP(2)                                                     
      PP(3) = DXX*(FIN(1)*FIN(3)+FIN(5)*FIN(7))                         
     +      + DVV*(FIN(9)*FIN(11)+FIN(13)*FIN(15))                      
     +      + DXV*(FIN(1)*FIN(11)+FIN(5)*FIN(15)+                       
     +             FIN(9)*FIN(3)+FIN(13)*FIN(7))                        
      PP(9) = PP(3)                                                     
      PP(4) = DXX*(FIN(1)*FIN(4)+FIN(5)*FIN(8))                         
     +      + DVV*(FIN(9)*FIN(12)+FIN(13)*FIN(16))                      
     +      + DXV*(FIN(1)*FIN(12)+FIN(5)*FIN(16)                        
     +      +      FIN(9)*FIN(4)+FIN(13)*FIN(8))                        
      PP(13)= PP(4)                                                     
      PP(6) = DXX*(FIN(2)*FIN(2)+FIN(6)*FIN(6))                         
     +      + DVV*(FIN(10)*FIN(10)+FIN(14)*FIN(14))                     
     +      + 2.*DXV*(FIN(2)*FIN(10)+FIN(6)*FIN(14))                    
      PP(7) = DXX*(FIN(2)*FIN(3)+FIN(6)*FIN(7))                         
     +      + DVV*(FIN(10)*FIN(11)+FIN(14)*FIN(15))                     
     +      + DXV*(FIN(2)*FIN(11)+FIN(6)*FIN(15)+                       
     +             FIN(10)*FIN(3)+FIN(14)*FIN(7))                       
      PP(10)= PP(7)                                                     
      PP(8) = DXX*(FIN(2)*FIN(4)+FIN(6)*FIN(8))                         
     +      + DVV*(FIN(10)*FIN(12)+FIN(14)*FIN(16))                     
     +      + DXV*(FIN(2)*FIN(12)+FIN(6)*FIN(16)+                       
     +             FIN(10)*FIN(4)+FIN(14)*FIN(8))                       
      PP(14)= PP(8)                                                     
      PP(11)= DXX*(FIN(3)*FIN(3)+FIN(7)*FIN(7))                         
     +      + DVV*(FIN(11)*FIN(11)+FIN(15)*FIN(15))                     
     +      + 2.*DXV*(FIN(3)*FIN(11)+FIN(15)*FIN(7))                    
      PP(12)= DXX*(FIN(3)*FIN(4)+FIN(7)*FIN(8))                         
     +      + DVV*(FIN(11)*FIN(12)+FIN(15)*FIN(16))                     
     +      + DXV*(FIN(3)*FIN(12)+FIN(7)*FIN(16)+                       
     +             FIN(11)*FIN(4)+FIN(15)*FIN(8))                       
      PP(15)=PP(12)                                                     
      PP(16)= DXX*(FIN(4)*FIN(4)+FIN(8)*FIN(8))                         
     +      + DVV*(FIN(12)*FIN(12)+FIN(16)*FIN(16))                     
     +      + 2.*DXV*(FIN(4)*FIN(12)+FIN(8)*FIN(16))                    
CX40024 CALL SBOUTX (24)                                                
CY40024 CALL SBOUTY (24)                                                
                                                                        
      RETURN                                                            
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     FITSET : RESET ERROR ENHANCEMENT PARAMETER			+                    
C									+                                                             
C      USAGE : CALL FITSET(EXTIN)					+                                 
C      EXTIN : NEW VALUE FOR EXTERR					+                               
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      ENTRY FITSET(EXTIN)                                               
CX30025 CALL SBINX (25)                                                 
CY30025 CALL SBINY (25)                                                 
      EXTERR=EXTIN                                                      
CX40026 CALL SBOUTX (26)                                                
CY40026 CALL SBOUTY (26)                                                
      RETURN                                                            
                                                                        
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     FIJGET : EVALUATE LINEARIZED TRANSFORMATION MATRIX		+             
C									+                                                             
C      USAGE : CALL FIJGET(PARM,F,IOK)					+                            
C       PARM : STANDARD BOOSTER PARAMETER VECTOR			+                    
C	   F : TRANSFORMATION MATRIX  [OUTPUT]				+                           
C        IOK : STATUS FLAG, NEGATIVE ON IMPROPER T-T(LAUNCH)		+         
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE FIJGET(PARM,F,IOK)                                     
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      DOUBLE PRECISION PARM(4),F(16),OMEGAE,RADE                        
      DOUBLE PRECISION TH,DL,PS,TL,CTH,STH,CDL,SDL,CPS,SPS              
      DOUBLE PRECISION VO,A,B,C,D,THA,THB,THC,THD,PHA,PHB               
      DOUBLE PRECISION PSA,PSC,AH,BH,THAH,THBH,PHAH,PHBH,PSAH           
      DOUBLE PRECISION Z,R,VZ,VR,AZ,AR                                  
      PARAMETER (RADE = 6378.145, OMEGAE = 7.272205E-5)                 
CX30027 CALL SBINX (27)                                                 
CY30027 CALL SBINY (27)                                                 
                                                                        
      TL=TIMDAT-PARM(4)                                                 
      IOK=-1                                                            
      IF(TL.LE.0.0) THEN                                                
CX40028 CALL SBOUTX (28)                                                
CY40028 CALL SBOUTY (28)                                                
      RETURN                                                            
      ENDIF                                                             
      IOK=1                                                             
      VO=RADE*OMEGAE                                                    
                                                                        
      CALL PROFYL(TL,Z,R,VZ,VR,AZ,AR)                                   
      TH=PARM(1)                                                        
      DL=PARM(2)-PHSENS-OMEGAE*TL                                       
      PS=PARM(3)                                                        
      CTH=COS(TH)                                                       
      STH=SIN(TH)                                                       
      CDL=COS(DL)                                                       
      SDL=SIN(DL)                                                       
      CPS=COS(PS)                                                       
      SPS=SIN(PS)                                                       
                                                                        
      A=-CDL*SPS-SDL*CPS*STH                                            
      B=SDL*CTH                                                         
      C=CTH*CPS                                                         
      D=STH                                                             
                                                                        
      THA=-SDL*CPS*CTH                                                  
      THB=-SDL*STH                                                      
      THC=-STH*CPS                                                      
      THD=CTH                                                           
                                                                        
      PSA=-CDL*CPS+SDL*SPS*STH                                          
      PSC=-CTH*SPS                                                      
                                                                        
      PHA=SDL*SPS-CDL*CPS*STH                                           
      PHB=CDL*CTH                                                       
                                                                        
      AH=-PHA                                                           
      BH=-PHB                                                           
      THAH=CDL*CPS*CTH                                                  
      THBH=CDL*STH                                                      
      PHAH=A                                                            
      PHBH=B                                                            
      PSAH=-SDL*CPS-CDL*SPS*STH                                         
                                                                        
       F(1) = THA*R+THB*Z-TL*VO*STH*CDL                                 
       F(2) = THC*R+THD*Z                                               
       F(3) = THA*VR+THB*VZ-VO*STH*CDL                                  
     +      + OMEGAE*(THAH*R+THBH*Z-VO*TL*STH*SDL)                      
       F(4) = THC*VR+THD*VZ                                             
       F(5) = PHA*R+PHB*Z-TL*VO*CTH*SDL                                 
       F(6) = 0.0                                                       
       F(7) = PHA*VR+PHB*VZ-VO*CTH*SDL                                  
     +      + OMEGAE*(PHAH*R+PHBH*Z+VO*TL*CTH*CDL)                      
       F(8) = 0.0                                                       
       F(9) = PSA*R                                                     
      F(10) = PSC*R                                                     
      F(11) = PSA*VR+OMEGAE*PSAH*R                                      
      F(12) = PSC*VR                                                    
      F(13) = -A*VR-B*VZ+OMEGAE*F(5)-VO*CTH*CDL                         
      F(14) = -C*VR-D*VZ                                                
      F(15) = -A*AR-B*AZ                                                
     +      + OMEGAE*(-AH*VR-BH*VZ-VO*CTH*SDL+F(7))                     
      F(16) = -C*AR-D*AZ                                                
CX40028 CALL SBOUTX (28)                                                
CY40028 CALL SBOUTY (28)                                                
                                                                        
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     COMCOV : COMBINE PARAMETER ESTIMATES AND COVARIANCE MATRICES	+    
C									+                                                             
C      USAGE : CALL COMCOV(P1,PP1,P2,PP2,P,PP,SCORE,FADE,ISTAT)		+      
C  	  P1 : FIRST PARAMETER VECTOR					+                                 
C	 PP1 : FIRST COVARIANCE MATRIX					+                                  
C         P2 : SECOND PARAMETER VECTOR					+                            
C        PP2 : SECOND COVARIANCE MATRIX					+                           
C	   P : COMBINED PARAMETER VECTOR	[OUTPUT]		+                          
C	  PP : COMBINED COVARIANCE MATRIX	[OUTPUT]		+                         
C      SCORE : ASSOCIATION SCORE, (1<->2)	[OUTPUT]		+                   
C	FADE : FADING MEMORY ENHANCEMENT OF PP2				+                          
C      ISTAT : STATUS, NEGATIVE ON INVERSION ERROR			+                  
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE COMCOV(P1,PP1,P2,PP2,P,PP,SCORE,FADE,ISTAT)            
      DOUBLE PRECISION P1(4),P2(4),P(4),DP(4)                           
      DOUBLE PRECISION PP1(16),PP2(16),PP(16),R(16),RINV(16),TM(16)     
      DOUBLE PRECISION SCORE,FADE                                       
CX30029 CALL SBINX (29)                                                 
CY30029 CALL SBINY (29)                                                 
                                                                        
C					SUPPRESS SECOND ESTIMATE IF REQUESTED                             
      IF(FADE.LE.1.0) GO TO 110                                         
CX10547 CALL DOINX( 547 )                                               
CY10547 CALL DOINY( 547 )                                               
      DO 100 K=1,16                                                     
  100 PP2(K)=PP2(K)*FADE                                                
CX20548 CALL DOOUTX( 548 )                                              
CY20548 CALL DOOUTY( 548 )                                              
                                                                        
C					INVERT COVARIANCE SUM                                             
  110 ISTAT=-1                                                          
CX10549 CALL DOINX( 549 )                                               
CY10549 CALL DOINY( 549 )                                               
      DO 120 K=1,16                                                     
  120 R(K)=PP1(K)+PP2(K)                                                
CX20550 CALL DOOUTX( 550 )                                              
CY20550 CALL DOOUTY( 550 )                                              
      CALL SINV4(R,RINV,JSTAT)                                          
      IF( JSTAT.LT.0 ) THEN                                             
CX40030 CALL SBOUTX (30)                                                
CY40030 CALL SBOUTY (30)                                                
      RETURN                                                            
      ENDIF                                                             
                                                                        
      SCORE=0.0                                                         
      CALL MATML4(PP2,RINV,TM)                                          
CX10551 CALL DOINX( 551 )                                               
CY10551 CALL DOINY( 551 )                                               
      DO 130 K=1,4                                                      
      P(K)=P2(K)                                                        
  130 DP(K)=P1(K)-P2(K)                                                 
CX20552 CALL DOOUTX( 552 )                                              
CY20552 CALL DOOUTY( 552 )                                              
CX10553 CALL DOINX( 553 )                                               
CY10553 CALL DOINY( 553 )                                               
                                                                        
C					UPDATE PARAMETER, GET SCORE                                       
      DO 150 I=1,4                                                      
      DO 140 J=1,4                                                      
      K=I+4*(J-1)                                                       
      P(I) = P(I)+TM(K)*DP(J)                                           
      SCORE = SCORE + DP(I)*DP(J)*RINV(K)                               
  140 CONTINUE                                                          
  150 CONTINUE                                                          
CX20554 CALL DOOUTX( 554 )                                              
CY20554 CALL DOOUTY( 554 )                                              
                                                                        
C					UPDATE THE COVARIANCE MATRIX                                      
      CALL MATML4(TM,PP1,PP)                                            
C					EXPLICITLY SYMMETRIZE                                             
      PP(2)=(PP(2)+PP(5))/2.0                                           
      PP(5)=PP(2)                                                       
      PP(3)=(PP(3)+PP(9))/2.0                                           
      PP(9)=PP(3)                                                       
      PP(4)=(PP(4)+PP(13))/2.0                                          
      PP(13)=PP(4)                                                      
      PP(7)=(PP(7)+PP(10))/2.0                                          
      PP(10)=PP(7)                                                      
      PP(8)=(PP(8)+PP(14))/2.0                                          
      PP(14)=PP(8)                                                      
      PP(12)=(PP(12)+PP(15))/2.0                                        
      PP(15)=PP(12)                                                     
                                                                        
      ISTAT=0                                                           
CX40030 CALL SBOUTX (30)                                                
CY40030 CALL SBOUTY (30)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     GETOBS : GENERATE ESTIMATED FP-STATE FROM PARAMETER VECTOR	+      
C									+                                                             
C      USAGE : CALL GETOBS(PARM,T,STATE)				+                           
C       PARM : STANDARD BOOSTER PARAMETER VECTOR			+                    
C	   T : TIME FOR STATE EVALUATION				+                                 
C      STATE : FOCAL PLANE STATE VECTOR		[OUTPUT]		+                    
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE GETOBS(PARM,T,STATE)                                   
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      DOUBLE PRECISION PARM(4),STATE(4),T                               
      DOUBLE PRECISION PHII,SPH,CPH,X(3),V(3),A(3)                      
      DOUBLE PRECISION OMEGAE                                           
      PARAMETER (OMEGAE = 7.272205E-5)                                  
CX30031 CALL SBINX (31)                                                 
CY30031 CALL SBINY (31)                                                 
                                                                        
      PHII=PHSENS+OMEGAE*T                                              
      SPH=SIN(PHII)                                                     
      CPH=COS(PHII)                                                     
      CALL BSTATE(PARM,T,X,V,A)                                         
                                                                        
      STATE(1) = -SPH*X(1)+CPH*X(2)                                     
      STATE(2) = X(3)                                                   
      STATE(3) = -SPH*V(1)+CPH*V(2)-OMEGAE*(CPH*X(1)+SPH*X(2))          
      STATE(4) = V(3)                                                   
CX40032 CALL SBOUTX (32)                                                
CY40032 CALL SBOUTY (32)                                                
                                                                        
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     CHIFIT : EVALUATE CHI^2 FOR PARAMETER<->DATA FIT			+              
C									+                                                             
C      USAGE : FUNCTION CHIFIT(PARM,XSDATA,WGTS)	+                      
C	PARM : ESTIMATED TRACK PARAMETER VECTOR				+                          
C     XSDATA : FOCAL PLANE STATE VECTOR					+                           
C       WGTS : DIAGONAL WEIGHTS FOR CHI^2 EVALUATION			+                
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      FUNCTION CHIFIT(PARM,XSDATA,WGTS)                                 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      DOUBLE PRECISION PARM(4),XSDATA(4),WGTS(4)                        
      DOUBLE PRECISION XS(4),SUM,TERM                                   
CX30033 CALL SBINX (33)                                                 
CY30033 CALL SBINY (33)                                                 
                                                                        
      CALL GETOBS(PARM,TIMDAT,XS)                                       
      SUM=0.0                                                           
CX10555 CALL DOINX( 555 )                                               
CY10555 CALL DOINY( 555 )                                               
      DO 100 K=1,4                                                      
      TERM=WGTS(K)*(XS(K)-XSDATA(K))                                    
      SUM=SUM+TERM*TERM                                                 
  100 CONTINUE                                                          
CX20556 CALL DOOUTX( 556 )                                              
CY20556 CALL DOOUTY( 556 )                                              
      CHIFIT=SUM                                                        
CX40034 CALL SBOUTX (34)                                                
CY40034 CALL SBOUTY (34)                                                
                                                                        
      RETURN                                                            
      END                                                               
C***********************************************************************
C									*                                                             
C	BOOSTER PROFILE PACKAGE						*                                        
C									*                                                             
C     ROUTINES IN THIS FILE ------------------------------------------- 
C	PROFYL : INTERPOLATE BOOSTER KINEMATIC VECTORS VERSUS TIME	*          
C	BSTATE : EVALUATE COORDINATES IN STANDARD ECI FRAME		*                
C									*                                                             
C     ADDITIONAL INPUT FILE ------------------------------------------- 
C	FOR015 : BOOSTER TABLE CONTENTS (OLD PROFILE.DAT)		*                  
C              : FILE IS READ ON FIRST ENTRY				*                       
C									*                                                             
C***********************************************************************
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     PROFYL : INTERPOLATION OF BOOSTER KINEMATIC TABLES		+             
C									+                                                             
C      USAGE : CALL PROFYL(TIME,Z,R,VZ,VR,AZ,AR)			+                    
C     	TIME : SPECIFIED TIME SINCE LAUNCH				+                          
C	   Z : VERTICAL POSITION	[OUTPUT]			+                                 
C	   R : HORIZONTAL POSITION	[OUTPUT]			+                               
C	  VZ : VERTICAL VELOCITY	[OUTPUT]			+                                 
C	  VR : HORIZONTAL VELOCITY	[OUTPUT]			+                               
C	  AZ : VERTICAL ACCELERATION	[OUTPUT]			+                             
C	  AR : HORIZONTAL ACCELERATION  [OUTPUT]			+                          
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE PROFYL(TIME,Z,R,VZ,VR,AZ,AR)                           
      DOUBLE PRECISION TAB1(1500),TAB2(1500),TAB3(1500)                 
      DOUBLE PRECISION TAB4(1500),TAB5(1500),TAB6(1500)                 
      DOUBLE PRECISION TIME,Z,R,VZ,VR,AZ,AR                             
      DOUBLE PRECISION DT,DTF,DELT,F0,F1,F2,A,B                         
      SAVE DT, MANY, TAB1, TAB2, TAB3, TAB4                             
      SAVE IS1ST  ,TAB6,TAB5                                  
C                                                                       
      DATA IS1ST /1/                                                    
CX30035 CALL SBINX (35)                                                 
CY30035 CALL SBINY (35)                                                 
C                                                                       
      IF( IS1ST.LT.1 ) GO TO 100                                        
      READ(15,*) DT,MANY                                                
      IF(MANY.GT.1500) MANY=1500                                        
CX10557 CALL DOINX( 557 )                                               
CY10557 CALL DOINY( 557 )                                               
      DO 90 K=1,MANY                                                    
      READ(15,*) TAB1(K),TAB2(K),TAB3(K),TAB4(K),TAB5(K),TAB6(K)        
   90 CONTINUE                                                          
CX20558 CALL DOOUTX( 558 )                                              
CY20558 CALL DOOUTY( 558 )                                              
      IS1ST = -1                                                        
                                                                        
  100 I1= TIME/DT+1.0                                                   
      IF(I1.GT.0) GO TO 110                                             
      Z=TAB1(1)                                                         
      R=TAB2(1)                                                         
      VZ=TAB3(1)                                                        
      VR=TAB4(1)                                                        
      AZ=TAB5(1)                                                        
      AR=TAB6(1)                                                        
CX40036 CALL SBOUTX (36)                                                
CY40036 CALL SBOUTY (36)                                                
      RETURN                                                            
                                                                        
  110 CONTINUE                                                          
      IF( I1.LE.MANY-2 ) GO TO 120                                      
      Z=TAB1(MANY)                                                      
      R=TAB2(MANY)                                                      
      VZ=TAB3(MANY)                                                     
      VR=TAB4(MANY)                                                     
      AZ=TAB5(MANY)                                                     
      AR=TAB6(MANY)                                                     
CX40036 CALL SBOUTX (36)                                                
CY40036 CALL SBOUTY (36)                                                
      RETURN                                                            
                                                                        
  120 DTF=I1-1                                                          
      DELT=TIME-DT*DTF                                                  
      I2=I1+1                                                           
      I3=I2+1                                                           
                                                                        
      F0=TAB1(I1)                                                       
      F1=TAB1(I2)                                                       
      F2=TAB1(I3)                                                       
      A=(4.0*F1-3.0*F0-F2)/(2.*DT)                                      
      B=(F0-2.*F1+F2)/(2.*DT*DT)                                        
      Z=F0+A*DELT+B*DELT*DELT                                           
                                                                        
      F0=TAB2(I1)                                                       
      F1=TAB2(I2)                                                       
      F2=TAB2(I3)                                                       
      A=(4.0*F1-3.0*F0-F2)/(2.*DT)                                      
      B=(F0-2.*F1+F2)/(2.*DT*DT)                                        
      R=F0+A*DELT+B*DELT*DELT                                           
                                                                        
      F0=TAB3(I1)                                                       
      F1=TAB3(I2)                                                       
      F2=TAB3(I3)                                                       
      A=(4.0*F1-3.0*F0-F2)/(2.*DT)                                      
      B=(F0-2.*F1+F2)/(2.*DT*DT)                                        
      VZ=F0+A*DELT+B*DELT*DELT                                          
                                                                        
                                                                        
      F0=TAB4(I1)                                                       
      F1=TAB4(I2)                                                       
      F2=TAB4(I3)                                                       
      A=(4.0*F1-3.0*F0-F2)/(2.*DT)                                      
      B=(F0-2.*F1+F2)/(2.*DT*DT)                                        
      VR=F0+A*DELT+B*DELT*DELT                                          
                                                                        
      F0=TAB5(I1)                                                       
      F1=TAB5(I2)                                                       
      F2=TAB5(I3)                                                       
      A=(4.0*F1-3.0*F0-F2)/(2.*DT)                                      
      B=(F0-2.*F1+F2)/(2.*DT*DT)                                        
      AZ=F0+A*DELT+B*DELT*DELT                                          
                                                                        
      F0=TAB6(I1)                                                       
      F1=TAB6(I2)                                                       
      F2=TAB6(I3)                                                       
      A=(4.0*F1-3.0*F0-F2)/(2.*DT)                                      
      B=(F0-2.*F1+F2)/(2.*DT*DT)                                        
      AR=F0+A*DELT+B*DELT*DELT                                          
CX40036 CALL SBOUTX (36)                                                
CY40036 CALL SBOUTY (36)                                                
                                                                        
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     BSTATE : EVALUATE BOOSTER ECI KINEMATIC VECTORS			+               
C									+                                                             
C      USAGE : CALL BSTATE(PARM,T,X,V,A)				+                           
C       PARM : BOOSTER PARAMETER VECTOR					+                           
C          T : SPECIFIED TIME FOR EVALUATION (STANDARD CLOCK)		+        
C	   X : BOOSTER POSITION VECTOR	   [OUTPUT]			+                        
C	   V : BOOSTER VELOCITY VECTOR	   [OUTPUT]			+                        
C	   A : BOOSTER ACCELERATION VECTOR [OUTPUT]			+                       
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE BSTATE(PARM,T,X,V,A)                                   
      DOUBLE PRECISION PARM(4),X(3),V(3),A(3),T                         
      DOUBLE PRECISION RE,OM,PHII,CTH,STH,CPH,SPH,CPS,SPS               
      DOUBLE PRECISION VXL,VYL,DELTAT,AX,BX,AY,BY,AZ,BZ                 
      DOUBLE PRECISION Z,R,VZ,VR,AAZ,AAR                                
      PARAMETER (RE = 6378.145, OM = 7.272205E-5)                       
CX30037 CALL SBINX (37)                                                 
CY30037 CALL SBINY (37)                                                 
                                                                        
C     SET A BUNCH OF COEFFICIENTS                                       
                                                                        
      PHII=PARM(2)+OM*PARM(4)                                           
      CTH=COS(PARM(1))                                                  
      STH=SIN(PARM(1))                                                  
      CPH=COS(PHII)                                                     
      SPH=SIN(PHII)                                                     
      CPS=COS(PARM(3))                                                  
      SPS=SIN(PARM(3))                                                  
      VXL=-OM*RE*CTH*SPH                                                
      VYL=OM*RE*CTH*CPH                                                 
                                                                        
C     GET LAUNCH FRAME COORDINATES                                      
                                                                        
      AX=SPH*SPS-CPH*CPS*STH                                            
      BX=CPH*CTH                                                        
      AY=-CPH*SPS-SPH*CPS*STH                                           
      BY=SPH*CTH                                                        
      AZ=CTH*CPS                                                        
      BZ=STH                                                            
      DELTAT=T-PARM(4)                                                  
      IF(DELTAT.LE.0.) DELTAT=0.                                        
      CALL PROFYL(DELTAT,Z,R,VZ,VR,AAZ,AAR)                             
                                                                        
C     COMPUTE INERTIAL FRAME COORDINATES                                
                                                                        
      X(1)=AX*R+BX*Z+VXL*DELTAT                                         
      X(2)=AY*R+BY*Z+VYL*DELTAT                                         
      X(3)=AZ*R+BZ*Z                                                    
      V(1)=AX*VR+BX*VZ+VXL                                              
      V(2)=AY*VR+BY*VZ+VYL                                              
      V(3)=AZ*VR+BZ*VZ                                                  
      A(1)=AX*AAR+BX*AAZ                                                
      A(2)=AY*AAR+BY*AAZ                                                
      A(3)=AZ*AAR+BZ*AAZ                                                
CX40038 CALL SBOUTX (38)                                                
CY40038 CALL SBOUTY (38)                                                
      RETURN                                                            
      END                                                               
C***********************************************************************
C									*                                                             
C	THREAT INITIALIZATION AND DATA GENERATION PACKAGE		*                  
C									*                                                             
C     ROUTINES IN THIS FILE ------------------------------------------- 
C	THINIT : INITIALIZE THREAT FROM DATA FILE (FOR016)		*                 
C  	SENINT : INITIALIZE GEOSTATIONARY SENSOR			*                        
C	GETDAT : GENERATE SENSOR DATA AT SPECIFIED TIME			*                   
C									*                                                             
C     ADDITIONAL INPUT FILE ------------------------------------------- 
C	FOR016 : THREAT SPECIFICATION (OLD THREAT.DAT)			*                    
C	       : FILE IS READ BY THINIT					*                                 
C									*                                                             
C***********************************************************************
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     THINIT : INITIALIZE THREAT FORM DATA FILE (FOR016)		+             
C									+                                                             
C      USAGE : CALL THINIT(IPFL)					+                                  
C	IPFL : PRINT FLAG, LIST THREAT DESCRIPTION IF POSITIVE		+             
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE THINIT(IPFL)                                           
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      PARAMETER (RADIAN = 57.2957795)                                   
CX30039 CALL SBINX (39)                                                 
CY30039 CALL SBINY (39)                                                 
                                                                        
      READ(16,*) NSITES                                                 
      IF( NSITES.LE.MAXSIT ) GO TO 100                                  
      WRITE(6,900) NSITES,MAXSIT                                        
      NSITES=MAXSIT                                                     
                                                                        
  100 LSTTHR=0                                                          
      IF( IPFL.GT.0 ) WRITE(6,901) NSITES                               
CX10559 CALL DOINX( 559 )                                               
CY10559 CALL DOINY( 559 )                                               
      DO 200 ISITE=1,NSITES                                             
      READ(16,*) NTH,V1,V2                                              
      NFSITE(ISITE)=LSTTHR+1                                            
      SITLAT(ISITE)=V1/RADIAN                                           
      SITLON(ISITE)=V2/RADIAN                                           
      IF( IPFL.GT.0 ) WRITE(6,902) ISITE,V1,V2,NTH                      
      DO 190 K=1,NTH                                                    
      LSTTHR=LSTTHR+1                                                   
      IF( LSTTHR.LE.MAXTHR) GO TO 110                                   
      NSITES=ISITE                                                      
      LSTTHR=MAXTHR                                                     
      WRITE(6,903) MAXTHR,NSITES                                        
      GO TO 210                                                         
  110 CONTINUE                                                          
      READ(16,*) V1,V2,V3,V4                                            
      THPARM(1,LSTTHR)=V1/RADIAN                                        
      THPARM(2,LSTTHR)=V2/RADIAN                                        
      THPARM(3,LSTTHR)=V3/RADIAN                                        
      THPARM(4,LSTTHR)=V4                                               
  190 CONTINUE                                                          
  200 CONTINUE                                                          
CX20560 CALL DOOUTX( 560 )                                              
CY20560 CALL DOOUTY( 560 )                                              
  210 ISITE=NSITES+1                                                    
      NFSITE(ISITE)=LSTTHR+1                                            
      IF( IPFL.GT.0 ) WRITE(6,904) LSTTHR                               
CX40040 CALL SBOUTX (40)                                                
CY40040 CALL SBOUTY (40)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(//' ****************************************'/             
     +' TOO MANY LAUNCH SITES SPECIFIED: ',I6/                          
     +' RESET TO MAXSIT : ',I3/                                         
     +' ****************************************'/)                     
  901 FORMAT(/' INITIALIZE ',I2,'-SITE THREAT ',26('-'))                
  902 FORMAT(' SITE ',I2,' AT ',F5.1,1X,F5.1,' HAS ',I3,' BOOSTERS')    
  903 FORMAT(//' ****************************************'/             
     +' SPECIFIED THREAT EXCEEDS STORAGE LIMIT'/                        
     +' THREAT REDUCED TO ',I4,' BOOSTERS (MAXTHR)'/                    
     +' NUMBER OF ACTIVE SITES IS ',I3/                                 
     +' ****************************************'/)                     
  904 FORMAT(' THREAT HAS ',I4,' TOTAL TARGETS')                        
CX40040 CALL SBOUTX (40)                                                
CY40040 CALL SBOUTY (40)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     SENINT : SENSOR INITIALIZATION FUNCTION				+                      
C									+                                                             
C      USAGE : CALL SENINT(PHSD,IPFL)					+                             
C	PHSD : SENSOR EAST LONGITUDE (DEGREES)				+                           
C       IPFL : PRINT FLAG, OUTPUT IF POSITIVE				+                      
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE SENINT(PHSD,IPFL)                                      
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
CX30041 CALL SBINX (41)                                                 
CY30041 CALL SBINY (41)                                                 
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      PHSENS=PHSD/57.2957795                                            
      IF( IPFL.GT.0 ) WRITE(6,900) PHSD                                 
CX40042 CALL SBOUTX (42)                                                
CY40042 CALL SBOUTY (42)                                                
      RETURN                                                            
  900 FORMAT(/' INITIALIZE SENSOR ',34('-')/                            
     +2X,F8.2,' : SENSOR EAST MERIDIAN [DEG]'/)                         
CX40042 CALL SBOUTX (42)                                                
CY40042 CALL SBOUTY (42)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     GETDAT : GENERATE SENSOR DATA AT SPECIFIED TIME			+               
C									+                                                             
C      USAGE : CALL GETDAT(TIME)					+                                  
C	TIME : SPECIFIED TIME FOR DATA (SEC)				+                             
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE GETDAT(TIME)                                           
      DOUBLE PRECISION TCLOUD,OMEGAE,RADE                               
      DOUBLE PRECISION DELTAT,Z,R,VZ,VR,AZ,AR                           
      DOUBLE PRECISION THETA,DEL,PSI,A,B,XXVAL,ZZVAL                    
      DOUBLE PRECISION CTH,STH,CDL,SDL,CPS,SPS,CELBY2                   
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
                                                                        
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TIMING VARIABLES 							+                                         
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TIMERC/ TSBI,TABI,TSKF,TAKF,TSPR,TAPR,TSTH,TATH           
                                                                        
C     TSBI : STEP TIME, BATCH INITIATION                                
C     TABI : TOTAL TIME, BATCH INITIATION                               
C     TSKF : STEP TIME, FOCAL PLANE FILTER                              
C     TAKF : TOTAL TIME, FOCAL PLANE FILTER                             
C     TSPR : STEP TIME, PRECISION TRACKER                               
C     TAPR : TOTAL TIME, PRECISION TRACKER                              
C     TSTH : STEP TIME, SENSOR DATA GENERATION                          
C     TATH : TOTAL TIME, SENSOR DATA GENERATION                         
                                                                        
      PARAMETER (TCLOUD = 26.0)                                         
      PARAMETER (RADE = 6378.145, OMEGAE = 7.272205E-5)                 
CX30043 CALL SBINX (43)                                                 
CY30043 CALL SBINY (43)                                                 
                                                                        
C     T1=CPUTYM(1.0)                                                    
      CALL CPUTIM(T1)                                                   
      TIMDAT=TIME                                                       
      LSTDAT=0                                                          
CX10561 CALL DOINX( 561 )                                               
CY10561 CALL DOINY( 561 )                                               
                                                                        
C     LOOP ON LAUNCH SITES                                              
                                                                        
      DO 300 ISITE=1,NSITES                                             
      IS2=ISITE+1                                                       
      NTH1=NFSITE(ISITE)                                                
      NTH2=NFSITE(IS2)-1                                                
      NFLAUN(ISITE)=LSTDAT+1                                            
      IF(NTH2.LT.NTH1) GO TO 300                                        
      ITFRST = LSTDAT+1                                                 
                                                                        
C     LOOP ON BOOSTERS WITHIN SITE                                      
                                                                        
      DO 290 NTH=NTH1,NTH2                                              
      DELTAT=TIMDAT-THPARM(4,NTH)                                       
      IF(DELTAT.LT.TCLOUD) GO TO 290                                    
      CALL PROFYL(DELTAT,Z,R,VZ,VR,AZ,AR)                               
      THETA=THPARM(1,NTH)                                               
      DEL=THPARM(2,NTH)-PHSENS-OMEGAE*DELTAT                            
      PSI=THPARM(3,NTH)                                                 
      CTH=COS(THETA)                                                    
      STH=SIN(THETA)                                                    
      CDL=COS(DEL)                                                      
      SDL=SIN(DEL)                                                      
      CPS=COS(PSI)                                                      
      SPS=SIN(PSI)                                                      
      A= -CDL*SPS-SDL*CPS*STH                                           
      B=SDL*CTH                                                         
      XXVAL=A*R+B*Z+OMEGAE*RADE*DELTAT*CTH*CDL                          
      ZZVAL=CTH*CPS*R+STH*Z                                             
      IIX=ABS(XXVAL)/CELSIZ                                             
      IIZ=ABS(ZZVAL)/CELSIZ                                             
      IIX=2*IIX+1                                                       
      IIZ=2*IIZ+1                                                       
      IF( XXVAL.LT.0.0 ) IIX =-IIX                                      
      IF( ZZVAL.LT.0.0 ) IIZ =-IIZ                                      
                                                                        
C     CHECH FOR DATA DUPLICATIONS                                       
                                                                        
      IF( LSTDAT.LT.ITFRST ) GO TO 200                                  
      DO 190 IDL=ITFRST,LSTDAT                                          
      IF( IIX.EQ.IXVL(IDL).AND.IIZ.EQ.IZVL(IDL) ) GO TO 290             
  190 CONTINUE                                                          
  200 LSTDAT=LSTDAT+1                                                   
      IXVL(LSTDAT)=IIX                                                  
      IZVL(LSTDAT)=IIZ                                                  
      ITHSIT(LSTDAT)=ISITE                                              
  290 CONTINUE                                                          
  300 CONTINUE                                                          
CX20562 CALL DOOUTX( 562 )                                              
CY20562 CALL DOOUTY( 562 )                                              
                                                                        
      IS2=NSITES+1                                                      
      NFLAUN(IS2) = LSTDAT+1                                            
      CELBY2=CELSIZ/2.0                                                 
CX10563 CALL DOINX( 563 )                                               
CY10563 CALL DOINY( 563 )                                               
      DO 400 K=1,LSTDAT                                                 
      THDATA(1,K)=CELBY2*REAL(IXVL(K))                                  
      THDATA(2,K)=CELBY2*REAL(IZVL(K))                                  
  400 CONTINUE                                                          
CX20564 CALL DOOUTX( 564 )                                              
CY20564 CALL DOOUTY( 564 )                                              
                                                                        
C     TSTH=CPUTYM(2.0)-T1                                               
      CALL CPUTIM(T2)                                                   
      TSTH=T2-T1                                                        
      TATH=TSTH+TATH                                                    
CX40044 CALL SBOUTX (44)                                                
CY40044 CALL SBOUTY (44)                                                
      RETURN                                                            
                                                                        
      END                                                               
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     COPYTR : TRACK STRUCTURE COPY UTILITY				+                        
C      									+                                                       
C      USAGE : CALL COPYTR(KOLD,KNEW)					+                             
C       KOLD : INPUT LOCATION IN /TRAXCM/				+                          
C       KNEW : OUTPUT LOCATION IN /TRAXCM/				+                         
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE COPYTR(KOLD,KNEW)                                      
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRACK STORAGE FOR FORTRAN TRACKER					+                           
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
CX30045 CALL SBINX (45)                                                 
CY30045 CALL SBINY (45)                                                 
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
      IF(KOLD.EQ.KNEW) THEN                                             
CX40046 CALL SBOUTX (46)                                                
CY40046 CALL SBOUTY (46)                                                
      RETURN                                                            
      ENDIF                                                             
      IF(KOLD.LT.1.OR.KOLD.GT.MAXTRK) THEN                              
CX40046 CALL SBOUTX (46)                                                
CY40046 CALL SBOUTY (46)                                                
      RETURN                                                            
      ENDIF                                                             
      IF(KNEW.LT.1.OR.KNEW.GT.MAXTRK) THEN                              
CX40046 CALL SBOUTX (46)                                                
CY40046 CALL SBOUTY (46)                                                
      RETURN                                                            
      ENDIF                                                             
CX10565 CALL DOINX( 565 )                                               
CY10565 CALL DOINY( 565 )                                               
      DO 100 K=1,8                                                      
      XH1(K,KNEW)=XH1(K,KOLD)                                           
  100 XH2(K,KNEW)=XH2(K,KOLD)                                           
CX20566 CALL DOOUTX( 566 )                                              
CY20566 CALL DOOUTY( 566 )                                              
CX10567 CALL DOINX( 567 )                                               
CY10567 CALL DOINY( 567 )                                               
      DO 110 K=1,4                                                      
  110 PRMTRK(K,KNEW)=PRMTRK(K,KOLD)                                     
CX20568 CALL DOOUTX( 568 )                                              
CY20568 CALL DOOUTY( 568 )                                              
CX10569 CALL DOINX( 569 )                                               
CY10569 CALL DOINY( 569 )                                               
      DO 120 K=1,16                                                     
  120 COVTRK(K,KNEW)=COVTRK(K,KOLD)                                     
CX20570 CALL DOOUTX( 570 )                                              
CY20570 CALL DOOUTY( 570 )                                              
CX10571 CALL DOINX( 571 )                                               
CY10571 CALL DOINY( 571 )                                               
      DO 130 K=1,5                                                      
  130 IHITS(K,KNEW)=IHITS(K,KOLD)                                       
CX20572 CALL DOOUTX( 572 )                                              
CY20572 CALL DOOUTY( 572 )                                              
      NMHITS(KNEW)=NMHITS(KOLD)                                         
      ISPREC(KNEW)=ISPREC(KOLD)                                         
      SCORE1(KNEW)=SCORE1(KOLD)                                         
      SCORE2(KNEW)=SCORE2(KOLD)                                         
      IDDSIT(KNEW)=IDDSIT(KOLD)                                         
CX40046 CALL SBOUTX (46)                                                
CY40046 CALL SBOUTY (46)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     PRTRAX : PRINT FOCAL-PLANE TRACK FILE				+                        
C									+                                                             
C      USAGE : CALL PRTRAX						+                                       
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE PRTRAX                                                 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRACK STORAGE FOR FORTRAN TRACKER					+                           
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      CHARACTER IDP,IDBL,IDPR                                           
      PARAMETER (IDBL = ' ', IDPR = 'P')                                
      PARAMETER (RADIAN = 57.2957795, RADE = 6378.145)                  
CX30047 CALL SBINX (47)                                                 
CY30047 CALL SBINY (47)                                                 
                                                                        
      PHLAUN=SITLON(1)                                                  
      THLAUN=SITLAT(1)                                                  
      DELPH=PHLAUN-PHSENS                                               
      XX=RADE*COS(THLAUN)*SIN(DELPH)                                    
      ZZ=RADE*SIN(THLAUN)                                               
      PHLD=PHLAUN*RADIAN                                                
      THLD=THLAUN*RADIAN                                                
      PHSD=PHSENS*RADIAN                                                
      WRITE(6,900) LSTTRK,LSTDAT,TIMDAT,PHSD,THLD,PHLD                  
      IF( LSTDAT.GT.0.AND.LSTTRK.GT.0) GO TO 100                        
      WRITE(6,903)                                                      
CX40048 CALL SBOUTX (48)                                                
CY40048 CALL SBOUTY (48)                                                
      RETURN                                                            
                                                                        
  100 WRITE(6,902)                                                      
CX10573 CALL DOINX( 573 )                                               
CY10573 CALL DOINY( 573 )                                               
      DO 400 KT=1,LSTTRK                                                
      X=XH1(1,KT)-XX                                                    
      Z=XH1(5,KT)-ZZ                                                    
      VX=XH1(2,KT)                                                      
      VZ=XH1(6,KT)                                                      
      NHMAX=NMHITS(KT)                                                  
      IF(NHMAX.GT.5) NHMAX=5                                            
      IDP=IDBL                                                          
      IF( ISPREC(KT).GT.0 ) IDP=IDPR                                    
      WRITE(6,901) KT,X,Z,VX,VZ,NMHITS(KT),IDP,                         
     +          (IHITS(J,KT),J=1,NHMAX)                                 
  400 CONTINUE                                                          
CX20574 CALL DOOUTX( 574 )                                              
CY20574 CALL DOOUTY( 574 )                                              
      WRITE(6,904)                                                      
CX40048 CALL SBOUTX (48)                                                
CY40048 CALL SBOUTY (48)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(//' FOCAL-PLANE TRACK FILE ',46('-')/                      
     +' TRACKER HAS ',I4,' TRACKS FOR ',I4,' DATA AT TIME ',            
     +F5.1,' SECONDS'/                                                  
     +' SENSOR LONGITUDE IS ',F6.1,' DEGREES'/                          
     +' PROJECTIONS RELATIVE TO NOMINAL LAUNCH SITE ',F6.1,1X,F6.1,     
     +' (LAT/LON)'/)                                                    
  901 FORMAT(1X,I3,2X,F8.2,2X,F8.2,2X,F7.3,2X,F7.3,                     
     +2X,I2,2X,A1,2X,5(I3,1X))                                          
  902 FORMAT(' NTR    X-XS      Z-ZS      VX       VZ   ',              
     +'  NH  P  RECENT HITS'/                                           
     +' ---  --------  --------  -------  -------',                     
     +'  --  -  -------------------')                                   
  903 FORMAT(' EMPTY TRACK AND/OR DATA FILE'/)                          
  904 FORMAT(1X)                                                        
CX40048 CALL SBOUTX (48)                                                
CY40048 CALL SBOUTY (48)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     PRTDAT : PRINT PRESENT SENSOR DATA FILE				+                      
C									+                                                             
C      USAGE : CALL PRTDAT						+                                       
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE PRTDAT                                                 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
      DIMENSION XP(5),ZP(5),ID(5),IS(5)                                 
      PARAMETER (RADIAN = 57.2957795, RADE = 6378.145)                  
CX30049 CALL SBINX (49)                                                 
CY30049 CALL SBINY (49)                                                 
                                                                        
      PHLAUN=SITLON(1)                                                  
      THLAUN=SITLAT(1)                                                  
      DELPH=PHLAUN-PHSENS                                               
      XX=RADE*COS(THLAUN)*SIN(DELPH)                                    
      ZZ=RADE*SIN(THLAUN)                                               
      PHLD=PHLAUN*RADIAN                                                
      THLD=THLAUN*RADIAN                                                
      PHSD=PHSENS*RADIAN                                                
      WRITE(6,900) TIMDAT,LSTDAT,PHSD,THLD,PHLD                         
      IF(LSTDAT.LT.1) THEN                                              
CX40050 CALL SBOUTX (50)                                                
CY40050 CALL SBOUTY (50)                                                
      RETURN                                                            
      ENDIF                                                             
                                                                        
      N1=1                                                              
  100 N2=N1+4                                                           
      IF(N2.GT.LSTDAT) N2=LSTDAT                                        
CX10575 CALL DOINX( 575 )                                               
CY10575 CALL DOINY( 575 )                                               
      DO 102 K=N1,N2                                                    
      J=K+1-N1                                                          
      ID(J)=K                                                           
      DO 101 IDS=1,NSITES                                               
      IF( K.GE.NFSITE(IDS) ) IS(J)=IDS                                  
  101 CONTINUE                                                          
      XP(J)=THDATA(1,K)-XX                                              
      ZP(J)=THDATA(2,K)-ZZ                                              
  102 CONTINUE                                                          
CX20576 CALL DOOUTX( 576 )                                              
CY20576 CALL DOOUTY( 576 )                                              
      JLAST=N2-N1+1                                                     
      WRITE(6,901) (ID(J),IS(J),J=1,JLAST)                              
      WRITE(6,902) (XP(J),J=1,JLAST)                                    
      WRITE(6,903) (ZP(J),J=1,JLAST)                                    
      WRITE(6,904)                                                      
      IF( N2.GE.LSTDAT ) THEN                                           
CX40050 CALL SBOUTX (50)                                                
CY40050 CALL SBOUTY (50)                                                
      RETURN                                                            
      ENDIF                                                             
      N1=N2+1                                                           
      GO TO 100                                                         
                                                                        
  900 FORMAT(/' DATA FILE AT TIME ',F6.1,' HAS ',I4,' REPORTS ',        
     +15('-')/2X,F8.2,' : EAST LONGITUDE OF SENSOR [DEG]'/              
     +2X,F8.2,' : LATITUDE OF NOMINAL LAUNCH SITE [DEG]'/               
     +2X,F8.2,' : LONGITUDE OF NOMINAL LAUNCH SITE [DEG]'/)             
  901 FORMAT(' N,SITE : ',5(I5,',',I2,2X))                              
  902 FORMAT(' X-X(L) : ',5(F8.2,2X))                                   
  903 FORMAT(' Z-Z(L) : ',5(F8.2,2X))                                   
  904 FORMAT(1X)                                                        
CX40050 CALL SBOUTX (50)                                                
CY40050 CALL SBOUTY (50)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     PRPARM : PRINT ESTIMATED TRACK PARAMETERS			+                     
C									+                                                             
C      CALL PRPARM							+                                              
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE PRPARM                                                 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRACK STORAGE FOR FORTRAN TRACKER					+                           
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
      DIMENSION VAL(4),ERR(4)                                           
      PARAMETER (RADIAN = 57.2957795)                                   
CX30051 CALL SBINX (51)                                                 
CY30051 CALL SBINY (51)                                                 
                                                                        
      NPR=0                                                             
CX10577 CALL DOINX( 577 )                                               
CY10577 CALL DOINY( 577 )                                               
      DO 100 K=1,LSTTRK                                                 
      IF(ISPREC(K).GT.0) NPR=NPR+1                                      
  100 CONTINUE                                                          
CX20578 CALL DOOUTX( 578 )                                              
CY20578 CALL DOOUTY( 578 )                                              
      IF( NPR.GT.0 ) GO TO 110                                          
      WRITE(6,900) TIMDAT                                               
CX40052 CALL SBOUTX (52)                                                
CY40052 CALL SBOUTY (52)                                                
      RETURN                                                            
                                                                        
  110 WRITE(6,901) TIMDAT,NPR                                           
CX10579 CALL DOINX( 579 )                                               
CY10579 CALL DOINY( 579 )                                               
      DO 200 KT=1,LSTTRK                                                
      IF( ISPREC(KT).LT.1 ) GO TO 200                                   
      DO 120 J=1,3                                                      
      VAL(J)=RADIAN*PRMTRK(J,KT)                                        
      J1=1+5*(J-1)                                                      
      ERR(J)=RADIAN*FNORM(COVTRK(J1,KT))                                
  120 CONTINUE                                                          
      VAL(4)=PRMTRK(4,KT)                                               
      ERR(4)=FNORM(COVTRK(16,KT))                                       
      WRITE(6,902) KT,VAL,ERR                                           
  200 CONTINUE                                                          
CX20580 CALL DOOUTX( 580 )                                              
CY20580 CALL DOOUTY( 580 )                                              
CX40052 CALL SBOUTX (52)                                                
CY40052 CALL SBOUTY (52)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(/' NO PRECISION TRACKS AT TIME ',F5.1,' SECONDS ',         
     +37('-')/)                                                         
  901 FORMAT(/' FILE AT TIME ',F6.1,' SECONDS HAS ',I4,                 
     +' PRECISION TRACKS ',27('-')/                                     
     +' NTR  LAT(L) [DEG]  LON(L) [DEG]  AIM(L) [DEG]  ',               
     +' T(L) [SEC] '/                                                   
     +' ---  ------------  ------------  ------------  ',               
     +'------------')                                                   
  902 FORMAT(1X,I3,4X,F10.5,4X,F10.5,4X,F10.5,4X,F10.5/                 
     +4X,4('  +-',F10.5)/)                                              
CX40052 CALL SBOUTX (52)                                                
CY40052 CALL SBOUTY (52)                                                
      END                                                               
                                                                        
      FUNCTION FNORM(ARG)                                               
      DOUBLE PRECISION ARG                                              
CX30053 CALL SBINX (53)                                                 
CY30053 CALL SBINY (53)                                                 
      VAL=ARG                                                           
      IF( VAL.LT.0.0 ) GO TO 100                                        
      VAL=SQRT(VAL)                                                     
      FNORM=VAL                                                         
CX40054 CALL SBOUTX (54)                                                
CY40054 CALL SBOUTY (54)                                                
      RETURN                                                            
  100 VAL=-SQRT(ABS(VAL))                                               
      FNORM=VAL                                                         
CX40054 CALL SBOUTX (54)                                                
CY40054 CALL SBOUTY (54)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C 									+                                                            
C     PRSCOR : PRINT TRACK AGE/SCORE SUMMARY				+                       
C									+                                                             
C      USAGE : CALL PRSCOR						+                                       
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE PRSCOR                                                 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRACK STORAGE FOR FORTRAN TRACKER					+                           
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
CX30055 CALL SBINX (55)                                                 
CY30055 CALL SBINY (55)                                                 
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
                                                                        
      IF( LSTTRK.LT.1 ) THEN                                            
CX40056 CALL SBOUTX (56)                                                
CY40056 CALL SBOUTY (56)                                                
      RETURN                                                            
      ENDIF                                                             
      WRITE(6,900) TIMDAT                                               
                                                                        
      K1=1                                                              
  100 K2=K1+1                                                           
      IF( K2.GT.LSTTRK ) GO TO 110                                      
      WRITE(6,901) K1,NMHITS(K1),SCORE1(K1),ISPREC(K1),SCORE2(K1),      
     +          K2,NMHITS(K2),SCORE1(K2),ISPREC(K2),SCORE2(K2)          
      K1=K1+2                                                           
      IF( K1.GT.LSTTRK ) GO TO 120                                      
      GO TO 100                                                         
  110 WRITE(6,901) K1,NMHITS(K1),SCORE1(K1),ISPREC(K1),SCORE2(K1)       
  120 CONTINUE                                                          
CX40056 CALL SBOUTX (56)                                                
CY40056 CALL SBOUTY (56)                                                
      RETURN                                                            
                                                                        
  900 FORMAT(/' AGE:SCORE SUMMARY AT TIME ',F6.1,' SECONDS ',35('-')/   
     +2(' NTR     LINEAR        PRECISION      ')/                      
     +2(' ---  -------------  -------------    '))                      
  901 FORMAT(2(1X,I3,2X,I2,':',G10.3,2X,I2,':',G10.3,4X))               
CX40056 CALL SBOUTX (56)                                                
CY40056 CALL SBOUTY (56)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRUTHP : PRINT ESTIMATED<->TRUTH ASSOCIATION SCORES		+            
C									+                                                             
C      USAGE : CALL TRUTHP						+                                       
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE TRUTHP                                                 
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C	THREAT/SENSOR DATA STORAGE FOR FORTRAN TRACKER 			+                   
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /THCMNB/ THPARM(4,500),THDATA(2,500),ITHSIT(500),          
     +NSITES,NFSITE(16),NFLAUN(16),SITLAT(15),SITLON(15),               
     +TIMDAT,TISTEP,LSTTHR,LSTDAT,CELSIZ,                               
     +PHSENS,MAXTHR,MAXSIT,ITROLD(500),                                 
     +IXVL(500),IZVL(500),NTRFST(500),NUSED(500),SIGMES,SIGMS2,         
     +XX1(500),ZZ1(500),XX2(500),ZZ2(500),XX3(500),ZZ3(500),            
     +NNS1(16),NNS2(16),NNS3(16)                                        
                                                                        
      DOUBLE PRECISION THPARM,THDATA,SITLAT,SITLON,TIMDAT,TISTEP,       
     +CELSIZ,PHSENS,SIGMES,SIGMS2,XX1,ZZ1,XX2,ZZ2,XX3,ZZ3               
C                                                                       
      INTEGER IVAL                                                      
                                                                        
C     THPARM(*,J) : STANDARD LAUNCH PARAMETERS FOR J-TH TARGET          
C     THDATA(*,I) : 2-DIMENSIONAL I-TH OBSERVATION                      
C     ITHSIT(I)   : SITE ID FOR I-TH OBSERVATION                        
C     NSITES	  : NUMBER OF LAUNCH SITES                                 
C     NFSITE(I)	  : FIRST BOOSTER (THPARM) PER SITE                     
C     NFLAUN(I)	  : FIRST DATUM (THDATA) PER SITE                       
C     SITLAT(I)	  : LAUNCH SITE LATITUDE (RADIANS)                      
C     SITLON(I)   : LAUNCH SITE LONGITUDE (RADIANS)                     
C     TIMDAT      : TIME OF PRESENT DATA SET                            
C     TISTEP	  : TIME STEP BETWEEN DATA SCANS                           
C     LSTTHR      : LAST THREAT IN THPARM                               
C     LSTDAT      : LAST SENSOR REPORT                                  
C     CELSIZ      : SENSOR RESOLUTION SIZE                              
C     PHSENS	  : SENSOR LONGITUDE (RADIANS)                             
C     MAXTHR	  : MAXIMUM THREAT SIZE (400, SET IN MAIN )                
C     MAXSIT      : MAXIMUM NUMBER OF SITES (10, SET IN MAIN )          
C                                                                       
C     NTRFST(I)	  : FIRST TRACK TO DATUM FROM EXTEND                    
C     NUSED(I)	  : DATA USE COUNTERS FOR EXTEND, BATCH                  
C     SIGMES	  : RMS MEASUREMENT RESOLUTION                             
C     SIGMS2	  : MEASUREMENT VARIANCE                                   
C     ITROLD(I)	  : ESTABLISHED TRACK TO DATUM FLAGS                    
C                                                                       
C     IXVL,IZVL   : PIXEL STORAGE FOR DATA GENERATION                   
C     XXJ,ZZJ	  : BATCH INITIATION DATA STORAGE                         
C                                                                       
C     NNSJ	  : FIRST HIT FROM SITE COUNTERS                             
C                                                                       
C     **** REMARK : IF THE MAXIMUM NUMBER OF THREATS (MAXTHR) OR        
C     		    SITES (MAXSIT) OR BOTH ARE CHANGED, THE REQUIRED            
C		    CHANGES IN THE DIMENSION STATEMENTS IN THIS FILE                 
C		    ARE AS FOLLOWS:                                                  
C                                                                       
C			400 -> MAXTHR                                                       
C			 10 -> MAXSIT                                                       
C			 11 -> MAXSIT+1                                                     
C                                                                       
C     ***** USERS ARE RESPONSIBLE FOR CONSISTENT MODIFICATIONS !!!      
C                                                                       
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     TRACK STORAGE FOR FORTRAN TRACKER					+                           
C									+                                                             
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      COMMON /TRAXCM/ XH1(8,1600),XH2(8,1600),PRMTRK(4,1600),           
     +COVTRK(16,1600),NMHITS(1600),ISPREC(1600),IHITS(5,1600),          
     +SCORE1(1600),SCORE2(1600),IDDSIT(1600),MAXTRK,LSTTRK              
                                                                        
      DOUBLE PRECISION XH1,XH2,PRMTRK,COVTRK,SCORE1,SCORE2              
C                                                                       
C        XH1(*,I) : FILTERED STATE VECTOR FOR I-TH TRACK                
C        XH2(*,I) : PREDICTED STATE VECTOR FOR I-TH TRACK               
C     PRMTRK(*,I) : ESTIMATED PARAMETER VECTOR FOR I-TH TRACK           
C     COVTRK(*,I) : PARAMETER COVARIANCE MATRIX FOR I-TH TRACK          
C       NMHITS(I) : NUMBER OF HITS FOR I-TH TRACK                       
C       ISPREC(I) : PRECISION FLAG (IS PRECISION IF POSITIVE)           
C      IHITS(*,I) : LATEST 5 HITS USED IN I-TH TRACK                    
C       SCORE1(I) : LINEAR FILTERING SCORE FOR I-TH TRACK               
C       SCORE2(I) : PRECISION FILTERING SCORE FOR I-TH TRACK            
C       IDDSIT(I) : SITE ID FOR I-TH TRACK                              
C          MAXTRK : MAXIMUM TRACK FILE SIZE (1200, SET IN MAIN)         
C          LSTTRK : SIZE OF PRESENT TRACK FILE                          
C                                                                       
      DOUBLE PRECISION PP(16),PINV(16),DP(4),SCORE                      
      DIMENSION IDT(4),IDD(4),SCR(4),SMIN(8),NSMIN(8)                   
      SAVE SMIN                                                         
      DATA SMIN/0.0,0.1,0.2,0.5,1.0,4.0,16.0,64.0/                      
CX30057 CALL SBINX (57)                                                 
CY30057 CALL SBINY (57)                                                 
                                                                        
      IF(LSTTRK.LT.1) THEN                                              
CX40058 CALL SBOUTX (58)                                                
CY40058 CALL SBOUTY (58)                                                
      RETURN                                                            
      ENDIF                                                             
CX10581 CALL DOINX( 581 )                                               
CY10581 CALL DOINY( 581 )                                               
      DO 50 K=1,8                                                       
   50 NSMIN(K)=0                                                        
CX20582 CALL DOOUTX( 582 )                                              
CY20582 CALL DOOUTY( 582 )                                              
      WRITE(6,900)                                                      
      N1=1                                                              
  100 N2=N1+3                                                           
      IF(N2.GT.LSTTRK) N2=LSTTRK                                        
      IF( N2.GE.N1 ) GO TO 102                                          
      WRITE(6,902)                                                      
      WRITE(4,902)                                                      
      WRITE(6,903) SMIN,NSMIN                                           
      WRITE(4,903) SMIN,NSMIN                                           
C                                                                       
      IVAL=0                                                            
      IF(NSMIN(1).NE.480) IVAL=1                                        
      IF(NSMIN(2).NE.415) IVAL=1                                        
      IF(NSMIN(3).NE.310) IVAL=1                                        
      IF(NSMIN(4).NE.107) IVAL=1                                        
      IF(NSMIN(5).NE.11 ) IVAL=1                                        
      IF(NSMIN(6).NE.0  ) IVAL=1                                        
      IF(NSMIN(7).NE.0  ) IVAL=1                                        
      IF(NSMIN(8).NE.0  ) IVAL=1                                        
C                                                                       
      IF(IVAL.EQ.0) THEN                                                
        WRITE(4,303)                                                    
303     FORMAT(//1X,'RESULTS FOR THIS RUN ARE:   VALID')                
      ELSE                                                              
        WRITE(4,304)                                                    
304     FORMAT(//1X,'RESULTS FOR THIS RUN ARE: INVALID')                
      ENDIF                                                             
CX40058 CALL SBOUTX (58)                                                
CY40058 CALL SBOUTY (58)                                                
C                                                                       
      RETURN                                                            
  102 CONTINUE                                                          
CX10583 CALL DOINX( 583 )                                               
CY10583 CALL DOINY( 583 )                                               
      DO 200 KT=N1,N2                                                   
      JIN=KT-N1+1                                                       
      SCR(JIN)=-2.0                                                     
      IF(ISPREC(KT).LT.1) GO TO 200                                     
      IDT(JIN)=KT                                                       
      IDAT=IHITS(1,KT)                                                  
      IDD(JIN)=IDAT                                                     
      DO 110 K=1,16                                                     
  110 PP(K)=COVTRK(K,KT)                                                
      CALL SINV4(PP,PINV,ISTAT)                                         
      SCR(JIN)=-1.0                                                     
      IF( ISTAT.LT.0 ) GO TO 200                                        
      DO 120 K=1,4                                                      
  120 DP(K)=PRMTRK(K,KT)-THPARM(K,IDAT)                                 
      SCORE=0.0                                                         
      DO 140 I=1,4                                                      
      DO 130 J=1,4                                                      
      K=J+4*(I-1)                                                       
  130 SCORE=SCORE+DP(I)*DP(J)*PINV(K)                                   
  140 CONTINUE                                                          
      SCR(JIN)=SCORE                                                    
      DO 150 J=1,8                                                      
      IF( SCR(JIN).GT.SMIN(J) ) NSMIN(J)=NSMIN(J)+1                     
  150 CONTINUE                                                          
  200 CONTINUE                                                          
CX20584 CALL DOOUTX( 584 )                                              
CY20584 CALL DOOUTY( 584 )                                              
      JLAST=N2-N1+1                                                     
      WRITE(6,901) (IDT(J),IDD(J),SCR(J),J=1,JLAST)                     
      N1=N2+1                                                           
      GO TO 100                                                         
                                                                        
  900 FORMAT(/' PARAMETER<->ESTIMATE SCORES ',49('-')/                  
     +1X,4('NTR NDT   SCORE     ')/1X,4('--- --- ---------   '))        
  901 FORMAT(1X,4(I3,1X,I3,1X,G9.2,3X))                                 
  902 FORMAT(/' TABLE KEY: -2=NOT PRECISION, -1=SCORE ERROR, ',         
     +'POSITIVE=ASSOCIATION SCORE'/)                                    
  903 FORMAT('      SMIN : ',8(1X,F4.1,1X)/                             
     +' N[S>SMIN] : ',8(1X,I4,1X)/)                                     
CX40058 CALL SBOUTX (58)                                                
CY40058 CALL SBOUTY (58)                                                
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     MATMLT : GENERAL MATRIX MULTIPLICATION UTILITY			+                
C									+                                                             
C      USAGE : CALL MATMLT(M1,M2,M3,L,M,N)				+                         
C	       REAL M1(),M2(),M3()					+                                      
C									+                                                             
C     COMPUTE:	M3[LXN] = M1[LXM] M2[MXN]				+                           
C		WHERE A[NXM] DENOTES A MATRIX WITH N ROWS, M COLUMNS	+               
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE MATMLT(M1,M2,M3,L,M,N)                                 
      DOUBLE PRECISION M1(L*M),M2(M*N),M3(L*N)                          
CX30059 CALL SBINX (59)                                                 
CY30059 CALL SBINY (59)                                                 
CX10585 CALL DOINX( 585 )                                               
CY10585 CALL DOINY( 585 )                                               
                                                                        
      DO 120 JL=1,L                                                     
      DO 110 JN=1,N                                                     
      J=JL+L*(JN-1)                                                     
      M3(J)=0.0                                                         
      DO 100 JM=1,M                                                     
      K1=JL+L*(JM-1)                                                    
      K2=JM+M*(JN-1)                                                    
  100 M3(J)=M3(J)+M1(K1)*M2(K2)                                         
  110 CONTINUE                                                          
  120 CONTINUE                                                          
CX20586 CALL DOOUTX( 586 )                                              
CY20586 CALL DOOUTY( 586 )                                              
CX40060 CALL SBOUTX (60)                                                
CY40060 CALL SBOUTY (60)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     MATADD : MATRIX LINEAR COMBINATION				+                           
C									+                                                             
C      USAGE : CALL MATADD(M1,M2,M3,M,N,S1,S2)				+                     
C              REAL M1(),M2(),M3()					+                                
C									+                                                             
C     COMPUTE: M3[MXN] = S1 M1[MXN] + S2 M2[MXN]			+                    
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE MATADD(M1,M2,M3,M,N,S1,S2)                             
      DOUBLE PRECISION M1(M*N),M2(M*N),M3(M*N),S1,S2                    
CX30061 CALL SBINX (61)                                                 
CY30061 CALL SBINY (61)                                                 
      IMAX=M*N                                                          
CX10587 CALL DOINX( 587 )                                               
CY10587 CALL DOINY( 587 )                                               
      DO 100 I=1,IMAX                                                   
  100 M3(I)=S1*M1(I)+S2*M2(I)                                           
CX20588 CALL DOOUTX( 588 )                                              
CY20588 CALL DOOUTY( 588 )                                              
CX40062 CALL SBOUTX (62)                                                
CY40062 CALL SBOUTY (62)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     MATTRP : MATRIX TRANSPOSITION					+                               
C									+                                                             
C      USAGE : CALL MATTRP(MM,MT,L,M)					+                             
C	       REAL MM(),MT()						+                                          
C									+                                                             
C     COMPUTE: MT[MXL] = TRANSPOSE( MM[LXM] )				+                      
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE MATTRP(MM,MT,L,M)                                      
      DOUBLE PRECISION MM(L*M),MT(M*L)                                  
CX30063 CALL SBINX (63)                                                 
CY30063 CALL SBINY (63)                                                 
CX10589 CALL DOINX( 589 )                                               
CY10589 CALL DOINY( 589 )                                               
      DO 110 I=1,L                                                      
      DO 100 J=1,M                                                      
      I1=I+L*(J-1)                                                      
      I2=J+M*(I-1)                                                      
      MT(I2)=MM(I1)                                                     
  100 CONTINUE                                                          
  110 CONTINUE                                                          
CX20590 CALL DOOUTX( 590 )                                              
CY20590 CALL DOOUTY( 590 )                                              
CX40064 CALL SBOUTX (64)                                                
CY40064 CALL SBOUTY (64)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     MATML4 : (FAST) 4X4 MATRIX MULTIPLICATION				+                    
C									+                                                             
C      USAGE : CALL MATML4(A,B,C)					+                                 
C									+                                                             
C     COMPUTE:  C[4X4] = A[4X4]*B[4X4]					+                            
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE MATML4(A,B,C)                                          
      DOUBLE PRECISION A(16),B(16),C(16)                                
CX30065 CALL SBINX (65)                                                 
CY30065 CALL SBINY (65)                                                 
      C(1) = A(1)*B(1) + A(5)*B(2) + A(9)*B(3) +A(13)*B(4)              
      C(2) = A(2)*B(1) + A(6)*B(2) +A(10)*B(3) +A(14)*B(4)              
      C(3) = A(3)*B(1) + A(7)*B(2) +A(11)*B(3) +A(15)*B(4)              
      C(4) = A(4)*B(1) + A(8)*B(2) +A(12)*B(3) +A(16)*B(4)              
      C(5) = A(1)*B(5) + A(5)*B(6) + A(9)*B(7) +A(13)*B(8)              
      C(6) = A(2)*B(5) + A(6)*B(6) +A(10)*B(7) +A(14)*B(8)              
      C(7) = A(3)*B(5) + A(7)*B(6) +A(11)*B(7) +A(15)*B(8)              
      C(8) = A(4)*B(5) + A(8)*B(6) +A(12)*B(7) +A(16)*B(8)              
      C(9) = A(1)*B(9) + A(5)*B(10)+ A(9)*B(11)+A(13)*B(12)             
      C(10)= A(2)*B(9) + A(6)*B(10)+A(10)*B(11)+A(14)*B(12)             
      C(11)= A(3)*B(9) + A(7)*B(10)+A(11)*B(11)+A(15)*B(12)             
      C(12)= A(4)*B(9) + A(8)*B(10)+A(12)*B(11)+A(16)*B(12)             
      C(13)= A(1)*B(13)+ A(5)*B(14)+ A(9)*B(15)+A(13)*B(16)             
      C(14)= A(2)*B(13)+ A(6)*B(14)+A(10)*B(15)+A(14)*B(16)             
      C(15)= A(3)*B(13)+ A(7)*B(14)+A(11)*B(15)+A(15)*B(16)             
      C(16)= A(4)*B(13)+ A(8)*B(14)+A(12)*B(15)+A(16)*B(16)             
CX40066 CALL SBOUTX (66)                                                
CY40066 CALL SBOUTY (66)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C     MATPRT : PRINT A MATRIX						+                                    
C									+                                                             
C      USAGE : CALL MATPRT(A,M,N,LABEL)					+                           
C          A : THE MATRIX						+                                        
C          M : NUMBER OF ROWS IN MATRIX					+                           
C          N : NUMBER OF COLUMNS IN MATRIX				+                         
C      LABEL : HOLLERITH LABEL (CHARACTER*6 LABEL(2))			+               
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE MATPRT(A,M,N,LABEL)                                    
      DOUBLE PRECISION A(M,N)                                           
      CHARACTER*12 LABEL(2)                                             
  900 FORMAT(//' MATRIX : ',2A6,2X,20('-')/)                            
  901 FORMAT(8(2X,G12.5))                                               
  902 FORMAT(1X)                                                        
CX30067 CALL SBINX (67)                                                 
CY30067 CALL SBINY (67)                                                 
      WRITE(6,900) LABEL                                                
      N1=1                                                              
      N2=N                                                              
      IF(N2.GT.8) N2=8                                                  
  100 CONTINUE                                                          
CX10591 CALL DOINX( 591 )                                               
CY10591 CALL DOINY( 591 )                                               
      DO 110 K=1,M                                                      
      WRITE(6,901) (A(K,J),J=N1,N2)                                     
  110 CONTINUE                                                          
CX20592 CALL DOOUTX( 592 )                                              
CY20592 CALL DOOUTY( 592 )                                              
      WRITE(6,902)                                                      
      IF(N2.GE.N) THEN                                                  
CX40068 CALL SBOUTX (68)                                                
CY40068 CALL SBOUTY (68)                                                
      RETURN                                                            
      ENDIF                                                             
      N1=N2+1                                                           
      N2=N2+8                                                           
      IF(N2.GT.N) N2=N                                                  
      GO TO 100                                                         
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C       INV4 : GENERAL 4X4 MATRIX INVERSION				+                        
C									+                                                             
C      USAGE : CALL INV4(A,AIN,ISTAT)					+                             
C          A : INITIAL 4X4 MATRIX					+                                 
C        AIN : INVERTED MATRIX						+                                   
C      ISTAT : STATUS, NEGATIVE IF COMPUTATIONALLY SINGULAR 		+         
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE INV4(A,AIN,ISTAT)                                      
      DOUBLE PRECISION A(16),AIN(16)                                    
      DOUBLE PRECISION DET,ZERODT,M12,M13,M14,M23,M24,M34               
      PARAMETER (ZERODT = 1.0E-34)                                      
CX30069 CALL SBINX (69)                                                 
CY30069 CALL SBINY (69)                                                 
                                                                        
      M12= A(3)*A(8) - A(4)*A(7)                                        
      M13= A(3)*A(12)- A(4)*A(11)                                       
      M14= A(3)*A(16)- A(4)*A(15)                                       
      M23= A(7)*A(12)- A(8)*A(11)                                       
      M24= A(7)*A(16)- A(8)*A(15)                                       
      M34=A(11)*A(16)-A(12)*A(15)                                       
                                                                        
      AIN(1) = A(6)*M34-A(10)*M24+A(14)*M23                             
      AIN(2) =A(10)*M14- A(2)*M34-A(14)*M13                             
      AIN(3) = A(2)*M24- A(6)*M14+A(14)*M12                             
      AIN(4) = A(6)*M13- A(2)*M23-A(10)*M12                             
                                                                        
      AIN(5) =-A(5)*M34+ A(9)*M24-A(13)*M23                             
      AIN(6) =-A(9)*M14+ A(1)*M34+A(13)*M13                             
      AIN(7) =-A(1)*M24+ A(5)*M14-A(13)*M12                             
      AIN(8) =-A(5)*M13+ A(1)*M23+ A(9)*M12                             
                                                                        
      M12= A(1)*A(6) - A(2)*A(5)                                        
      M13= A(1)*A(10)- A(2)*A(9)                                        
      M14= A(1)*A(14)- A(2)*A(13)                                       
      M23= A(5)*A(10)- A(6)*A(9)                                        
      M24= A(5)*A(14)- A(6)*A(13)                                       
      M34= A(9)*A(14)-A(10)*A(13)                                       
                                                                        
      AIN(9) = A(8)*M34-A(12)*M24+A(16)*M23                             
      AIN(10)=A(12)*M14- A(4)*M34-A(16)*M13                             
      AIN(11)= A(4)*M24- A(8)*M14+A(16)*M12                             
      AIN(12)= A(8)*M13- A(4)*M23-A(12)*M12                             
                                                                        
      AIN(13)= -A(7)*M34+A(11)*M24-A(15)*M23                            
      AIN(14)=-A(11)*M14+ A(3)*M34+A(15)*M13                            
      AIN(15)= -A(3)*M24+ A(7)*M14-A(15)*M12                            
      AIN(16)= -A(7)*M13+ A(3)*M23+A(11)*M12                            
                                                                        
      DET = A(1)*AIN(1)+A(5)*AIN(2)+A(9)*AIN(3)+A(13)*AIN(4)            
      ISTAT=-1                                                          
      IF(ABS(DET).LT.ZERODT) THEN                                       
CX40070 CALL SBOUTX (70)                                                
CY40070 CALL SBOUTY (70)                                                
      RETURN                                                            
      ENDIF                                                             
      ISTAT=1                                                           
CX10593 CALL DOINX( 593 )                                               
CY10593 CALL DOINY( 593 )                                               
      DO 100 K=1,16                                                     
  100 AIN(K)=AIN(K)/DET                                                 
CX20594 CALL DOOUTX( 594 )                                              
CY20594 CALL DOOUTY( 594 )                                              
CX40070 CALL SBOUTX (70)                                                
CY40070 CALL SBOUTY (70)                                                
      RETURN                                                            
      END                                                               
                                                                        
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C									+                                                             
C      SINV4 : SYMMETRIC 4X4 MATRIX INVERSION				+                      
C									+                                                             
C      USAGE : CALL SINV4(A,AIN,ISTAT)					+                            
C          A : INITIAL MATRIX (ASSUMED SYMMETRIC)			+                   
C        AIN : THE INVERTED MATRIX					+                                
C      ISTAT : STATUS, NEGATIVE IF MATRIX IS COMPUTATIONALLY SINGULAR	+ 
C									+                                                             
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                                                                        
      SUBROUTINE SINV4(A,AIN,ISTAT)                                     
      DOUBLE PRECISION A(16),AIN(16)                                    
      DOUBLE PRECISION ZERODT,DET,M12,M13,M14,M23,M24,M34               
      PARAMETER (ZERODT = 1.0E-34)                                      
CX30071 CALL SBINX (71)                                                 
CY30071 CALL SBINY (71)                                                 
                                                                        
      M12= A(3)*A(8) - A(4)*A(7)                                        
      M13= A(3)*A(12)- A(4)*A(11)                                       
      M14= A(3)*A(16)- A(4)*A(15)                                       
      M23= A(7)*A(12)- A(8)*A(11)                                       
      M24= A(7)*A(16)- A(8)*A(15)                                       
      M34=A(11)*A(16)-A(12)*A(15)                                       
                                                                        
      AIN(1) = A(6)*M34-A(10)*M24+A(14)*M23                             
      AIN(2) =A(10)*M14- A(2)*M34-A(14)*M13                             
      AIN(3) = A(2)*M24- A(6)*M14+A(14)*M12                             
      AIN(4) = A(6)*M13- A(2)*M23-A(10)*M12                             
                                                                        
      AIN(5) = AIN(2)                                                   
      AIN(6) =-A(9)*M14+ A(1)*M34+A(13)*M13                             
      AIN(7) =-A(1)*M24+ A(5)*M14-A(13)*M12                             
      AIN(8) =-A(5)*M13+ A(1)*M23+ A(9)*M12                             
                                                                        
      M12= A(1)*A(6) - A(2)*A(5)                                        
      M13= A(1)*A(10)- A(2)*A(9)                                        
      M14= A(1)*A(14)- A(2)*A(13)                                       
      M23= A(5)*A(10)- A(6)*A(9)                                        
      M24= A(5)*A(14)- A(6)*A(13)                                       
      M34= A(9)*A(14)-A(10)*A(13)                                       
                                                                        
      AIN(9) = AIN(3)                                                   
      AIN(10) = AIN(7)                                                  
      AIN(11)= A(4)*M24- A(8)*M14+A(16)*M12                             
      AIN(12)= A(8)*M13- A(4)*M23-A(12)*M12                             
                                                                        
      AIN(13) = AIN(4)                                                  
      AIN(14) = AIN(8)                                                  
      AIN(15) = AIN(12)                                                 
      AIN(16)= -A(7)*M13+ A(3)*M23+A(11)*M12                            
                                                                        
      DET = A(1)*AIN(1)+A(5)*AIN(2)+A(9)*AIN(3)+A(13)*AIN(4)            
      ISTAT=-1                                                          
      IF(ABS(DET).LT.ZERODT) THEN                                       
CX40072 CALL SBOUTX (72)                                                
CY40072 CALL SBOUTY (72)                                                
      RETURN                                                            
      ENDIF                                                             
      ISTAT=1                                                           
CX10595 CALL DOINX( 595 )                                               
CY10595 CALL DOINY( 595 )                                               
      DO 100 K=1,16                                                     
  100 AIN(K)=AIN(K)/DET                                                 
CX20596 CALL DOOUTX( 596 )                                              
CY20596 CALL DOOUTY( 596 )                                              
CX40072 CALL SBOUTX (72)                                                
CY40072 CALL SBOUTY (72)                                                
      RETURN                                                            
      END                                                               
