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
Fortran 2003 has (re-)allocation upon assignment for allocatable arrays, and the program
program xgrid
implicit none
real, allocatable :: x(:)
integer :: i,n
do n=5,10,5
x = 0.1*[(i,i=0,n)]
write (*,"('x =',100(1x,f0.1))") x
end do
end program xgrid
compiled with gfortran 4.8.0, shows a Fortran one-liner equivalent to seq(), giving output
x = .0 .1 .2 .3 .4 .5
x = .0 .1 .2 .3 .4 .5 .6 .7 .8 .9 1.0