Fortran & MODFLOW


Fortran

Fortran is a programming language that is used heavily in groundwater flow and contaminant transport numerical modeling.

To get started with Fortran, you will need a compiler, a text editor, and a shell; for visualization you will need a separate graphing utility.

  • Open-source Compiler: gfortran
  • Open-source Text Editor: notepad++
  • Shell : Command Prompt (Windows operating system)
  • Open-source Graphing Utility: gnuplot

A typical order for running Fortran is as follows:

1) write code in notepad++ (gobucks)

2) compile code using gfortran via the command prompt {gfortran gobucks.f95 -o gobucks}, 3) execute code via the command prompt {gobucks}, and 4) write results to a text file via the command prompt {gobucks>C:\Users\wendy\fortran\gobucks.txt}

5) view results in a text file

In an effort to teach Fortran for groundwater modeling, updated pre-Fortran 90/95 code from Wang and Anderson (1982) to Fortran 90/95  code is provided in the .txt files below; many of the pre-Fortran 90/95 statements in Wang and Anderson are obsolescent or deleted, but the fundamentals of the code remain highly relevant today.   To run the .txt files below, you must first save them as .f95 files, then compile them using gfortran to .exe files, and then run them as programs; each program will generate an output file of the simulation as a .txt file, this output file can then be read as in input file for visualization, e.g., iso-head contour maps, using gnuplot. A draft document with much more detail for computation and visualization of groundwater flow is here: Computation and Visualization of Groundwater Flow


Updated Fortan code from Wang and Anderson (1982) & Gnuplot code for visualization of groundwater flow


Visualizations of Groundwater Flow


MODFLOW

MODFLOW is an open-source numerical (finite difference) model, written in Fortran by the United States Geological Survey (USGS), that is used heavily in groundwater flow simulations.

To get started with MODFLOW, you will need to download the complied source code and their executable files and consult a user’s guide for formatting the input files and running the model; for visualization you will need a separate graphing utility, e.g., gnuplot.

Note: a graphical user interface (GUI) is not needed to run MODFLOW.  However, several GUI’s, either open source or commercial, are available.


MODFLOW Input Files

MODFLOW requires several input files to run a groundwater flow simulation.  Below are MODFLOW input files for each of the 7 examples shown above from Wang & Anderson (1982).  Note that the outputs  (heads vs space or time) from MODFLOW and those from the Fortran code, shown above, are nearly identical, yet completely independent of each other.   The outputs are nearly identical because the fundamental flow equations, finite-difference methodology to solve them, and their boundary/initial conditions are effectively the same.

  • Ex. 1 Input Files: 2D Steady Flow Near Well
  • Ex. 2 Input Files: 2D Steady Regional Flow
    1. name (.nam)
    2. discretization (.dis)
    3. basic (.ba6)
    4. flow (.bc6)
    5. solver (.pcg)
    6. output control (.oc)
  • Ex. 3 Input Files: 2D Steady Flow to Well
    1. name (.nam)
    2. discretization (.dis)
    3. basic (.ba6)
    4. flow (.bc6)
    5. recharge (.rch)
    6. solver (.pcg)
    7. output control (.oc)
  • Ex. 4 Input Files: 2D Steady Flow Thru Dam
  • Ex. 5 Input Files:  2D Steady Flow to Phreatic Well
  • Ex. 6 Input Files: 1D Unsteady Flow Head Change
  • Ex. 7 Input Files:  2D Unsteady Flow to Well