Saving files within parfor loop with every iteration

10 ビュー (過去 30 日間)
Josh
Josh 2013 年 11 月 21 日
コメント済み: Felipe Rincón 2023 年 3 月 10 日
Hello and thanks for reading. I am trying to utilize Matlab's convenient parallelization toolbox for some Monte-Carlo sampling (each sample is independent). Unfortunately, I don't think it is possible for my particular problem and would like an expert opinion. My problem is such:
parfor i=1:NSamples
"Generation of Required Files for External Program Execution"
save '/local_directory/New_file' New_Matrix -ACSII
"Execution of External Programs" % Uses 'New_file' for execution
Data = importdata('data.out',delimiterIn,headerlinesIn); % Import data from execution of
% external program.
"Analysis in MATLAB"
save '/local_directory/results' from_analysis -ACSII % This is not necessary but I would
% like to be able to check progress as
% the calculations take days.
end
There is no way of getting around not saving a new file for the external programs. Is it possible to use a 'parfor' loop when saving files to a local directory is necessary? I appreciate any assistance in this matter.
best, josh
  1 件のコメント
Felipe Rincón
Felipe Rincón 2023 年 3 月 10 日
Hi Josh, did you managed to solve this issue?

サインインしてコメントする。

回答 (1 件)

Edric Ellis
Edric Ellis 2013 年 11 月 22 日
I presume the problem is that saving data to the disk is causing clashes. You need to make each worker write its results to a separate file. See this answer for more details:

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by