Files
imdd_silas/projects/WDM/WDM_settings.m
Silas Oettinghaus cbfdf4d222 wdm update pt 3
2025-09-17 15:16:55 +02:00

34 lines
1.2 KiB
Matlab

% Add the imdd_simulation framework to the path
if ispc
addpath(genpath('C:\Users\Silas\Documents\MATLAB\imdd_simulation'));
else
% Linux path on the cluster
addpath(genpath('/work_beegfs/sutef391/imdd_simulation'));
end
% Quiet the ambiguous CET warning (best is to set TZ in sbatch; see below)
warning('off','MATLAB:datetime:AmbiguousTimeZone');
% How many workers?
cpus = str2double(getenv('SLURM_CPUS_PER_TASK'));
if ~isfinite(cpus) || cpus < 1, cpus = max(1, feature('numcores')); end
% Use a per-job, node-local JobStorageLocation to avoid stale locks on $HOME
% Prefer $TMPDIR if your cluster provides it, else tempdir().
tmpbase = getenv('TMPDIR');
if isempty(tmpbase), tmpbase = tempdir; end
jsl = fullfile(tmpbase, sprintf('matlab_jobstorage_%s_%s', ...
getenv('USER'), getenv('SLURM_JOB_ID')));
if ~exist(jsl,'dir'); mkdir(jsl); end
% Configure the local cluster explicitly and start the pool
c = parcluster('local');
c.NumWorkers = cpus;
c.JobStorageLocation = jsl;
p = gcp('nocreate');
if isempty(p) || p.NumWorkers ~= cpus
if ~isempty(p), delete(p); end
p = parpool(c, cpus); % avoids the “queued” state
end
fprintf('parpool up with %d workers; JobStorage=%s\n', p.NumWorkers, c.JobStorageLocation);