Currently I\'m brushing up on my Fortran95 knowledge (don\'t ask why)...
I\'m running in to a problem though. How does one handle large integers, eg. the size of: ~7
The portable to declare an integer "index" that will have at least 12 decimal digits is:
integer, parameter :: MyLongIntType = selected_int_kind (12)
integer (kind=MyLongIntType) :: index
The "kind=" may be omitted.
Using specific values such as 3 is completely non-portable and not recommended. Some compilers use the type numbers consecutively, others use the number of bytes. The "selected_int_kind" will return the kind number of the smallest integer kind available to the compiler that can represent that requested number of digits. If no such type exists, -1 will be returned, and the value will fail when used kind value to declare an integer.
Both gfortran and ifort return a kind for decimal digits input to selected_int_kind up up to 18. Large values such as 18 will typically select an 8-byte integer with a largest positive value of 9223372036854775807. This has 19 digits, but if a compiler supports this type but not a longer one, selected_int_kind (19) will be -1, because not all 19 digit integers are representable.