NOAA-GFDL/MOM6

get_param() with %blocks not working as expected

Opened this issue · 0 comments

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.