function 	y=fixpoint(x,nd)
%%%  x = input variable  
%%%  nd = number of digits including decimal point

%%  Kriging Software Package  version 1.0 beta,   October 29, 1998
%%  Copyright (c) 1998, property of Dezhang Chu and Woods Hole Oceanographic
%%  Institution.  All Rights Reserved.


ep=log10(abs(x));
if x > 1
   epi=ceil(ep);
   pow=nd-epi-1;
   if pow < 0
      nd=pow+1+epi;		%	modify nd
   end
else
   epi=floor(ep);
   pow=nd+epi-1;
   if pow < 0
      nd=pow+1-epi;
      pow=0;
   end
end
y1=round(x*10^pow)/10^pow;
y2=num2str(y1);
nm=min(length(y2),nd);
y=y1(1:nm);
