get_param() with %blocks not working as expected
Opened this issue · 0 comments
adcroft commented
The code
call openParameterBlock(param_file,'ABC') ! Prepend ABC% to all parameters
call get_param(param_file, mdl, "USE_XYZ", use_xyz, "Comment", default=.false.)
call closeParameterBlock(param_file)
correctly generates and reads parameters formatted as
ABC%
USE_XYZ = True ! [Boolean] default = False
! Comment
%ABC
The above is the normal form but a user can also write a shortcut of the form
ABC%USE_XYZ = True
which will also be read correctly (I do not think we have a mechanism to write in this shortcut form).
A problem arises when we need to read a parameter from another module. Currently if we use call openParameterBlock()
the doc file gets a %block inserted which would then be out of place. I thought that
call get_param(param_file, mdl, "ABC%USE_XYZ", use_xyz, do_not_log=.true., default=.false.)
would work but it is looking for lines with MLE%USE_XYZ
and not seeing the non-shortcut form. It seems we need to either
- add
do_not_log=
toopenParameterBlock()
; or - extend
get_param()
to parse theMLE%
(this seems ugly to me); or - add a
block='MLE'
optional argument toget_param()
which would silently look inside the block.
The last option seems best to me because we could then also check that we have no "%" characters in parameter names.
Summary:
- Current bug is that
call get_param(..., "ABC%USE_XYZ", ...)
does not work as expected. - Enhancement suggestion is to catch this and provide a mechanism to read a parameter from outside of the declared block.