function FD_coefs =  ReadData(filenm)

fid = fopen(filenm);

fseek(fid,0,'eof');
end_position = ftell(fid);
fseek(fid,0,'bof');

[C, position] = textscan(fid, '%[^\n]', 2);
title = cell2mat(C{1}(1));
float = cell2mat(C{1}(2));

[C, position] = textscan(fid, '%*s %*s %f',3);
water_depth = C{1}(1);
wave_amp = C{1}(2);
wave_angle = C{1}(3);

[C, position] = textscan(fid, '%*s %*s %*s %*s %d',1);
sym_planes = C{1}(1);

[C, position] = textscan(fid, '%*s %*s %*s  %d',2);
n_elements = C{1}(1);
n_nodes = C{1}(2);

[C, position] = textscan(fid, '%[^\n]', 1);

[C, position] = textscan(fid, '%d %f %f %f',n_nodes);

pts = cell(1,3);
pts{1} = C{2};
pts{2} = C{3};
pts{3} = C{4};

[C, position] = textscan(fid, '%[^\n]', 1);


[C, position] = textscan(fid, '%d %f %f %f %f %f %f %f %f',n_elements);
conn(:,1) = C{2};
conn(:,2) = C{3};
conn(:,3) = C{4};
conn(:,4) = C{5};
conn(:,5) = C{6};
conn(:,6) = C{7};
conn(:,7) = C{8};
conn(:,8) = C{9};
conn(:,9) = C{2};

k = []; w = []; T = [];

F = cell(7,6);
FT = cell(7,6);
while(1)
  [C, position] = textscan(fid, '%*s %*s %f',3);
  if(position == end_position)  break; end;
  k = [k, C{1}(1)];
  w = [w, C{1}(2)];
  T = [T, C{1}(3)];
  
  if(length(k) == 1)  %Read normalized solid angle the first time.
  [C, position] = textscan(fid, '%[^\n]', 1); 
  [C, position] = textscan(fid, '%d %f %f',n_nodes);    
  solid_angle(:,1) = C{2};
  solid_angle(:,2) = C{3};
  end
 
  [C, position] = textscan(fid, '%[^\n]', 1); %Read "Generalized Forces" title line
  for i = 1:7
    [C1, position] = textscan(fid, '%d %f %f %f %f %f %f',1);
    [C2, position] = textscan(fid, '%f %f %f %f %f %f',2);
    for j = 1:6  
        F{i,j} = [F{i,j} complex(C1{j+1},C2{j}(1))]; 
        FT{i,j} = [FT{i,j} C2{j}(2)]; 
    end
  end
end
fclose(fid);
clear C C1 C2 position end_position fid i j;

FD_coefs.F = F;
FD_coefs.w = w;
FD_coefs.k = k;
FD_coefs.T = T;
FD_coefs.pts = pts;
FD_coefs.conn = conn;
FD_coefs.water_depth = water_depth;
FD_coefs.wave_amp= wave_amp;
FD_coefs.wave_angle = wave_angle;
FD_coefs.sym_planes = sym_planes;
FD_coefs.n_nodes = n_nodes;
FD_coefs.n_elements = n_elements;













