        PROGRAM FP

********************************************************************* 
*                                                                   *
*       This program, named as FP including subroutines             *
*       init(fp0.3a.f), ellipse(fp0.3b.f), hyperbolic(fp0.3c.f),    *
*       output(fp0.3d.f), and final(fp0.3e.f) calculates the        *
*       spatial and temporal evolution of ionospheric F-region      *
*       perturbations generated by gravity waves. This program also *
*       requires an MSIS-90 profile (msis.dat) and a common         *
*       variable list (var.inc).                                    *
*                                                                   *
*       Version 0.4 - Last Modified 5/05/04                         *
*                                                                   *
*********************************************************************  

        INCLUDE "fpvar.inc"

        CALL INIT
        DO WHILE (T.LE.TMAX)
           DO 10, I=ST,NZ
              DO 10, J=ST,NX
                 Z=DZ*REAL(I-1)-Z0/2.
                 X=DX*REAL(J-1)-X0/2.
                 U1Z(I,J)=U1Z0H(I)*COS(XK*X+ZKR(I)*Z-W*T)
 10              U1X(I,J)=U1X0H(I)*COS(XK*X+ZKR(I)*Z-W*T)
           CALL HYPERBOLIC
           CALL ELLIPSE
           IF (EPC.GT.100.0) THEN
              WRITE(6,*) 'Divergent Calculation - Program Aborted!'
              STOP
              END IF

*********************************************************************
*                                                                   *
*       Outputs initial data as well as every tenth iteration.      *
*                                                                   *
*********************************************************************

           IF (II.EQ.10) THEN
              CALL OUTPUT      
             ELSE
              II=II+1
              END IF

*********************************************************************
*                                                                   *
*         Writes loop values to a troubleshooting file              *
*         named "trouble.dat".                                      *
*                                                                   *
*********************************************************************

           OPEN (STATUS='OLD',ACCESS='APPEND',UNIT=8,FILE='trouble.dat')
           T=T+DT
	   WRITE(8,*)'epc=',EPC
           WRITE(8,*)'dt=',DT
           WRITE(8,*)'t=',T
           CLOSE(8)
           END DO
	CALL FINAL
        STOP
        END

**********************************************************************
*                                                                    *
*       These are the required files for the 5 subroutines           *
*                                                                    *
*       a - INIT                                                     *
*       b - ELLIPSE                                                  *
*       c - HYPERBOLIC                                               *
*       d - OUTPUT                                                   *
*       e - FINAL                                                    *
*                                                                    *
**********************************************************************

        INCLUDE "fp0.4a.f"
        INCLUDE "fp0.4b.f"
        INCLUDE "fp0.4c.f"
        INCLUDE "fp0.4d.f"
        INCLUDE "fp0.4e.f"

