The intrinsic SIZE() returns a 64 bit value (KIND = 4) by default.
Using /ISO or /SIZE_ISO is supposed to change this to the default integer kind but this doesn't seem to work. It is always kind = 4.
Instead /ISO changes the default integer kind to 4. It seems it is changing the wrong kind value to get the match. Furthermore /ISO is supposed to imply /SIZE_ISO but they give different behavior. /SIZE_ISO doesn't do anything.
Have a look at this code and the results below.
program main
integer i
real a(5)
i = 0
a = (/1.0,2.0,4.0,3.0,0.0/)
print *,' size is kind ', kind(size(a))
print *,' default integer is kind ', kind(i)
end
Here are the results of the code above.
/ISO not used and /SIZE_ISO not used
integer default kind = 3 size returns integer(kind=4)
not ISO compliant but this is OK in this case
/ISO used
integer default kind = 4 size returns integer(kind=4)
ISO compliant
/ISO used and /DEFINT_KIND 3 used
integer default kind = 3 size returns integer(kind=4)
not ISO compliant
/SIZE_ISO used
integer default kind = 3 size returns integer(kind=4)
not ISO compliant
The non-compliant cases above means the following doesn't work
module foo
contains
function find_max(a, n)
integer :: n
real :: a(n)
real :: find_max
find_max = maxval(a)
end function find_max
end module foo
program main
use foo
real a(5)
a = (/1.0,2.0,4.0,3.0,0.0/)
print *, find_max(a, size(a))
end