Added safety checks to fopen() calls that did not have them.
Opening a file for writing (e.g. fopen("example.txt", "w")
) almost always works, and because of that we have been sloppy checking the fopen()
return value in the past. Some recent crashes of the big FLAMINGO run have shown that this is not a good idea: writing to a NULL
file pointer (which is what you get if fopen()
fails) leads to a segfault with no indication that it is a file issue. This merge request adds appropriate checks to all fopen()
calls that did not have one yet, so that file opening issues will always lead to a crash with a useful error message.
Note that fopen()
can fail to create a file if
- the process has no write access to the folder
- the file already exists and the process has no write access to it
Both issues could occur if multiple users submit jobs for the same simulation, as was the case for FLAMINGO.
Edited by Bert Vandenbroucke