Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Conditionally allocated variables #30

Open
rmcd-mscb opened this issue May 12, 2020 · 1 comment
Open

Conditionally allocated variables #30

rmcd-mscb opened this issue May 12, 2020 · 1 comment

Comments

@rmcd-mscb
Copy link
Collaborator

@pnorton-usgs and @mdpiper

How should we handle conditionally allocated variables in the BMI? PRMS has variables that are conditionally allocated. For example upslope_hortonian which is allocated depending on the state cascade_flag.

So in a BMI get_value call how should the return be handled when the variable is not allocated? And should the return status be SUCCESS or FAILURE if it's not allocated. Likewise if the variable was an input variable how should we handle the set_value call?

One possibility is

    case('upslope_hortonian')
        if(this%model%control_data%cascade_flag%value == 1) then
            dest = [this%model%model_simulation%runoff%upslope_hortonian]
            bmi_status = BMI_SUCCESS
        else
            dest(:) = -1.d0
            bmi_status = BMI_SUCCESS
        endif
@mdpiper
Copy link
Collaborator

mdpiper commented May 12, 2020

@rmcd-mscb I like what you've done. It causes the least amount of disruption, and minimizes changes to your BMI implementation.

The value of -1 is good; it matches what we use as a "bad" return from other BMI methods. Plus, if it was omitted, dest would return with numbers that may be mistaken for data.

I think get_value should return BMI_FAILURE if the variable is conditionally undefined. This would be in line with getting the value of any other undefined variable. Likewise for set_value.

(cc-ing @mcflugen to get his take.)

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

No branches or pull requests

2 participants