modflowpy / flopy

A Python package to create, run, and post-process MODFLOW-based models.
https://flopy.readthedocs.io
Other
517 stars 313 forks source link

writing BAS file to reference binary head save for initial heads #178

Closed aleaf closed 7 years ago

aleaf commented 7 years ago

when I run the following code from my "autotest" folder:

import glob
import os
import shutil
import flopy

path = 'temp'
fbpath = '../examples/data/freyberg'
glob.glob(fbpath + '/*')
for f in glob.glob(fbpath + '/*'):
    if os.path.isfile(f):
        shutil.copy(f, path)
mf = flopy.modflow
m = mf.Modflow.load('freyberg.nam', model_ws=path)
shutil.copy('temp/freyberg.hds', 'freyberg_initial.hds')
m.bas = mf.ModflowBas(m, ibound=1, strt='freyberg_initial.hds')
m.write_input()

I get the following BAS file:

# Basic package file for MODFLOW, generated by Flopy.
 FREE
CONSTANT          1                                #ibound layer 1                
        -999.99
OPEN/CLOSE            freyberg_initial.hds               1     (FREE) -1 strt layer 1  

then when I run the model, this error:

forrtl: severe (59): list-directed I/O syntax error, unit 99, file Z:\Users\aleaf\Documents\GitHub\flopy3\autotest\temp\freyberg_initial.hds
Image              PC        Routine            Line        Source             
mf2005.exe         008F1CA0  Unknown               Unknown  Unknown
mf2005.exe         008EF8C3  Unknown               Unknown  Unknown
mf2005.exe         008B3866  Unknown               Unknown  Unknown
mf2005.exe         0089F342  Unknown               Unknown  Unknown
mf2005.exe         0089E684  Unknown               Unknown  Unknown
mf2005.exe         008842D1  Unknown               Unknown  Unknown
mf2005.exe         008822CA  Unknown               Unknown  Unknown
mf2005.exe         00406434  Unknown               Unknown  Unknown
mf2005.exe         0040EA51  Unknown               Unknown  Unknown
mf2005.exe         00807636  Unknown               Unknown  Unknown
mf2005.exe         008F2C53  Unknown               Unknown  Unknown
mf2005.exe         008DADE9  Unknown               Unknown  Unknown
KERNEL32.dll       7B84399C  Unknown               Unknown  Unknown
KERNEL32.dll       7B845A86  Unknown               Unknown  Unknown
ntdll.dll          7BC5D0EC  Unknown               Unknown  Unknown
ntdll.dll          7BC5F0DD  Unknown               Unknown  Unknown
ntdll.dll          7BC5D0B2  Unknown               Unknown  Unknown
ntdll.dll          7BC3F6BD  Unknown               Unknown  Unknown

the listing file stops at reading initial heads for the first layer. I get very similar results for a different model with Modflow-NWT. I would like to be able to specify a binary head-save for starting heads so that they can easily be swapped out without additional file creation. Thanks

langevin-usgs commented 7 years ago

@aleaf, instead of (FREE), it needs to be (BINARY). @jtwhite79 can this be done through an argument to strt?

aleaf commented 7 years ago

thanks, that worked.

jtwhite79 commented 7 years ago

you should be able to just reset the strt instance, then reset the fmtin attribute:

>>>m.bas6.strt = "freyberg_initial.hds"
>>>m.bas6.strt.fmtin = "(BINARY)"

@aleaf, is this how you did it?