title: Fortran and OpenMP: Why are OpenMP directives not allowed inside pure procedures?
body: <p>I currently use OpenMP to parallelize a legacy application. During my work we added INTENTs to parameters of subroutines and functions which are meant to be called in parallel threads and used extensively the keywork pure to get the compiler to check for side-effect free code for functions and subroutinges to be sure not to change any global state.</p>
  
  <p>Now it came to my attention, that within the OpenMP standard (including the 4.0 draft) it is written: </p>
  
  <blockquote>
    <p>"Fortran Restrictions: The following restriction applies to all OpenMP
    directives: • OpenMP directives may not appear in PURE or ELEMENTAL
    procedures."</p>
  </blockquote>
  
  <p>Why is that so? Especially INTENT and pure are great tools to force the compiler to check for side-effect-free code. Why is it not allowed to be combined? What is the technical reason behind it? </p>
  
  <p>The currently implemented code compiles and runs bug free, without any complains and it is really running in parallel, as we can see it with tools and the process management tools.</p>
  
  <p>If it is not working that way, how can we utilize the compiler to check for side-effect-free code and run it in parallel with OpenMP? The current application make extensive use of (changed) global state for runtime control which we need to identify.</p>
  
  <p>It was tested mostly with Intel Fortran Compiler (ifort).</p>