Skip to content

Commit

Permalink
Add constant for max supported int
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 2, 2024
1 parent ba97d21 commit 2b8f6ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/src/fortran/lib/constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 ``i<len>t`` or ``r<len>_<exp>t``
Expand Down
10 changes: 10 additions & 0 deletions fortran/src/include/constants.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b8f6ba

Please sign in to comment.