Make Starting Heads (mkshead)



The mkshead program is used to extract starting heads for a set of simulations from a previous simulation.

The V12p7 simulation consists of a steady state stress period followed by 996 transient stress periods. The steady state represents a pre-development period. The transient periods covers the 83 years from 1918 to 2000 in monthly increments for a a total of 996 transient stress periods. The heads are saved at the end of the steady state and each transient stress period.

The annual simulations consists of twelve transient stress periods. The heads are saved at the end of each stress period.

The initial heads for the V12p7 simulation are merely the initial numerical solution. The predicted heads for the steady state stress period depend only on the aquifer properties and steady state stresses.

The steady state heads are used as the initial condition to the V12p7 transient stress periods. For the annual simulations, the initial condition is the predicted heads at the end of the previous year.

Simulations are done in groups of five, representing the historical and four impact simulations. Heads are transferred for each simulation from a corresponding preceding simulation.

Principles of Operation

The mkshead program reads a binary head file and produces in turn a binary head file that is read as the initial condition.

Binary head files are used in order to ensure that the result of a sequence of annual simulations are identical to a single multi-year simulation. By using binary files, heads are transferred in their full binary resolution. If heads were transferred using formatted text files, numerical rounding would occur which introduces small perturbations to the numerical solution between simulations. While in general, groundwater flow solutions are typically not sensitive to such perturbations, binary files are used to avoid any possible problems.

The MODFLOW-2000 program reads and writes binary files using standard FORTRAN records. The record consists of a fixed length word (typically four bytes) indicating the length of the record (in bytes). This is followed by the data in the record, followed again by the record length. This structure allows a FORTRAN program to read the record correctly regardless of the number of items on the READ statement. Of course, attempting to read more items from the record than was written typically causes and error. The structure also allows records to be skipped by using a READ statement with no list, and allows the BACKSPACE command to work correctly.

Some compilers distinguish between UNFORMATTED and BINARY files. The structure described above is usually called UNFORMATTED. For BINARY files, the record length at the beginning and end of each record is omitted, and the file is treated as a continuous stream of bytes. The record structure of the file is therefore not maintained.

Another complication is that in binary files, the internal machine representation of numbers is revealed. All modern hardware uses a machine representation of floating point numbers based on the IEEE 754 standard. This standard defines how bits in a 32 bit word and a 64 bit word are used to represent a floating point number as a sign, mantissa and exponent. However, the order in which the bits are represented remains implementation dependent.

In what is called big-endian architectures, bits are ordered in the same way as numbers are usually written from left to right, starting with the most significant digits and ending with the least significant digit. Examples of architectures that use this order are processors made by Motorola, Hewlett-Packard, Sun, IBM and Cray. Other machines use what is called a little-endian architecture, where numbers are stored as if written from right to left. Examples of processors using this architecture are made by Intel and Digital-Compaq-HP. The source of this confusion is centuries old, when Europeans using a left to right writing style adopted an Hindu-Arabic number system from people using a right to left writing style. Suffice it to say that binary files read on a little endian architecture cannot be read verbatim on a big endian architecture, and vice versa.

The mkshead program does not attempt to copy individual head values. Instead, it deals with entire records. A MODFLOW-2000 head record actually consists of two FORTRAN records. The first record contains the time step, period, time step length, total time, variable name, number of rows, number of columns and layer. The variable name is 16 characters long, the time step length and total time are floating point numbers, and the rest are integers. Since integers are typically four bytes (32 bits), the length of this record is 36 bytes plus the length of two floating point numbers.

The second FORTRAN record consists of the head values. The RRCA Groundwater Model contains 165 rows by 326 columns, or 53790 cells. Each value is a floating point number.

The length of a head record RECL is therefore equal to
  RECL = l+32+2*r+l   +   l+326*165*r+l
where l is the length of the record length field and r is the length of a floating point number. Typically l equals four, but if the file is written using a compiler that omits this field it may be zero.

The length of a floating point number is either four or eight. Typically, the FORTRAN REAL type is four bytes, while the FORTRAN DOUBLE PRECISION type is eight bytes. However, a compiler flag on most compilers allow REAL values to be promoted to DOUBLE PRECISION.

In the model runs on the RRCA web site, all floating point values are DOUBLE PRECISION. It was found that the numerical accuracy of the model is greatly improved by compiling MODFLOW-2000 with a compiler flag that promotes all REAL values to DOUBLE PRECISION. Therefore, DOUBLE PRECISION is used in all programs.

The mkshead program determines the length of a head record as described above. It then skips over as many records as necessary to get to the year in question, and reads one record. That record is then rewritten verbatim to the output file.

Command Reference

The mkshead program expects a year as a command line argument. Unless the -d option appears, the program reads the heads from the twelfth stress period from files for the previous year. For the year yyyy, the output files are named yyyy.shead, yyyya.shead, yyyyb.shead, yyyyc.shead and yyyyd.shead, for the historical, Colorado pumping, Kansas pumping, Nebraska pumping and Nebraska mound runs, respectively.

The following optional parameters may appear on the command line.

-d directory

This option specifies a non-default directory from which to read the starting heads. When the directory specified contains the string v12p7, the starting heads are read from files named 12p.head, 12p1.head, 12p2.head, 12p3.head and 12p4.head. For the year yyyy, the program skips 12*(yyyy-1918) stress periods to read the heads at the end of the year preceding the year yyyy. All other directory names causes the program to read files named xxxx.head, xxxxa.head, xxxxb.head, xxxxc.head and xxxxd.head, where xxxx = yyyy-1. Stress period 12 is read for these files by skipping 11 records. The default directory read when the -d option is not specified is ../xxxx.

-r len

This option specifies the length of a FORTRAN REAL. The RRCA groundwater model is best run in double precision, but circumstances sometimes require it to be run in single precision. In that case, a value of 4 should be specified. When the -r option is omitted, a value of 8 is used.

-l len

This option is used to specify the length of the record length field. This would normally be 4, which is the default value used if the -l option is not specified, but a value of zero may be needed with some compilers.

Example: Get starting heads for 2002

The starting heads for 2002 are read from stress period 12 in the files ../2001/2001.head, ../2001/2001a.head, ../2001/2001b.head, ../2001/2001c.head and ../2001/2001d.head, for the historical and four impact runs, respectively. Output is written to 2002.shead, 2002a.shead, 2002b.shead, 2002c.shead and 2002d.shead.
mkshead 2002

Example: Get starting heads for 2000

The starting heads for 2000 are read from stress period 984 from the files ../v12p7/12.head, ../v12p7/12p1.head, ../v12p7/12p2.head, ../v12p7/12p3.head and ../v12p7/12p4.head, for the historical and four impact runs, respectively. Output is written to 2000.shead, 2000a.shead, 2000b.shead, 2000c.shead and 2000d.shead.
mkshead -d../v12p7 2000

Example: Get starting heads for 2002 in single precision

Starting heads are copied from the 2001 files as before, but using single precision (32 bit) reals instead of double precision (64 bit) reals.
mkshead -r4 2002

Example: Get starting heads for 2002 for BINARY files

Some compilers distinguish between FORM=UNFORMATTED (record oriented) and FORM=BINARY (no record) files. To read the latter form, a record field length of zero is used.
mkshead -l0 2002

Home | Index | Previous | Next

Model Units
Directory Structure
Programs
Static Files
Precipitation Data Entry
Colorado Data Entry
ET Data Entry
Stream Data Entry
Kansas Data Entry
Nebraska Data Entry
Running the Model