Skip to content

Add present_and_true() to 5 modules#1114

Open
Hallberg-NOAA wants to merge 5 commits into
NOAA-GFDL:dev/gfdlfrom
Hallberg-NOAA:add_present_and_true
Open

Add present_and_true() to 5 modules#1114
Hallberg-NOAA wants to merge 5 commits into
NOAA-GFDL:dev/gfdlfrom
Hallberg-NOAA:add_present_and_true

Conversation

@Hallberg-NOAA
Copy link
Copy Markdown
Member

This pull request consists of 5 commits that add local copies of the function present_and_true() to the MOM_debugging, MOM_checksums, MOM_file_parser, MOM_document and MOM_forcing_type modules, and then uses them to simplify
unnecessarily complicated code logic in a total of 95 expressions. In 4 other cases a simple call to present() was able to simplify the code. In the case of tests for use_glc_runoff in the MOM_forcing_type module, this effectively adds a test for the logical setting of that argument instead of just its presence, so this could prevent the unnecessary declaration of some unused diagnostics, which could show up as added entries in available_diags files for cases using the NUOPC coupler. All answers are bitwise identical.

  Added a local copy of the function `present_and_true()` to the MOM_debugging
module, and used it to clean up the logic in 6 places.  This includes
eliminating the `are_scalars` local variables in 6 routines, as they are no
longer necessary.  All answers are bitwise identical.
  Added a local copy of the function `present_and_true()` to the MOM_checksums
module, and used it to clean up the logic in 27 places.  This includes
eliminating the `vector_pair` local variable in 6 places and the `do_corner`
local variable in 8 places, as they are no longer necessary.  All answers are
bitwise identical.
  Added a local copy of the function `present_and_true()` to the
MOM_forcing_type module, and used it to simplify the logic in 22 places. This
includes eliminating the `tau2ustar`, `shelf_sfc_acc` and `do_pres` local
variables in routines where they are no longer necessary.  In the case of tests
for `use_glc_runoff` this commit effectively adds a test for the logical setting
of that argument instead of just its presence, so this could prevent the
unnecessary declaration of some unused diagnostics, which could show up as added
entries in available_diags files for cases using the NUOPC coupler.   In 4 other
cases a simple call to `present()` was able to simplify the code.  All answers
are bitwise identical.
  Added a local copy of the function `present_and_true()` to the MOM_document
module, and used it to clean up the logic in 13 places.  All answers are
bitwise identical.
  Added a local copy of the function `present_and_true()` to the MOM_document
module, and used it to clean up the logic in 27 places.  This includes
eliminating the `variableKindIsLogical` and `do_log` local variables in places
where they are no longer necessary.  All answers are bitwise identical.
@Hallberg-NOAA Hallberg-NOAA added the refactor Code cleanup with no changes in functionality or results label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code cleanup with no changes in functionality or results

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant