Skip to content

Commit

Permalink
Merge pull request #41 from jdhughes-usgs/develop
Browse files Browse the repository at this point in the history
fix(ArrayReaders): Fix issue reading binary 2d arrays
  • Loading branch information
langevin-usgs committed Sep 18, 2018
2 parents 868fb81 + 447b97c commit 9bcd7c4
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Automated Testing Status on Travis-CI

### Version 6.0.3 develop — build 13
### Version 6.0.3 develop — build 18
[![Build Status](https://travis-ci.org/MODFLOW-USGS/modflow6.svg?branch=develop)](https://travis-ci.org/MODFLOW-USGS/modflow6)

## Introduction
Expand All @@ -31,7 +31,7 @@ MODFLOW 6 is the latest core version of MODFLOW. It synthesizes many of the capa

#### ***Software/Code citation for MODFLOW 6:***

[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2018, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 30 August 2018, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)
[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2018, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 17 September 2018, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)


## Instructions for building definition files for new packages
Expand Down
138 changes: 121 additions & 17 deletions autotest/test_gwf_binaryinput01.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,32 +74,126 @@ def get_model(idx, dir):
relaxation_factor=relax)
sim.register_ims_package(ims, [gwf.name])

# discretization
# write botarr to binary file
if idx == 0:
botarr = []
for k in range(nlay):
text = 'BOTM_L{}'.format(k+1)
fname = 'botm.l{:02d}.bin'.format(k+1)
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='HEAD',
precision='double',
text=text,
nrow=nrow,
ncol=ncol,
ilay=k+1, pertim=1.0,
totim=1.0, kstp=1,
kper=1)
flopy.utils.Util2d.write_bin((nrow, ncol), f,
np.ones((nrow, ncol),
dtype=np.float64) * botm[k],
header_data=header)
f.close()
botarr.append({'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1})
elif idx == 1:
fname = 'botm.bin'
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
tarr = np.ones((nlay, nrow, ncol), dtype=np.float64)
for k in range(nlay):
tarr[k, :, :] = botm[k]
tarr = tarr.flatten()
header = flopy.utils.BinaryHeader.create(bintype='HEAD',
precision='double',
text='BOTM', nrow=1,
ncol=ncol*nrow*nlay,
ilay=1, pertim=1.0,
totim=1.0, kstp=1, kper=1)
flopy.utils.Util2d.write_bin((nrow, ncol), f,
tarr,
header_data=header)
f.close()
botarr = {'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1}

# write idomain to binary file
if idx == 0:
idomain = []
for k in range(nlay):
text = 'IDOMAIN_L{}'.format(k+1)
fname = 'idomain.l{:02d}.bin'.format(k+1)
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='HEAD',
precision='double',
text=text,
nrow=nrow,
ncol=ncol,
ilay=k+1, pertim=1.0,
totim=1.0, kstp=1,
kper=1)
flopy.utils.Util2d.write_bin((nrow, ncol), f,
np.ones((nrow, ncol),
dtype=np.int32),
header_data=header)
f.close()
idomain.append({'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1})
elif idx == 1:
fname = 'idomain.bin'
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='HEAD',
precision='double',
text='IDOMAIN', nrow=1,
ncol=ncol*nrow*nlay,
ilay=1, pertim=1.0,
totim=1.0, kstp=1, kper=1)
flopy.utils.Util2d.write_bin((nrow, ncol), f,
np.ones((nrow*ncol*nlay),
dtype=np.int32),
header_data=header)
f.close()
idomain = {'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1}

dis = flopy.mf6.ModflowGwfdis(gwf, nlay=nlay, nrow=nrow, ncol=ncol,
delr=delr, delc=delc,
top=0., botm=botm,
idomain=1,
top=0., botm=botarr,
idomain=idomain,
fname='{}.dis'.format(name))

# initial conditions
# write initial heads to binary file
fname = 'ic.strt.bin'
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
if idx == 0:
strt = []
for k in range(nlay):
text = 'IC_L{}'.format(k+1)
fname = 'ic.strt_l{:02d}.bin'.format(k+1)
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='HEAD',
precision='double',
text='HEAD',
text=text,
nrow=nrow,
ncol=ncol,
ilay=k+1, pertim=1.0,
totim=1.0, kstp=1,
kper=1)
flopy.utils.Util2d.write_bin((nrow, ncol), f,
np.ones((nrow, ncol),
dtype=np.float),
dtype=np.float64),
header_data=header)
f.close()
strt.append({'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1})
elif idx == 1:
fname = 'ic.strt.bin'
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='HEAD',
precision='double',
text='HEAD', nrow=1,
Expand All @@ -108,21 +202,23 @@ def get_model(idx, dir):
totim=1.0, kstp=1, kper=1)
flopy.utils.Util2d.write_bin((nrow, ncol), f,
np.ones((nrow*ncol*nlay),
dtype=np.float),
dtype=np.float64),
header_data=header)
f.close()
strt = {'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1}
f.close()
strt = {'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1}

ic = flopy.mf6.ModflowGwfic(gwf, strt=strt,
fname='{}.ic'.format(name))

# node property flow
# write icelltype to binary file
fname = 'npf.icelltype.bin'
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
if idx == 0:
icelltype = []
for k in range(nlay):
fname = 'npf.icelltype.l{}.bin'.format(k+1)
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='head',
text='ICELLTYPE',
precision='double',
Expand All @@ -136,7 +232,13 @@ def get_model(idx, dir):
np.ones((nrow, ncol),
dtype=np.int32),
header_data=header)
f.close()
icelltype.append({'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1})
elif idx == 1:
fname = 'npf.icelltype.bin'
pth = os.path.join(exdirs[idx], fname)
f = open(pth, 'wb')
header = flopy.utils.BinaryHeader.create(bintype='head',
text='ICELLTYPE',
precision='double',
Expand All @@ -149,9 +251,11 @@ def get_model(idx, dir):
np.ones((nrow*ncol*nlay),
dtype=np.int32),
header_data=header)
f.close()
icelltype = {'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1}
icelltype = {'factor': 1., 'filename': fname,
'data': None, 'binary': True, 'iprn': 1}

f.close()

npf = flopy.mf6.ModflowGwfnpf(gwf, save_flows=True,
icelltype=icelltype,
k=hk,
Expand Down
18 changes: 9 additions & 9 deletions code.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[
{
"status": "Release Candidate",
"languages": [
"Fortran2008"
],
"downloadURL": "https://code.usgs.gov/usgs/modflow/modflow6/archive/master.zip",
"repositoryURL": "https://code.usgs.gov/usgs/modflow/modflow6.git",
"disclaimerURL": "https://code.usgs.gov/usgs/modflow/modflow6/blob/master/DISCLAIMER.md",
"tags": [
"MODFLOW",
"groundwater model"
],
"vcs": "git",
"name": "modflow6",
"downloadURL": "https://code.usgs.gov/usgs/modflow/modflow6/archive/master.zip",
"description": "MODFLOW is the USGS's modular hydrologic model. MODFLOW is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface-water interactions.",
"contact": {
"name": "Christian D. Langevin",
"email": "[email protected]"
},
"languages": [
"Fortran2008"
],
"vcs": "git",
"laborHours": -1,
"version": "6.0.3.13",
"version": "6.0.3.18",
"date": {
"metadataLastUpdated": "2018-08-30"
"metadataLastUpdated": "2018-09-17"
},
"organization": "U.S. Geological Survey",
"permissions": {
Expand All @@ -33,6 +33,6 @@
"usageType": "openSource"
},
"homepageURL": "https://code.usgs.gov/usgs/modflow/modflow6/",
"description": "MODFLOW is the USGS's modular hydrologic model. MODFLOW is considered an international standard for simulating and predicting groundwater conditions and groundwater/surface-water interactions."
"name": "modflow6"
}
]
4 changes: 2 additions & 2 deletions doc/version.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\newcommand{\modflowversion}{mf6.0.3.13}
\newcommand{\modflowdate}{August 30, 2018}
\newcommand{\modflowversion}{mf6.0.3.18}
\newcommand{\modflowdate}{September 17, 2018}
\newcommand{\currentmodflowversion}{Version \modflowversion---\modflowdate}
4 changes: 2 additions & 2 deletions src/Utilities/ArrayReaders.f90
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ subroutine read_array_int2d(iu, iarr, aname, ndim, jj, ii, iout, k)
else
! -- Read data as binary
locat = -locat
call read_binary_header(locat, iout, aname, nval)
do i=1,ii
call read_binary_header(locat, iout, aname, nval)
read(locat,iostat=istat,iomsg=ermsgr) (iarr(j,i),j=1,jj)
if (istat /= 0) then
arrname = adjustl(aname)
Expand Down Expand Up @@ -453,8 +453,8 @@ subroutine read_array_dbl2d(iu, darr, aname, ndim, jj, ii, iout, k)
else
! -- Read data as binary
locat = -locat
call read_binary_header(locat, iout, aname, nval)
do i = 1, ii
call read_binary_header(locat, iout, aname, nval)
read(locat,iostat=istat,iomsg=ermsgr) (darr(j,i), j = 1, jj)
if (istat /= 0) then
arrname = adjustl(aname)
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/version.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module VersionModule
public
! -- modflow 6 version
integer(I4B), parameter :: IDEVELOPMODE = 1
character(len=40), parameter :: VERSION = '6.0.3.13 08/30/2018'
character(len=40), parameter :: VERSION = '6.0.3.18 09/17/2018'
character(len=10), parameter :: MFVNAM = ' 6'
character(len=*), parameter :: MFTITLE = &
'U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL'
Expand Down
6 changes: 3 additions & 3 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# MODFLOW 6 version file automatically created using...pre-commit.py
# created on...August 30, 2018 13:49:52
# created on...September 17, 2018 20:48:28

# add some comments on how this version file
# should be manually updated and used

major = 6
minor = 0
micro = 3
build = 13
commit = 114
build = 18
commit = 119

0 comments on commit 9bcd7c4

Please sign in to comment.