Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masking added to ESMF regridding for samplers incompatible with external code #3280

Closed
bena-nasa opened this issue Jan 6, 2025 · 5 comments
Assignees
Labels
0 Diff The changes in this pull request have verified to be zero-diff with the target branch. ❗ High Priority This is a high priority PR ❓ Question Further information is requested

Comments

@bena-nasa
Copy link
Collaborator

A while ago for @metdyn sampler work we added made use of the masking capability in ESMF regridding to handle the geostationary sampler. When creating a grid, we added a mask, anywhere the satellite sees is set to a constant MAPL_MASK_IN and everywhere else MAPL_MASK_OUT, via enumerators so assuming these are 0 and 1. Then when creating the ESMF_RouteHandle we say set anywhere that is MAPL_MASK_OUT to MAPL_UNDF if a mask is present in the destination grid.

Turns out this is problem for UFS. Remember here the grid is passed in from outside and they have a land/ocean mask which are 0 and 1 so the it says, oh the grid has a mask, I'll mask, but in this case we do not want to be masking based on this for the emissions since this is for GOCART.

I'm not sure best solution. Clearly this is dangerous. Dusan suggested, making our mask or there's just different values from 0/1 but that's just relying on coincidence so seems not the ideal solution

How about this, what if in our own grid factory when the mask is set, we also set an attribute on the grid, saying the values to mask out. So in the MAPL/ESMF regridding layer the grid just have BOTH a mask and an attribute saying what values to mask. So if the UFS grid doesn't set this, even if there is a mask, it won't be applied to the ESMF_RouteHandle unless this attribute is set.

@bena-nasa bena-nasa added ❓ Question Further information is requested 0 Diff The changes in this pull request have verified to be zero-diff with the target branch. ❗ High Priority This is a high priority PR labels Jan 6, 2025
@tclune
Copy link
Collaborator

tclune commented Jan 6, 2025

I agree with the analysis of the root cause.

I think the solution must be to have a registry so that components don't actually set the value in ESMF but rather request a value. This would be akin to "new_unit" in Fortran OPEN statement.

Easy enough to say for MAPL, but ... that does not really solve the problem for the UFS people who rightly should not use ESMF.

I will open a related ticket in ESMF for this.

@tclune
Copy link
Collaborator

tclune commented Jan 6, 2025

I suppose another solution is to arrange a deep copy of the grid so that different components don't see each other's masks ... Not that ESMF supports that option either.

@bena-nasa
Copy link
Collaborator Author

bena-nasa commented Jan 6, 2025

@tclune What about the simple solution I proposed in the first post?

@weiyuan-jiang
Copy link
Contributor

I think this is easy and doable . quote "How about this, what if in our own grid factory when the mask is set, we also set an attribute on the grid, saying the values to mask out. So in the MAPL/ESMF regridding layer the grid just have BOTH a mask and an attribute saying what values to mask. So if the UFS grid doesn't set this, even if there is a mask, it won't be applied to the ESMF_RouteHandle unless this attribute is set. "

@bena-nasa
Copy link
Collaborator Author

made a PR to implement a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 Diff The changes in this pull request have verified to be zero-diff with the target branch. ❗ High Priority This is a high priority PR ❓ Question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants