function modes2ascii
%
%  Name: modes2ascii
% 
%  Usage: modes2ascii
% 
%  Description:
%    Exports the MODES in Memory to an ascii file
%

%  Version SWD970822
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally     %
% developed as part of "DIAMOND" at          %
% Los Alamos National Laboratory. It may     %
% be copied, modified, and distributed in    %
% any form, provided:                        %
%  a) This notice accompanies the files and  %
%     appears near the top of all source     %
%     code files.                            %
%  b) No payment or commercial services are  %
%     received in exchange for the code.     %
%                                            %
% Original copyright is reserved by the      %
% Regents of the University of California,   %
% in addition to Scott W. Doebling, Phillip  %
% J. Cornwell, Erik G. Straser, and Charles  %
% R. Farrar.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

global MODES pathname

%
%   Get the filename
%

if pathname == 0, pathname = 'c:\'; end

[filename,pathname,error]=savefile(5,pathname);

if error ~= 0,
   errordlg(['Error #',num2str(error),' saving ASCII file'])
   return
end

if isempty('MODES'),
   errordlg('ERROR: No Modes in Memory')
   return
end

fprintf(1,'Saving ASCII Modes file...')

fid = fopen([pathname,filename],'wt');

for imod = 1:MODES.nmodes,
   
   % Write the mode number
   
   fprintf(fid,'%4i\n',imod);
   
   % Write the frequency (Hz)
   
   fprintf(fid,'%10.5e\n',MODES.Freq{imod}(1));
   
   % Write the damping (fraction of critical)
   
   fprintf(fid,'%10.5e\n',MODES.Damp{imod}(1));
   
   % Write the modal vector
   
   for j = 1:length(MODES.modalvector{imod}),
      
      fprintf(fid,'%10.5e\n',MODES.modalvector{imod}(1,j));
      
   end
   
end

fclose(fid);

fprintf(1,'done\n')

return