function [ind,indp]=match_old_new_itp(itp_old,itp,flagtrim)

%dirRoot='/scratch/atnguyen/aste_270x450x180/run_template/input_insitu/';
%fileO=[dirRoot '+global/+30x30/itp_llc270_may2014.nc'];
%fileN=[dirRoot '+aste/+30x30/itp_llc270_may2014_ASTE.nc'];

%a=MITprof_load(fileN);
%b=MITprof_load(fileO);

a=itp;    na=a.np;
b=itp_old;nb=b.np;

%first filter: depth
iz=1:41;
fld={'T','Tweight','Testim','Terr','Tflag','S','Sweight','Sestim','Serr','Sflag'};
for k=1:size(fld,2);eval(['b.prof_' fld{k} '=b.prof_' fld{k} '(:,iz);']);end;

%2nd filter: zero weights
ind=[];
tmp=sum(b.prof_Tweight,2);ii=find(tmp~=0);[length(tmp) length(ii)]
fld={'T','Tweight','Testim','Terr','Tflag',...
     'S','Sweight','Sestim','Serr','Sflag',...
     'YYYYMMDD','HHMMSS','lon','lat','descr','date','basin','point',...
     'interp_XC11','interp_YC11','interp_XCNINJ','interp_YCNINJ',...
     'interp_i','interp_j','interp_lon','interp_lat','interp_weights'};
for k=1:size(fld,2);eval(['b.prof_' fld{k} '=b.prof_' fld{k} '(ii,:);']);end;	%17762

ii_first_cut=ii;

if(b.np<length(ii_first_cut)|flagtrim~=0);

%3rd: some strange filters that should be investigated, 1833 more prof removed (why?)
prof_descr=char(b.prof_descr);

    itp_no=zeros(size(prof_descr,1),1);
    for i=1:size(prof_descr,1)
      ip=find(prof_descr(i,:)=='p');
      ipf=find(prof_descr(i,:)=='f');
      itp_no(i)=str2num(prof_descr(i,ip+1:ipf-1));
    end;
    sz=size(itp_no);if(sz(1)==1);itp_no=itp_no';end;

%[xa,ya]=llssmi1(a.prof_lon,a.prof_lat,-45,1);xa=xa./1e6;ya=ya./1e6;
[xb,yb]=llssmi1(b.prof_lon,b.prof_lat,-45,1);xb=xb./1e6;yb=yb./1e6;
    
    ii=[];
    ij=find(itp_no==28|itp_no==36);ii=cat(1,ii,ij);
    ij=find(xb>-0.25&xb<-0.1&yb>-.2781&yb<0.3);	ii=cat(1,ii,ij);%403 prof (itp_no 15, some of 16
    ij=find(xb>-1.1991&xb<-1.1517&yb>0.3513&yb<0.4157);ii=cat(1,ii,ij);	%41prof
    ij=find(xb>-1.1542&xb<-1.1424&yb>0.3124&yb<0.3568);ii=cat(1,ii,ij);	%14 prof
    ij=find(xb>-1.1349&xb<-1.1325&yb>0.3181&yb<0.3184);ii=cat(1,ii,ij);	%2prof
    ij=find(xb>-1.1278&xb<-1.1129&yb>0.3179&yb<0.3295);ii=cat(1,ii,ij);	%13 prof
    ij=find(xb>-1.1121&xb<-1.0898&yb>0.3305&yb<0.3333);ii=cat(1,ii,ij);	%4prof
    ij=find(xb>-1.0898&xb<-0.9883&yb>0.3232&yb<0.3299);ii=cat(1,ii,ij);	%15prof
    ij=find(xb>-0.9902&xb<-0.9854&yb>0.3230&yb<0.3249);ii=cat(1,ii,ij);	%3prof
    ij=find(xb>-1.0744&xb<-1.0475&yb>0.3081&yb<0.3231);ii=cat(1,ii,ij);	%9prof
    ij=find(xb>-1.1323&xb<-1.0758&yb>0.3876&yb<0.4209);ii=cat(1,ii,ij);	%15prof
    ij=find(xb>-0.7871&xb<-0.5981&yb>0.0812&yb<0.2141);ii=cat(1,ii,ij);	%46prof
    ij=find(xb>-0.6869&xb<-0.4891&yb>-0.3186&yb<-0.0851);ii=cat(1,ii,ij);	%937prof
    ij=find(xb>-0.6880&xb<-0.6868&yb>-0.2118&yb<-0.2090);ii=cat(1,ii,ij);	%3
    ij=find(xb>-0.6919&xb<-0.6862&yb>-0.2039&yb<-0.1896);ii=cat(1,ii,ij);	%2
    ij=find(xb>-0.637105&xb<-0.63708&yb>-0.08372&yb<-0.08366);ii=cat(1,ii,ij);	%3
    ij=find(xb>-0.5550&xb<-0.5388&yb>-0.0854&yb<-0.0177);ii=cat(1,ii,ij);	%21
    ij=find(xb>-0.5431&xb<-0.5407&yb>-0.3207&yb<-0.3185);ii=cat(1,ii,ij);  	%3
    ij=find(xb>-0.6044&xb<-0.5954&yb>-0.3229&yb<-0.3156);ii=cat(1,ii,ij);	%3
    ii=unique(ii);

    clear ij;ij=setxor(1:length(b.prof_lon),ii);
else;
    ij=1:length(ii_first_cut);
end;

ind=ii_first_cut(ij);
indp=ij;
%for k=1:size(fld,2);eval(['b.prof_' fld{k} '=b.prof_' fld{k} '(ij,:);']);end;	%15929

%itp_new=b;

%load('/home/atnguyen/nansen/DATA/ice/arctic10_landmask.mat');
%figure(1);clf;plot(xb,yb,'.',xa,ya,'ro',xb(ii),yb(ii),'gs');grid;

return
