segfault with inquire()
N.M. Maclaren
nmm1@cam.ac.uk
Tue Dec 3 19:48:00 GMT 2019
On Dec 3 2019, Andrew Benson wrote:
>
> I'm attempting to track down a segfault that seems to be associated with
> the inquire() statement. Unfortunately it only happens when running a
> massively parallel code, using both MPI and OpenMP parallelism, and I
> have as yet been unable to make a simple test case that reproduces the
> bug. I also haven't convinced myself 100% that the problem is really in
> the libgfortran code for inquire() and not in my own code, but since it
> seems that inquire() should be thread safe it seems that the problem at
> least could be in libgfortran.
Well, that's an assumption and a half! A good principle is to assume that
no I/O is thread-safe, not even in C/C++/POSIX (which specify it to be).
If you had a race condition between INQUIRE and anything else that changed
what files were open or anything that operated on the file you looked at,
I would expect trouble.
The Fortran standard does not have threading, and says nothing about it.
And the OpenMP specification is a complete mess in this respect.
Unfortunately, TPTB have pulled the plug on my Web pages and I haven't
arranged another server, so I can't point you at my course. But I quite
strongly advise synchronising all I/O, though there are some short cuts
that are fairly safe.
Regards,
Nick Maclaren.
More information about the Fortran
mailing list