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

Axis and Field labels not allocated properly when appended to IO handle lists. #261

Closed
alperaltuntas opened this issue Oct 31, 2023 · 4 comments
Assignees

Comments

@alperaltuntas
Copy link
Member

When running MOM6 in DEBUG mode with the intel compiler, we get the following error:

forrtl: severe (408): fort: (8): Attempt to fetch from allocatable variable LABEL when it is not allocated

Upon closer look, it seems that the issue results from the way register_axis_nc and register_netcdf_axis work. The register_axis_nc function acts as a wrapper for the register_netcdf_axis function. While register_axis_nc sets the axis%label member, the latter function does not. When register_axis_nc appends a copy of the provided axis to the handle%axes list, this appended copy lacks an allocated and assigned %label member, as it is constructed through the register_netcdf_axis function. Consequently, when the %get method is invoked to retrieve an axis instance, the returned axis does not possess an allocated and assigned label member.

This issue applies to the field instances as well, since register_field_nc and register_netcdf_field functions exhibit the same behavior.

This may be one of (many?) issues contributing to the recent memory-related issues.

I am currently testing a fix and will follow up with a PR.

@marshallward
Copy link

marshallward commented Oct 31, 2023

Thanks for working out the problem, Alper. Leaving axis%label (and field%label) unset on the netcdf side seems rather disastrous; I'm sorry for any headaches this may have caused. I think we never saw this because we do everything through the get_netcdf_fields mega-function, which does set those labels.

I guess the simplest fix is to also set %label in register_field_nc and register_axis_nc? (Ed: see below)

@alperaltuntas
Copy link
Member Author

I guess the simplest fix is to also set %label in register_field_nc and register_axis_nc?

Actually, I thought It would be better to set %label in register_netcdf_axis and register_netcdf_field instead, since those functions construct the axis and field instances. Would that be okay?

@marshallward
Copy link

Sorry, I mistyped, I agree with what you wrote 😅

@marshallward
Copy link

Oh, just to clarify, the axis%label = label still needs to exist in register_axis_nc. This is actually a MOM_axis, rather than a netcdf_axis. The issue that you identified is that the label in netcdf_axis was never set! (Except in the kooky case of get_netcdf_fields.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants