The groundwater modeling software MODFLOW underwent a major revision last year. Unfortunately, binaries are available for windows only and no packages for Debian/Ubuntu or RedHat/Fedora are provided. Hence, we have to compile it on our own. This is straight forward since it is written in FORTRAN and therefore can be deployed easily on high performances computing clusters.

First, we have to create a new folder, get the last release and unpack it.

$ mkdir MODFLOW
$ cd MODFLOW
$ curl -OLC - https://water.usgs.gov/ogw/modflow/mf6.0.2.zip
$ 7z x mf6.0.2.zip

Here is what we got:

$ cd mf6.0.2
$ tree -d
├── bin
├── doc
├── examples
│   ├── ex01-twri
│   ├── ex02-tidal
│   ├── ex03-bcf2ss
│   ├── ex04-fhb
│   ├── ex05-mfusg1disu
│   ├── ex06-mfusg1disv
│   ├── ex07-mfusg1lgr
│   ├── ex08-mfusg1xt3d
│   ├── ex09-bump
│   ├── ex10-bumpnr
│   ├── ex11-disvmesh
│   ├── ex12-hanicol
│   ├── ex13-hanirow
│   ├── ex14-hanixt3d
│   ├── ex15-whirlsxt3d
│   ├── ex16-mfnwt2
│   ├── ex17-mfnwt3h
│   ├── ex18-mfnwt3l
│   ├── ex19-zaidel
│   ├── ex20-keating
│   ├── ex21-sfr1
│   ├── ex22-lak2
│   ├── ex23-lak4
│   ├── ex24-neville
│   ├── ex25-flowing-maw
│   ├── ex26-Reilly-maw
│   ├── ex27-advpakmvr
│   ├── ex28-mflgr3
│   ├── ex29-vilhelmsen-gc
│   ├── ex30-vilhelmsen-gf
│   ├── ex31-vilhelmsen-lgr
│   └── ex32-periodicbc
├── make
├── msvs
├── src
│   ├── Exchange
│   ├── Model
│   │   ├── Geometry
│   │   ├── GroundWaterFlow
│   │   └── ModelUtilities
│   ├── Solution
│   │   └── SparseMatrixSolver
│   ├── Timing
│   └── Utilities
│       ├── Memory
│       ├── Observation
│       ├── OutputControl
│       └── TimeSeries
└── utils
    ├── mf5to6
    │   ├── make
    │   ├── msvs
    │   └── src
    │       ├── LGR
    │       ├── MF2005
    │       ├── NWT
    │       └── Preproc
    └── zonebudget
        ├── make
        ├── msvs
        └── src
$ cd make
$ make

After compiling we end up with the binary (mf6) and temporary object files in the subfolder obj_temp:

