%
%  
%  Name: uff2mat
%
%  Usage: uff2mat
%
%  Description:
%    Prompts user for UFF (Universal File Format)
%    filename, reads data from the universal file
%    into MATLAB. Use 'uff2dmnd' to convert
%    the results to DIAMOND format

%  Version SWD960702
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%
%  Prompt for Type of data to load
%

disp(' ')
disp(' Please select a data type to load:')
disp(' ')
disp('  58)   Measurement Data')
disp('  55r)  Modal Analysis Results (real modes)')
disp('  55c)  Modal Analysis Results (complex modes)')
disp('  15)   Coordinates of Measurement and Excitation Points')
disp('  82)   Disply Sequence')
disp(' ')
typestr = input('  ****  Please Select: ');

if ~isstr(typestr), typestr = num2str(typestr); end

%
%  Prompt for Universal Filename
%

[filename,pathname,error] = loadfile(4,'~doebling/uc_data');

if error == 0,

filename = [pathname filename];

%
%  Load data from UFF and assign to DIAMOND variables
%

if strcmp(typestr,'58'),

 disp('Loading Measurement Data...')

%     Load measurement data

 [freq,data,errcode,errmessage,descript1,descript2,date,IDs,resp_pt_num, ...
  r_direction,excit_ptnum,excit_direction,function_type]=read_uff(filename,58);

%     Load Modal Data

elseif strcmp(typestr,'55r'),

 disp('Loading real modal data...')

 [analysis_type,data_character,response_type,mode_num, ...
  mode_freq,mode_mass,mode_v_damping_ratio,mode_h_damping_ratio, ...
  node_num,r1,r2,r3,r4,r5,r6,errcode,errmessage] = read_uff(filename,55);

elseif strcmp(typestr,'55c'),

 disp('Loading complex modal data...')

 [analysis_type,data_character,response_type,mode_num, ...
  eig_val,model_A,model_B,dummy_var, ...
  node_num,r1,r2,r3,r4,r5,r6,errcode,errmessage] = read_uff(filename,55);

%     Load Coordinate Data

elseif strcmp(typestr,'15'),

 [pt_num,x_coord,y_coord,z_coord,errcode,errmessage] = read_uff(filename,15);

%     Load Display Sequence Data

elseif strcmp(typestr,'82'),
 
  [disp_sequence,erc,ermessage] = read_uff(filename,82);

else

 disp(' ERROR: DATA TYPE NOT RECOGNIZED')

end

end

%
%  ALL DONE
%
