Thursday, February 3, 2011

Read Modflow Head file using Matlab

When I first started working with Modflow, I used to use a utility program to convert the output data from binary to ascii. However, I have writen a function in Matlab that extracts the head field directly from the binary file to matlab workspace.

function H=readheadfile(filename,NR,NC,NL)
%NR, NC, NL: number of rows, columns, layers
A=fread(fid,'float'); %reads the entire file and stores it to the variable A
The constant number 11 depends on the preprocessor platform. For Groundwater vistas, version 4 and 5, this number should be 11. For an old version of PmWin I had to change that to 14.
for i=1:NL

Note that the output of the function readheadfile is a 3D array where the top layer corresponds to the bottom layer of the aquifer and vice versa.

No comments: