clear all;
% Read in basic model parameters from file "tape7".
fid1=fopen('tape7','r');
y=0;
sflag=0;
while (feof(fid1) == 0 & sflag ~=2)
  line=fgetl(fid1);
  if (line(1:4)=='SIZE')
    a=sscanf(line(5:length(line)),'%f',4);
    nx=a(1)-424;
    ny=a(2);
    dx=a(3);
    dy=a(4);
    sflag=sflag+1;
  elseif (line(1:4)=='TIME')
    a=sscanf(line(5:length(line)),'%f',4);
    dt=a(3);
    sflag=sflag+1;
  end
end
% Open tapeMAT file which specifies material properties on finite difference grid.
fid=fopen('tapeMAT','r');
frewind(fid);
status=fseek(fid,0,'bof');
model=fread(fid,[nx+424,ny],'uint');
model1=model(213:812,:);
imagesc([0:dx/1000:599*dx/1000],[0:dy/1000:399*dy/1000],model1')
%load /seis/earth3/shragge/ScriptsMatlab/lines.mat
for ii=1:size(model1,1);
    for jj=1:size(model1,2);
        if model1(ii,jj)==model1(400,200);
            Pvel(ii,jj)=8.0;
            Svel(ii,jj)=4.5;
        elseif model1(ii,jj)==model1(400,150)
            Pvel(ii,jj)=8.1;
            Svel(ii,jj)=4.9;
        elseif model1(ii,jj)==model1(400,2) 
            Pvel(ii,jj)=6.2;
            Svel(ii,jj)=3.6;
        end
    end
end
Pslow=1./Pvel;
Sslow=1./Svel;
save Velmodels Pvel Svel Pslow Sslow
