How to correctly add an integer multi-option switch to lfric_apps namelist and pass to UM physics? #282
Replies: 2 comments 5 replies
-
Hi Michael, sorry, I think you should take the "tedious" route :-) We went to great effort to get away from "magic numbers" that make little sense to the uninformed unless they go to the original documentation. I do appreciate that many of the benefits are lost when things are translated by the um interfacing routine, but I'd rather we were not held back by this history, particularly as the fork of the UM physics is somewhat imminent. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I didn't intend to be rude about the numbers - it's just a term used by software engineers for values that have no implicit meaning. The reality is that the someone reading the code, such as a code reviewer, may not want to keep referring to the metadata, and sometimes the link between a value and its metadata is not obvious. Historically, some numbering schemes have sometimes got quite complicated. The LFRic system converts the strings in the metadata into integers in the code. But the code hides their values (which are actually set using a random number generator!). The choice and option values will be held in variables named after the namelist and the option names which hopefully makes it easier to find the relevant metadata. I wouldn't suggest trying to anticipate what happens after the change, as whatever you do there will be work to change away from your method of defining the options to the method set by the LFRic configuration system (and some recent work in support of new science requirements may change aspects of how we do it). The migration away from the UM interfacing routine may be done iteratively over time as it is recognised that there is a lot to do and there will be other things to do that have higher priority. |
Beta Was this translation helpful? Give feedback.
-
Hi all!
In my UM ticket:
https://code.metoffice.gov.uk/trac/um/ticket/7815
I've added a new multi-option integer switch (i_update_precfrac) to the microphysics namelist, to allow the user to select between different methods for calculating something.
Then in a linked lfric_apps ticket:
https://code.metoffice.gov.uk/trac/lfric_apps/ticket/467
I add the same integer switch to the lfric_apps namelist and attempt to copy it into the UM physics in mphys_inputs_mod.F90.
The branches as they stand do not correctly set i_update_precfrac in lfric_apps. The problem seems to be that in LFRic, specifying the meta-data for my new switch to have
values=1,2
doesn't seem to result in the namelist item in the autogenerated code actually being integer kind (whereas in the UM we always define integer switches this way). So when the code tries to copy the lfric namelist i_update_precfrac to the integer one in the UM physics, the resulting integer is garble (a huge positive number).
I tried explicitly stating in the lfric_apps rose-meta that i_update_precfrac has
type=integer
But then if I do this, it won't let me specify the allowed 'values' and 'value-titles' to display in the GUI (rose metadata-check complains these are not consistent with 'type=integer').
I know I could just let the lfric one be non-integer, and then use a
SELECT CASE
block inum_physics_init_mod.f90
to tediously set the UM physics integer version separately for each allowed value of the lfric namelist version. But I'd much rather just have the name, meta-data and kind of my namelist inputs be completely consistent between the UM and lfric to avoid confusion! Does anyone know a way I can do this?Cheers!
Mike
Beta Was this translation helpful? Give feedback.
All reactions