Suggestions on Compiling MODFLOW-2000

  • Scroll to top of this topic Scroll to Top of Page

  • Print the current topic Print Topic

  • Expand/collapse expanding elements on page Show/Hide Expanders

Most users will not need to compile MODFLOW-2000 because you can download a compiled version of MODFLOW-2000 from the USGS web site.  However, if you wish to make changes to the source code, you will need to compile it yourself.

Nearly all the Fortran code in MODFLOW is standard Fortran that will compile the same way with any compiler.  However, a small portion of the code uses compiler-dependent code.  This compiler dependent code is included in the file "openspec.inc".  Be sure to modify this file to the correct form for your compiler.  There are extensive comments in openspec.inc that can help you.

Prior to version 1.15.00, MODFLOW-2000 was written entirely in Fortran.  However, the GMG package added in version 1.15.00 is written primarily in C (with a small amount of Fortran code to link to the C code).  This makes compiling MODFLOW-2000 a bit more challenging than previously. Now, instead of just a Fortran compiler, a C compiler is also required. If one is not aware that the C language is case-sensitive and  the Fortran language is case insensitive, some error messages returned by compilers may be difficult to understand. Often the C compiler will "decorate" the name of the C function and the linker can't figure out how to link Fortran object code with an undecorated name with C object code with a decorated name. Users should try to find the switches in the compilers and linkers that control how names are decorated so that the object code generated by the C and Fortran compilers use consistent names.

This web page gives advice on compiling MODFLOW-2000 with some compilers.  However, no attempt has been made to test all Fortran compilers.  If you have information on how to compile it with another compiler, please send to rbwinst@usgs.gov so it can be included on this web page.

If you wish to compile a parallel version of MODFLOW-2000, you will need to get a copy of mpif.h.  

To enable the parallel-processing capabilities of MODFLOW-2000, an implementation of MPI must first be installed on your computer(s).  MPI software is not distributed by the USGS and must be obtained and installed separately.  The mpif.h file and MPI subroutines referenced in the para-mpi.f file and other locations in the MODFLOW source code will be provided as part of the MPI installation.  After MPI has been installed, use mpif.h and other source-code files provided with the MPI implementation that is installed on your computer(s) when MODFLOW-2000 is compiled with para-mpi.f.  Some implementations of MPI support only certain compilers, so ensure that the MPI implementation you install supports the compiler you will be using to compile MODFLOW-2000.  Please refer to page 203 of USGS Open-File Report 00-184 for additional information.

There is more info in the FAQ about compiling a parallel version of MODFLOW-2000.

You should check that the variables specified in openspec.inc are specified correctly for your compiler. There is more information about this in the FAQ.

References to commercial vendors of software products or services are provided solely for the convenience of users when obtaining or using USGS software. Such references do not imply any endorsement by the U.S. Government.

The information on this web page was provided with the assistance of Edward Banta, Steffan Mehl, Henk den Adel, William R. Hutchison, and Richard Winston.  The instructions may be outdated or incorrect.  If you find that the instructions are in error, please send corrections to rbwinst@usgs.gov.

hmtoggle_plus1Lahey-Fujitsu Fortran 95 (LF95)
hmtoggle_plus1Compaq Digital Visual Fortran
hmtoggle_plus1Microsoft Visual Studio .NET 2003 and the Intel Fortran Compiler 8.1.
hmtoggle_plus1Microsoft Visual Studio C++ .NET 2003 and the Intel Fortran Compiler 9.0.
hmtoggle_plus1Microsoft Visual Studio 2005 with Intel Fortran Compiler 11.1
hmtoggle_plus1Visual Studio 2008 with Intel C++ compiler 11.0 and Intel Visual Fortran compiler 11.0
hmtoggle_plus1GNU gfortran on Mac OS X (UNIX)
hmtoggle_plus1GNU Fortran (gfortran)
hmtoggle_plus1GNU Fortran and the GNU C compiler on the Mac OSX
hmtoggle_plus1Suggestions for compiling the Conduit Flow Process for MODFLOW-2005
hmtoggle_plus1FTN95 and Watcom Compilers for Compiling MODFLOW-2005
hmtoggle_plus1Code::Blocks and Gfortran