Starting to develop main code elements and stand alone model - #19
Conversation
…n-3225006954108420233 Enhance setup tool for standard CMake integration
Replaced all occurrences of the C++20 std::format and the <format> header with std::ostringstream and std::iomanip. This ensures portability on systems where the compiler supports C++20 but does not yet provide the <format> header (e.g., GCC versions older than 13). Affected files: - src/ww4_utils/time_management.cpp - src/ww4_utils/ww4_logfile.cpp - src/ww4_utils/ww4_std_out.cpp All 27 unit tests passed. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
Replaced all occurrences of the C++20 std::format and the <format> header with std::ostringstream and std::iomanip for portability. Updated headers in: - src/ww4_utils/time_management.cpp - src/ww4_utils/ww4_logfile.cpp - src/ww4_utils/ww4_std_out.cpp Headers now include the correct last update date (2026-04-06) and follow The Aldgisl Protocol for author and date tags. All 27 unit tests passed. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…bility-2456046090949901966 Replace std::format with ostringstream and iomanip for portability
- Update w4core_init, w4core_wave, w4core_finl to accept DateTime - Update ww4_stand_alone.cpp to load and pass times - Add print statements for times in core routines - Add unit test for new core routine signatures - Update CMakeLists.txt with new test Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
- Update w4core_init, w4core_wave, w4core_finl to accept DateTime - Update ww4_stand_alone.cpp to load and pass times - Add print statements for times in core routines - Add unit test for new core routine signatures - Update documentation Last Update tags to 2026-04-06 Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…core-18335909203298507063 Pass simulation times from config to core routines
- Centralize configuration loading and reporting in w4core_init. - Provide getRunConfig() to expose settings to other core routines. - Remove redundant console output from ww4_stand_alone and core routines. - Ensure clean output by respecting produceStdOut setting. - Update file headers and handle unused parameters to satisfy strict build flags. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
- Centralize configuration loading and reporting in w4core_init. - Provide reportRunConfig() to standard output for use in multiple core routines. - Ensure w4core_init, w4core_wave, and w4core_finl all report the configuration when produceStdOut is enabled. - Clean up redundant output in ww4_stand_alone and core routines. - Updated headers and implemented parameter silencing to satisfy strict build flags. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
- Updated w4core_init, w4core_wave, and w4core_finl to print start/end times. - Simulation times are reported when produceStdOut is enabled. - Parameter names are now used, eliminating the need for silencing. - Maintained centralized configuration reporting via reportRunConfig. - Cleaned up redundant output in standalone program. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…fig-5474536972702568252 Refactor core initialization and configuration reporting
This change moves strict compiler flags (like -Werror and sanitizers) from global add_compile_options to target-specific target_compile_options. This prevents these flags from leaking into third-party dependencies like Google Test, which was causing build failures with the Intel icpx compiler. Key changes: - Introduced WW4_STRICT_WARNINGS and WW4_USE_SANITIZERS CMake options. - Added -Wno-error=unknown-warning-option for IntelLLVM and Clang. - Updated ww4_setup.py and ww4_compile.py to handle the new toggles. - Updated templates/ww4_compile_config.yml with the new configuration fields. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…rror-8246915673490259320 Resolve icpx compilation error by isolating strict compiler flags
- Added empty comment lines before subroutine calls in stand-alone program and core routines. - Updated `w4core_init` to initialize profiling, manage `log.ww4`, and report configuration to both stdout and log file. - Updated `w4core_finl` to capture and report memory usage and run time. - Implemented memory release in `w4core_finl` to clear persistent model data. - Refactored `reportRunConfig` to support flexible output streams. - Updated all related headers and call sites. - Verified with unit tests and code review. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…g-and-formatting-1019764527265556901 Enhance Logging, Finalization Summary, and Formatting in Core Routines
This commit implements the `extcde` and `writeExtcdeOutput` routines in the `ww4_utils::ww4_std_out` namespace, providing a modern C++ conversion of the WAVEWATCH III error-handling routine. Key changes: - Added `writeExtcdeOutput` to format error messages with a "WW4 ERROR:" prefix, including optional source location (FILE/LINE). - Added `extcde` as a `[[noreturn]]` function that calls the formatting logic and terminates the program via `std::exit`. - Added unit tests in `test_ww4_std_out.cpp` to verify output formatting. - Updated documentation and file headers to reflect heritage from `w3servmd.F90`. All tests passed (30/30). Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…ls-16669883094211413373 Port EXTCDE from WW3 to WW4 Utils
Removed an extra closing brace that caused the w4core_init function to close prematurely, leading to compilation errors. Verified by building the project and running all tests. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
Removed an extra closing brace in w4core_init.cpp and fixed clang-format violations (trailing spaces in empty comment lines) in ww4_stand_alone.cpp and core model files to resolve CI failures. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
- Declared and implemented reportRunConfig in ww4_utils. - Removed reportRunConfig from ww4_core. - Updated all callers to use ww4_utils::reportRunConfig. - Verified by building and running all tests. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
- Resolved syntax error in w4core_init.cpp. - Moved reportRunConfig refactoring from ww4_core to ww4_utils. - Added try-catch blocks and error reporting to main program and core routines. - Updated CMake to place only the main program in the exe directory. - Fixed clang-format violations. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…-error-2939422864198929835 Fix syntax error in w4core_init.cpp
- Separated multiple CMake commands onto individual lines to resolve parse errors. - Removed incorrect spaces in file paths and URLs. - Corrected malformed compiler flag arguments. - Standardized indentation and improved overall readability of the build configuration. - Verified successful configuration, build, and test execution (30/30 tests passed). Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…171-a3690cdd Fix CMakeLists.txt parse errors and reformat for HPC compatibility
… capture. - Modified `ww4_utils::loadRunConfig` to return `std::optional<RunConfig>`. - Updated `w4core_init` to capture a program name and use it in output banners. - Updated `w4core_finl` to use the captured program name in footers. - Enhanced `ww4_stand_alone` to extract program name from `argv[0]` and handle config loading errors with `extcde`. - Updated unit tests to match new API and semantics. - Ensured all 30 tests pass. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…er compatibility. - Modified `ww4_utils::loadRunConfig` to return `std::optional<RunConfig>`. - Updated `w4core_init` to capture a program name and use it in output banners. - Updated `w4core_finl` to use the captured program name in footers. - Enhanced `ww4_stand_alone` to extract program name from `argv[0]` and handle config loading errors with `extcde`. - Replaced `std::span` with `DateArray` references in `TimeManagement` for better compiler compatibility on supercomputers. - Updated unit tests to match new API and semantics. - Ensured all 30 tests pass. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…g-program-name-7561277135572640975 Error Capturing and Program Name Capture in Core and Stand-alone
@jcwarner-usgs Yes John, from my in person discussion with quite a few WW3 contributors, and with Jessica as a strong proponent of this, we intend to have the core WW4 code to work directly with NetCDF - Zarr, and no longer use flat binary files. This is described in the Phase II progress report, which was added to the NOAA Institutional Repository to day as https://doi.org/10.25923/0wyp-9f39 |
- Integrated yaml-cpp 0.8.0 into the build system. - Refactored StandaloneConfig and RunConfig to support nested YAML sections (simulation, general, physics, forcing, homogeneous_data, output). - Updated configuration templates in templates/ and all relevant integration tests in tests/ww4_core/. - Added Kit Stokes as a contributor for yaml-cpp integration. - Added Jessica Meixner as a contributor for nested data structures. - Improved robustness by wrapping YAML parsing in broad try-catch blocks to ensure noexcept compliance. - Verified that all 112 unit and integration tests pass. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
- Ran clang-format on all modified C++ source and header files. - Verified compliance using clang-format --dry-run --Werror. - Confirmed that all 112 unit and integration tests still pass. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
|
@ardhuin, @mickaelaccensi, @ukmo-ccbunney, @ukmo-juan-castillo, @ukmo-jianguo-li, @ukmo-kitstokes, @ukmo-daisybrown, @thesser1, @benoitp-cmc, @, @aronroland, @jcwarner-usgs, @sbrus89, @ErickRogers Thanks for all your input. This is really starting to move this from a Hendrik effort to a community effort! I have addressed all comment so far (correct me if I am wrong), with quite a few modifications, and moving some things to four new issues. In the background, I did the initial YAML refactoring, but I cannot test this right now as my target machines are down for maintenance. The only other outstanding issue is to rename the log.ww4 file. I will be out on leave from noon today through June 16. When I am back, I intend to work with Jessica on merging this PR (with the last two additions mentioned above). With that in mind, please provide feedback on the PR by then, or leave it to future discussions. Note that I intend to invite all of you later in June to start having a regular vitula discussion time slot for WW4, which is intended to eventually become a code managers meetings. Thanks again, Hendrik |
It may be worth investigating the use of a I/O server such as XIOS for reading and writing the netcdf files, as it is done e.g in NEMO. |
…nested-2785785070788750801 Refactor YAML config processing and implement nested structures
- Rename the primary log file to 'ww4_log.txt' for better clarity and consistency. - Update .gitignore and relevant integration tests to reflect the new log filename. - Reset simulation start and end times in 'templates/ww4_standalone.yaml' to 2026-01-01 and 2026-01-02 respectively. - Update documentation headers to reflect the last update date. Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…dates-18420770574438370462 Rename log file and update standalone template dates
JessicaMeixner-NOAA
left a comment
There was a problem hiding this comment.
In the future, it would be helpful to have smaller PRs. Here are the opened issues based on reviewer feedback and comments that need to be addressed:
#20
#21
#22
#23
#25
#26
Additionally, before extensive work goes some of these issues need to be addressed and we need to determine numerical methods. I think this will be helpful in ensuring we're pushing the code forward instead of simply rewriting WW3 in C++. That being said I'll "approve" so @HendrikTolman-NOAA can work on next steps, even though I'd personally prefer to have seen more of the above issues addressed first.
Moved Doxygen @struct and @enum documentation blocks from implementation (.cpp) files to their corresponding header (.h) files in ww4_utils. This ensures that type documentation is co-located with its declaration, following standard practices and improving Doxygen's association logic. Affected files: - memory_utils.h/cpp - time_management.h/cpp - ww4_input_utils.h/cpp - ww4_logfile.h/cpp - ww4_output_utils.h/cpp - ww4_run_config.h/cpp - ww4_service.h/cpp - ww4_standalone_config.h/cpp Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
Moved Doxygen @struct and @enum documentation blocks from implementation (.cpp) files to their corresponding header (.h) files in ww4_utils. Updated '@Date Last update' Doxygen tags in all modified files to 2026-07-07. Affected files: - memory_utils.h/cpp - time_management.h/cpp - ww4_input_utils.h/cpp - ww4_logfile.h/cpp - ww4_output_utils.h/cpp - ww4_run_config.h/cpp - ww4_service.h/cpp - ww4_standalone_config.h/cpp Co-authored-by: HendrikTolman-NOAA <237313876+HendrikTolman-NOAA@users.noreply.github.com>
…-ww4-utils-15121581559121438800 Move Doxygen documentation for structs and enums to headers
|
I am about to merge this PR. I would like to note that this PR has been much larger than I would generally prefer. However, with the purpose to start working with real code to jumpstart working as a community, this behemoth did serve a unique purpose. FRom no on , however, I intend to focus PRs on single issues and features. |
Description
This PR introduces a core skeleton of a stand-alone ww4 program (ww4_stand_alone) centered around three core routines for initialization (w4core_init), time stepping (w4core_wave), and finalization (w4core_finl) as graphically depicted in the ARCHITECTURE.md. The focus is on clean C++ programming with high code cohesion and low code coupling, following linting and documentation (doxygen tag) documentation, integrating unit testing, and setting up a simple compile environment. Moreover, it provides a test of moving from WW3 .inp files to using YAML files to set user input, and sets up the time stepping around model input fields and output fields. Finally, screen output and log file output is set up. It DOES NOT execute actual input and output, and it DOES NOT address time stepping from a numerical solution perspective. This is still a serial code only.
Issue(s) addressed
Other than working toward a core model structure that will allow for parallel and community based code development, the main goals are to establish good C++ coding practices, and automating linting, code formatting, unit testing as part of the GitHub work flow. Doxygen tags are included throughout the code, but are not yet automated in the GitHub workflow, and Doxygen documentation generation is not yet used (the Doxyfile is just a placeholder for now).
Commit Message
Introducing the core skeleton of a stand-alone ww4 program (ww4_stand_alone) with three main routines, a YAML based user input, time stepping of input and output, clean screen and log output, and full automation of unit testing, linting and code formatting.
Check list
Testing
The GitHub workflow automates linting and unit testing. The code developed for this PR and previous PRs is 100% covered in the automated unit testing.