$ tree
.
├── makefile
├── mf6
├── mfsim.lst
└── obj_temp
    ├── arrayhandlersmodule.mod
    ├── ArrayHandlers.o
    ├── arrayreadersmodule.mod
    ├── ArrayReaders.o
    ├── basedismodule.mod
    ├── baseexchangemodule.mod
    ├── BaseExchange.o
    ├── basegeometrymodule.mod
    ├── BaseGeometry.o
    ├── basemodelmodule.mod
    ├── BaseModel.o
    ├── basesolutionmodule.mod
    ├── BaseSolution.o
    ├── blockparsermodule.mod
    ├── BlockParser.o
    ├── bndmodule.mod
    ├── BndUzfKinematic.o
    ├── BoundaryPackage.o
    ├── budgetmodule.mod
    ├── Budget.o
    ├── chdmodule.mod
    ├── circulargeometrymodule.mod
    ├── CircularGeometry.o
    ├── compilerversion.mod
    ├── compilerversion.o
    ├── connectionsmodule.mod
    ├── Connections.o
    ├── constantsmodule.mod
    ├── Constants.o
    ├── DiscretizationBase.o
    ├── disvgeom.mod
    ├── DisvGeom.o
    ├── drnmodule.mod
    ├── evtmodule.mod
    ├── ghbmodule.mod
    ├── ghostnodemodule.mod
    ├── GhostNode.o
    ├── gwf3chd8.o
    ├── gwf3dis8.o
    ├── gwf3disu8.o
    ├── gwf3disv8.o
    ├── gwf3drn8.o
    ├── gwf3evt8.o
    ├── gwf3ghb8.o
    ├── gwf3hfb8.o
    ├── gwf3ic8.o
    ├── gwf3lak8.o
    ├── gwf3maw8.o
    ├── gwf3mvr8.o
    ├── gwf3npf8.o
    ├── gwf3.o
    ├── gwf3obs8.o
    ├── gwf3oc8.o
    ├── gwf3rch8.o
    ├── gwf3riv8.o
    ├── gwf3sfr8.o
    ├── gwf3sto8.o
    ├── gwf3uzf8.o
    ├── gwf3wel8.o
    ├── gwfdismodule.mod
    ├── gwfdisumodule.mod
    ├── gwfdisvmodule.mod
    ├── gwfgwfexchangemodule.mod
    ├── GwfGwfExchange.o
    ├── gwfhfbmodule.mod
    ├── gwficmodule.mod
    ├── gwfmodule.mod
    ├── gwfmvrmodule.mod
    ├── gwfnpfmodule.mod
    ├── gwfobsmodule.mod
    ├── gwfocmodule.mod
    ├── gwfstomodule.mod
    ├── hashtablemodule.mod
    ├── HashTable.o
    ├── ims8linear.o
    ├── ims8reordering.o
    ├── imslinearmodule.mod
    ├── imsreorderingmodule.mod
    ├── inputoutputmodule.mod
    ├── InputOutput.o
    ├── iunitmodule.mod
    ├── Iunit.o
    ├── kindmodule.mod
    ├── kind.o
    ├── lakmodule.mod
    ├── listmodule.mod
    ├── List.o
    ├── listreadermodule.mod
    ├── ListReader.o
    ├── listsmodule.mod
    ├── mawmodule.mod
    ├── memorylistmodule.mod
    ├── MemoryList.o
    ├── memorymanagermodule.mod
    ├── MemoryManager.o
    ├── Memory.o
    ├── memorytypemodule.mod
    ├── mf6lists.o
    ├── mf6.o
    ├── Mover.o
    ├── mvrmodule.mod
    ├── namefilemodule.mod
    ├── NameFile.o
    ├── numericalexchangemodule.mod
    ├── NumericalExchange.o
    ├── numericalmodelmodule.mod
    ├── NumericalModel.o
    ├── numericalpackagemodule.mod
    ├── NumericalPackage.o
    ├── numericalsolutionmodule.mod
    ├── NumericalSolution.o
    ├── Obs3.o
    ├── obscontainermodule.mod
    ├── ObsContainer.o
    ├── observemodule.mod
    ├── Observe.o
    ├── obsmodule.mod
    ├── obsoutputlistmodule.mod
    ├── ObsOutputList.o
    ├── obsoutputmodule.mod
    ├── ObsOutput.o
    ├── obsutilitymodule.mod
    ├── ObsUtility.o
    ├── openspecmodule.mod
    ├── OpenSpec.o
    ├── outputcontroldata.mod
    ├── OutputControlData.o
    ├── outputcontrolmodule.mod
    ├── OutputControl.o
    ├── packagemovermodule.mod
    ├── PackageMover.o
    ├── printsavemanagermodule.mod
    ├── PrintSaveManager.o
    ├── rchmodule.mod
    ├── rectangularchgeometrymodule.mod
    ├── RectangularChGeometry.o
    ├── rectangulargeometrymodule.mod
    ├── RectangularGeometry.o
    ├── rivmodule.mod
    ├── sfrmodule.mod
    ├── simmodule.mod
    ├── Sim.o
    ├── simulationcreatemodule.mod
    ├── SimulationCreate.o
    ├── simvariablesmodule.mod
    ├── SimVariables.o
    ├── SmoothingFunctions.o
    ├── smoothingmodule.mod
    ├── solutiongroupmodule.mod
    ├── SolutionGroup.o
    ├── sparsemodule.mod
    ├── Sparse.o
    ├── stringlistmodule.mod
    ├── StringList.o
    ├── tdismodule.mod
    ├── tdis.o
    ├── timearraymodule.mod
    ├── TimeArray.o
    ├── timearrayserieslinkmodule.mod
    ├── TimeArraySeriesLink.o
    ├── timearrayseriesmanagermodule.mod
    ├── TimeArraySeriesManager.o
    ├── timearrayseriesmodule.mod
    ├── TimeArraySeries.o
    ├── timermodule.mod
    ├── Timer.o
    ├── timeseriesfilelistmodule.mod
    ├── TimeSeriesFileList.o
    ├── timeserieslinkmodule.mod
    ├── TimeSeriesLink.o
    ├── timeseriesmanagermodule.mod
    ├── TimeSeriesManager.o
    ├── timeseriesmodule.mod
    ├── TimeSeries.o
    ├── timeseriesrecordmodule.mod
    ├── TimeSeriesRecord.o
    ├── uzfkinematicmodule.mod
    ├── uzfmodule.mod
    ├── welmodule.mod
    ├── xt3dalgorithmmodule.mod
    ├── Xt3dAlgorithm.o
    ├── Xt3dInterface.o
    └── xt3dmodule.mod

