Skip to main content

Hi, 



I've recently experienced an issue when using ZPL/Zrdplayback command for optimizing a non sequential system. 



The local optimizer/orthogonal descent, worked fine, but the two global optimizers (Global search & Hammer) stopped at the start of the optimization process with the following error message 'Unable to save file...'. 



I've found a design file in this forum showing the same behavior (please check the attached file). I suspect that the problem arises when  several variations of the initial model are generated and attempt to create and/or read the rayfile from the ZPL macro.



Could you please comment and propose a fix that would ideally, preserve the call to zrdplayback?  



Thank you



 

Hi Olivier,



I think you're right about the problem. It looks like when the system is copied across the different threads, the error appears. While both the Hammer and Local optimizer are set up to be multi-threaded, it is often the case that the cost to produce copies of the system data across threads in the Local optimizer outruns the benefit of running any pieces of the computation in parallel. As such, it is likely that the Local optimization routine remained single threaded while you used it and was therefore able to avoid this error.



To continue using this ZPLM, you will need to change the settings of the Hammer optimization so that it is only using 1 core. That means that only 1 copy of the file is being created. I don't see another way to get around this error as text files are not able to be opened by multiple sources at one time.



Best,



Allie


If the macro is being called ina multi-threaded manner, use $TEMPFILENAME() to get a temporary file name inside the macro. That way, each copy gets its own file.



 




Mark,



That's a great idea. I didn't think of that. In this case, the macro solve will probably need to be updated to delete the temp file at the end. Otherwise we could run into a memory allocation error if the Hammer optimization is run too long. Since the data from the temp file is already stored as variable 'X' in the provided sample, deleting the ZRD file shouldn't be a problem. 



Thanks Mark!



Allie


Hi Allie, Mark, 



Thanks, that works like a charm!



Olivier


Hi Allie, Mark,

I am experiencing a problem similar to Olivier's: NONSEQ system, optimization routine which calls a ZPLM macro, data on a detector are saved to .ZRD file, then ZRDPLAYBACK is applied to the .ZRD output.

The macro works perfectly for a single raytracing run, or when updating the merit function. But, when optimizing or running a tolerance analysis on multiple threads, I get the “Unable to save file” alert. The only solution so far is to run on a single thread.

It is not clear to me how $TEMPFILENAME() can be used in this context and applied to the .ZRD output. Could you provide an example?

I attached an example of macro that I use in my case,

Thank you and kind regards,


Reply