Skip to content

Unit conversion bug when variable is used by two different schemes (with different units) #594

@peverwhee

Description

@peverwhee

Description

Scenario 1

If a variable is used in two different schemes and:

  1. The first scheme has the same units as the host variable.
  2. The second scheme has different units than the host variable.

It produces this error:

Invalid new variable, <variable>, incompatible  between <variable>,

Scenario 2

On the flip side, if:

  1. The first scheme has different units than the host variable.
  2. The second scheme has the same units as the host variable.

The framework will convert the variable to pass into the first scheme, but not convert it back for the second scheme (thus using the wrong units)

Steps to Reproduce

  1. Modify ps in cld_ice.meta in the advection test to have units of "hPa", run the tests and observe the error.
  2. Remove your modification to cld_ice.meta. Modify ps in cld_liq.meta in the advection test and inspect the generated code to see the wrong units passed into cld_liq

Output

Generated code for scenario number 2 (where the wrong units are used):

! Compute reverse (pre-scheme) transforms
ps_local(:) = 1.0E-2_kind_phys*ps(:)
! Call scheme
call cld_liq_run(ncol=ncol, timestep=timestep, tcld=tcld, temp=temp, qv=qv,              &
              ps=ps_local, cld_liq_array=cld_liq_array, errmsg=errmsg, errflg=errflg)
...
! Call scheme
call cld_ice_run(ncol=ncol, timestep=timestep, temp=temp, qv=qv, ps=ps_local,            &
              cld_ice_array=cld_ice_array, errmsg=errmsg, errflg=errflg)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugFor issues describing bugs, or PRs fixing bugs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions