Re: Question about KIND



Wade Ward <invalid@xxxxxxxxxxx> wrote:

"*** Hendrickson" <***.hendrickson@xxxxxxx> wrote in message
news:EOnZh.91094$VU4.52168@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

It's relatively easy to use "8 bytes" if it's available and "4 bytes"
otherwise. Something like
integer, parameter :: double_int = selected_int_kind(16)
integer, parameter :: single_int = selected_int_kind(7)
integer, parameter :: working_int = max(double_int, single_int)
integer (kind=working_int) :: lb, allocated_ub, currently_used_ub
...
IF(double_int < 0) print *, "whoops"

Most people would put the initial parameters in a module and USE that
as a way to save a few trees.

Both you and Steve use the max function when getting the behavior that OP is
looking for. I don't quite see what the if statement tells you about double
versus single int. My compiler sees the same lack of distinction:
comment 1031 - This IF statement is redundant as it will never succeed
What gives?

What gives is that the IF statement seems redundant for any particular
compiler, insomuch as the expression in it is an initialization
expression and thus can be evaluated at compile time. For your compiler,
apparently it reduces to

if (.false.) print *, "whoops"

which, in turn, could be reduced to just

continue

But it will get different results for different compilers, so in fact,
it is not really redundant. On some other compiler, it would reduce to

if (.true.) print *, "whoops"

which could be further reduced to

print *, "whoops"

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.