generate a sequence array in fortran
问题 Is there an intrinsic in Fortran that generates an array containing a sequence of numbers from a to b, similar to python's range() >>> range(1,5) [1, 2, 3, 4] >>> range(6,10) [6, 7, 8, 9] ? 回答1: No, there isn't. You can, however, initialize an array with a constructor that does the same thing, program arraycons implicit none integer :: i real :: a(10) = (/(i, i=2,20, 2)/) print *, a end program arraycons 回答2: If you need to support floats, here is a Fortran subroutine similar to linspace in