NOAA-GFDL / FMS

GFDL's Flexible Modeling System
Other
87 stars 128 forks source link

ifort warning in fms_string_utils #1494

Closed dkokron closed 2 months ago

dkokron commented 2 months ago

I am chasing down the following warning from the Intel ifort compiler. "warning #6178: The return value of this FUNCTION has not been defined. [MY_POINTER]"

The only mention of a variable names "my_pointer" in in FMS (fms-noaa-gfdl-2024.01-beta5/string_utils/fms_string_utils.F90).

I have commented out the fms_sort_this() function which had my_pointer decorated with intent 'inout' even though my_pointer wasn't set in the routine. Still see the warning.

I commented 'allocated' test in fms_array_to_pointer(). Still see the warning.

Now I'm wondering what fms_find_my_string_binding() is supposed to do. It declares some variables but never sets anything.

rem1776 commented 2 months ago

@dkokron Most routines in that module including that one are bound to C routines in fms_string_utils_binding.c. On the fortran side of things they just look like empty routines but you can think of them more as declarations to be later defined by the functions in the C code.

It may be an erroneous warning due to some confusion between the two languages, but sometimes a small syntax change can fix things like this. It seems like its picking up my_pointer as a function pointer, when really it should be an array of pointers. Maybe switching my_pointer to a deferred shape array instead of a assumed one will fix it (ie. switching * to :)

dkokron commented 2 months ago

update: Changing my_pointer to my_pointer2 in fms_array_to_pointer() changes the warning accordingly.

dkokron commented 2 months ago

@rem1776 I isolated the issue to the fms_array_to_pointer() routine. Any suggestions for that routine?

bensonr commented 2 months ago

@dkokron - what compiler and version is giving this warning? Also, can you provide the flags you are using to generate the warning.

dkokron commented 2 months ago

The warning is coming at the 'use fms' stage in a user application.

The message is present when using ifort-19.1.3.304 and ifort-2021.6.0 (from the 2022.2.0 suite). The message goes away when using either ifort-2021.9.0 (from the 2023.1.0 suite) or ifort-2021.10.0 (from the 2023.2.0 suite).

I have a relatively small reproducer that I have already provided to Intel support. Do you want that?

bensonr commented 2 months ago

As the warning is not present with recent releases, there is no need to provide the reproducer.

dkokron commented 2 months ago

I'm happy to blame the compiler, but NOAA wants a root cause. Is there anything about fms_array_to_pointer() that might make the compiler think there is a problem?

dkokron commented 2 months ago

Intel posted that they found the code change that addressed this issue in ifort-2021.8 (from OneAPI-2023.0.0).