%==================================
%read function
%==================================
function [GeomParam,MatlParam,MiscParam,AnisParam,AnisFlag]=Read_Param(FileName, MatlLib)

global GeomParam MatlParam MiscParam AnisParam AnisFlag;

GeomParam=[];
MatlParam=[];
MiscParam=[];
AnisParam=[];
AnisFlag=[];
fid=fopen(FileName,'r');
fid2=fopen(MatlLib,'r');

%% begin reading model geom and misc parameters
while(1)
LayerNm=fgetl(fid);
if LayerNm(1)=='$';break;end;
LayerNm=str2num(LayerNm);
for i=1:6,GeomParam{LayerNm}{i}=fgetl(fid);end;
end;

for i=1:7;MiscParam{i}=fgetl(fid);end;
fclose(fid);

%% begin reading material lib
while(1)
MatlNm=fgetl(fid2);
if MatlNm(1)=='#';break;end;
MatlNm=str2num(MatlNm);
for i=1:7;MatlParam{MatlNm}{i}=fgetl(fid2);end;
end;

AnisFlag(1:length(MatlParam))=0;
AnisParam=[];
while(1)
MatlNm=fgetl(fid2);
if MatlNm(1)=='*';break;end;
MatlNm=str2num(MatlNm);
AnisFlag(MatlNm)=1;
for i=1:6,
   for j=i:7,
      AnisParam{MatlNm}{i,j}=fgetl(fid2);
   end;
end;
end;%while


fclose(fid2);
