Skip to content

Commit ff6f4d1

Browse files
authored
docs(dfns): deprecate reader, infer from other attributes (#2565)
The reader attribute for DFN variables seems unnecessary. Deprecate it and infer it in mf6ivar.py from shape/type. It is only used for generating documentation. Leave reader in the DFNs for now in case other people are using it. Also, the DFN spec listed old, outdated values from MF2005 like "u1ddbl" as still in use, clean that up.
1 parent ef62c3f commit ff6f4d1

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

doc/mf6io/mf6ivar/mf6ivar.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,18 @@ def parse_mf6var_file(fname):
193193
TEX_DIR_PATH.mkdir(exist_ok=True)
194194

195195

196+
def infer_reader(v):
197+
"""
198+
Infer the reader from the variable's attributes.
199+
Arrays use 'readarray', everything else `urword`.
200+
"""
201+
type_ = v.get("type", "")
202+
has_shape = "shape" in v and v["shape"].strip() != ""
203+
if has_shape and type_ in ("integer", "double precision"):
204+
return "readarray"
205+
return "urword"
206+
207+
196208
def block_entry(varname, block, vardict, prefix=" "):
197209
key = (varname, block)
198210
v = vardict[key]
@@ -236,9 +248,9 @@ def block_entry(varname, block, vardict, prefix=" "):
236248
s = f"{s}\n{prefix}{s}\n{prefix}..."
237249

238250
# layered and netcdf
239-
elif v["reader"] in ["readarray", "u1ddbl", "u2ddbl", "u1dint"]:
251+
elif infer_reader(v) == "readarray":
240252
shape = v["shape"]
241-
reader = v["reader"].upper()
253+
reader = "READARRAY"
242254
layered = ""
243255
if "layered" in v:
244256
if v["layered"] == "true":

doc/mf6io/mf6ivar/readme.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ A MODFLOW 6 input variable is described by a set of attributes. Some attributes
6767
| tagged | Whether a keyword is required before the parameter value. | No | True | Set to false for keyword parameters (which do not take a value). |
6868
| in_record | Whether the parameter is part of a record. | No | False | If true, the parameter must follow a record parameter keyword rather than being listed on its own line. |
6969
| layered | Whether the parameter is layered. | No | False | If true, then the LAYERED keyword will be written to the input instructions. |
70-
| reader | The MODFLOW 6 routine used to read the parameter value. | Yes | | Valid values are: `urword`, `u1ddbl`, `u2ddbl`, `readarray`. |
70+
| reader | The MODFLOW 6 routine used to read the parameter value. | No | (inferred) | This attribute is deprecated and is now inferred from `type` and `shape` but remains supported for compatibility. Valid values are: `urword`, `readarray`. |
7171
| optional | Whether the parameter is optional. | No | False | |
7272
| longname | A brief but descriptive label for the parameter. | Yes | | May contain spaces. |
7373
| description | A full description of the parameter. | Yes | | Should describe the parameter in detail. Underscores must be escaped since this value is parsed and substituted into LaTeX files for the MF6IO documentation. |
@@ -80,14 +80,15 @@ A MODFLOW 6 input variable is described by a set of attributes. Some attributes
8080

8181
### Reader Attribute
8282

83-
The reader attribute indicates what reader is used by MODFLOW 6 for the information. There are several reader types that result in specialized input instructions. For example, the delr array of the DIS package is read using u1ddbl. Because the MODFLOW 6 array readers often require a control record, when this reader type is specified, information about the control record is written. For example, the following block identifies how delr is specified:
83+
The reader attribute indicates which read routine is used by MODFLOW 6. It is only used to generate documentation. **This attribute is now automatically inferred** from attributes `type` and `shape` and does not need to be specified in DFN files. If present in a DFN file, it will be ignored in favor of the inferred value. Array types (`integer` or `double precision` with a non-empty shape) use reader `readarray`. All other types use `urword`.
84+
85+
The `readarray` reader is used for array variables and results in specialized documentation. It allows for a LAYERED keyword to be specified. For example, the delr array of the DIS package might be specified as:
8486

8587
```
8688
block griddata
8789
name delr
8890
type double precision
8991
shape (ncol)
90-
reader u1ddbl
9192
longname spacing along a row
9293
description is the is the column spacing in the row direction.
9394
```
@@ -97,11 +98,11 @@ This results in the following block description:
9798
```
9899
BEGIN GRIDDATA
99100
DELR
100-
delr(ncol) -- U1DDBL
101+
<delr(ncol)> -- READARRAY
101102
END GRIDDATA
102103
```
103104

104-
The READARRAY reader is another reader that results in specialized input. It allows for a LAYERED keyword to be specified. The icelltype variable is read using readarray and is specified as:
105+
The icelltype variable also uses readarray and is specified as:
105106

106107
```
107108
block GRIDDATA

0 commit comments

Comments
 (0)