function savesmms(a,filename)
% Function savesmms(a,filename)
%   Saves the "a" variable in SMMS format in a file "filename"
%   (adds a dimension line and a "0 0 0" terminating line)
eval(['fid=fopen(''' filename ''',''w'');']);
[n1 n2] = size(a);
% Following statement for PC version
% fprintf(fid,'%d %d\r\n',n1,n2);
% Following statement for Unix version
fprintf(fid,'%d %d\n',n1,n2);
[tmpi tmpj tmpv] = find(a);
ap = [tmpi tmpj tmpv]';
% Following 2 statements for PC version
% fprintf(fid,'%d %d %f\r\n',ap);
% fprintf(fid,'0 0 0\r\n');
% Following 2 statements for Unix version
fprintf(fid,'%d %d %f\n',ap);
fprintf(fid,'0 0 0\n');
fclose(fid);
