Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Intrinsic Function HUGE result is 0.0

Ed_Martin
Beginner
590 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
Honored Contributor III
590 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.

0 Kudos
mecej4
Honored Contributor III
590 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!

0 Kudos
Ed_Martin
Beginner
590 Views

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

0 Kudos
Steve_Lionel
Honored Contributor III
590 Views

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

0 Kudos
Ed_Martin
Beginner
590 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

 

 

0 Kudos
Steve_Lionel
Honored Contributor III
590 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.

0 Kudos
Reply