corrected definition of Sgh array to be a 1D vector; simplified loops in routine; this resolves issue #3.