
%Reads IRFs from output files generated by WAMIT and F2T
%Start: 0 seconds
%End: 10 seconds
%delt: 0.02 seconds


function [L tau] =  ReadWamitIRF(filenm)
%filenm = 'test25';
filenm1 = '_IR.1';filenm1 = strcat(filenm,filenm1);


s1 = load(filenm1);
N = length(s1(:,1));

tim = zeros(N/10,1);
sint= zeros(N/10,10);

for i = 1:10:N-9;
    
    k = i-1;
    k=k/10 +1;
    tim(k,1) = s1(i,1);
    sint(k,1) = s1(i,5);
end
for i = 2:10:N-8;
    
    k = i-2;
    k=k/10 +1;

    sint(k,2) = s1(i,5);
end
for i = 3:10:N-7;

    k = i-3;
    k=k/10 +1;

    sint(k,3) = s1(i,5);
end
for i = 4:10:N-6;

    k = i-4;
    k=k/10 +1;

    sint(k,4) = s1(i,5);
end
for i = 5:10:N-5;

    k = i-5;
    k=k/10 +1;

    sint(k,5) = s1(i,5);
end
for i = 6:10:N-4;

    k = i-6;
    k=k/10 +1;

    sint(k,6) = s1(i,5);
end
for i = 7:10:N-3;

    k = i-7;
    k=k/10 +1;

    sint(k,7) = s1(i,5);
end
for i = 8:10:N-2;

    k = i-8;
    k=k/10 +1;

    sint(k,8) = s1(i,5);
end
for i = 9:10:N-1;

    k = i-9;
    k=k/10 +1;

    sint(k,9) = s1(i,5);
end
for i = 10:10:N;

    k = i-10;
    k=k/10 +1;

    sint(k,10) = s1(i,5);
end


filenm3 = '_JR.3';filenm3 = strcat(filenm,filenm3);

kij= load(filenm3);

L = cell(7,6);

for i=1:6
    for j=1:6
        L{i,j} = zeros(501,1);
    end
end

L{1,1} = sint(:,1);
L{1,5} = sint(:,2);
L{2,2} = sint(:,3);
L{2,4} = sint(:,4);
L{3,3} = sint(:,5);
L{4,2} = sint(:,6);
L{4,4} = sint(:,7);
L{5,1} = sint(:,8);
L{5,5} = sint(:,9);
L{6,6} = sint(:,10);

for i=1:6
    for j=1:6
        L{i,j} = 1025*L{i,j};
    end
end

for j=1:6;
    L{7,j} = 1025*9.80665*kij(:,j+1);
    
end
tau = tim(:,1);









    
