	subroutine gg_leo (flag,gglat,gglon,gmlat,gmlon)
	integer flag
c	flag =  1 for geographic to geomagnetic conversion
c	flag = -1 for geomagnetic to geographic conversion
	pi = 3.141592654
	radeg = 180. / pi
	degrad = pi / 180.
	pole_lat = 78.5
	pole_lon = 291.0
	cp = cos((90.0 - pole_lat) * degrad)
	sp = sin((90.0 - pole_lat) * degrad)
	if(flag.eq.1) slat = gglat
	if(flag.eq.-1) slat = gmlat
	if(flag.eq.1) slon = gglon +(360.0 - pole_lon)
	if(flag.eq.-1) slon = gmlon
	cb = cos(slat*degrad)
	sb = sin(slat*degrad)
	cl = cos(slon)
	sl = sin(slon)
	sbb = sb * cp + flag * cb * cl * sp
	if(abs(sbb).gt.1.0) sbb = sign(1.0,sbb)
	ggg = asin(sbb)
	if(flag.eq.1) gglat = ggg
	if(flag.eq.-1) gmlat = ggg
	cbb = cos(ggg)
	cg = cos(ggg)
	cll = -flag * sb * sp + cb * cl * cp
	if(cll.gt.1.) cll = sign(1.0,cll)
	flon = acos(cll)
	sll = cb * sl / cg
	if(sll.gt.0.) flon = 2.0 * pi - flon
c
	if(flag.eq.1) gmlat = gmlat * radeg
	if(flag.eq.-1) gglat = gglat * radeg
	if(flag.eq.1) gmlon = gmlon * radeg
	if(flag.eq.-1) gglon = gglon * radeg
c
	return
	end

