title: ISO_C_BINDING: Impact on performance/optimization
body: <p>In the context of MPI with derived data types, I've been told to be careful when using the <code>bind(C)</code> construct as it inhibits certain optimizations of the compiler. Consider this (rather unlikely example):</p>
  
  <pre><code>type, bind(C) :: myType
    integer(2) :: a
    complex    :: z
    integer(2) :: b
  end type myType
  </code></pre>
  
  <p>Without the <code>bind(C)</code> statement the compiler would probably reorder the structure and group the two integers for better alignment. Especially for large structures and when trying to use auto-vectorization this will be beneficial. </p>
  
  <p>With <code>bind(C)</code>, this regrouping is impossible (to stay compatible to <code>C</code>, where the compiler probably won't optimize that much). This would either lead to a large memory consumption (three words instead of two) if all elements are aligned to words, or to a loss of alignment. (At least, so I've been told. )</p>
  
  <p>Until recently, I have never mixed C and Fortran, and I have never used derived types for MPI communications. In the near future, I'm going to look into mixed language programming, and these issues seem to be important. </p>
  
  <p>So my question is two-fold:</p>
  
  <ul>
  <li><code>bind(C)</code>: Does this misalignment play a role in "real-world" applications? Has anyone experienced performance/optimization issues here?</li>
  <li><code>iso_c_binding</code>: Are there additional pitfalls when (additionally) using the module <code>iso_c_binding</code>? Which restrictions are imposed on the code and which optimizations are disabled?</li>
  </ul>