I want to write a piece of code that can find all of the available integer kinds of my machine and print the range for all of them.
Finding the kinds was not the hard part, using selected_int_kind
I was able to iterate over all of the available kind number till I got a -1 value that indicated that the integer was not longer representable by the compiler.
This process resulted in an array of the available kind number for example (/ 1 2 4 8 16/)
(this was the result for my gfortran compiler)
The next step is to use this array to define 5 different kinds of integers and ask for what the maximum representable integer is. My idea was to use an allocatable integer and allocate it every time with an other kind parameter, something like
program main
integer,allocatable :: i
integer::j
integer,dimension(:)::nb_kind
call give_me_the_kinds(nb_kind)
for j=1,size(nb_kind)
allocate(i,kind=nb_kind(j))
print *,huge(i)
deallocate(i)
end program
But this did not work out for me. Has anybody has some experience with this? I think it could be done but I'm not sure how to do it.