Let’s do a quick test run if the binary is working:

$ ./mf6 
                                   MODFLOW 6
                U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL
                       VERSION mf6.0.2 February 23, 2018

  MODFLOW 6 compiled Apr  14 2018 21:48:57 with GFORTRAN compiler (ver. 7.2.0)

This software has been approved for release by the U.S. Geological 
Survey (USGS). Although the software has been subjected to rigorous 
review, the USGS reserves the right to update the software as needed 
pursuant to further analysis and review. No warranty, expressed or 
implied, is made by the USGS or the U.S. Government as to the 
functionality of the software and related material nor shall the 
fact of release constitute any such warranty. Furthermore, the 
software is released on condition that neither the USGS nor the U.S. 
Government shall be held liable for any damages resulting from its 
authorized or unauthorized use. Also refer to the USGS Water 
Resources Software User Rights Notice for complete use, copyright, 
and distribution information.

 Run start date and time (yyyy/mm/dd hh:mm:ss): 2018/04/14 21:51:57

 Writing simulation list file: mfsim.lst

ERROR REPORT:

 *** ERROR OPENING FILE "mfsim.nam" ON UNIT 1001
       SPECIFIED FILE STATUS: OLD
       SPECIFIED FILE FORMAT: FORMATTED
       SPECIFIED FILE ACCESS: SEQUENTIAL
       SPECIFIED FILE ACTION: READ
         IOSTAT ERROR NUMBER: 2
  -- STOP EXECUTION (openfile)
 Stopping due to error(s)

Now we can run our one of our examples:

$ cd ../examples/ex01-twri/
$ ./../../make/mf6 
                                   MODFLOW 6
                U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL
                       VERSION mf6.0.2 February 23, 2018

  MODFLOW 6 compiled Apr  14 2018 21:48:57 with GFORTRAN compiler (ver. 7.2.0)

This software has been approved for release by the U.S. Geological 
Survey (USGS). Although the software has been subjected to rigorous 
review, the USGS reserves the right to update the software as needed 
pursuant to further analysis and review. No warranty, expressed or 
implied, is made by the USGS or the U.S. Government as to the 
functionality of the software and related material nor shall the 
fact of release constitute any such warranty. Furthermore, the 
software is released on condition that neither the USGS nor the U.S. 
Government shall be held liable for any damages resulting from its 
authorized or unauthorized use. Also refer to the USGS Water 
Resources Software User Rights Notice for complete use, copyright, 
and distribution information.

 Run start date and time (yyyy/mm/dd hh:mm:ss): 2018/04/14 22:04:10

 Writing simulation list file: mfsim.lst
 Using Simulation name file: mfsim.nam
 Solving:  Stress period:     1    Time step:     1
 Run end date and time (yyyy/mm/dd hh:mm:ss): 2018/04/14 22:04:10
 Elapsed run time:  0.026 Seconds

 Normal termination of simulation.

I recommend to move mf6 (perhaps including examples, source code and documentation) to /opt/MODFLOW6/, set appropriate folder and file permission and create a link to it to call it directly.