function [ meshnod,meshele,bathy,bndele,bcs]=filein(filename)
% filein.m
% Read the files out in proper format
% [ meshnod,meshele,bathy,bndele,bcs]=filein('mesh');

fid = fopen([filename,'.nod'],'rt');
if fid~=-1
meshnod = fscanf(fid,'%f',[3,inf])';
fclose(fid);
else
meshnod=[];
end

fid = fopen([filename,'.ele'],'rt');
if fid~=-1
meshele = fscanf(fid,'%f',[4,inf])';
fclose(fid);
else
meshele=[];
end


 
fid = fopen([filename,'.bat'],'rt');
if fid~=-1
bathy = fscanf(fid,'%f',[2,inf])';
fclose(fid);
else
bathy=[];
end



fid = fopen([filename,'.bel'],'rt');
if fid~=-1
[a,count]=fscanf(fid,'%s\n',1);
fscanf(fid,'%s',3);
bndele = fscanf(fid,'%8i %8i %8i %8i %8i\n',[5,inf])';
fclose(fid);
else
bndele=[];
end


fid = fopen([filename,'.bcs.s2c'],'rt');
if fid~=-1
%fprintf(fid,[filename,'.bel \n']);
%fprintf(fid,' M2 Elevation BCs 1000km long wave \n');
%fprintf(fid,'   .1405E-03 \n');
%  try this out      textline = fgetl(fid);
fscanf(fid,'%s',1);
fscanf(fid,'%s',6);
fscanf(fid,'%s',1);
bcs = fscanf(fid,'%f',[4,inf])';
fclose(fid);
else
bcs=[];
end



