Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when we're going to set_value #3

Open
wk1984 opened this issue May 17, 2019 · 3 comments
Open

Issue when we're going to set_value #3

wk1984 opened this issue May 17, 2019 · 3 comments

Comments

@wk1984
Copy link

wk1984 commented May 17, 2019

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
Copy link
Member

mdpiper commented May 17, 2019

Thanks, @wk1984!

@mdpiper
Copy link
Member

mdpiper commented May 17, 2019

@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
Copy link
Member

mdpiper commented May 17, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants