function fldOut=calc_UV_conv_1face(U,V)
%--------------------------------------------------
% function fldOut=calc_UV_conv_1face(U,V,nx,ny)
% Input: 
% [U,V]: U and V at mitgcm C-grid points [East,South] for a single face
% [nx,ny]: dimensions in x and y 
%
% Output:
%  fldOut: convergence field (scalar), 1 face
%  fldOut [nx x ny x nz] 
%
% atn 17/Mar/2019, copy from Gael's calc_UV_conv.m
%--------------------------------------------------

%check size
su=size(U);
sv=size(V);
if(su(1)~=sv(1)|sv(2)~=sv(2));error('size U and V inconsistent and need to be the same');end;

%add 1 more column to rightmost of U and 1 more row to top of V
sz=size(U);
if(length(sz)==2);sz=[sz 1];end;

up=nan(sz(1)+1,sz(2),sz(3));
up(1:sz(1),1:sz(2),1:sz(3))=U;

vp=nan(sz(1),sz(2)+1,sz(3));
vp(1:sz(1),1:sz(2),1:sz(3))=V;

uc(1:sz(1),1:sz(2),1:sz(3)) = ( up(1:sz(1),:,1:sz(3)) - up(2:sz(1)+1,:,1:sz(3)) );
vc(1:sz(1),1:sz(2),1:sz(3)) = ( vp(:,1:sz(2),1:sz(3)) - vp(:,2:sz(2)+1,1:sz(3)) );

fldOut=uc+vc;

return
