function []=write2(a,heading,idigit);
%function []=write2(a,heading,idigit);
%              makes string format of a

[m,n]=size(a);
if nargin==2
	idigit=0;
end;
diary off
if exist('temp.asc')==3
      !del temp.asc
end

diary temp.asc
fprintf(heading);
fprintf( '\n')
for j=1:m
  if ((a(j,1)>999)|(a(j,1)==nan)|(a(j,1)<-99))
        fprintf( ' * ')
  else
        fprintf( '%3.0f',a(j,1));
  end

  for i=2:n
	    if ((abs(a(j,i))>999)|(a(j,i)==nan))
		           fprintf( ' *  ')
		 else
            fprintf( '%4.0f',a(j,i));
		 end
  end
  fprintf('\n')
end
diary off
disp('output in temp.asc')


