Array Input

  • Scroll to top of this topic Scroll to Top of Page

  • Print the current topic Print Topic

  • No expanding elements on this page Show/Hide Expanders

The real two-dimensional array reader (U2DREL), the integer two-dimensional array reader (U2DINT), and the real one-dimensional array reader (U1DREL) read one array-control record and, optionally, a data array in a format specified on the array-control record. Five alternate structures for the control record are provided. The original fixed-format control records work as documented (McDonald and Harbaugh, 1988). Four free-format versions of the control record have been added in addition to the original fixed-format control record.

FIXED FORMAT CONTROL RECORD FOR REAL AND INTEGER ARRAY READERS:

1. LOCAT CNSTNT FMTIN IPRN

Format: I10 F10.0 A20 I10

For U2DINT, CNSTNT is an integer that is read with an I10 format.

FREE-FORMAT CONTROL RECORD FOR REAL ARRAY READERS

Values in bold italics are key words that can be specified as uppercase or lowercase. Each control record is limited to a length of 79 characters.

1. CONSTANT CNSTNT

All values in the array are set equal to CNSTNT.

2. INTERNAL CNSTNT FMTIN IPRN

The individual array elements will be read from the same file that contains the control record.

3. EXTERNAL Nunit CNSTNT FMTIN IPRN

The individual array elements will be read from the file unit number specified by Nunit. The name of the file associated with this file unit is contained in the name file.

4. OPEN/CLOSE FNAME CNSTNT FMTIN IPRN

The array will be read from the file whose name is specified by FNAME. This file will be opened on unit 99 just prior to reading the array and closed immediately after the array is read. Thus, a file that is read using this control record can contain only a single array. Files opened using the OPEN/CLOSE option should not be included in the name file.

Explanation of Parameters in the Array-Control Records

Nunit-- is the unit for reading the array when the EXTERNAL free-format control record is used.

CNSTNT-- is a real-number constant for U2DREL and U1DREL, and an integer constant for U2DINT. If the array is being defined as a constant, CNSTNT is the constant value. If individual elements of the array are being read, the values are multiplied by CNSTNT after they are read. When CNSTNT is used as a multiplier and if it is specified as 0, it is changed to 1.

FMTIN-- is the format for reading array elements. The format must contain 20 characters or less. The format must either be (1) a standard Fortran format that is enclosed in parentheses, (2) "(FREE)", which indicates free format, or (3) "(BINARY)", which indicates binary (unformatted) data. When using a free-format control record, the format must be enclosed in apostrophes if it contains one or more blanks or commas. The binary files that can be read by the array readers must have either been created by MODFLOW or by another program capable of generating binary files with the appropriate structure. "(FREE)" and "(BINARY)" can only be specified in free-format control records. Also, "(BINARY)" can only be specified when using U2DREL or U2DINT, and only when the control record is EXTERNAL or OPEN/CLOSE.

LOCAT-- indicates the location of the array values for a fixed-format array control record. If LOCAT=0, all elements are set equal to CNSTNT. If LOCAT>0, it is the unit number for reading formatted records using FMTIN as the format. If LOCAT<0, it is the unit number for binary(unformatted) records, and FMTIN is ignored. Also, when LOCAT is not 0, the array values are multiplied by CNSTNT after they are read.

IPRN-- is a flag indicating that the array being read should be printed and a code for indicating the format that should be used. The format codes are different for each of the three array-reader modules as shown below. IPRN is set to zero when the specified value exceeds those defined. If IPRN is less than zero, the array will not be printed.

 

IPRN

U2DREL

U2DINT

U1DREL

0

10G11.4

10I11

10G12.5

1

11G10.3

60I1

5G12.5

2

9G13.6

40I2


3

15F7.1

30I3


4

15F7.2

25I4


5

15F7.3

20I5


6

15F7.4

10I11


7

20F5.0

20I2


8

20F5.1

15I4


9

20F5.2

10I6


10

20F5.3



11

20F5.4



12

10G11.4



13

10F6.0



14

10F6.1



15

10F6.2



16

10F6.3



17

10F6.4



18

10F6.5



Several examples of free-format control records used to read a real array consisting of 4 rows with 7 values per row are shown below.

CONSTANT 5.7

This sets an entire array to the value "5.7".

INTERNAL 1.0 (7F4.0) 3

1.2 3.7 9.3 4.2 2.2 9.9 1.0

3.3 4.9 7.3 7.5 8.2 8.7 6.6

4.5 5.7 2.2 1.1 1.7 6.7 6.9

7.4 3.5 7.8 8.5 7.4 6.8 8.8

This reads the array values from the file that contains the control record. Thus, the values immediately follow the control record.

EXTERNAL 52 1.0 (7F4.0) 3

This reads the array from the file opened on unit 52.

EXTERNAL 47 1.0 (BINARY) 3

This reads the array from the binary file opened on unit 47.

OPEN/CLOSE test.dat 1.0 (7F4.0) 3

This reads the array from the file named "test.dat".