def CONTROLE(KGAS,LGAS,X,Y,Z,T,EINIT,ISHELL):
	# IMPLICIT #real*8(A-H,O-Z)
	# IMPLICIT #integer*8(I-N)
	#CHARACTER*6 SCR(17),SCR1(17)
	# COMMON/COMP/LCMP,LCFLG,LRAY,LRFLG,LPAP,LPFLG,LBRM,LBFLG,LPEFLG
	# COMMON/GENCAS/ELEV[17,79],NSDEG(17),AA[17],BB[17],SCR,SCR1
	# COMMON/MIXC/PRSH(6,3,17,17),ESH(6,3,17),AUG(6,3,17,17,17),RAD[6,3,17,17],PRSHBT(6,3,17),IZ[6,3],INIOCC(6,3,17),ISHLMX(6,3),AMZ[6,3]
	# COMMON/UPD/NOCC(6,3,17),AUGR(6,3,17,17,17),RADR(6,3,17,17)
	# COMMON/CALCASE/IONSUM(10),IFLSUM(10),ESTORE(10,28),EPHOTON(10,28),DRXE(10,28),DRYE(10,28),DRZE(10,28),DRX(10,28),DRY(10,28),DRZ[10,28]
	# COMMON/CALCAS1E/IONSUM1(10),IFLSUM1(10),ESTOR1(10,28),EPHOTG1(10,28),DRXE1(10,28),DRYE1(10,28),DRZE1(10,28),DRX1(10,28),DRY1(10,28),DRZ1(10,28)
	# COMMON/CALCAS2E/IONSUM2(10),IFLSUM2(10),ESTOR2(10,28),EPHOTG2(10,28),DRXE2(10,28),DRYE2(10,28),DRZE2(10,28),DRX2(10,28),DRY2(10,28),DRZ2(10,28)
	# COMMON/CALCAS3E/IONSUM3(10),IFLSUM3(10),ESTOR3(10,28),EPHOTG3(10,28),DRXE3(10,28),DRYE3(10,28),DRZE3(10,28),DRX3(10,28),DRY3(10,28),DRZ3(10,28)
	# COMMON/CALCAS4E/IONSUM4(10),IFLSUM4(10),ESTOR4(10,28),EPHOTG4(10,28),DRXE4(10,28),DRYE4(10,28),DRZE4(10,28),DRX4(10,28),DRY4(10,28),DRZ4(10,28)
	# COMMON/CALCAS5E/IONSUM5(10),IFLSUM5(10),ESTOR5(10,28),EPHOTG5(10,28),DRXE5(10,28),DRYE5(10,28),DRZE5(10,28),DRX5(10,28),DRY5(10,28),DRZ5(10,28)
	#COMMON/COMP/
	global LCMP,LCFLG,LRAY,LRFLG,LPAP,LPFLG,LBRM,LBFLG,LPEFLG
	#COMMON/GENCAS/
	global ELEV#(17,79)
	global NSDEG#(17)
	global AA#(17)
	global BB#(17)
	global SCR,SCR1
	#COMMON/MIXC/
	global PRSH#(6,3,17,17)
	global ESH#(6,3,17)
	global AUG#(6,3,17,17,17)
	global RAD#(6,3,17,17)
	global PRSHBT#(6,3,17)
	global IZ#(6,3)
	global INIOCC#(6,3,17)
	global ISHLMX#(6,3)
	global AMZ#(6,3)
	#COMMON/UPD/
	global NOCC#(6,3,17)
	global AUGR#(6,3,17,17,17)
	global RADR#(6,3,17,17)
	#COMMON/CALCASE/
	global IONSUM#(10)
	global IFLSUM#(10)
	global ESTORE#(10,28)
	global EPHOTON#(10,28)
	global DRXE#(10,28)
	global DRYE#(10,28)
	global DRZE#(10,28)
	global DRX#(10,28)
	global DRY#(10,28)
	global DRZ#(10,28)
	#COMMON/CALCAS1E/
	global IONSUM1#(10)
	global IFLSUM1#(10)
	global ESTOR1#(10,28)
	global EPHOTG1#(10,28)
	global DRXE1#(10,28)
	global DRYE1#(10,28)
	global DRZE1#(10,28)
	global DRX1#(10,28)
	global DRY1#(10,28)
	global DRZ1#(10,28)
	#COMMON/CALCAS2E/
	global IONSUM2#(10)
	global IFLSUM2#(10)
	global ESTOR2#(10,28)
	global EPHOTG2#(10,28)
	global DRXE2#(10,28)
	global DRYE2#(10,28)
	global DRZE2#(10,28)
	global DRX2#(10,28)
	global DRY2#(10,28)
	global DRZ2#(10,28)
	#COMMON/CALCAS3E/
	global IONSUM3#(10)
	global IFLSUM3#(10)
	global ESTOR3#(10,28)
	global EPHOTG3#(10,28)
	global DRXE3#(10,28)
	global DRYE3#(10,28)
	global DRZE3#(10,28)
	global DRX3#(10,28)
	global DRY3#(10,28)
	global DRZ3#(10,28)
	#COMMON/CALCAS4E/
	global IONSUM4#(10)
	global IFLSUM4#(10)
	global ESTOR4#(10,28)
	global EPHOTG4#(10,28)
	global DRXE4#(10,28)
	global DRYE4#(10,28)
	global DRZE4#(10,28)
	global DRX4#(10,28)
	global DRY4#(10,28)
	global DRZ4#(10,28)
	#COMMON/CALCAS5E/
	global IONSUM5#(10)
	global IFLSUM5#(10)
	global ESTOR5#(10,28)
	global EPHOTG5#(10,28)
	global DRXE5#(10,28)
	global DRYE5#(10,28)
	global DRZE5#(10,28)
	global DRX5#(10,28)
	global DRY5#(10,28)
	global DRZ5#(10,28)

	#
	#
	#  CALCULATES AUGER AND FLUORESCENCE CASCADE FOR VACANCY IN ICSHELL
	#
	IFIRST=1
	ISECOND=2
	ICONPH=1
	NVAC=1
	X0=X
	Y0=Y
	Z0=Z
	T0=T
	IZERO=0
	IONE=1
	ADIST=0.0
	# 
	# CALCULATE CASCADE EVENT
	#     WRITE(6,991) NVAC,KGAS,LGAS,EINIT,ISHELL
	# 991 print(' NVAC=',I3,' KGAS=',I3,' LGAS=',I3,' EINIT=','%.4f' % ,' 
	#    /ISHELL=',I3)
	CALCE(NVAC,KGAS,LGAS,EINIT,ISHELL)
	# STORE EVENT 
	#     Z0=DIST
	CASSTOREE(NVAC,X0,Y0,Z0,T0)
	# IF INCLUDE PHOTOABSORPTION OF FLUORESENCE : 
	if(ICONPH == 1):
		if(IFLSUM[NVAC]== 0): 
			# ZERO COUNTER
			L1=0
			CSSTF1E(NVAC,L1,ADIST)
			pass
			# endif
			# LOOP AROUND FIRST GEN FLUORESCENCE
		else:
			IFL1=IFLSUM[NVAC]
			for L1 in range(1,IFL1):
				EPH=EPHOTON[NVAC][L1]
				#
				# CALC ABSORPTION POSITION X1,Y1,Z1 FOR FLUORESENCE PHOTON OF ENERGY EPH
				# WITH ABSORPTION IN SHELL ISHELL1 IN GAS KGAS1 COMPONENT LGAS1 
				ABSO(ISECOND,EPH,ISHELL1,KGAS1,LGAS1,DIST1)
				# LOW ENERGY PHOTON
				if(ISHELL1 == -1):
					IFLSUM[NVAC]=IFLSUM[NVAC]-1
					pass
					# endif
					#
					# CALCULATE CASCADE IN GAS 
				else:
					CALC1E(NVAC,KGAS1,LGAS1,EPH,ISHELL1,L1)
					# STORE EVENT
					CSSTF1E(NVAC,L1,DIST1) 
		#
		# SECOND GENERATION FLUORESCENCE
		if(IFLSUM1[NVAC]== 0):
			# ZERO COUNTER
			L2=0
			CSSTF2E(NVAC,L2,ADIST)
			pass
			# endif 
			# LOOP AROUND SECOND GEN FLUORESCENCE
		else:
			IFL2=IFLSUM1[NVAC]
			for L2 in range(1,IFL2):
				EPH=EPHOTG1(NVAC,L2)
				#
				# CALC ABSORPTION POSITION X2,Y2,Z2 FOR FLUORESENCE PHOTON OF ENERGY EPH
				# WITH ABSORPTION IN SHELL ISHELL2 IN GAS KGAS2 COMPONENT LGAS2
				ABSO(ISECOND,EPH,ISHELL2,KGAS2,LGAS2,DIST2)
				# LOW ENERGY PHOTON
				if(ISHELL2 == -1):
					IFLSUM1[NVAC]=IFLSUM1[NVAC]-1
					pass
					# endif
					#
					# CALCULATE CASCADE IN GAS 
				else:
					CALC2E(NVAC,KGAS2,LGAS2,EPH,ISHELL2,L2)
					# STORE EVENT
					CSSTF2E(NVAC,L2,DIST2)               
		# 
		# THIRD GENERATION FLUORESCENCE
		if(IFLSUM2[NVAC]== 0):
			# ZERO COUNTER
			L3=0
			CSSTF3E(NVAC,L3,ADIST)
			pass
			# endif
			# LOOP AROUND THIRD GEN FLUORESCENCE
		else:
			IFL3=IFLSUM2[NVAC]
			for L3 in range(1,IFL3):
				EPH=EPHOTG2[NVAC][L3]
				#
				# CALC ABSORPTION POSITION X3,Y3,Z3 FOR FLUORESENCE PHOTON OF ENERGY EPH
				# WITH ABSORPTION IN SHELL ISHELL3 IN GAS KGAS3 COMPONENT LGAS3
				ABSO(ISECOND,EPH,ISHELL3,KGAS3,LGAS3,DIST3)
				# LOW ENERGY PHOTON
				if(ISHELL3 == -1):
					IFLSUM2[NVAC]=IFLSUM2[NVAC]-1
					pass
					# endif
					#
					# CALCULATE CASCADE IN GAS 
				else:
					CALC3E(NVAC,KGAS3,LGAS3,EPH,ISHELL3,L3)
					# STORE EVENT
					CSSTF3E(NVAC,L3,DIST3)               
		# 
		# FOURTH GENERATION FLUORESCENCE
		if(IFLSUM3[NVAC]== 0):
			# ZERO COUNTER
			L4=0
			CSSTF4E(NVAC,L4,ADIST)
			pass
			# endif
			# LOOP AROUND FOURTH GEN FLUORESCENCE
		else:
			IFL4=IFLSUM3[NVAC]
			for L4 in range(1,IFL4):
				EPH=EPHOTG3[NVAC][L4]
				#
				# CALC ABSORPTION POSITION X4,Y4,Z4 FOR FLUORESENCE PHOTON OF ENERGY EPH
				# WITH ABSORPTION IN SHELL ISHELL4 IN GAS KGAS4 COMPONENT LGAS4
				ABSO(ISECOND,EPH,ISHELL4,KGAS4,LGAS4,DIST4)
				# LOW ENERGY PHOTON
				if(ISHELL4 == -1):
					IFLSUM3[NVAC]=IFLSUM3[NVAC]-1
					pass
					# endif
					#
					# CALCULATE CASCADE IN GAS 
				else:
					CALC4E(NVAC,KGAS4,LGAS4,EPH,ISHELL4,L4)
					# STORE EVENT
					CSSTF4E(NVAC,L4,DIST4)                    
		# 
		# FIFTH GENERATION FLUORESCENCE
		if(IFLSUM4[NVAC]== 0):
			# ZERO COUNTER
			L5=0
			CSSTF5E(NVAC,L5,ADIST)
			pass
			# endif
			# LOOP AROUND FIFTH GEN FLUORESCENCE
		else:
			IFL5=IFLSUM5[NVAC]
			for L5 in range(1,IFL5):
				EPH=EPHOTG4(NVAC,L5)
				#
				# CALC ABSORPTION POSITION X5,Y5,Z5 FOR FLUORESENCE PHOTON OF ENERGY EPH
				# WITH ABSORPTION IN SHELL ISHELL5 IN GAS KGAS5 COMPONENT LGAS5
				ABSO(ISECOND,EPH,ISHELL5,KGAS5,LGAS5,DIST5)
				# LOW ENERGY PHOTON
				if(ISHELL5 == -1):
					IFLSUM5[NVAC]=IFLSUM[NVAC]-1
					pass
					# endif
					#
					# CALCULATE CASCADE IN GAS 
				else:
					CALC5E(NVAC,KGAS5,LGAS5,EPH,ISHELL5,L5)
					# STORE EVENT
					CSSTF5E(NVAC,L5,DIST5)               
					if(IFLSUM5[NVAC]>= 1):
						print(' WARNING SIXTH GENERATION EXISTS IFLSUM5=',IFLSUM5)
	# endif
	return 
	# end