https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113313
--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Thu, Jan 11, 2024 at 07:03:05AM +0000, john.harper at vuw dot ac.nz wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113313 > > --- Comment #2 from john.harper at vuw dot ac.nz --- > Thank you! You may wish to know that in my Ubuntu system the program > runs properly if the function iam is used in an assignment statement not a > print statement. Interesting. One of the first things that the internal implementation does is /* Flush all I/O units before executing the command. */ flush_all_units(); libgfortran is supposedly thread-safe and looking into flush_all_units() shows some unlocking and testing for locks. With 'print *, iam('john')', there may be lock contention.