Question: Maple API - Simulate ("...too many files opened.")

Hi all,

A while ago, I had asked a question relating to calling to an MapleSim .msim simulation within maple .mw worksheet. (Thank you Acer! :) I got it working but then another issue just popped up...The basic structure is as follows:

********************************************************************

A := MapleSim:-LinkModel('filename' = "TriplePendulum_WORKS_v2.msim")

for z from 1 to 50 do

     initialize_variables;

     resultpack:=fopen(cat("myfile_",convert(z,string),".txt"),WRITE,TEXT):

     for y from 1 to 50 do

          myresults:= A:-Simulate(...,params = [...]);

          retrieve_results_and_updateVariables;

          fprintf(resultpack,"%a %a %a \n", result1, result2, result3);

     end do;

     fclose(resultpack);

end do;

*******************************************************************

The script executes without any issues for 'small' iterations. However, for large iteration for-loops (i.e. 1000+ cycles), it runs into "too many files open" error. Investigating further, I discovered the command iostatus( ) that lists all files open. Thus, the message that I saw was:

*******************************************************************

[478, 0, 448, [1, "C:\DOCUME~1\rwong\LOCALS~1\Temp\maplesim3075023763175332657.msys", STREAM, FP = 2015108088, WRITE, TEXT], [2, "C:\DOCUME~1\rwong\LOCALS~1\Temp\maplesim1625722222573516433.msys", STREAM, FP = 2015108120, WRITE, TEXT], [3, "C:\DOCUME~1\rwong\LOCALS~1\Temp\maplesim6198839605748543298.msys", STREAM, FP = 2015108152, WRITE, TEXT], ...]]

*******************************************************************

It seems that everytime A:-Simulate calls the msim file, it opens a new I/O file of type .msys. However, I'm not able to close this. Therefore, for high iteration cycles, the script/Maple crashes. I've tried digging around the Maple and Mapleprime's website but to no success. I'm able to close my own I/O files but the .msys are generated behind the scene.

Any thoughts/Ideas? 

Regards,

Ron.

Please Wait...