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

Fortran configury: Ensure F08 real_kinds are actually valid kinds #5401

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

lrbison
Copy link

@lrbison lrbison commented Mar 21, 2025

Issue: #5090

max_decimal_prec = 1

prec: DO ik = 2, 36
exp: DO jk = 1, 700
k = SELECTED_REAL_KIND(ik,jk)
IF(k.LT.0) EXIT exp
do kk = 1,num_rkinds
if (real_kinds(kk) == k) found_rkinds(kk) = .true.
end do
max_decimal_prec = ik
Copy link
Collaborator

@brtnfld brtnfld Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the KIND is not supported, then the maximum decimal precision, max_decimal_prec, should not be set for that KIND.

@brtnfld
Copy link
Collaborator

brtnfld commented Mar 24, 2025

For consistency, the same changes should be made to FC_AVAIL_KINDS.

@brtnfld brtnfld self-assigned this Mar 24, 2025
INTEGER :: num_rkinds, num_ikinds, num_lkinds
logical :: found_rkinds( 1:SIZE(real_kinds) )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use uppercase keyword intrinsics

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

@brtnfld
Copy link
Collaborator

brtnfld commented Mar 24, 2025

I have to ensure this does not suppress detected kinds of other compilers since that scenario would not cause tests to fail.

@vchoi-hdfgroup vchoi-hdfgroup added the Component - Fortran Fortran wrappers label Mar 24, 2025
@vchoi-hdfgroup vchoi-hdfgroup added Component - Build CMake, Autotools and removed Component - Fortran Fortran wrappers labels Mar 24, 2025
@lrbison
Copy link
Author

lrbison commented Mar 24, 2025

please use uppercase keyword intrinsics

Done!

I have to ensure this does not suppress detected kinds of other compilers since that scenario would not cause tests to fail.

Sure. In my testing I saw that GNU Fortran was unaffected. You can see output here.

For these next two points let me clarify that SELECTED_REAL_KIND is correct in ACfL, it is only the F08 ISO_FORTRAN_ENV array REAL_KINDS that was wrong. That array was only used to print the real kinds the compiler supported (not max precision), so I don't think the following comments items require a change:

If the KIND is not supported, then the maximum decimal precision, max_decimal_prec, should not be set for that KIND.

The REAL_KINDS array was not used in the loop to determine max decimal precision, so it is already correct.

For consistency, the same changes should be made to FC_AVAIL_KINDS.

The non-F08 version of this loop builds the list of kinds based on the return values of SELECTED_REAL_KIND, so it never had the problem.

... however it makes me wonder if the preferred fix is just to ignore REAL_KINDS altogether and use FC_AVAIL_KINDS's logic to find real kinds.

@byrnHDF byrnHDF added Component - Fortran Fortran wrappers Component - Configure Configuration, build system/defaults and removed Component - Build CMake, Autotools labels Mar 26, 2025
@brtnfld
Copy link
Collaborator

brtnfld commented Mar 28, 2025

The non-F08 version of this loop builds the list of kinds based on the return values of SELECTED_REAL_KIND, so it never had the problem.

I'm not sure the compiler does not also have an issue with SELECTED_REAL_KIND, as from our discussion, #5090,

k = SELECTED_REAL_KIND(19,2)
print*,k
end

Printed -1, so it does not support KIND=16.

@lrbison
Copy link
Author

lrbison commented Mar 28, 2025

Printed -1, so it does not support KIND=16.

Correct. ACfL does not support KIND=16, yet it includes 16 in REAL_KINDS (a compiler bug). This caused HDF5 configuration to make code with REAL(KIND=16) which then fails to compile. I am suggesting this patch to work around the compiler bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Configure Configuration, build system/defaults Component - Fortran Fortran wrappers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants