function runprop = communicatingDecodeFcn(runprop)
%parallel.cluster.generic.communicatingDecodeFcn Prepare a worker to run a MATLAB task in a communicating job

% Copyright 2011-2022 The MathWorks, Inc.

dctSchedulerMessage(2, 'In parallel.cluster.generic.communicatingDecodeFcn');

% Read environment variables into local variables. The names of
% the environment variables were determined by the submit function
storageConstructor = parallel.internal.cluster.getParallelServerEnv('PARALLEL_SERVER_STORAGE_CONSTRUCTOR');
storageLocation    = parallel.internal.cluster.getParallelServerEnv('PARALLEL_SERVER_STORAGE_LOCATION');
jobLocation        = parallel.internal.cluster.getParallelServerEnv('PARALLEL_SERVER_JOB_LOCATION');
% For a communicating job, the task location is derived from spmdIndex
taskLocation = fullfile(jobLocation, sprintf('Task%d', spmdIndex));

% Set runprop properties from the local variables:
set(runprop, ...
    'LocalSchedulerName', 'parallel.cluster.TaskRunner', ...
    'StorageConstructor', storageConstructor, ...
    'StorageLocation', storageLocation, ...
    'JobLocation', jobLocation, ...
    'TaskLocation', taskLocation);
