From 2b8f6ba5371b23960ac80b8cd90a77434ceaab40 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sat, 28 Sep 2024 22:07:11 -0500 Subject: [PATCH] Add constant for max supported int --- docs/src/fortran/lib/constants.rst | 2 ++ fortran/src/include/constants.f90 | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/docs/src/fortran/lib/constants.rst b/docs/src/fortran/lib/constants.rst index 67c3ebf2..d1b8f9fc 100644 --- a/docs/src/fortran/lib/constants.rst +++ b/docs/src/fortran/lib/constants.rst @@ -11,6 +11,8 @@ View source code :source:`fortran/include/constants.f90` :type: integer .. f:variable:: i18t :type: integer +.. f:variable:: imaxt + :type: integer A set of digit type constraints that denote how many decimal digits a number can support. They are given as ``it`` or ``r_t`` diff --git a/fortran/src/include/constants.f90 b/fortran/src/include/constants.f90 index 329b2793..05617081 100644 --- a/fortran/src/include/constants.f90 +++ b/fortran/src/include/constants.f90 @@ -4,6 +4,16 @@ module constants integer, parameter :: i1t = selected_int_kind(1) integer, parameter :: i4t = selected_int_kind(4) integer, parameter :: i18t = selected_int_kind(18) + integer :: imaxt + if (selected_int_kind(38) >= 0) then + imaxt = selected_int_kind(38) + elseif (i18t >= 0) then + imaxt = i18t + else + ! fall back to default value of 64-bit in most compilers + imaxt = 8 + i18t = 8 + end if integer(i1t), parameter :: errort = 0 integer(i1t), parameter :: int64t = 1