Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_param() with %blocks not working as expected #350

Open
adcroft opened this issue Apr 17, 2023 · 0 comments
Open

get_param() with %blocks not working as expected #350

adcroft opened this issue Apr 17, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@adcroft
Copy link
Member

adcroft commented Apr 17, 2023

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

  1. add do_not_log= to openParameterBlock(); or
  2. extend get_param() to parse the MLE% (this seems ugly to me); or
  3. add a block='MLE' optional argument to get_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.
@adcroft adcroft added bug Something isn't working enhancement New feature or request labels Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant