C==== MAIN PROGRAM FOR PHOSEP========
      INTEGER NES,NE,S,NW1,
     *  K,KZ(4),F,F1,FZ(4),M,M1,MZ(4),
     *  IZ(18),IT(4),IL(4),LV(4),EXPI,
     *  M3(10),M4(10),KK1(18),NNL(18),
     *  LLK(4),SSK(4),SPI(18),IAL(20),
     *  I3(4),LMM(4),IMIN(4)
      REAL*8 LAML1(4),
     *  CC(25),QQ(25),DD1(25),DD2(25),RP(25),RM(25),
     *  ARB(900),ARB1(900),ARB2(200),
     *  LAMM(25),LAMF(25),LAMK(43),LAM(18),
     *  ME4(25),ME5(25),ME6(25),ME7(25),
C    *  ME8(25),ME9(25),ME10(25),
     *  RE(25),IM(25),RED(25),IMD(25),
     *  ME(625),ME1(625),ME2(625),ME3(625),
     *  RRR(625),RRM(625),SR(2500),
     *  MME1(26000),MME2(26000),MME4(900),MME5(900),
     *  D3(100),D4(100),D5(100),D6(100),XMAXM(4),XM0(4),DELXM(4),
     *  LAMKK(4),LAMI1(18),FME(50),FMEA(50),
     *  CLS(4),B1(4),AL(4),BL(4),OMEGA(250),
     *  MA(25000),
     *  R1(1015),R2(1015),R3(1015),R4(1015),R5(1015),
     *  R6(1015),R7(1015),R8(140000),R9(1015)
C       REAL*8 R1[ALLOCATABLE](:), R2[ALLOCATABLE](:),
C     * R3[ALLOCATABLE](:),R4[ALLOCATABLE](:),
C     * R5[ALLOCATABLE](:),R6[ALLOCATABLE](:),
C     * R7[ALLOCATABLE](:),R8[ALLOCATABLE](:),
C     * R9[ALLOCATABLE](:),
C     * MME1[ALLOCATABLE](:),MME2[ALLOCATABLE](:),
C     * MME4[ALLOCATABLE](:),MME5[ALLOCATABLE](:),
C     * ME[ALLOCATABLE](:),ME1[ALLOCATABLE](:),
C     * MA[ALLOCATABLE](:),ME2[ALLOCATABLE](:),
C    * ME3[ALLOCATABLE](:),RRR[ALLOCATABLE](:),
C    * RRM[ALLOCATABLE](:),SR[ALLOCATABLE](:)

      NAMELIST/PHOS/NES,NC,K,KZ,F,F1,FZ,M,M1,MZ,
     *      IT,IL,LV,EXPI,LAML1,NE,S,NW1
C      NNN=1015
C      MMM=900000
C      KKK=50000
C      III=30000
C      JJJ=2500
C      ALLOCATE(R1(NNN),STAT=IE)
C      ALLOCATE(R2(NNN),STAT=IE)
C      ALLOCATE(R3(NNN),STAT=IE)
C      ALLOCATE(R4(NNN),STAT=IE)
C      ALLOCATE(R5(NNN),STAT=IE)
C      ALLOCATE(R6(NNN),STAT=IE)
C      ALLOCATE(R7(NNN),STAT=IE)
C      ALLOCATE(R8(MMM),STAT=IE)
C      ALLOCATE(R9(NNN),STAT=IE)
C      ALLOCATE(MME1(KKK),STAT=IE)
C      ALLOCATE(MME2(KKK),STAT=IE)
C      ALLOCATE(MME4(III),STAT=IE)
C      ALLOCATE(MME5(III),STAT=IE)
C      ALLOCATE(ME(NNN),STAT=IE)
C      ALLOCATE(ME1(NNN),STAT=IE)
C      ALLOCATE(ME2(NNN),STAT=IE)
C      ALLOCATE(ME3(NNN),STAT=IE)
C      ALLOCATE(RRR(NNN),STAT=IE)
C      ALLOCATE(RRM(NNN),STAT=IE)
C      ALLOCATE(SR(JJJ),STAT=IE)
C      ALLOCATE(MA(JJJ),STAT=IE)

      OPEN(5,FILE='SYS$INPU',STATUS='OLD')
      READ(5,PHOS)
      OPEN(6,FILE='SYS$OUTP',STATUS='NEW')
      OPEN(9,FILE='OLD$DB1',STATUS='OLD',FORM='UNFORMATTED')
      OPEN(11,FILE='OLD$DB2',STATUS='OLD',FORM='UNFORMATTED')
      OPEN(12,FILE='OLD$DB3',STATUS='OLD',FORM='UNFORMATTED')
      OPEN(13,FILE='OLD$DB4',STATUS='OLD',FORM='UNFORMATTED')
      IF((NES.GT.3).OR.(NE.GT.1000).OR.
     * (NC.GT.3).OR.
     *(S.GT.18).OR.(NW1.GT.25)) WRITE(6,10)
 10   FORMAT('CHECK ARRAYS" DIMENSIONS')
C     ============================================
      CALL  PHOSEP(NES,NC,IZ,K,KZ,F,F1,FZ,M,M1,MZ,
     *       IT,IL,LV,EXPI,LAML1,NE,S,NW1,
     *       NNL,M3,M4,LLI,LAMM,LAMF,LAMK,LAM,ME,
     *       ME1,ME2,ME3,ME4,ME5,ME6,ME7,RP,RM,
C    *       ME8,ME9,ME10,
     *       RE,IM,RED,IMD,
     *       MME1,MME2,MME4,MME5,
     *       KK1,RRR,RRM,SR,
     *       CC,QQ,DD1,DD2,ARB,ARB1,ARB2,
     *       LLK,SSK,
     *       I3,LMM,CLS,B1,IMIN,
     *       D3,D4,D5,D6,XMAXM,XM0,DELXM,
     *       LAMKK,LAMI1,FME,FMEA,
     *       AL,BL,MA,SPI,IAL,OMEGA,
     *       R1,R2,R3,R4,R5,R6,R7,R9,R8)
C      DEALLOCATE(R1,STAT=IE)
C      DEALLOCATE(R2,STAT=IE)
C      DEALLOCATE(R3,STAT=IE)
C      DEALLOCATE(R4,STAT=IE)
C      DEALLOCATE(R5,STAT=IE)
C      DEALLOCATE(R6,STAT=IE)
C      DEALLOCATE(R7,STAT=IE)
C      DEALLOCATE(R8,STAT=IE)
C      DEALLOCATE(R9,STAT=IE)
C      DEALLOCATE(MME1,STAT=IE)
C      DEALLOCATE(MME2,STAT=IE)
C      DEALLOCATE(MME4,STAT=IE)
C      DEALLOCATE(MME5,STAT=IE)
C      DEALLOCATE(ME,STAT=IE)
C      DEALLOCATE(ME1,STAT=IE)
C      DEALLOCATE(ME2,STAT=IE)
C      DEALLOCATE(ME3,STAT=IE)
C      DEALLOCATE(RRR,STAT=IE)
C      DEALLOCATE(RRM,STAT=IE)
C      DEALLOCATE(SR,STAT=IE)
C      DEALLOCATE(MA,STAT=IE)

      STOP
      END
