Clone wiki

modflow_utilities / Home

Getting Started

This page shows how to use and verify the code under your system.

Reading head output

To read the output head file use the readModflowArrays function:

H = readModflowArrays(['Example_files/gvmod.hds']);

The file gvmod.hds contains the head distribution of a single layer aquifer. The simulation is transient state with 119 stress periods.

The output of the command is a matrix where each row containts the head distribution for one layer of one time step of one stress period. Each row is actually a struct variable with the following fields:

  1. KST : the time step number

  2. KPRE : the stress period number

  3. PERTIM : the time in the current stress period

  4. TOTIM : the total elapsed time

  5. DESC : a description of the array

  6. NCOL : the number of columns in the array

  7. NROW : the number of rows in the array

  8. ILAY : the layer number

  9. data : A matrix [NROWxNCOL].

To plot the head distribution in matlab is as easy as



However as you can see the figure is not very informative. The reason is that the no-flow cells get usually a very high or very low values such as 9999 or -9999. Before plotting, we should replace these values with nans. Usually I find a cell that is no flow. In this example the cell (1,1) is designated as no-flow and set all values that are equal to that no-flow cell to nan.

Head = H(1,1).data;
Head( Head == Head(1,1) ) = nan;


This figure is better but not quite right yet. The plot is upside down. There are two ways to fix this. Either provide the coordinates i.e. surf(X,Y,Head) or use ij axis system. The following shows the second way since I dont have a coordinate system. I also dont like to show the cell edges and most of the time I hide them.

axis ij


Reading Drawdown output

Reading drowdown is identical to hydraulic head.

DDN = readModflowArrays(['Example_files/gvmod.ddn']);

Reading Cell by cell flow file

Reading the cell by cell flow from a user perspecive is not very different than reading hydraulic head

CBC = readModflowFlowdata(['Example_files/gvmod.cbb']);

This command will return a struct variable with similar fields as described above.


The readModflowFlowdata function does not read all types of data. If anyone has files that have properties that this script cannot read and can share the file please contact me at