title: Compiler agnostic fortran name mangling function
body: <p>I am dynamically linking to a fortran static object and need to be able (at run time) to take the name of the fortran function (which is a C++ string) and name mangle it appropriately for the compiler. Is there any pre-built function that would serve this purpose? In the statically linked case I am using autoconf's FC_FUNC.</p>
  
  <p>For clarity, I want a function that would be able to take a string, interpret it as a fortran subroutine name and mangle it appropriately for the given compiler. In psuedo-C++,:</p>
  
  <pre><code>std::string subroutine = "FORTRANSUBROUTINE";
  std::string symbol     = FortranMangle(subroutine);
  
  std::cout &lt;&lt; symbol &lt;&lt; endl; // Would output something like "fortransubroutine_"
  </code></pre>
  
  <p>I do not know all of the used name mangling schemes to write this mysterious "FortranMangle" function, myself.</p>