	subroutine rotate8(alfa, beta, gamma, phi, rlat)

	real*8 sinb, cosb, sinl, cosl, sinp, cosp, cost
	real*8 alfa, beta, gamma, phi, rlat

	phi = phi - alfa
	sinb = dsind(beta)
	cosb = dcosd(beta)
	sinl = dsind(rlat)
	cosl = dcosd(rlat)
	sinp = dsind(phi)
	cosp = dcosd(phi)
	cost = sinl*cosb + cosl*sinb*cosp
	if(dabs(cost).ne.1.D0) then
	  sinp = cosl*sinp
	  cosp = cosl*cosb*cosp - sinl*sinb
	else
	  if(sinb.eq.0.D0) cosp=cosb*cosp
	endif
	phi = datan2d(sinp,cosp)
	phi = phi - gamma
	phi = dmod(dmod(phi,360.D0)+360.D0,360.D0) !0<phi<360
	rlat = 90.D0 - dacosd(cost)
	return
	end
