%==================================
%write material library
%==================================
function Write_Matl(MatlParam,AnisParam,AnisFlag,MatlLib)

global GeomParam MatlParam MiscParam AnisParam AnisFlag;

fid=fopen(MatlLib,'w');

for i=1:length(MatlParam);
   fprintf(fid,'%d\n',i);
   for j=1:length(MatlParam{1});
      fprintf(fid,'%s\n',MatlParam{i}{j});
   end;
end;

fprintf(fid,'########\n');
for k=1:length(MatlParam);
   if AnisFlag(k)==1,
   fprintf(fid,'%d\n',k);
   for i=1:6,
      for j=i:7,
            fprintf(fid,'%s\n',AnisParam{k}{i,j});
      end;%j
   end; %i
   end;
end; %k

fprintf(fid,'********\n');

fclose(fid);
   
