I'm working with integers larger than 2^31-1 and so I'm trying to set the precision of my integer variables to a higher value. The method I thought was correct was
PROGRAM f1
IMPLICIT NONE
INTEGER,PARAMETER :: LONG = SELECTED_INT_KIND(15)
INTEGER(KIND=LONG) :: n
n=2**31
END PROGRAM f1
which, as I understand, should allow n
to be in [-10^15, 10^15]. However the above code throws a compiler error using gfortran 4.6, namely
n=2**31
1
Error: Arithmetic overflow at (1)
I've tried replacing the trouble line with n=int8(2**31)
but to no avail. Any recommendations?