function [uc,vc]=centering_llcuv(uI,vI,nfx,nfy)
%----
%%%nx,ny,nz);
%function [uc,vc]=centering_llcuv(uI,vI,nfx,nfy);   %%%nx,ny,nz);
%assume that hfac[W,S] have already been applied
%[uI,vI]: in compact format
%[uc,vc]: 5 faces
%----
%keyboard
%assume global, can readjust later to accomodate aste
sz=size(uI);
nx=sz(1);ny=sz(2);if(length(sz)==2);nz=1;elseif(length(sz)==3);nz=sz(3);end;
%nfx=[nx,nx,nx,3*nx,3*nx];
%nfy=[3*nx,3*nx,nx,nx,nx];
%iskip=[0,3,6,7,10,13].*nx;
iskip=[0,nfy(1),sum(nfy(1:2)),sum(nfy(1:3)),sum(nfy(1:3))+nfx(4),sum(nfy(1:3))+sum(nfx(4:5))];

  for iface=1:5;
%define size
    if(nfx(iface)==0|nfy(iface)==0);
      uc{iface}=[];vc{iface}=[];
    else;
      u{iface}=zeros(nfx(iface)+1,nfy(iface),nz);
      v{iface}=zeros(nfx(iface),nfy(iface)+1,nz);
      uc{iface}=zeros(nfx(iface),nfy(iface),nz);
      vc{iface}=zeros(nfx(iface),nfy(iface),nz);

%now filling in faces:
      u{iface}(1:nfx(iface),1:nfy(iface),1:nz)=...
           reshape(uI(1:nx,iskip(iface)+1:(iskip(iface+1)),1:nz),nfx(iface),nfy(iface),nz);
      v{iface}(1:nfx(iface),1:nfy(iface),1:nz)=...
           reshape(vI(1:nx,iskip(iface)+1:(iskip(iface+1)),1:nz),nfx(iface),nfy(iface),nz);
    end;
  end;

%now u edge:
  clear ut;
  if(nfx(2)==0|nfy(2)==0);ut=nan(1,nfy(1),nz);else;ut=u{2}(1,1:nfy(2),1:nz);end;u{1}(nfx(1)+1,1:nfy(1),1:nz)=ut;

  clear ut;
  if(nfx(2)>0&nfy(2)>0);ut=sym_g_mod(v{4}(1:nfx(4),1,1:nz),7,0);u{2}(nfx(2)+1,1:nfy(2),1:nz)=ut;end;
  
  clear ut;
  if(nfx(4)==0|nfy(4)==0);ut=nan(1,nfy(4),nz);else;ut=u{4}(1,1:nfy(4),1:nz);end;u{3}(nfx(3)+1,1:nfy(3),1:nz)=ut;
%will not fill the last cells nx*3+1 for u{4} and u{5} because they're land, so assume zeros

%now v edge: (a bit more complicated that u)
  clear vt;vt=sym_g_mod(u{3}(1,1:nfy(3),1:nz),5,0);v{1}(1:nfx(1),nfy(1)+1,1:nz)=vt;
  if(nfx(2)>0&nfy(2)>0);clear vt;vt=v{3}(1:nfx(3),1,1:nz);v{2}(1:nfx(2),nfy(2)+1,1:nz)=vt;end;
  clear vt;vt=sym_g_mod(u{5}(1,1:nfy(5),1:nz),5,0);v{3}(1:nfx(3),nfy(3)+1,1:nz)=vt;
  clear vt;if(nfx(4)>0&nfy(4)&0);vt=v{5}(1:nfx(5),1,1:nz);v{4}(1:nfx(4),nfy(4)+1,1:nz)=vt;end;
  clear vt;vt=sym_g_mod(u{1}(1,1:nfy(1),1:nz),5,0);v{5}(1:nfx(5),nfy(5)+1,1:nz)=vt;


%now centering:
  for iface=1:5;
    if(nfx(iface)>0&nfy(iface)>0);
      uc{iface}=(u{iface}(1:nfx(iface),1:nfy(iface),1:nz)+u{iface}(2:nfx(iface)+1,1:nfy(iface),1:nz))./2;
      vc{iface}=(v{iface}(1:nfx(iface),1:nfy(iface),1:nz)+v{iface}(1:nfx(iface),2:nfy(iface)+1,1:nz))./2;
    else;
      uc{iface}=[];
      vc{iface}=[];
    end;
  end;

return
