I\'m trying to work with large numbers (~10^14), and I need to be able to store them and iterate over loops of that length, i.e.
n=SOME_BIG_NUMBER
do i=n,1,-
You've misunderstood the precise definition of the HUGE function. HUGE(num) returns the largest number with the same kind and type as num. The value returned also has the same kind and type as num. Since all your input values are (default) integers HUGE, correctly, returns the largest default-size integer.
HUGE(num) does not return the largest integer with kind=num. Nor does HUGE(num) return the largest number representable in num bytes. While many compilers use integer(kind=4) and integer(kind=8) etc for 4- and 8-byte integers, this is not guaranteed by the language standard and cannot be relied upon to be portable.
@MSB's answer tells you how to do what you want, I'm just butting in with some clarification.