title: Correctly Building Fortran Libraries And Using Them To Build Applications
body: <p>I found a few previous questions regarding this, but was unable to find something specific for advice on correctly associating libraries and module files <code>*.mod</code> in a Makefile. 
  I have a project directory named <code>project</code> where all source files for a library are in <code>project/src</code>, all compiled <code>*.mod</code> files are placed in <code>project/include</code>, and static libraries are created into the directory <code>project/lib</code> using the following:</p>
  
  <pre><code>ar rc myLibrary.a module1.o module2.o module3.o
  </code></pre>
  
  <p>Following this, I create an application code (a Fortran program that uses these libraries) in the directory <code>project/applications</code>. I have now, at the root level (that is, inside <code>project</code>) created a simple shell script that can build the application. This part is where I cannot get the process to work. </p>
  
  <p>Here is what I am doing:</p>
  
  <pre><code>INCLUDELIB='./include'
  LINKLIB='./lib'
  INCLUDEOTHER=&lt;include directories for other math libraries&gt;
  LINKOTHER=&lt;link directories and link flags for other math libraries&gt;
  COMPILER='ifort'
  COMPOPTS=&lt;compiler flags, currently I use none&gt;
  # building the application:
  $COMPILER $COMPOPTS -c ./applications/application.f90 -I$INCLUDELIB $INCLUDEOTHER -L$LINKLIB $LINKOTHER
  $COMPILER $COMPOPTS application.o -I$INCLUDELIB $INCLUDEOTHER -L$LINKLIB $LINKOTHER -o application.out
  </code></pre>
  
  <p>This procedure does not work, and it gives <code>Error in opening the compiled module file.  Check INCLUDE paths.</code></p>
  
  <p>I tried a few variants of the above from my readings on the web about this, and I hope that it is not some minor/silly error that I am overlooking that is leading to this. </p>
  
  <p>Any help or advise will be much appreciated.</p>