Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
43 Views

Intrinsic Function HUGE result is 0.0

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
Highlighted
Black Belt Retired Employee
43 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
Highlighted
Black Belt
43 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
Highlighted
Beginner
43 Views

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

0 Kudos
Highlighted
Black Belt Retired Employee
43 Views

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

0 Kudos
Highlighted
Beginner
43 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
Highlighted
Black Belt Retired Employee
43 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