Skip to content

Conversation

@tibisabau
Copy link
Contributor

Description

Removed the FieldSet.add_constant() method from Parcels v4 as it is no longer necessary without JIT compilation. In v4, kernel functions can directly inherit variables from their enclosing scope, eliminating the need for an explicit method to add constants to the fieldset.

The implementation maintains backward compatibility for internal use by keeping the constants dictionary and updating internal kernel initialization code to use direct dictionary assignment (fieldset.constants[key] = value) instead of the removed method. Warning messages were updated to guide users toward the new approach.

Closes #2337.

The code in this pull request was generated by GitHub Copilot with the Claude Sonnet 4.5 model.

Checklist if Applicable

  • The tests passed – pytest tests
  • Linting passed
  • Documentation has been added
  • CHANGELOG.md has been updated

@erikvansebille
Copy link
Member

Thanks @tibisabau, for this very nice and clean implementation. Great that you're helping out with development of Parcels! Once we have green ticks on the CI, I think this is ready to be merged

@erikvansebille erikvansebille merged commit baa20f2 into Parcels-code:v4-dev Feb 3, 2026
12 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Parcels development Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Remove FieldSet.add_constant() method?

2 participants