https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113313
--- Comment #9 from john.harper at vuw dot ac.nz --- This variant of my test program (now called test4) hangs with gfortran but not with other compilers if iam is written to output_unit (like the original version) or to a file with a different positive unit number, but it does not hang if written to a file with a negative unit number obtained by opening it with newunit=u. Its user has those 3 choices at run time. I hope it helps you explore this oddity of gfortran. program test4 use iso_fortran_env, only: output_unit ! Linux with f2008 (newunit=, execute_command_line, allocatable scalar) implicit none integer:: u = output_unit+20 character:: ch*1, line(2)*80 print "(A)",'Output from iam will go to unit u;', & ' u=output_unit if you enter a, or',& ' unit=u (u>0) if you enter b, or',& ' newunit=u (u<0) if you enter anything else.' read "(A)", ch if(ch=='a') then u = output_unit else if(ch=='b') then open( unit=u,file='test4.out') else open(newunit=u,file='test4.out') end if print "(A,I0)",'Output from iam will be written to unit ',u write(u,"(A,L2)")'I am john',iam('john') write(u,"(A,L2)")'I am JOHN',iam('JOHN') if(u/=output_unit) then rewind u read(u,"(A)") line print "(A)", line close(u,status='delete') end if contains logical function iam( name) character(*),intent(in)::name integer estat character(:),allocatable:: cmd cmd = 'if [ `whoami` != "'//name//'" ]; then exit 1; else exit 0; fi' call execute_command_line(cmd,exitstat=estat) iam = (estat==0) end function iam end program test4 -- John Harper, School of Mathematics and Statistics Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand. e-mail john.har...@vuw.ac.nz