Skip to content

Moving Nest Code Restructure and Port to fms2_io#227

Merged
bensonr merged 22 commits into
NOAA-GFDL:dev/emcfrom
hafs-community:feature/mn_cleanup_202211
Dec 14, 2022
Merged

Moving Nest Code Restructure and Port to fms2_io#227
bensonr merged 22 commits into
NOAA-GFDL:dev/emcfrom
hafs-community:feature/mn_cleanup_202211

Conversation

@wramstrom
Copy link
Copy Markdown

@wramstrom wramstrom commented Dec 1, 2022

Description

  1. Improve modularization of moving nest code (see also PR in fv3atm)
  2. Code cleanup for moving nest and remove debugging outputs
  3. Upgrade to fms2_io

The moving nest code directory has been moved from atmos_cubed_sphere up one level to FV3. This directory restructuring removes all references to physics code due to moving nest in the dynamic core code in atmos_cubed_sphere. All calls into moving nest functionality are now performed from FV3/atmos_model.F90. atmos_cubed_sphere code no longer depends on moving nest code, or calls its subroutines.

Debugging print statements and subroutines that would print out data structure contents have been removed. While these were disabled during real-time and operational runs, some overhead in executing conditional statements remained. A minor performance improvement may be noticed. In addition, code clarity is now improved by removing these lines and subroutines.

Port to fms2_io was performed. The moving nest code no longer depends on the legacy fms_io library. Operational moving nest code only uses fms2_io for reading the high-resolution static files. This read code performs the file access to read from disk only on the head node of the PElist, then broadcasts the data to the other PEs. This may permit improved performance over the prior method, where each nest PE read the file from disk. Additional debugging code to dump netCDF files of model variables is normally commented out, but can be enabled during development. This debugging code makes use of the fms2_io domain decomposed write functionality.

Fixes #182

Related to PR 610 which creates the new FV3/moving_nest directory.
NOAA-EMC/ufsatm#610

How Has This Been Tested?

Tests were performed on Orion. Moving nest code showed bitwise identical results as older runs from the code cleanup and fms2_io. Some additional parts of the merge in other areas cause differences in forecast values, buy these are expected according to Bin Liu.

Full regression suite was run on Orion, with all tests running to completion. 148 of the tests passed fully. The remaining tests are 13 of the HAFS tests, which ran to completion but showed expected differences in numerical outputs.

Checklist:

Please check all whether they apply or not

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link
Copy Markdown
Contributor

@lharris4 lharris4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all of the moving-nest specific code is removed from the dycore, then this commit is good modulo the one very minor suggestion I have. Thank you for working on this.

Comment thread tools/fv_grid_tools.F90 Outdated
integer, save :: id_timer1, id_timer2, id_timer3, id_timer3a, id_timer4, id_timer5, id_timer6, id_timer7, id_timer8
logical :: use_timer = .false. ! Set to True for detailed performance profiling
integer, save :: id_timer1, id_timer2, id_timer3, id_timer3a, id_timer3b, id_timer4, id_timer5, id_timer6, id_timer7, id_timer8
logical :: use_timer = .True. ! Set to True for detailed performance profiling
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to set to .false. or be triggered by some runtime option.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggestion makes sense. I think that adding a namelist option to turn on the timing code makes sense, so that we could do it without a recompile. @BinLiu-NOAA and others, do you agree?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lharris4 I have added a namelist flag, defaulting to false, that enables the detailed performance timing calls. It parallels fv_debug, and is called fv_timers.

In looking at the code for this change, I noticed that there are lines of moving nest code in tools/fv_diagnostics.F90 to reinitialize zsurf after nest moves, and to register/produce lat/lon variables that reflect the nest motion, called grid_mlat, grid_mlon, grid_mlatt, and grid_mlont, which I had forgotten to mention. Let me know your thoughts on these code additions.

@lharris4
Copy link
Copy Markdown
Contributor

lharris4 commented Dec 9, 2022 via email

@junwang-noaa
Copy link
Copy Markdown
Collaborator

@wramstrom
Copy link
Copy Markdown
Author

@junwang-noaa That code is part of the dycore, not the moving nest; I'm not familiar with that section. It looks from the log that @bensonr made some changes over the summer to this file to prepare it for fms2_io, and from the comments that perhaps that last fms_io call can be removed. I'd like to have @bensonr weigh in with his opinion on this.

@laurenchilutti
Copy link
Copy Markdown
Member

laurenchilutti commented Dec 13, 2022

That section of fv_restart was intentionally left as a redundancy between fmsio and fms2io in the cases where other model components may still be using fms_io and would need this old fmsio set_filename_appendix called. I can discuss removing this with @bensonr and some of the fms2io developers. But I do not think Bill needs to remove it in this PR.

@junwang-noaa
Copy link
Copy Markdown
Collaborator

@wramstrom @laurenchilutti Thanks for the explanation!

@jkbk2004
Copy link
Copy Markdown

all regression tests are done on ufs wm pr 1518. please, go ahead to start merging in this pr.

Comment thread model/fv_arrays.F90
!< is recommended to only set this to .true. when initializing the model.
logical :: fv_debug = .false. !< Whether to turn on additional diagnostics in fv_dynamics.
!< The default is .false.
logical :: fv_timers = .false. !< Whether to turn on performance metering timers in the dycore and moving nest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice addition; it could be extended in the future to add more fine-grained timers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the granularity of output for MPP clocks is determined by an FMS namelist variable that works with the various timer levels specified in the clock_id to determine at what level a clock will be output.

Copy link
Copy Markdown
Contributor

@lharris4 lharris4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks.

@jkbk2004
Copy link
Copy Markdown

@lharris4 thanks for the approval! @laurenchilutti @bensonr could you go ahead to merge the pr?

Comment thread model/fv_arrays.F90
!< is recommended to only set this to .true. when initializing the model.
logical :: fv_debug = .false. !< Whether to turn on additional diagnostics in fv_dynamics.
!< The default is .false.
logical :: fv_timers = .false. !< Whether to turn on performance metering timers in the dycore and moving nest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the granularity of output for MPP clocks is determined by an FMS namelist variable that works with the various timer levels specified in the clock_id to determine at what level a clock will be output.

@bensonr bensonr merged commit a839395 into NOAA-GFDL:dev/emc Dec 14, 2022
@BinLiu-NOAA BinLiu-NOAA deleted the feature/mn_cleanup_202211 branch February 14, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants