Basically I am running multiple threads at the same time from the same directory, which means that the individual threads are overwriting or deleting the solid.txt file.
As simple fix so that files from multiple threads would not conflict would be to make the file names unique with something like.
import uuid
txt_file = os.path.abspath(f’solid.{uuid.uuid1().hex}.txt')
if os.path.isfile(txt_file):
os.remove(txt_file)
No need to change soon on my account, I found a workaround but others might run into a similar problem in a production environment.
This unique TXT filename should be passed to the Fortran code directly as a function argument.
A bug found with a solution suggested by @fastice:
This unique TXT filename should be passed to the Fortran code directly as a function argument.