Skip to content

Conversation

@dhaumont
Copy link
Contributor

This PR is a refactoring to eliminate duplicated code between trltog and trgtol in the cpu branch.

The duplicated codehas been extracted into new routines in a new module trgl_mod, and they are called from trltog and trgtol.

IMPORTANT: The PR is still a draft and was not completely tested nor properly validated.

@dhaumont dhaumont marked this pull request as draft October 16, 2025 12:21
@samhatfield
Copy link
Collaborator

Thanks for this @dhaumont. Naturally it'll take some time to test, but assuming you've done your homework this could be a really nice restructuring.

Just a quick suggestion: TRGTOL_PROLOG and TRLTOG_PROLOG don't do much now - you could save even more complexity and line numbers by deleting them and moving the code into the parent subroutines?

@dhaumont
Copy link
Contributor Author

@samhatfield The code is not properly tested on my side, it is really still WIP.

About merging the code iinto parent subourtine, I did my best to move as much as I could, and what is left are the communication routines. But indeed we can still go further and have a single file for both.

@wdeconinck wdeconinck changed the title Factorize duplicated betweem trltog and trgtol (cpu only). Factorize duplication between trltog and trgtol (cpu only) Oct 21, 2025
@samhatfield
Copy link
Collaborator

If I understand what you said the other day @dhaumont, you're well aware that this isn't finished, and just want some early feedback on the overall idea before you commit more time to finishing it.

I think in principle we'd be happy to accept a change like this. TRLTOG/TRGTOL are very much in the category of "too scary, don't touch it", and anything that simplifies them is welcome. It's good to reduce repetition, and I like how the actual communication routines are now shorter and to the point.

My only concern is that we're introducing a lot more variables (derived types) that are now wrapping the other variables. So it's sort of more complicated and less complicated at the same time.

With time maybe we can simplify even further without making the code more of a headache. Maybe we could work on this PR together, and keep it up to date with develop. Eventually we might decide not to merge it, but it wouldn't be a waste of time because we would learn a lot about TRGTOL/TRLTOG during the process, which are subroutines I've avoided up to now as they're too scary.

My question is, is this PR related to your FIELD API developments or is it orthogonal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants