Closed alperaltuntas closed 8 months ago
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)
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?
Sorry, I mistyped, I agree with what you wrote :sweat_smile:
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
.)
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
andregister_netcdf_axis
work. Theregister_axis_nc
function acts as a wrapper for theregister_netcdf_axis
function. Whileregister_axis_nc
sets theaxis%label
member, the latter function does not. Whenregister_axis_nc
appends a copy of the provided axis to thehandle%axes
list, this appended copy lacks an allocated and assigned%label
member, as it is constructed through theregister_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
andregister_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.