Output from the submodel
By default, submodels use the same location for their output as their parent model. This implies that, when several (sub)models are run in parallel their output, for example on screen, is likely to mix up. The best way to handle this situation is to redirect the output from each model to a separate file.
Output may be redirected directly within the submodel with statements like the following added to the model before any output is printed:
fopen("testout.txt", F_OUTPUT+F_APPEND) ! Output to file (in append mode) fopen("tee:testout.txt&", F_OUTPUT) ! Output to file and on screen fopen("null:", F_OUTPUT) ! Disable all output
where the first line redirects the output to the file testout.txt, the second statement maintains the output on screen while writing to the file at the same time, and the third line makes the model entirely silent. The output file is closed by adding the statement fclose(F_OUTPUT) after the printing statements in the model.
The same can be achieved from the master model by adding output redirection before the run statement for the corresponding submodel ('modSub'), such as:
setdefstream(modSub, F_OUTPUT, "testout.txt") ! Output to file setdefstream(modSub, F_OUTPUT, "tee:testout.txt&") ! Output to file and on screen setdefstream(modSub, F_OUTPUT, "null:") ! Disable all output
The output redirection for a submodel may be terminated by resetting its output stream to the default output:
setdefstream(modSub, F_OUTPUT, "")