- Wrap everything inside your “parfor” in a function. Then you can create an “if” condition to run the “parfor” loop only when the “Parallel” flag is set to 1. This will enable you to edit and debug your code in the function and before codegen you can set the “Parallel” flag to 0. Belos is a sample code snippet to achieve this:
- Instead of “parfor” you can use “parfeval” function. This allows you to use the “Diary” property of each “parallel.Future” instance which you can log according to you needs. Please refer to the following MATLAB Answer to understand more about this approach - https://www.mathworks.com/matlabcentral/answers/380044-logging-parellel-pool-worker-diaries-to-single-file

