Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/cs_grid/latloncap/croptiled.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
6a75a3b8ef Chri*0001 function t = croptiled(t, cspec )
                0002 %
                0003 % Crop size of variables listed vlist in a tiled structure t.
                0004 %
                0005 
                0006 d=1;
                0007 for c=1:length(cspec.crops)
                0008  vlist=cspec.crops(c).fields;
                0009  rlist=cspec.crops(c).ranks;
                0010  ilo=cspec.crops(c).indexlo;
                0011  ihi=cspec.crops(c).indexhi;
                0012  for v=1:length(vlist)
                0013   vn=vlist{v};
                0014   % Figure out range to crop
                0015   ranks=[1:ndims(getfield(t(1).var,vn))];
                0016   rstr='(';
                0017   for r=ranks
                0018    [ri,ii]=intersect(rlist,r);
                0019    if isempty( ri )
                0020     rstr=sprintf('%s:,',rstr);
                0021    else
                0022     rstr=sprintf('%s%d:%d,',rstr,ilo(ii),ihi(ii));
                0023    end
                0024   end
                0025   rstr(end)=')';
                0026   if d > 0
                0027    fprintf(1,'%s=%s%s\n',vn,vn,rstr);
                0028   end
                0029   % Do crop
                0030   for tn=1:length(t)
                0031    phi=getfield(t(tn).var,vn);
                0032    estr=sprintf('phi=phi%s;',rstr);
                0033    eval(estr);
                0034    estr=sprintf('t(%d).var.%s=phi;',tn,vn);
                0035    eval(estr);
                0036   end
                0037  end
                0038 end
                0039 
                0040 end
                0041