Probably the sun position calculation shouldbe replaced
with 

 G_calc_solar_position()

currently used in r.sunmask. G_calc_solar_position() is based on
solpos.c from NREL and very precise.

MN 4/2001
