%                togrid2.m
%               for constructing ascii flat file with lon,lat,u(ind),v(ind)
%               where each of the variables is subsampled by 2

ghval=[1 2 3 4 5 6 7 9];
lat=[]; lon=[]; depth=[]; ucoef=[]; vcoef=[];
for k=1:8
	disp(ghval(k))
	m=[];
	eval(concat('load gh',int2str(ghval(k)),'nav.bin'))
	eval(concat('load gh',int2str(ghval(k)),'cof.tid'))
	m1=subsamp(2,2,lonbin);
	m2=subsamp(2,2,latbin);
	m3=subsamp(2,2,depthbin);
	uc=subsamp(2,2,unew(:,ind));
	vc=subsamp(2,2,vnew(:,ind));
	i=length(lat);
	inew=length(m1);
	lat(i+1:i+inew)=m1;
	lon(i+1:i+inew)=m2;
	depth(i+1:i+inew)=m3;
	ucoef(i+1:i+inew,:)=uc;
	vcoef(i+1:i+inew,:)=vc;
end
