Trend-surface analysis

Is anybody writing (or has written) a trend surface analysis
routine?

I've pretty much given up on the idea of a Universal Kriging
routine and I will therefore have to write a trend surf.
routine as the first step in regular Block Kriging...can
anyone help me out?

cheers,
chris