NASA-LIS / LISF

Land Information System Framework
Apache License 2.0
114 stars 153 forks source link

GFortran in debug mode flags calls to HDF-EOS2 gdrdfld function with inconsistent buffer types #1432

Open emkemp opened 11 months ago

emkemp commented 11 months ago

Bug Description

When compiling with gfortran in debug mode, syntax errors will be reported for subroutines that call the HDF-EOS2 'gdrdfld' function with inconsistent buffer types.

For example, in ldt/DAobs/GLASSlai/readGLASSlaiObs.F90, there are two calls to gdrdfld for AVHRR and MODIS data (depending on user settings). The AVHRR buffer array is of type integer2, but for MODIS it is of type integer1.

gdrdfld is implemented in C, and is specified to treat the buffer argument as a void pointer (e.g., type is ignored). So this is not illegal per se. However, if gfortran is being used to debug other code, the compiler will not compile this code.

A partial solution is to disable HDF-EOS2 when compiling. But a better solution is needed if the user actually needs that library.

A better solution would be to write simple customized wrapper functions to gdrdfld in Fortran 90 (with an interface block containing module procedure declarations), and call gdrdfld within those wrapper functions. If only a single gdrdfld call occurs in each wrapper function, then I don't expect gfortran to report a problem.

Steps to Replicate

Run the LDT configure script with a GNU module (e.g., lisf_7.5_gnu_11.2.0_impi_2021.4.0), select Optimization level -2 (strict checks), and select use HDFEOS. Then compile LDT.

emkemp commented 1 month ago

Still TODO.