function [localX, szLeftPad] = padLocalX(X, padSz)
%PADLOCALX adds padding to local parts of a distributed array.  The
%"padding" is actually values from adjacent workers.
%   X is an array codistributed 1d.
%   padSz is a two-element vector [numBefore numAfter].

%   Copyright 2021-2022 The MathWorks, Inc.

codistributed.pVerifyUsing1d('padLocalX', X);
szLeftPad = 0;
localX = getLocalPart(X);
if max(padSz) < 1
    return
end

[localX, szLeftPad] = stencilCommPad(X, padSz);
end
