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

[develop] Add Community Fire Behavior Model #1139

Merged

Conversation

mkavulich
Copy link
Collaborator

@mkavulich mkavulich commented Oct 16, 2024

DESCRIPTION OF CHANGES:

This PR introduces the Community Fire Behavior Module (ufs-community/ufs-weather-model#2220) to the SRW App. In addition, there are a number of general improvements to the UFS SRW code and workflow. All of these changes are described in more detail below.

Community Fire Behavior Module

Documentation has been added to the Users Guide, but the basics are that the fire build requires an additional build flag

./devbuild.sh --platform=[hera|derecho|etc.] --app=ATMF

and has an additional fire: section in config.yaml. There is an example fire configuration available in the new example config config.fire.yaml. Many settings are described in detail in config_defaults.yaml, but I am working on additional details.

The fire model outputs additional netCDF files with fire-specific information; two example plots of this data can be found here:
ncview emis_smoke_trim
ncview fire_area_trim

Sample data for the case in the example file has been staged on Derecho (/glade/derecho/scratch/kavulich/FIRE/2024/test_data) and Hera (/scratch2/BMC/fv3lam/kavulich/UFS/workdir/UFS_FIRE/test_data). I will reach out to EPIC to see if they would be willing to officially stage this sample data on all Level 1 platforms for community use and potential future tests. This PR does not include a WE2E test because the testing system does not currently have a neat way to handle multiple build types, but in theory the new example case could be used.

Two new pre-defined domains SUBCONUS_CO_1km and SUBCONUS_CO_3km, for use with high-resolution fire experiments, are added.

build_settings.yaml

In develop there is currently no way to reference build settings at configure and run time. There was a vestigial capability in the ufs_srweather_app.settings.in which was added 4+ years ago, but it has never really been used or updated and it is in an ad-hoc format that cannot be easily used. I have leveraged this existing capability to create a new file, build_settings.yaml in the build directory that contains useful build information (the application built, the compiler, the git hash, etc.) and can be easily read using uwtools in the existing workflows and run scripts. Specifically this is used in this PR to ensure that the app has been built with the fire behavior capability if fire options are selected, but this should prove very useful in other parts of the workflow going forward; for just a few examples:

  • checking that the right compiler was specified for the experiment settings
  • checking that machine settings are correct compared to the build
  • checking app-specific settings for other builds such as AQM

This new file and the unused (but potentially useful in the future) ufs_srweather_app_meta.h.in files are moved to the sorc directory to keep the source code more organized and uncluttered.

Improve capability to use a different set of vertical levels

Currently the instructions for running SRW with a different number of vertical levels from the default 65 is quite convoluted, involving the need to manually edit the template namelist file. This PR adds LEVP as a configuration variable to more easily allow for runs with different vertical levels. The users guide instructions have been updated accordingly.

Flexible config file name

Now rather than being forced to use the name config.yaml for your experiment config, you can reference any yaml file by using the -c option for workflow generation:

./generate_FV3LAM_wflow.py -c config.fire.yaml

With these changes, EXPT_CONFIG_FN is removed as a configurable option, but this was uselessly self-referential anyway.

Additional options for retrieve_data.py

A big limitation in specifying filenames in the current app is that there is no capability for filenames to change based on the forecast hour vs the cycle hour. Therefore a new set of variables, identical to the originals but with the prefix f, can now be used when specifying filenames with respect to the forecast hour rather than the cycle hour.

An example of this new usage can be seen in the newly added config.fire.yaml experiment:

  EXTRN_MDL_FILES_LBCS:
    - '{fyyyymmdd}.hrrr.t{fhh}z.wrfprsf00.grib2'

This instructs retrieve_data.py to look for filenames specific to the valid forecast hour for the specific lateral boundary condition file. So for forecast hour zero (valid 2020081318), the expected filename will be 20200813.hrrr.t18z.wrfprsf00.grib2. But at the 18 hour forecast, the LBC filename will be 20200814.hrrr.t12z.wrfprsf00.grib2. This was not previously possible without these new variables, and represents a vast improvement in flexibility for users.

Speedup of symbolic linking

I found that (depending on the platform) the create_symlink_to_file.sh function could take as many as several seconds for each link, an absurdly long time for such a simple operation! I removed some superfluous logic from this function and boolify.sh (which ensures that booleans are properly compared in bash, a necessary evil), which brought this time down to tenths of seconds. This results in a speedup of a minute or more for the run_fcst task, depending on the platform and the settings.

Various random improvements

  • Fixed regex statements in WE2E tests to fix SyntaxWarning: invalid escape sequence
  • Updated build modulefiles to include FC variable, which is needed by the Fire Behavior component.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

TESTS CONDUCTED:

A number of fundamental test runs have been conducted on Derecho, Hera, and Orion, both with and without the ATMF build. Not all are passing, but seems to be unrelated to this development; see the note at the top. This section will be updated once those issues are resolved.

  • derecho.intel
    • fundamental tests, both with and without -a=ATMF build
    • new UFS_FIRE test
  • gaea.intel
  • hera.gnu
  • hera.intel
  • hercules.intel
  • jet.intel
  • orion.intel
  • wcoss2.intel
  • NOAA Cloud (indicate which platform)
  • Jenkins
  • fundamental test suite
  • comprehensive tests (specify which if a subset was used)

DEPENDENCIES:

#1136 should be merged first, as it includes a fix for Hera runs with the new UFS weather model hash.

DOCUMENTATION:

Users guide has been updated with instructions for building and running with these new capabilities; see draft documentation build in the Github checks below. Specifically, this is the new chapter on the UFS_FIRE capability.

ISSUE:

CHECKLIST

  • My code follows the style guidelines in the Contributor's Guide
  • I have performed a self-review of my own code using the Code Reviewer's Guide
  • I have commented my code, particularly in hard-to-understand areas
  • My changes need updates to the documentation. I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • Any dependent changes have been merged and published

CONTRIBUTORS (optional):

Thanks to the whole Fire Behavior team for bringing me on to this project, and their extensive efforts to get this capability ready for use by the scientific community: @danrosen25 @masih-e @pedro-jm and @mefrediani

danrosen25 and others added 30 commits October 6, 2023 11:40
cleanup create_nems_configure_file.py to use arguments rather than environment variables,
add fire capabilities
 - Add remainder of configurable fire namelist options to config_defaults
 - Add fire namelist filenames and paths to config_defaults
 - Add LEVP (number of vertical levels) as a config variable, and explicitly
   set levp and npz as namelist variables. This will require some updates to documentation
 - Generate the majority of the UFS_FIRE namelist in the workflow generation script. The
   rest (start and end times) will be set in the run_fcst step to account for cycling
 - Needed correct naming template for input ICS and LBCS in config.fire.yaml
 - Incorrectly formatted lines in create_nems_configure_file.py
 - Fix incorrect namelist location for levp
 - Forgot to ignore FIRE_INPUT_DIR when creating &fire namelist
 - Fill in &time namelist section
 - Link namelist.fire to namelist.input for now (until we can get the name changed)
 - Link in geo_em file

Stuck on namelist errors for now due to old weather model hash.
…file does not exist. This avoids weird error handling from calling an argparse error class.
 - Force bash to output decimal numbers when creating fire namelist
 - Remove rogue ln command
 - Create a new variable FIRE_NUM_TASKS to choose the number of tasks to assign to the fire behavior model.
 - Modify PE_MEMBER01 so it accounts for FIRE_NUM_TASKS if set
 - Check that FIRE_NUM_TASKS is positive if running the fire model
 - Remove last remnants of old namelist variables
 - Update nems.configure to assign weather model to first petlist, then the fire tasks last
 - Remove deprecated namelist options "fire_grows_only" and "fire_lfn_ext_up"
 - Add functionality to create_diag_table_file.py that gives the ability to add additional entries to an existing diag_table
 - When UFS_FIRE is active, add line to diag_table for "fsmoke" tracer
…_workflow

Resolved Conflicts:
	Externals.cfg
	parm/ufs.configure
	ush/create_ufs_configure_file.py
	ush/generate_FV3LAM_wflow.py
	ush/get_crontab_contents.py
	ush/set_namelist.py
…ile. This gives ~5x speedup for create_symlink_to_file on derecho
@mkavulich mkavulich force-pushed the feature/ufs_fire_workflow branch from de7f71f to c77770f Compare November 7, 2024 01:25
@mkavulich
Copy link
Collaborator Author

@christinaholtNOAA @MichaelLueken I believe I have addressed all your comments. Note that I did update how the fire ignition variables are handled in setup.py and generate_FV3LAM_wflow.py slightly, and add a new WE2E test that covers multiple ignitions. You can see those changes in this diff.

Let me know if you have any more comment/concerns.

Copy link
Collaborator

@MichaelLueken MichaelLueken left a comment

Choose a reason for hiding this comment

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

@mkavulich - While attempting to run the two new WE2E tests, they failed to submit because FIRE_ATM_FEEDBACK > 0.0 for these new configurations. Should the test configuration use FIRE_ATM_FEEDBACK: 0.0 instead of FIRE_ATM_FEEDBACK: 1.0?

ush/setup.py Show resolved Hide resolved
Initial capability needs FIRE_ATM_FEEDBACK=0.0
Copy link
Collaborator

@MichaelLueken MichaelLueken left a comment

Choose a reason for hiding this comment

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

Thanks, @mkavulich! The tests are successfully generated and run. Also, thank you very much for updating the documentation in ConfigWorkflow.rst. We'll need to see if there is some way to pull information directly from config_defaults.yaml into the ConfigWorkflow.rst file so that we don't need to repeat modifications to both.

@mkavulich
Copy link
Collaborator Author

@MichaelLueken Thanks for the review. Let me know when the data is staged for the WE2E tests; I'll likely need to make some modifications to those test files to point to the correct data.

@MichaelLueken
Copy link
Collaborator

@mkavulich -

The UFS Fire data has been staged on Tier-1 platforms:

  • Hera - /scratch1/NCEPDEV/nems/role.epic/UFS_SRW_data/develop/UFS_FIRE
  • Derecho - /glade/work/epicufsrt/contrib/UFS_SRW_data/develop/UFS_FIRE
  • Gaea - /gpfs/f5/epic/world-shared/UFS_SRW_data/develop/UFS_FIRE
  • Hercules/Orion - /work/noaa/epic/role-epic/contrib/UFS_SRW_data/develop/UFS_FIRE
  • Jet - /mnt/lfs5/HFIP/hfv3gfs/role.epic/UFS_SRW_data/develop/UFS_FIRE

And many thanks to @RatkoVasic-NOAA for staging the data across the platforms!

 - New variable to WE2E test data, we should use this to consolidate test variables in the future
 - Shorten fire tests to 3 hours
 - Fix extra prints in workflow generation
@mkavulich
Copy link
Collaborator Author

@MichaelLueken I pushed the final changes for the new fire WE2E tests, I believe this PR is ready for merging presuming all tests pass and @christinaholtNOAA approves.

Copy link
Collaborator

@christinaholtNOAA christinaholtNOAA left a comment

Choose a reason for hiding this comment

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

LGTM.

@MichaelLueken MichaelLueken added the run_we2e_coverage_tests Run the coverage set of SRW end-to-end tests label Nov 12, 2024
@MichaelLueken
Copy link
Collaborator

@mkavulich -

The Jenkins tests are all failing in the Functional WorkflowTaskTests phase of the pipeline. The Jenkins tests don't have an exec directory, but an install_${compiler}/exec directory. The ush/setup.py script needs to have the build_config_fp variable updated to point to either exec (standard build) or install_${compiler}/exec (Jenkins build), otherwise the Jenkins tests will be unable to run.

@MichaelLueken
Copy link
Collaborator

@mkavulich -

On Hera, you can see the directory structure for GNU - /scratch2/NAGAPE/epic/role.epic/jenkins/workspace/s-srweather-app_pipeline_PR-1139/hera - and Intel - /scratch2/NAGAPE/epic/role.epic/jenkins/workspace/s-srweather-app_pipeline_PR-1139__2/hera. We'll need to ensure that the new build_settings.yaml file can be located, whether the file is in exec or in some_user_defined_directory/exec.

@mkavulich
Copy link
Collaborator Author

@MichaelLueken Thanks for the update. I pushed a fix that should work, can you try again?

@MichaelLueken
Copy link
Collaborator

Thanks, @mkavulich! The Jenkins tests have been resubmitted.

@MichaelLueken
Copy link
Collaborator

@mkavulich -

The Jenkins tests are now running without issue, but there is a conflict in doc/conf.py where Gillian removed the Options for autoyaml extension section that you had modified in this PR.

@MichaelLueken
Copy link
Collaborator

@mkavulich -

All Jenkins WE2E tests have successfully passed! I will be able to merge this PR once the conflict in doc/conf.py has been resolved.

@MichaelLueken MichaelLueken merged commit fae3a7c into ufs-community:develop Nov 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EPIC Support Requested run_we2e_coverage_tests Run the coverage set of SRW end-to-end tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need an easy way to reference build settings at runtime
4 participants