      PROGRAM mlmsis92
      IMPLICIT none

      INTEGER DATE,M,TS,MASS,APMI,I
      REAL ALT,LONG,LAT,STL,D,T,AP,F107A,F107,UT,DT,APM,PHIL
      DIMENSION D(1:8),T(1:2),APM(1:8)                      
      
      OPEN(3,'Data.txt',STATUS='OLD') 
      OPEN(4,'Res.txt',STATUS='NEW')
             
      MASS=48
      I=1

      READ(3,*)DATE,TS,ALT,F107A,F107
      READ(3,*)APM

      DT=24/TS
                                                              
      DO WHILE (I.EQ.1)

       READ(3,*,END=200)LONG,LAT
  
       DO M=1,TS

        UT=DT*(M-1)
        
        STL=UT+LONG/15
        IF(STL.GE.24)THEN
         STL=STL-24
        ELSE IF(STL.LT.0)THEN
         STL=STL+24
        END IF 

        IF(UT.LT.3)THEN
         APMI=1
        ELSE IF(UT.LT.6)THEN
         APMI=2
        ELSE IF(UT.LT.9)THEN
         APMI=3
        ELSE IF(UT.LT.12)THEN
         APMI=4
        ELSE IF(UT.LT.15)THEN
         APMI=5
        ELSE IF(UT.LT.18)THEN
         APMI=6
        ELSE IF(UT.LT.21)THEN
         APMI=7
        ELSE 
         APMI=8
        END IF

        AP=APM(APMI)
        UT=3600*UT

        CALL GTD6(DATE,UT,ALT,LAT,LONG,STL,F107A,F107,AP,MASS,D,T,PHIL)
        WRITE(4,*)T(2),T(1),PHIL,D(2),D(7)

       END DO

      END DO

200   CONTINUE      

      CLOSE(3)
      CLOSE(4)

      END
