Added warning macro that flushes immediately and writes to the standard error.
During recent debugging efforts, the need has arisen for an alternative to the message()
macro that is flushed immediately.
An example scenario where this could be useful is tracing the origin of an unphysical variable, e.g. a high temperature. If the high temperature is caused by a weird value of another variable, then crashing the code where the high temperature occurs is not very helpful, since the original cause might no longer be traceable at that point. Crashing the code earlier is also not ideal, since then it might be hard to show that a high temperature would occur in the future, assuming you would know where to crash in the first place. In this case, having a warning message printed out whenever a potential cause of the high temperature triggers earlier can help identify the chain of events.
In order for this to work, warning messages need to be printed out before a crash happens, which is not necessarily the case for messages written by the message()
macro. The alternative macro implemented by this MR provides this functionality. warning()
messages contain the string WARNING
(to make them grep
able) and are written to the standard error, which ensures that they are flushed immediately.