title: Call a subroutine from a DLL in a Fortran program
body: <p>I wish to make use of a subroutine in a DLL for my research. The dll is provided to me as a blackbox and can be used in a leading FE software. </p>
  
  <p>I executed the following code for the dll </p>
  
  <pre><code>dumpbin /EXPORTS UDSM_HPS.dll &gt; UDSM_HPS.exports
  </code></pre>
  
  <p>and ended up with the following subroutine </p>
  
  <pre><code>2    0 00020D50 _getmodelcount@4
  4    1 00020D60 _getmodelname@12
  6    2 00020E50 _getparamcount@8
  8    3 00020E80 _getparamname@16
  10    4 00021AE0 _getparamunit@16
  12    5 00001010 _user_mod@124
  1    6 00020D50 getmodelcount
  3    7 00020D60 getmodelname
  5    8 00020E50 getparamcount
  7    9 00020E80 getparamname
  9    A 00021AE0 getparamunit
  11    B 00001010 user_mod
  </code></pre>
  
  <p>My interest lies in the '<strong>user_mod</strong>' subroutine. I created a .lib file from the .def file, by adding 'EXPORTS' in the beginning of the file and isolating the subroutine names, using the following code</p>
  
  <pre><code>lib /def:UDSM_HPS.def /out:UDSM_HPS.lib
  </code></pre>
  
  <p>and attached the .lib file to the 'Resourse Files' to my Visual Studio 2013, while placing a copy of my .dll to my 'Debug' folder. </p>
  
  <p>No surprises here, the 'user_mod' subroutine is not seen by the compiler.</p>
  
  <p>Now My question, am I missing something, or is there a differnt way of utilising the subroutine from the dll?</p>
  
  <p>The dll is written in FORTRAN too, and I have written a simple piece of FE code in FORTRAN to run this subroutine. </p>
  
  <p>Long story short: Any assistance is figuring out how to utilise a FORTRAN dll in FORTRAN program is much appreciated. </p>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>I am using the Intel Fortran compiler - Intel(R) Visual Fortran Compiler XE 15.0.6.285 [IA-32]. I had tried compiling the same piece of code in Intel(R) Fortran Compiler 10.1.021 [IA-32], but in vain. </p>
  
  <p>The subroutine I intend to call is </p>
  
  <pre><code>call user_mod(IDTask, iMod, IsUndr, iStep, iTer,&amp; 
      iEl, Int, X, Y, Z, Time0, dTime, Props, Sig0, Swp0, StVar0,&amp; 
      dEps, D, BulkW, Sig, Swp, StVar, ipl, nStat, NonSym, iStrsDep,&amp;
      iTimeDep, iTang, iAbort)
  </code></pre>
  
  <p>To clarify my rather vague sentence of 'not seen by the compiler', I meant this error </p>
  
  <blockquote>
    <p>Error 1    error LNK2019: unresolved external symbol USER_MOD referenced in function PLAXIS_DLL_INTF  interface_files.obj </p>
  </blockquote>
  
  <p><strong>Edit 2:</strong>
  Thanks for the all the help.
  Adding </p>
  
  <pre><code>!DEC$ ATTRIBUTES STDCALL,REFERENCE :: USER_MOD
  </code></pre>
  
  <p>was all that was needed to get my code going. Code is behaving like how it should now. </p>