We are working on adding some multithreading to a segment of our product which involves managing several files in the background. While working on this we found that occasionally, the program would end up deadlocked with one thread sitting in OPEN and another in INQUIRE.
I attached a small sample program that replicates our problem. Two threads are created on the C++ side and for simplicity, each thread will then loop though a list of file names. In the loops are the calls to a Fortran wrapper subroutine around the OPEN and INQUIRE calls, one loop for each. Without any modifications, this program seems to lock up immediately as OPEN and INQUIRE try to run on the first file listed. However, to test if it is only locking when using the same file, lines are added to delay the execution of either or both threads. When doing this one can see that a deadlock can occur regardless of what file OPEN or INQUIRE are using so long as they are attempting to execute at the same time.
Please update to the current compiler release. It's part of oneAPI 2022.2. I know that there are bug fixes regarding I/O since PSXE 2019.
If you are a registered user with Intel Registration Center (IRC), you should have received an email in the last 24 hours announcing its availability.
Otherwise, you can download it from here. The Fortran compiler is part of the oneAPI HPC Toolkit.
I suggest updating to VS2019, too.