function Knn= IceReducematrix( Kgg, Gmn, pv_m,pv_n,msize,flag)
%ICEREDUCEMATRIX - reduce stiffness matrix from g to n
%
%   Usage:
%      Knn= IceReducematrix( Kgg, Gmn, pv_m,pv_n,msize,flag)

if msize>0,
	Kmm=Kgg(pv_m,pv_m);
	Kmn=Kgg(pv_m,pv_n);
	Knm=Kgg(pv_n,pv_m);
	Knn=Kgg(pv_n,pv_n);

	Knn= Knn + Knm * Gmn;

	if flag~=1,
		Kmn = Kmn + Kmm * Gmn;
		Knn = Knn + Gmn' * Kmn;
	end

else
	Knn=Kgg;
end
