	function ttmax()
	dimension xa(100),ya(100),y2(100),prod(100),fi(100)
	common/cfff/nnodi,hcf(100),xt(100)
	common/spettro/al(100),asp(100,200),at(200)
	common/pinco/xxa(100,100),yya(100,100),nt(100)
	common/line1/line,kkt
	common/demmax/demmax
c	write(*,*)'x',x,al(line),line
	ttmax=0.
	xx=0
	in=0
	nnnn=kkt
c
c	calcola nelle temperature dove e' campionata la g(T) la fi(T)
c
c	do i=1,32
	do i=1,kkt
	xx=at(i)
	call spline(xt,hcf,nnodi,2.e30,2.e30,y2)
	call splint(xt,hcf,y2,nnodi,xx,yyfi)
	fi(i)=yyfi
	prod(i)=fi(i)-asp(line,i)
	end do

c	write(*,*)line,j, asp(line,1),asp(line,kkt),kkt
c
c	cerca il massimo della g(t)
c

	amax=0
	amax=-1e30
c	do it =1,32
	do it =1,kkt
	if((prod(it)).gt.amax)then
	amax=(prod(it))
	demmax=fi(it)
	tttmax=at(it)
	end if
c	write(77,6)line,at(it),prod(it),asp(line,it),fi(it)
6	format(i4,4(f10.2))
	end do
	ttmax=tttmax
	return
	end

