Skip to content

Conversation

mabruzzo
Copy link
Collaborator

This should be reviewed after #400 has been merged


As the title states, I was doing some cleanup in initialize_metal_chemistry_rates.cpp. More cleanup is definitely required.

I had originally intended to do slightly less work here (mostly, I wanted to replace some the unit-calculations with machinery in InternalGrUnit before there was too much churn), but I went a little overboard. (But, at the end of the day, I think we probably want to do all this before we merge newchem-cpp into main -- it needs to happen sooner or later).

This all boiled down to moving around code and slightly rewording comments. It may be easier to go through commit-by-commit than to view all changes at once

These deleted declarations already occur within the grackle.h header.
Some include directives were also deleted that were redundant with
including then grackle.h header
This is important once we start compiling with C++
For context, the historic convention in Grackle project was to use .C as
the suffix for C++ source files. Thus, when we began transcribing files,
we used the .C suffix (even though it is a less common choice than .cpp)

However, it turns out that converting a file named `<prefix>.c` to
`<prefix>.C` causes lots of issues performing Git operations when your
machine has a case-insensitive file-system (common on macOS). This comes
up in operations as simple as changing between 2 branches

Consequently, we will be transitioning to the .cpp suffix
A few tweaks were necessary:
- I needed to add the `extern "C"` annotation to a number of functions
  that are publicly exposed as the C API
- I removed the leading underscore from some internal helper functions
- I needed to tweak make the group name argument passed to
  initialize_cloudy_data expect a `const char*`, rather than just a
  `char*`. This is essential since we are passing a string literal (this
  was a very minimal change)

I also added to the `static` specifier to some internal functions (this
ensures that these helper functions will not be accessible to external
code)
I also renamed initialize_rates.h to initialize_rates.hpp to denote that
the header is **ONLY** compatible with C++ source files
This information has been formatted into a markdown table (that will be
rendered into a table if/when we use doxygen)
These docstrings include a lot of context from the comments that were
originally in the Fortran rates calculation routines and that were
previously copied into initialize_metal_chemistry_rates.cpp (and into
initialize_rates, but that is less of a concern right now)
@mabruzzo mabruzzo added the refactor internal reorganization or code simplification with no behavior changes label Aug 30, 2025
@mabruzzo mabruzzo changed the base branch from main to newchem-cpp August 30, 2025 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor internal reorganization or code simplification with no behavior changes
Projects
Status: Awaiting Review
Development

Successfully merging this pull request may close these issues.

1 participant