Open peverwhee opened 1 day ago
is this also a problem with prebuild or just with capgen?
@climbfuji good question!
I ran a brief test with prebuild and it looks like it works as expected for Scenario 1, but Scenario 2 results in an incorrect conversion before the second scheme. For example, if you have variable unit_conversion_var
with units of km in the host model and then Scheme A has units for m (different from host) for that variable, while Scheme B has units of km (same as host) for that variable, you get code that looks like:
tmpvar_1 = 1.0E+3_kind_phys*unit_conversion_var(one:nx)
call schemeA(errmsg,errflg,tmpvar_1)
unit_conversion_var(one:nx) = 1.0E-3_kind_phys*tmpvar_1
...
tmpvar_1 = 1.0E+3_kind_phys*unit_conversion_var(one:nx)
call schemeB(errmsg,errflg,tmpvar_1)
unit_conversion_var(one:nx) = 1.0E-3_kind_phys*tmpvar_1
When you should get code that looks like:
tmpvar_1 = 1.0E+3_kind_phys*unit_conversion_var(one:nx)
call schemeA(errmsg,errflg,tmpvar_1)
unit_conversion_var(one:nx) = 1.0E-3_kind_phys*tmpvar_1
...
call schemeB(errmsg,errflg,unit_conversion_var)
NOTE: I modified the optional arguments prebuild test for this, so the fact that the conversions are being done on optional arguments may be part of the problem!
Thanks for testing. This is not what I expected (from my vague memory of how this is implemented)!
Description
Scenario 1
If a variable is used in two different schemes and:
It produces this error:
Scenario 2
On the flip side, if:
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
ps
in cld_ice.meta in the advection test to have units of "hPa", run the tests and observe the error.ps
in cld_liq.meta in the advection test and inspect the generated code to see the wrong units passed into cld_liqOutput
Generated code for scenario number 2 (where the wrong units are used):