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

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

Open
emkemp opened this issue Oct 16, 2023 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@emkemp
Copy link
Contributor

emkemp commented Oct 16, 2023

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 emkemp added bug Something isn't working good first issue Good for newcomers labels Oct 16, 2023
@emkemp
Copy link
Contributor Author

emkemp commented Jul 16, 2024

Still TODO.

@ShangyongShi
Copy link

I am currently compiling LISF 7.5.1 and I came across the same problem about gdrdfld. I checked the codes that used gdrdfld using

grep -rnw '/path/LISF/' -e 'gdrdfld'

and found that same problem exist in these codes:

image

I checked the /ldt/make/Makefile and found the following lines:

ifeq ($(LIS_ARCH),linux_gfortran)
# For MPI
LDT_historyMod.o: LDT_historyMod.F90
        $(FC) $(FFLAGS) -fallow-argument-mismatch $(HEADER_DIRS) $<
# For HDF-EOS2
readGLASSlaiObs.o: readGLASSlaiObs.F90
        $(FC) $(FFLAGS) -fallow-argument-mismatch $(HEADER_DIRS) $<
readNASA_AMSREsmObs.o: readNASA_AMSREsmObs.F90
        $(FC) $(FFLAGS) -fallow-argument-mismatch $(HEADER_DIRS) $<
endif

This is when I found that my LIS_ARCH was set to linux_ifc. After changing it to LIS_ARCH=linux_gfortran, the mismatch in types can be ignored by gfortran. Hope this could provide some hints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants