pymt-lab / pymt_ecsimplesnow

PyMT plugin for ECSimpleSnow
MIT License
0 stars 0 forks source link

Issue when we're going to set_value #3

Open wk1984 opened 5 years ago

wk1984 commented 5 years ago

The issue occurs when we loop the model multiple times.

we have to initialize the model at the beginning of each loop:

ec.initialize('snow_model.cfg' )

then, we'd like to change a parameter in each loop:

ec.set_value('open_area_or_not', 1)

it will crash.

Currently, the alternative solution is to reload the module at the most beginning of each loop:

for example:

ec = pymt.models.ECSimpleSnow() ec.initialize('snow_model.cfg' ) ec.set_value('open_area_or_not', 1)

It works.

Please find my example Jupyter notebook below.

Untitled.ipynb.zip

To check whether there are some problems in the Fortran source code, I also checked the BMIs in Fortran code. It works.

bmi_main_check.txt

So, this issue is confusing to me, @mdpiper.

mdpiper commented 5 years ago

Thanks, @wk1984!

mdpiper commented 5 years ago

@wk1984 When the units keyword is omitted from the get_value call, both cases in the example Notebook run to completion.

I wonder if this is related to the problems with the cfunits package that @mcflugen has been trying to fix lately?

mdpiper commented 5 years ago

The workaround that @wk1984 identified (reinstatiating the model) is a good one, and not onerous on the user. If you want to run a model multiple times, it seems OK to create a new instance each time.