title: Convert FORTRAN DEC UNION/MAP extensions to anything else
body: <p><strong>Edit: Gfortran 6 now supports these extensions :)</strong></p>
  
  <p>I have some old f77 code that extensively uses UNIONs and MAPs.  I need to compile this using gfortran, which does not support these extensions.  I have figured out how to convert all non-supported extensions except for these and I am at a loss.  I have had several thoughts on possible approaches, but haven't been able to successfully implement anything.  I need for the existing UDTs to be accessed in the same way that they currently are; I can reimplement the UDTs but their interfaces must not change.</p>
  
  <p>Example of what I have:</p>
  
  <pre><code>TYPE TEST
    UNION
      MAP
        INTEGER*4 test1
        INTEGER*4 test2
      END MAP
      MAP
        INTEGER*8 test3
      END MAP
    END UNION
  END TYPE
  </code></pre>
  
  <p>Access to the elements has to be available in the following manners: TEST%test1, TEST%test2, TEST%test3</p>
  
  <p>My thoughts thusfar:</p>
  
  <ol>
  <li>Replace somehow with fortran EQUIVALENCE.</li>
  <li>Define the structs in C/C++ and somehow make them visible to the FORTRAN code (doubt that this is possible)</li>
  </ol>
  
  <p>I imagine that there must have been lots of refactoring of f77 to f90/95 when the UNION and MAP were excluded from the standard.  How if at all was/is this handled?</p>
  
  <p>EDIT: The accepted answer has a workaround to allow memory overlap, but as far as preserving the API, it is not possible.</p>