Skip to content

Commit

Permalink
refactor(export_array): testing (#1702)
Browse files Browse the repository at this point in the history
* add export array testing to autotest/test_gwf_npf01_75x75.py
* update tex files

There is still an unresolved issue in that export_array only works for "layered" variables, but if we add "layered true" to disv1d variables, then the io guide says "layered" for these variables.  Also, for the swf-dis2d grid, if we include support for export_array, then we get nrow files created, each with ncol values in it.  So there is some work left to do in supporting disv1d, dis2d, and other variables, such as gwf-dis-top, that might be considered "layered".
  • Loading branch information
langevin-usgs authored Apr 3, 2024
1 parent b548242 commit 9721877
Show file tree
Hide file tree
Showing 40 changed files with 135 additions and 4 deletions.
1 change: 0 additions & 1 deletion autotest/TestList.f90
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ subroutine test_get_next_previous_item_reset(error)
type(ListType), pointer :: list
type(IntNodeType), pointer :: n1, n2, n3
class(*), pointer :: p
integer(I4B) :: i

allocate (list)
allocate (n1)
Expand Down
38 changes: 35 additions & 3 deletions autotest/test_gwf_npf01_75x75.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import pathlib as pl
import flopy
import numpy as np
import pytest
Expand Down Expand Up @@ -94,6 +94,7 @@ def build_models(idx, test):

dis = flopy.mf6.ModflowGwfdis(
gwf,
export_array_ascii=True,
nlay=nlay,
nrow=nrow,
ncol=ncol,
Expand All @@ -106,11 +107,21 @@ def build_models(idx, test):
)

# initial conditions
ic = flopy.mf6.ModflowGwfic(gwf, strt=strt, filename=f"{name}.ic")
ic = flopy.mf6.ModflowGwfic(
gwf,
export_array_ascii=True,
strt=strt,
filename=f"{name}.ic"
)

# node property flow
npf = flopy.mf6.ModflowGwfnpf(
gwf, save_flows=False, icelltype=laytyp[idx], k=hk, k33=hk
gwf,
export_array_ascii=True,
save_flows=False,
icelltype=laytyp[idx],
k=hk,
k33=hk
)
# storage
sto = flopy.mf6.ModflowGwfsto(
Expand Down Expand Up @@ -193,12 +204,33 @@ def build_models(idx, test):
return sim, mc


def check_output(idx, test):
print("evaluating model...")
ws = test.workspace

# ensure export array is working properly
name = cases[idx]
flist = ["dis.botm", "dis.idomain", "ic.strt", "npf.icelltype", "npf.k", "npf.k33"]
files = [pl.Path(ws / f"{name}-{f}.l1.txt") for f in flist]
gwf = test.sims[0].gwf[0]
for i, fpth in enumerate(files):
assert fpth.is_file(), f"Expected file does not exist: {fpth.name}"
a = np.loadtxt(fpth)
array_name = flist[i][flist[i].index(".") + 1:]
package_name = flist[i][0:flist[i].index(".")]
package = getattr(gwf, package_name)
b = getattr(package, array_name).array
assert np.allclose(a, b)
return


@pytest.mark.parametrize("idx, name", enumerate(cases))
def test_mf6model(idx, name, function_tmpdir, targets):
test = TestFramework(
name=name,
workspace=function_tmpdir,
targets=targets,
build=lambda t: build_models(idx, t),
check=lambda t: check_output(idx, t),
)
test.run()
18 changes: 18 additions & 0 deletions doc/mf6io/mf6ivar/md/mf6ivar.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions doc/mf6io/mf6ivar/tex/appendixA.tex
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
GWF & DISU & VERTICES & yes \\
GWF & DISU & CELL2D & yes \\
\hline
GWF & IC & OPTIONS & yes \\
GWF & IC & GRIDDATA & no \\
\hline
GWF & NPF & OPTIONS & yes \\
Expand Down Expand Up @@ -205,6 +206,7 @@
GWT & DISU & VERTICES & yes \\
GWT & DISU & CELL2D & yes \\
\hline
GWT & IC & OPTIONS & yes \\
GWT & IC & GRIDDATA & no \\
\hline
GWT & NAM & OPTIONS & yes \\
Expand Down Expand Up @@ -285,6 +287,7 @@
GWE & EST & GRIDDATA & no \\
GWE & EST & PACKAGEDATA & yes \\
\hline
GWE & IC & OPTIONS & yes \\
GWE & IC & GRIDDATA & no \\
\hline
GWE & LKE & OPTIONS & yes \\
Expand Down Expand Up @@ -343,6 +346,7 @@
SWF & CXS & PACKAGEDATA & yes \\
SWF & CXS & CROSSSECTIONDATA & yes \\
\hline
SWF & IC & OPTIONS & yes \\
SWF & IC & GRIDDATA & no \\
\hline
SWF & STO & OPTIONS & yes \\
Expand Down
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwe-cnd-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

\item \texttt{XT3D\_RHS}---add xt3d terms to right-hand side, when possible. This option uses less memory, but may require more iterations.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwe-cnd-options.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BEGIN OPTIONS
[XT3D_OFF]
[XT3D_RHS]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwe-dis-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the lower-left corner of the model grid. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwe-dis-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwe-disv-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the model grid coordinate system relative to a real-world coordinate system. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwe-disv-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
6 changes: 6 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwe-ic-desc.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
% DO NOT MODIFY THIS FILE DIRECTLY. IT IS CREATED BY mf6ivar.py

\item \textbf{Block: OPTIONS}

\begin{description}
\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

\begin{description}
Expand Down
3 changes: 3 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwe-ic-options.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN OPTIONS
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwf-dis-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the lower-left corner of the model grid. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwf-dis-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwf-disv-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the model grid coordinate system relative to a real-world coordinate system. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwf-disv-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
6 changes: 6 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwf-ic-desc.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
% DO NOT MODIFY THIS FILE DIRECTLY. IT IS CREATED BY mf6ivar.py

\item \textbf{Block: OPTIONS}

\begin{description}
\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

\begin{description}
Expand Down
3 changes: 3 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwf-ic-options.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN OPTIONS
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwf-npf-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

\item \texttt{tvk6\_filename}---defines a time-varying hydraulic conductivity (TVK) input file. Records in the TVK file can be used to change hydraulic conductivity properties at specified times or stress periods.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwf-npf-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ BEGIN OPTIONS
[K22OVERK]
[K33OVERK]
[TVK6 FILEIN <tvk6_filename>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwt-dis-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the lower-left corner of the model grid. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwt-dis-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwt-disv-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the model grid coordinate system relative to a real-world coordinate system. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwt-disv-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwt-dsp-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

\item \texttt{XT3D\_RHS}---add xt3d terms to right-hand side, when possible. This option uses less memory, but may require more iterations.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/gwt-dsp-options.dat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BEGIN OPTIONS
[XT3D_OFF]
[XT3D_RHS]
[EXPORT_ARRAY_ASCII]
END OPTIONS
6 changes: 6 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwt-ic-desc.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
% DO NOT MODIFY THIS FILE DIRECTLY. IT IS CREATED BY mf6ivar.py

\item \textbf{Block: OPTIONS}

\begin{description}
\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

\begin{description}
Expand Down
3 changes: 3 additions & 0 deletions doc/mf6io/mf6ivar/tex/gwt-ic-options.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN OPTIONS
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/prt-dis-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the lower-left corner of the model grid. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/prt-dis-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/prt-disv-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the model grid coordinate system relative to a real-world coordinate system. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/prt-disv-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/prt-mip-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
\begin{description}
\item \texttt{zero\_method}---the root finding algorithm to solve ternary subcells. 0 euler, 1 brent, 2 chandrupatla, 3 test.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/prt-mip-options.dat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BEGIN OPTIONS
[ZERO_METHOD <zero_method>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/swf-dis2d-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the lower-left corner of the model grid. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/swf-dis2d-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
2 changes: 2 additions & 0 deletions doc/mf6io/mf6ivar/tex/swf-disv-desc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

\item \texttt{angrot}---counter-clockwise rotation angle (in degrees) of the model grid coordinate system relative to a real-world coordinate system. If not specified, then a default value of 0.0 is assigned. The value for ANGROT does not affect the model simulation, but it is written to the binary grid file so that postprocessors can locate the grid in space.

\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: DIMENSIONS}

Expand Down
1 change: 1 addition & 0 deletions doc/mf6io/mf6ivar/tex/swf-disv-options.dat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ BEGIN OPTIONS
[XORIGIN <xorigin>]
[YORIGIN <yorigin>]
[ANGROT <angrot>]
[EXPORT_ARRAY_ASCII]
END OPTIONS
6 changes: 6 additions & 0 deletions doc/mf6io/mf6ivar/tex/swf-ic-desc.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
% DO NOT MODIFY THIS FILE DIRECTLY. IT IS CREATED BY mf6ivar.py

\item \textbf{Block: OPTIONS}

\begin{description}
\item \texttt{EXPORT\_ARRAY\_ASCII}---keyword that specifies input grid arrays, which already support the layered keyword, should be written to layered ascii output files.

\end{description}
\item \textbf{Block: GRIDDATA}

\begin{description}
Expand Down
3 changes: 3 additions & 0 deletions doc/mf6io/mf6ivar/tex/swf-ic-options.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN OPTIONS
[EXPORT_ARRAY_ASCII]
END OPTIONS

0 comments on commit 9721877

Please sign in to comment.