I’m surprised the AoA worked as well as it did. (I was also unaware that arrays could be used inside an array constructor expression. Neat!)
A couple suggestions:
- I think you’d be better off using
system_clock(withint64arguments) in your timings, and not including the print statements (with the calculation ofmaxval(abs(a-xran))) in the timed portion. - For move_alloc, a lot of what you are timing is just the procedure call overhead to
grow_vec(accounts for 75% of the time with ifort on linux for me). Consider this third in-line alternative:
a = [real ::]
na = 0
do
block
real, allocatable :: temp(:)
allocate(temp(na+ngrow))
temp(:na) = a
temp(na+1:) = xran(na+1:na+ngrow)
deallocate(a)
call move_alloc(temp, a)
end block
na = size(a)
if (size(a) >= nmax) exit
end do