%
%  transfer_from_modes_H_files.m  ver 1.4  January 12, 2014
%
function[varname1,varname2,varname3]=...
                         transfer_from_modes_H_files(iam,i,k,freq,H,HM,PHA)  
%
    if(iam==1)
        str1= sprintf(' H_disp_force_%d_%d',i,k);
        str2=sprintf(' HM_disp_force_%d_%d',i,k);
        str3=sprintf('HMP_disp_force_%d_%d',i,k);        
    end
%    
    if(iam==2)
        str1= sprintf(' H_vel_force_%d_%d',i,k);
        str2=sprintf(' HM_vel_force_%d_%d',i,k);
        str3=sprintf('HMP_vel_force_%d_%d',i,k);        
    end
%    
    if(iam==3)
        str1= sprintf('  H_acc_force_%d_%d',i,k);
        str2= sprintf(' HM_acc_force_%d_%d',i,k);
        str3= sprintf('HMP_acc_force_%d_%d',i,k);        
    end
%    
    if(iam==4)
        str1= sprintf(' H_force_disp_%d_%d',i,k);
        str2=sprintf(' HM_force_disp_%d_%d',i,k);
        str3=sprintf('HMP_force_disp_%d_%d',i,k);        
    end    
%    
    if(iam==5)
        str1= sprintf(' H_force_vel_%d_%d',i,k);
        str2=sprintf(' HM_force_vel_%d_%d',i,k);
        str3=sprintf('HMP_force_vel_%d_%d',i,k);        
    end  
%    
    if(iam==6)
        str1= sprintf(' H_force_acc_%d_%d',i,k);
        str2=sprintf(' HM_force_acc_%d_%d',i,k);
        str3=sprintf('HMP_force_acc_%d_%d',i,k);        
    end     
%
    if(iam==7)
        str1= sprintf(' H_acc_acc_%d_%d',i,k);
        str2=sprintf(' HM_acc_acc_%d_%d',i,k);
        str3=sprintf('HMP_acc_acc_%d_%d',i,k);        
    end    
%    
    varname1 = genvarname(str1);
    varname2 = genvarname(str2); 
    varname3 = genvarname(str3);      
%
    varname1b = genvarname(str1);
    varname2b = genvarname(str2);
    varname3b = genvarname(str3);    
%
    eval([varname1b ' = [freq  real(H) imag(H)];']);    
    eval([varname2b ' = [freq HM];']); 
    eval([varname3b ' = [freq HM PHA];']);     
%    
    v1=sprintf('%s.txt',varname1b);
    v2=sprintf('%s.txt',varname2b);   
    v3=sprintf('%s.txt',varname3b);      
%   
    save(v1,varname1b,'-ASCII');
    save(v2,varname2b,'-ASCII');
    save(v3,varname3b,'-ASCII');    