title: gfortran can't find OpenMP library (omp_lib.mod) using MinGW
body: <p>I am trying to compile a Fortran code including OpenMP. I am replicating the use of OpenMP from a different code. It built successfully once yesterday and then the next time I built it I get the following error:</p>
  
  <pre><code>../MAXBRG3D.f90:3:4:
  
   USE OMP_LIB      ! USED WITH OMP FUNCTIONS
      1
   Fatal Error: Can't open module file 'omp_lib.mod' for reading at (1): No such file or directory
  compilation terminated.
  subdir.mk:329: recipe for target 'MAXBRG3D.o' failed
  make: *** [MAXBRG3D.o] Error 1
  </code></pre>
  
  <p>The only changes I made to the code where to comment out a few sections of code unrelated to the OpenMP capabilities. I have since removed the comments but am still getting the same error. My compilation command is as follows.</p>
  
  <pre><code>gfortran -funderscoring -O0 -g -Wall -c -fmessage-length=0 -fopenmp -o "MAXBRG3D.o" "../MAXBRG3D.f90"
  </code></pre>
  
  <p>I have seen the following link: <a href="https://stackoverflow.com/questions/44630301/gfortran-cant-find-openmp-library-omp-lib-mod-under-mingw">gfortran can&#39;t find OpenMP library (omp_lib.mod) under MinGW</a>
  and when I run <code>gfortran -v, --enable-libgomp</code> does show up.</p>
  
  <pre><code>&gt;gfortran -v
  Using built-in specs.
  COLLECT_GCC=gfortran
  COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/6.3.0/lto-wrapper.exe
  Target: mingw32
  Configured with: ../src/gcc-6.3.0/configure --build=x86_64-pc-linux-gnu --host=mingw32 --with-gmp=/mingw --with-mpfr=/mingw --with-mpc=/mingw --with-isl=/mingw --prefix=/mingw --disable-win32-registry --target=mingw32 --with-arch=i586 --enable-languages=c,c++,objc,obj-c++,fortran,ada --with-pkgversion='MinGW.org GCC-6.3.0-1' --enable-static --enable-shared --enable-threads --with-dwarf2 --disable-sjlj-exceptions --enable-version-specific-runtime-libs --with-libiconv-prefix=/mingw --with-libintl-prefix=/mingw --enable-libstdcxx-debug --with-tune=generic --enable-libgomp --disable-libvtv --enable-nls
  Thread model: win32
  gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
  </code></pre>
  
  <p>I was able to run the following little Fortran code.</p>
  
  <pre><code>PROGRAM TEST
    INTEGER M
    REAL C(3), D(3)
  
    M=3
    C(1) = 2
    C(2) = 5
    C(3) = 10
    call A1(M,C,D)
    write(*,5)D(3)
    5 format(1x,'D3=',G12.5)
  END PROGRAM
  
  SUBROUTINE A1(N, A, B)
    INTEGER I, N
    REAL B(N), A(N)
  !$OMP PARALLEL DO !I is private by default
    DO I=2,N
      B(I) = (A(I) + A(I-1)) / 2.0
    ENDDO
  !$OMP END PARALLEL DO
  END SUBROUTINE A1
  </code></pre>
  
  <p>Also I do have libgomp.a, libgomp.dll.a, libgomp.spec, (located in MinGW\lib\gcc\mingw32\6.3.0) and libgomp-1.dll (located in MinGW\bin).</p>