function outputLevel = userMessageDetail(detailLevel)
; %#ok undocumented
% private function used by mpiprofile command to store -messagedetail
% settings to allow users to change the default setting on a separate
% command line.
%   Copyright 2007-2022 The MathWorks, Inc.

import parallel.internal.profiler.types.MessageDetail
persistent dL;
DEFAULT_MSG_DETAIL = MessageDetail.Default;

if nargin > 0 && detailLevel.isValidCallstatsMessage()
    dL = detailLevel;
elseif isempty(dL) || (nargin > 0 && detailLevel == MessageDetail.Reset)
    % the default message detail level 
    dL = DEFAULT_MSG_DETAIL;
end

if nargout > 0
    outputLevel = dL;
end
% lock the current file
mlock;
