I am forever indebted to Salem from cboard.cprogramming.com for his tireless efforts and patience while helping a complete stranger debug their code. You can find the relevant thread here: https://cboard.cprogramming.com/c-programming/172520-debugging-multi-threaded-code-openmp.html