Skip to content

Commit 131b6d9

Browse files
authored
feat: make binary grid file name configurable (#2228)
Add option to all discretization packages to configure the grb output file path, usage GRB6 OUTFILE <filepath>. Motivated by modflowpy/flopy#2462.
1 parent 6e2dfde commit 131b6d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2334
-206
lines changed

autotest/test_gwf_disu.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
in binary grid file is correct.
77
"""
88

9-
import os
9+
from pathlib import Path
1010

1111
import flopy
1212
import numpy as np
@@ -15,6 +15,7 @@
1515
from framework import TestFramework
1616

1717
cases = ["disu01a", "disu01b"]
18+
grb_filename = "disu.grb"
1819

1920

2021
def build_models(idx, test):
@@ -43,7 +44,7 @@ def build_models(idx, test):
4344
tdis = flopy.mf6.ModflowTdis(sim)
4445
gwf = flopy.mf6.ModflowGwf(sim, modelname=name)
4546
ims = flopy.mf6.ModflowIms(sim, print_option="SUMMARY")
46-
disu = flopy.mf6.ModflowGwfdisu(gwf, **disukwargs)
47+
disu = flopy.mf6.ModflowGwfdisu(gwf, grb_filerecord=grb_filename, **disukwargs)
4748
ic = flopy.mf6.ModflowGwfic(gwf, strt=0.0)
4849
npf = flopy.mf6.ModflowGwfnpf(gwf)
4950
spd = {0: [[(0,), 1.0], [(nrow * ncol - 1), 0.0]]}
@@ -52,9 +53,7 @@ def build_models(idx, test):
5253

5354

5455
def check_output(idx, test):
55-
name = test.name
56-
57-
fname = os.path.join(test.workspace, name + ".disu.grb")
56+
fname = Path(test.workspace) / grb_filename
5857
grbobj = flopy.mf6.utils.MfGrdFile(fname)
5958
nodes = grbobj._datadict["NODES"]
6059
ia = grbobj._datadict["IA"]

autotest/test_gwf_disv.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
in binary grid file is correct.
88
"""
99

10-
import os
10+
from pathlib import Path
1111

1212
import flopy
1313
import numpy as np
@@ -16,6 +16,7 @@
1616
from framework import TestFramework
1717

1818
cases = ["disv01a", "disv01b"]
19+
grb_filename = "disv.grb"
1920

2021

2122
def build_models(idx, test):
@@ -46,7 +47,7 @@ def build_models(idx, test):
4647
tdis = flopy.mf6.ModflowTdis(sim)
4748
gwf = flopy.mf6.ModflowGwf(sim, modelname=name)
4849
ims = flopy.mf6.ModflowIms(sim, print_option="SUMMARY")
49-
disv = flopy.mf6.ModflowGwfdisv(gwf, **disvkwargs)
50+
disv = flopy.mf6.ModflowGwfdisv(gwf, grb_filerecord=grb_filename, **disvkwargs)
5051
ic = flopy.mf6.ModflowGwfic(gwf, strt=0.0)
5152
npf = flopy.mf6.ModflowGwfnpf(gwf)
5253
spd = {0: [[(0, 0), 1.0], [(0, nrow * ncol - 1), 0.0]]}
@@ -55,9 +56,7 @@ def build_models(idx, test):
5556

5657

5758
def check_output(idx, test):
58-
name = test.name
59-
60-
fname = os.path.join(test.workspace, name + ".disv.grb")
59+
fname = Path(test.workspace) / grb_filename
6160
grbobj = flopy.mf6.utils.MfGrdFile(fname)
6261
ncpl = grbobj._datadict["NCPL"]
6362
ia = grbobj._datadict["IA"]

doc/ReleaseNotes/develop.tex

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ \subsection{Version mf6.6.1---February 7, 2025}
88
\begin{itemize}
99
\item Support for adjusting time step lengths using the adaptive time stepping (ATS) capability was added to the GWT Advection (ADV) Package of the Groundwater Transport (GWT) Model in release 6.6.0. The same functionality that was added to GWT is now available with the Groundwater Energy Transport (GWE) Model. A description of how this functionality works and how to activate it can be found in the release notes for version 6.6.0 (Appendix A) and in the MODFLOW 6 input-output guide.
1010
\item The binary grid file written by MODFLOW 6 for DISU models did not include the IDOMAIN array. The binary grid file now includes IDOMAIN for all discretization types, including DISU.
11+
\item The binary grid file's name may now be specified in all discretization packages with option GRB6 FILEOUT followed by a file path. If this option is not provided, the binary grid file will be named as before, identical to the discretization file name plus a ``.grb'' extension. Note that renaming the binary grid file may break downstream integrations which expect the default name.
1112
% \item xxx
1213
\end{itemize}
1314

doc/mf6io/framework/binaryoutput.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
\newpage
88
\subsection{Binary Grid File}
9-
\mf~writes a binary grid file that can be used for post processing model results. The file structure was designed to be self-documenting so that it can evolve if necessary. The file name is assigned automatically by the program by adding ``.grb'' to the end of the discretization input file name. The structure of the binary grid file depends on the type of discretization package that is used. The following subsections summarize the binary grid file for the different grid types. The red text is not written to the binary grid file, but is shown here to explain the file content. The binary grid file is written for the GWF Model, but is not written for the GWT Model.
9+
\mf~writes a binary grid file that can be used for post processing model results. The file structure was designed to be self-documenting so that it can evolve if necessary. By default, the file name is assigned automatically by the program by adding ``.grb'' to the end of the discretization input file name. Alternatively, the binary grid file name may be specified in the relevant discretization input file. The structure of the binary grid file depends on the type of discretization package that is used. The following subsections summarize the binary grid file for the different grid types. The red text is not written to the binary grid file, but is shown here to explain the file content. The binary grid file is written for the GWF Model, but is not written for the GWT Model.
1010

1111
\newpage
1212
\subsubsection{DIS Grids}

doc/mf6io/mf6ivar/dfn/chf-disv1d.dfn

+42
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,48 @@ optional true
1616
longname do not write binary grid file
1717
description keyword to deactivate writing of the binary grid file.
1818

19+
block options
20+
name grb_filerecord
21+
type record grb6 fileout grb6_filename
22+
reader urword
23+
tagged true
24+
optional true
25+
longname
26+
description
27+
28+
block options
29+
name grb6
30+
type keyword
31+
in_record true
32+
reader urword
33+
tagged true
34+
optional false
35+
longname grb keyword
36+
description keyword to specify that record corresponds to a binary grid file.
37+
extended true
38+
39+
block options
40+
name fileout
41+
type keyword
42+
in_record true
43+
reader urword
44+
tagged true
45+
optional false
46+
longname file keyword
47+
description keyword to specify that an output filename is expected next.
48+
49+
block options
50+
name grb6_filename
51+
type string
52+
preserve_case true
53+
in_record true
54+
reader urword
55+
optional false
56+
tagged false
57+
longname file name of GRB information
58+
description defines a binary grid output file. If this option is not provided, the output file will have the same name as the discretization input file, plus extension ``.grb''.
59+
extended true
60+
1961
block options
2062
name xorigin
2163
type double precision

doc/mf6io/mf6ivar/dfn/gwe-dis.dfn

+42
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,48 @@ optional true
1717
longname do not write binary grid file
1818
description keyword to deactivate writing of the binary grid file.
1919

20+
block options
21+
name grb_filerecord
22+
type record grb6 fileout grb6_filename
23+
reader urword
24+
tagged true
25+
optional true
26+
longname
27+
description
28+
29+
block options
30+
name grb6
31+
type keyword
32+
in_record true
33+
reader urword
34+
tagged true
35+
optional false
36+
longname grb keyword
37+
description keyword to specify that record corresponds to a binary grid file.
38+
extended true
39+
40+
block options
41+
name fileout
42+
type keyword
43+
in_record true
44+
reader urword
45+
tagged true
46+
optional false
47+
longname file keyword
48+
description keyword to specify that an output filename is expected next.
49+
50+
block options
51+
name grb6_filename
52+
type string
53+
preserve_case true
54+
in_record true
55+
reader urword
56+
optional false
57+
tagged false
58+
longname file name of GRB information
59+
description defines a binary grid output file. If this option is not provided, the output file will have the same name as the discretization input file, plus extension ``.grb''.
60+
extended true
61+
2062
block options
2163
name xorigin
2264
type double precision

doc/mf6io/mf6ivar/dfn/gwe-disu.dfn

+42
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,48 @@ optional true
1616
longname do not write binary grid file
1717
description keyword to deactivate writing of the binary grid file.
1818

19+
block options
20+
name grb_filerecord
21+
type record grb6 fileout grb6_filename
22+
reader urword
23+
tagged true
24+
optional true
25+
longname
26+
description
27+
28+
block options
29+
name grb6
30+
type keyword
31+
in_record true
32+
reader urword
33+
tagged true
34+
optional false
35+
longname grb keyword
36+
description keyword to specify that record corresponds to a binary grid file.
37+
extended true
38+
39+
block options
40+
name fileout
41+
type keyword
42+
in_record true
43+
reader urword
44+
tagged true
45+
optional false
46+
longname file keyword
47+
description keyword to specify that an output filename is expected next.
48+
49+
block options
50+
name grb6_filename
51+
type string
52+
preserve_case true
53+
in_record true
54+
reader urword
55+
optional false
56+
tagged false
57+
longname file name of GRB information
58+
description defines a binary grid output file. If this option is not provided, the output file will have the same name as the discretization input file, plus extension ``.grb''.
59+
extended true
60+
1961
block options
2062
name xorigin
2163
type double precision

doc/mf6io/mf6ivar/dfn/gwe-disv.dfn

+42
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,48 @@ optional true
1717
longname do not write binary grid file
1818
description keyword to deactivate writing of the binary grid file.
1919

20+
block options
21+
name grb_filerecord
22+
type record grb6 fileout grb6_filename
23+
reader urword
24+
tagged true
25+
optional true
26+
longname
27+
description
28+
29+
block options
30+
name grb6
31+
type keyword
32+
in_record true
33+
reader urword
34+
tagged true
35+
optional false
36+
longname grb keyword
37+
description keyword to specify that record corresponds to a binary grid file.
38+
extended true
39+
40+
block options
41+
name fileout
42+
type keyword
43+
in_record true
44+
reader urword
45+
tagged true
46+
optional false
47+
longname file keyword
48+
description keyword to specify that an output filename is expected next.
49+
50+
block options
51+
name grb6_filename
52+
type string
53+
preserve_case true
54+
in_record true
55+
reader urword
56+
optional false
57+
tagged false
58+
longname file name of GRB information
59+
description defines a binary grid output file. If this option is not provided, the output file will have the same name as the discretization input file, plus extension ``.grb''.
60+
extended true
61+
2062
block options
2163
name xorigin
2264
type double precision

doc/mf6io/mf6ivar/dfn/gwf-dis.dfn

+42
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,48 @@ optional true
1717
longname do not write binary grid file
1818
description keyword to deactivate writing of the binary grid file.
1919

20+
block options
21+
name grb_filerecord
22+
type record grb6 fileout grb6_filename
23+
reader urword
24+
tagged true
25+
optional true
26+
longname
27+
description
28+
29+
block options
30+
name grb6
31+
type keyword
32+
in_record true
33+
reader urword
34+
tagged true
35+
optional false
36+
longname grb keyword
37+
description keyword to specify that record corresponds to a binary grid file.
38+
extended true
39+
40+
block options
41+
name fileout
42+
type keyword
43+
in_record true
44+
reader urword
45+
tagged true
46+
optional false
47+
longname file keyword
48+
description keyword to specify that an output filename is expected next.
49+
50+
block options
51+
name grb6_filename
52+
type string
53+
preserve_case true
54+
in_record true
55+
reader urword
56+
optional false
57+
tagged false
58+
longname file name of GRB information
59+
description defines a binary grid output file. If this option is not provided, the output file will have the same name as the discretization input file, plus extension ``.grb''.
60+
extended true
61+
2062
block options
2163
name xorigin
2264
type double precision

doc/mf6io/mf6ivar/dfn/gwf-disu.dfn

+42
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,48 @@ optional true
1616
longname do not write binary grid file
1717
description keyword to deactivate writing of the binary grid file.
1818

19+
block options
20+
name grb_filerecord
21+
type record grb6 fileout grb6_filename
22+
reader urword
23+
tagged true
24+
optional true
25+
longname
26+
description
27+
28+
block options
29+
name grb6
30+
type keyword
31+
in_record true
32+
reader urword
33+
tagged true
34+
optional false
35+
longname grb keyword
36+
description keyword to specify that record corresponds to a binary grid file.
37+
extended true
38+
39+
block options
40+
name fileout
41+
type keyword
42+
in_record true
43+
reader urword
44+
tagged true
45+
optional false
46+
longname file keyword
47+
description keyword to specify that an output filename is expected next.
48+
49+
block options
50+
name grb6_filename
51+
type string
52+
preserve_case true
53+
in_record true
54+
reader urword
55+
optional false
56+
tagged false
57+
longname file name of GRB information
58+
description defines a binary grid output file. If this option is not provided, the output file will have the same name as the discretization input file, plus extension ``.grb''.
59+
extended true
60+
1961
block options
2062
name xorigin
2163
type double precision

0 commit comments

Comments
 (0)