**==aa0001.spg  processed by SPAG 4.50J  at 14:50 on 30 Jun 1995
      IMPLICIT NONE
C*** Start of declarations inserted by SPAG
      REAL ABIn , ABUnd , ABUnj , be , BIN , BINmin , BINsyz , BLN , 
     &     BLNmin , BLNsyz , CION , cionh , CNC , CONce , crec , dene , 
     &     DNE , GNDrec , HENeut , HEPlus
      INTEGER i , icx , idens , iphot , iprint , jprint , k , n , NBIn , 
     &        NBLn , NJ , no , num
      REAL PCOol , PHOT , PM , POT , POU , POWer , PTOt , RE , RF , 
     &     rf1 , RHY , t , TAU , TAUhe , TPLus , TU
C*** End of declarations inserted by SPAG
C  CALLS XSPCT FOR VARIOUS PARAMETERS:
 
      CHARACTER*1 irep , iab
 
 
      COMMON /BLN   / BLN(1000) , BLNmin , BLNsyz , NBLn
      COMMON /PARAMS/ NJ(12) , ABUnj(12) , ABUnd , BINmin , BINsyz , 
     &                NBIn
      COMMON /RESULT/ CONce(30) , GNDrec(30) , POWer(220) , RHY , 
     &                HENeut , HEPlus , DNE , PCOol , POU , POT , RE , 
     &                TU , PM(4)
      COMMON /PT    / RF(500) , TAU(150) , TAUhe(150) , TPLus(150)
      COMMON /COM   / CNC(12,30) , PTOt(12,220) , ABIn(1000) , BIN(1000)
 
      DATA ABUnj/10.93 , 8.52 , 7.96 , 8.82 , 7.92 , 7.42 , 7.52 , 7.2 , 
     &     6.9 , 6.3 , 7.6 , 6.3/
      DATA RF/500*1.0/
 
      OPEN (UNIT=1,FILE='file1.dat')
      OPEN (UNIT=2,FILE='atomic.dat')
      OPEN (UNIT=3,FILE='file2.dat')
      OPEN (UNIT=7,FILE='answers.dat')
 
      PRINT * , 
     &'HELLO.  THIS PROGRAM COMPUTES EQUILIBRIUM OPTICALLY THIN X-RAY AN
     &D EUV EMISSION SPECTRA.  ENTER NBIN, BINMIN, BINSYZ.'
      READ * , NBIn , BINmin , BINsyz
      PRINT * , ' WAVELENGTH BINS MAYBE? NBLN,BLNMIN,BLNSYZ'
      READ * , NBLn , BLNmin , BLNsyz
      PRINT * , 'NUM, IPRINT, JPRINT, IPHOT, IDENS, ICX?'
      READ * , num , iprint , jprint , iphot , idens , icx
 
      CALL ATREAD(num)
 
      IF ( iphot.NE.0 ) THEN
         PRINT * , 'RF1?'
         READ * , rf1
         CALL RADRD(1)
         DO 50 n = 1 , NBIn
            ABIn(n) = rf1*ABIn(n)
 50      CONTINUE
      ENDIF
 
 
 100  PRINT * , 'DO YOU WISH TO MODIFY ABUNDANCES?'
      READ (5,99001) iab
      IF ( iab.EQ.'Y' .OR. iab.EQ.'y' ) THEN
 150     PRINT * , 'NO, ABUND?'
         READ (5,*) no , ABUnd
C
         ABUnj(no) = ABUnd
C
         PRINT * , ' ANOTHER ABUNDANCE MODIFICATION?'
         READ (5,99001) iab
         IF ( iab.EQ.'Y' .OR. iab.EQ.'y' ) GOTO 150
      ENDIF
      PRINT * , 'LOG T?'
      READ (5,*) t
      t = 10.**t
      PRINT * , ' LOG DENE?'
      READ (5,*) dene
      dene = 10.**dene
C COMPUTE RATIO OF IONIZED TO NEUTRAL HYDROGEN
      cionh = CION(1,1,13.6,t)
      IF ( iphot.NE.0 ) cionh = cionh + PHOT(1,1,13.6,t,dene)/dene
      be = 157890./t
      crec = 2.06E-11*(.4288+.5*ALOG(be)+.469*be**(-.33333))/SQRT(t)
      RHY = cionh/crec
C
C
      PRINT 99002 , NBLn
      DO 200 i = 1 , NBIn
         BIN(i) = 0.
 200  CONTINUE
      CALL FELINE(t,dene,num,iprint,jprint,0,iphot,idens,icx)
      IF ( NBIn.NE.0 ) THEN
         WRITE (1,99003) t , BINmin , BINsyz , ABUnj
         WRITE (1,99004) (BIN(k),k=1,NBIn)
         PRINT 99002 , NBLn
         IF ( NBLn.NE.0 ) THEN
            PRINT 99002 , NBLn
            WRITE (3,99003) t , BLNmin , BLNsyz , ABUnj
            WRITE (3,99004) (BLN(k),k=1,NBLn)
         ENDIF
      ENDIF
      PRINT * , ' ANOTHER SET OF PARAMETERS?'
      READ (5,99001) irep
      IF ( irep.EQ.'Y' .OR. irep.EQ.'y' ) GOTO 100
      STOP
99001 FORMAT (A1)
99002 FORMAT ('  NBLN = ',I5)
99003 FORMAT (' TEMPERATURE=',E10.2,
     &        ' BINMIN,                             BINSYZ=',2F7.1,
     &        ' ABUNJ',12F6.2)
99004 FORMAT (10E12.3)
      END
