title: Compiling a 32 bit fortran program on 64 bit Ubuntu 14.04
body: <p>I have a 32 bit fortran code that I need to compile on a 64 bit machine. I researched and found that it is possible to do it. I installed gfortran-multilib to compile it. But I got errors like this:</p>
  
  <pre><code>gfortran -lm bessj.o bessj0.o bessj1.o bessj2.o caxcb.o cgemp.o cmemcpy.o   four1.o gemp.o getdata.o qsbstab.o qsfftinv.o qshkpsv.o qshksh.o qskern.o qslayer.o qsmainC.o qsmatinv.o qsmatrix.o qsmoment.o qspsv.o qsqmodel.o qssh.o qssublay.o qswaveno.o qswvint.o wavelet.o -o qsmainC.0
  /usr/bin/ld: i386 architecture of input file `bessj0.o' is incompatible with i386:x86-64 output
  /usr/bin/ld: i386 architecture of input file `bessj2.o' is incompatible with i386:x86-64 output
  /usr/bin/ld: i386 architecture of input file `caxcb.o' is incompatible with i386:x86-64 output
  /usr/bin/ld: i386 architecture of input file `cgemp.o' is incompatible with i386:x86-64 output
  </code></pre>
  
  <p>Then I used -m32 flag as suggested in one of the threads here in stackoverflow. And I found out that some of the subroutines have 32-bit architecture while some have 64-bit architecture. I am getting error for the other files now, like this:</p>
  
  <pre><code>gfortran -m32 -lm bessj.o bessj0.o bessj1.o bessj2.o caxcb.o cgemp.o cmemcpy.o four1.o gemp.o getdata.o qsbstab.o qsfftinv.o qshkpsv.o qshksh.o qskern.o qslayer.o qsmainC.o qsmatinv.o qsmatrix.o qsmoment.o qspsv.o qsqmodel.o qssh.o qssublay.o qswaveno.o qswvint.o wavelet.o -o qsmainC.0
  /usr/bin/ld: i386:x86-64 architecture of input file `bessj.o' is incompatible with i386 output
  /usr/bin/ld: i386:x86-64 architecture of input file `bessj1.o' is incompatible with i386 output
  /usr/bin/ld: i386:x86-64 architecture of input file `four1.o' is incompatible with i386 output
  /usr/bin/ld: i386:x86-64 architecture of input file `qsfftinv.o' is incompatible with i386 output
  </code></pre>
  
  <p>Is there any way to compile this code? Can someone please suggest?</p>