-
Notifications
You must be signed in to change notification settings - Fork 1
Style Guide
The Tiger HLM routing code is written in C++, utilizing some functions from native C libraries. As of now, it consists of approximately 1,400 lines of C++ code. The codebase follows a procedure-oriented programming (POP) structure, with the logic broken into many small, modular functions.
While the current program is relatively small, additional modules and functionality will be added over time. To ensure long-term maintainability, performance, and readability, the following guidelines must be followed when editing or extending the codebase:
- All code must conform to the C++17 standard.
- Code must compile cleanly using
icpxwithout warnings or errors.
- Use header (
.hpp) files to declare function prototypes and structures. - Function implementations must be placed in separate
.cppfiles. - Keep functions small and focused. Each should perform a single, clearly defined task.
- The
main.cppshould not need to be touched!
- Use lowercase filenames.
- Separate words using underscores, not camelCase.
- Examples:
build_info.cpp
- All functions should be documented with brief, clear comments describing their purpose and inputs/outputs.
- Inline comments should explain non-obvious logic, but avoid restating what the code already says.
- There is no strict format for comments, but they must be easy to understand by future developers.
- It is recommended to use the GitHub Copilot extension in VSCode to assist with writing and documenting code.
- Use descriptive names for variables and functions.
- Avoid overly short or cryptic names unless they're standard (e.g.,
i,jfor loop indices). - Constants should use
UPPER_CASE_WITH_UNDERSCORES.
- Avoid use of
using namespace std;in header files. Prefer explicitstd::prefixes for clarity. Exception:using namespace boost::numeric::odeintis currently implemented but can be refactored later. - Avoid global variables unless absolutely necessary.
- Prefer
constandconstexprwhere applicable for clarity and safety. - Favor standard containers (
std::vector,std::map, etc.) over raw pointers unless performance dictates otherwise. - Initialize all variables and avoid magic numbers.
- All contributions should be made via pull requests with clear commit messages.
- Keep commits focused and logical — avoid lumping unrelated changes together.
Maintaining a clean and consistent style ensures that the Tiger HLM routing model can grow in complexity without becoming difficult to understand or modify. Even small contributions should aim to meet these standards.
Getting Started
User Guide
- Background
- Compiling
- OpenMP
- Solver
- The YAML File
- Parameters
- Initial Conditions
- Boundary Conditions
- Reservoirs
- Runoff Forcings
- Output Files
Programmer Guide