C
C PURPOSE: COMPUTE INELASTIC MULTIPOLAR COLLISIONAL RATE
C
C INPUTS:
C       IJ    UPPER LEVEL INDEX
C       IJ1   LOWER LEVEL INDEX
C       K     MULTIPOLAR INDEX
C OUTPUTS:
C       GAMMAI
C COMMON:
C       CATOM CLU
C RESTRICTIONS:  THE TOTAL COLLISIONAL RATES C(I,J) ARE ASSUMED
C       TO BE THE RESULT OF 1 MULTIPOLE COMPONENT.  THIS MAY NOT BE 
C       CONSISTENT WITH THE INPUT DATA. SEE THE README FILE WITH THIS PROGRAM. 
C
C COMMENTS: OCTOBER 6, 1999, P. JUDGE
C 
	FUNCTION GAMMAI(IJ,IJ1,K)
	INCLUDE 'PREC'
	INCLUDE 'PARAM'
	INCLUDE 'CSE'
	INCLUDE 'CLU'
	INCLUDE 'CATMOS'
	INCLUDE 'CATOM'
	INCLUDE 'CINPUT'
	INCLUDE 'CINTS'
	DATA ICALL /0/
	SAVE ICALL
	GAMMAI=ZERO
C	CALL STOP('MUST CHECK CAREFULLY GAMMAI AND GAMMAS')
	IF(ICOLL .EQ. 0 .OR. IJ1.GE.IJ) RETURN
	IF(ICALL.EQ.0) THEN 
	   WRITE (LJOBLO,80)
 80	   FORMAT('GAMMAI AND GAMMAS:'/
     *     'E1 AND E2 TRANSITIONS, NO EXCHANGE OR STRONG COUPLING'/
     *     'OTHERS, STRONG COUPLING IS ASSUMED')
	   ICALL=ICALL+1
	ENDIF
C
	IF(ITTYPE(IJ1,IJ) .EQ. 1 .AND. K .EQ. 1) GAMMAI=C(IJ1,IJ)
	IF(ITTYPE(IJ1,IJ) .EQ. 2 .AND. K .EQ. 2) GAMMAI=C(IJ1,IJ)
C
C  CMM FORMALISM
C
C THIS IS THE EQUATION  AFTER EQ (A4.2) OF LANDI'S BOOK, FOR THE DIAGONAL CASE
C (N=N', N''=N''')
C
	AA=AJ(IJ) 
	AA1=AJ(IJ1)
	FK=FLOAT(K)
C
C HERE WE ASSUME FOR SPIN-CHANGING AND STRONG COUPLING CASES
C THAT C(IJ1,IJ,N1,N) = C(IJ1,IJ)/(2*IJ1+1)
C THIS IS FLAGGED FOR LEVELS IJ1 AND IJ WHEN ITTYPE(IJ1,IJ) < ZERO
C
	CASSUME=ZERO
	IF(ITTYPE(IJ1,IJ) .LE. 0 .AND. ICOLL .NE. 2) 
     *    CASSUME=C(IJ1,IJ)/(TWO*AA1+ONE)
C
	DO AN=-AA,AA
	   DO AN1=-AA1,AA1
	      DO P=-FK,FK
		 N=INT(AN)
		 N1=INT(AN1)
		 F3=FUN3J(AA,AA1,FK,-AN,AN1,P)
		 GAMMAI=GAMMAI + (CMM(IJ1,IJ,N1,N)+CASSUME) *F3*F3
     *                 * (TWO*FK+ONE)/(TWO*AA1+ONE)
	      ENDDO
	   ENDDO
	ENDDO
	IF(IDEBUG .NE. 0 .AND. GAMMAI .NE. 0.) THEN 
           WRITE(LOUT,*)
     *     'GAMMAI IJ,IJ1, K ',GAMMAI, IJ, IJ1, K
	   WRITE(LOUT,*)'ITTYPE  CASSUME ',ITTYPE(IJ1,IJ),CASSUME
	ENDIF
C	WRITE(*,*) IJ,IJ1,GAMMAI
C	WRITE(*,*) ITTYPE(IJ1,IJ),K
	RETURN
	END

