title: Function call stopping/hanging when containing a write-statement, but only when linking with certain libraries during compilation
body: <p>Here is my minimal example:</p>
  
  <pre><code>program test    
    implicit none
    real :: testfunc
    write(*,*) "Writing from main"
    write(*,*) testfunc()
  end program test
  
  function testfunc() result(y)
    real             :: y
    write(*,*) "Write from function g"
    y=1.0
    return
  end function testfunc
  </code></pre>
  
  <p>When compiling with a simple</p>
  
  <pre><code>gfortran test.f90
  </code></pre>
  
  <p>or when including a library like Slatec</p>
  
  <pre><code>gfortran test.f90 -lslatec
  </code></pre>
  
  <p>It works fine.</p>
  
  <p>However, when changing the library to -llapack of -lblas, then the program hangs at runtime 
  when calling testfunc(). Note that my example code here does not actually use any of these libraries. The last thing i see is "Writing from main", then nothing happens, and i have to CTRL-C to regain control. When hanging, the process does not appear to be using any CPU cycles.</p>
  
  <p>The strange thing now is that, if i comment out the write statement inside testfunc(), it works all the time.</p>
  
  <p>So my question is really: Can these libraries really prevent me from printing inside my own functions? Why? How?</p>
  
  <p>(I'm actually working on a larger program which needs lapack and blas, so i obviously can't just stop linking to them.)</p>