Execute_command_line problem

This is the same behavior that one sees when recursive i/o is invoked. Based on that observation, if you change the main program to

   logical :: q
   q = iam('john')
   print "(A,L2)", 'I am john', q
   q = iam('JOHN')
   print "(A,L2)", 'I am JOHN', q

then I think the code will work (it does on MacOS+gfortran). Of course, the code is not doing recursive i/o, so this appears to be some kind of compiler or library bug.

[edit] I experimented a little more with this. It appears that the error has nothing to do with the execute_command_line intrinsic. If you comment out that call, the program still hangs. I also experimented a little with constructing the cmd string with substring indexing and assignments,

    cmd(1:18) = 'if [ `whoami` != "'
    cmd(18+1:18+len(name)) = name
    cmd(19+len(name):) = '" ]; then exit 1; fi'

and the program still hangs. If you eliminate cmd, and just insert the expression as the subroutine argument, it still hangs. I don’t see anything wrong with either the original code or any of these modified versions, they all look alright to my eye. One can disagree with the concept of executing functions just for side effects (i.e. a subroutine might be better), but the language allows this so it looks like it should work.