Closed rtrepos closed 2 years ago
Output files (files *.value) of the SPAWN simulation are not created when simulation fails. The CMD works well yet and creates the output file: "vle.exe --write-output res.value model.vpz"
It looks like the vpz is not written soon enough before the simulation is launched. The writing of the vpz is here :
A way around is to add the two followinfg lines just after the previous line :
using namespace std::chrono_literals;
std::this_thread::sleep_for(2000ms);
This suggests that there is a missing flush of the output stream when writing the vpz file. Nevertheless, when the flush is added at all possible locations, there is stille the error.
The simulation works. This suggests that the writing of the vpz is not the problem.
THe initialisation of the random number generator is done differently on Windows with std::time(0)
THis is maybe due to an old bug on std::random_device (see the Note of the documentation). Replacing std::time(0) by std::random_device (same code for linux and windows) fixes the probelm. I will propose the commit.
Most of the time, launching a spawned simulation leads to the following exception :
error: VLE sub process: unable to start 'C:\Users\rtrepos\AppData\Local\Temp\vle-aec8-3b60-033b-g9g3.vpz' in 'C:\Users\rtrepos\Documents' with the 'vle.exe -V '5' --write-output 'C:\Users\rtrepos\AppData\Local\Temp\vle-aec8-3b60-033b-g9g3.value' 'C:\Users\rtrepos\AppData\Local\Temp\vle-aec8-3b60-033b-g9g3.vpz'' command (Path::file_size(): cannot stat file C:\Users\rtrepos\AppData\Local\Temp\vle-aec8-3b60-033b-g9g3.value) error: fail to run
This error is caught here :
https://github.com/vle-forge/vle/blob/d163b23b19aa7fe63f51649d597772ec227b8913/src/vle/manager/Simulation.cpp#L281
This occurs with both gvle and rvle. Note also that sometimes the same simulation can work.