I would like to write Fortran code that works like the R function seq(). E.g.:
x <- seq(0,1,0.1)
will give the vector
x
A simple implementation, if you really wanted the function, not wanting to always compute the n
by hand. May need some clarification of the upper bound.
print *,seq(1.,10.,0.1)
contains
function seq(from, to, step)
real, allocatable :: seq(:)
real, intent(in) :: from, to, step
allocate(seq(0:int((to - from)/step)))
do i = 0, size(seq)
seq(i) = from + i * step
end do
end function
end
Regarding your program, when you use the fretures the compiler has, the backtrace would be much more helpful. Your resize_array should probably have tmp_arr(1:new-1)=t
. The move_alloc()
subroutine could make it little bit shorter.