Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!

Intrinsic Function HUGE result is 0.0

Ed_Martin
Beginner
209 Views

I am use Intel Fortran XE 17 update 4

Previously the following code sets the real variable to a very large negative value

      real :: no_lower = -HUGH(1.0)

Now the variable is set to zero.  Did something change in the Fortran standard?

 

Thanks for your help.

0 Kudos
6 Replies
Steve_Lionel
Black Belt Retired Employee
209 Views

Did you actually write HUGH or HUGE? I get the correct value (in version 18) with HUGE.

Please show a short but complete example that demonstrates the problem, the compilation command you used and the output.

mecej4
Black Belt
209 Views

If he actually wrote "HUGH", that would be a non-standard function, and the linking of the program would have failed, unless there was a function called HUGH in the user's code or in some library provided by the user. Therefore, it is mysterious how the program could have been compiled, linked and run to the point where it produced output, erroneous as that output might have been!

Ed_Martin
Beginner
209 Views

I actually used HUGE(1.0). Sorry for the typo.

Steve_Lionel
Black Belt Retired Employee
209 Views

I figured as much - and yes, HUGH would have triggered multiple errors. Please show an example that demonstrates the problem.

Ed_Martin
Beginner
209 Views

Here's a program that demonstrates the issue:

!  T_HUGE.f90
!
!  FUNCTIONS:
!  T_HUGE - Entry point of console application.
!

!****************************************************************************
!
!  PROGRAM: T_HUGE
!
!  PURPOSE:  Entry point for the console application.
!
!****************************************************************************

    program T_HUGE

    implicit none

    ! Variables
    real :: no_upper_limit = HUGE(1.0)
    real :: no_lower_limit = -HUGE(1.0)

    ! Body of T_HUGE
    print *, 'Hello World'
    print *, 'no_upper_limit =', no_upper_limit
    print *, 'no_lower_limit =', no_lower_limit
    
    print *,'<press return to end>'
    read *

    end program T_HUGE

 

Command line:

/nologo /debug:full /Od /warn:interfaces /fpconstant /module:"Debug\\" /object:"Debug\\" /Fd"Debug\vc150.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c

Output:

 Hello World
 no_upper_limit =  3.4028235E+38
 no_lower_limit =  0.0000000E+00
 <press return to end>

 

The critical option is /fpconstant.  Without it the no_lower_limit = -3.4028235E+38

 

 

Steve_Lionel
Black Belt Retired Employee
209 Views

Thanks for the more complete information. That's a compiler bug, still present in 18. Please report it to Intel using the Online Service Center.

In the meantime I would recommend against using /fpconstant - this option should be avoided anyway as it papers over nonportable and nonstandard code.

Reply