title: gfortran: multiple definitions of... first defined here
body: <p>I have code that includes main program and many modules in separate files that I am linking. Currently I have a makefile that creates .o files for each module (one on separate line) and then I put them all together, such as here:</p>
  
  <pre><code>mpif90 - modutils
  mpif90 -c modvarsym
  mpif90 -c s1_Phi.f90
  mpif90 -c s2_Lambda.f90
  
  mpif90 maincode.f90 modutils.o modvarsym.o  s1_Phi.o s2_Lambda.o -o maincode 
  </code></pre>
  
  <p>The above compiles fine and runs OK - except tat I suspect that I suspect array bound problems in my variables. So I include -fbounds-check maincode statement such as here:</p>
  
  <pre><code>mpif90 maincode.f90 modutils.o modvarsym.o  s1_Phi.o s2_Lambda.o -o -fbounds-check maincode 
  </code></pre>
  
  <p>That's when numerous "multiple definition" errors appear, and the code will no longer compile. I imagine that is because of -fbounds-check: rather than just enabling checking for array bounds, it probably does some additional checks. I also suspect that the error is in the way that I enter files in the make file. However I could not find the way that would work. In these files, both modvarsym and modutils is used by the main code as well as by the other two modules. The main code uses all four modules. 
  There is no include statement in these files. Maincode is the only file with the program statement, the variables are declared only once in modvarsym. Overall, the code compiles and runs without -fbounds-check. However I really want to use -fbounds-check to make sure the arrays do not overrun. Would anybody be able to put me on the right track? Thank you.</p>