Skip to content

Set relative path to external files #1126

@wkitlasten

Description

@wkitlasten

@spaulins-usgs mentioned set_model_relative_path() in a previous issue. Unfortunately sim.set_all_data_external() does not seem to see the model.set_model_relative_path(). Adding model.set_model_relative_path() directly above sim.write_simulation() (i.e. all packages have been created) in the example adds the relative path to the nam file, but does not add the relative path to the OPEN/CLOSE lines in the package files (e.g.):

BEGIN griddata
  delr
    OPEN/CLOSE  'example_model.dis_delr.txt'  FACTOR  1.0
  delc
    OPEN/CLOSE  'example_model.dis_delc.txt'  FACTOR  1.0
  top
    OPEN/CLOSE  'example_model.dis_top.txt'  FACTOR  1.0
  botm  LAYERED
    OPEN/CLOSE  'example_model.dis_botm_layer1.txt'  FACTOR  1.0
    OPEN/CLOSE  'example_model.dis_botm_layer2.txt'  FACTOR  1.0
END griddata

No relative path on the dis_delr.txt file, so:

ERROR REPORT:

  1. *** ERROR OPENING FILE "example_model.dis_delr.txt" ON UNIT 1014
  2.       SPECIFIED FILE STATUS: OLD
  3.       SPECIFIED FILE FORMAT: FORMATTED
  4.       SPECIFIED FILE ACCESS: SEQUENTIAL
  5.       SPECIFIED FILE ACTION: READ
  6.         IOSTAT ERROR NUMBER: 29
  7.  -- STOP EXECUTION (openfile)

Something like this seems to get the appropriate information into the .dis file, but it seems cumbersome, especially with more packages/layers (obviously I could generate the dictionaries and lists outside the dis call):

dis_package = flopy.mf6.ModflowGwfdis(model, pname='dis', length_units='FEET', nlay=2,
                                      nrow=2, ncol=5, delr={'filename': os.path.join('model_folder',model.name+'.dis_delr.txt')},
                                      delc={'filename': os.path.join('model_folder',model.name+'.dis_delc.txt')},
                                      top={'filename': os.path.join('model_folder',model.name+'.dis_top.txt')},
                                      botm=[os.path.join('model_folder',model.name+'.dis_botm_layer1.txt'),
                                            os.path.join('model_folder',model.name+'.dis_botm_layer2.txt')],
                                      filename='{}.dis'.format(model_name))

.dis file created above:

# File generated by Flopy version 3.3.4 on 06/02/2021 at 10:01:23.
BEGIN options
  LENGTH_UNITS  feet
END options

BEGIN dimensions
  NLAY  2
  NROW  2
  NCOL  5
END dimensions

BEGIN griddata
  delr
    OPEN/CLOSE  'model_folder\example_model.dis_delr.txt'  FACTOR  1.0
  delc
    OPEN/CLOSE  'model_folder\example_model.dis_delc.txt'  FACTOR  1.0
  top
    OPEN/CLOSE  'model_folder\example_model.dis_top.txt'  FACTOR  1.0
  botm  LAYERED
    OPEN/CLOSE  'model_folder\example_model.dis_botm_layer1.txt'  FACTOR  1.0
    OPEN/CLOSE  'model_folder\example_model.dis_botm_layer2.txt'  FACTOR  1.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions