% Example skeleton code for parpool

% Set max usable threads to be equal to how many cores were granted for our job
NSLOTS = str2num(getenv('NSLOTS'));
maxNumCompThreads(NSLOTS);

% Check to see if we already have a parpool, if not create one with our desired parameters
poolobj = gcp('nocreate');
if isempty(poolobj)
	myCluster=parcluster('local');
	%Necessary so multiple parpool jobs don't overwrite other's temp files
	myCluster.JobStorageLocation = getenv('TMPDIR');
	poolobj = parpool(myCluster, NSLOTS);
end

% Now we can do our parallel stuff
parfor (i = 1:10, NSLOTS)
    disp("li "+num2str(labindex))
    disp("it "+num2str(i))
end
