Dear Xing,
It appears that for some reason when you stop your Simulink simulation, it is not properly calling the FAST_End() routine to deallocate memory and close files. But I’m not sure why this is the case. Does the model run fine a second time when the Simulink simulation ends properly i.e. when simulation time TMax is reached?
An error generated by the ALLOCATE() function implies that your computer does not have enough memory to allocate the array e.g. because the memory was not deallocated properly in a prior simulation. Closing and restarting MATLAB should fix the problem in this case.
Best regards,