{S,D,C,Z}COPY (n, x, incx, y, incy)
n integer*4 On entry, the number of elements in the vector x. On exit, n is unchanged. x real*4 | real*8 | complex*8 | complex*16 On entry, a one-dimensional array X of length at least (1+(n-1)*|incx|), containing the elements of the vector x. On exit, x is unchanged. incx integer*4 On entry, the increment for the array X. If incx >= 0, vector x is stored forward in the array, so that x(i) is stored in location X(1+(i-1)*incx). If incx < 0, vector x is stored backward in the array, so that x(i) is stored in location X(1+(n-i)*|incx|). On exit, incx is unchanged. y real*4 | real*8 | complex*8 | complex*16 On entry, a one-dimensional array Y of length at least (1+(n-1)*|incy|). On exit, if n<=0, y is unchanged. If n > 0, y is overwritten; y(i) is replaced by x(i). incy integer*4 On entry, the increment for the array Y. If incy >= 0, vector y is stored forward in the array, so that y(i) is stored in location Y(1+(i-1)*incy). If incy < 0, vector y is stored backward in the array, so that y(i) is stored in location Y(1+(n-i)*|incy|). On exit, incy is unchanged.
The _COPY subprograms copy the elements of the vector x to the vector y, performing the following operation: y(i) = x(i) If incx = 0, each y(i) is set to x(1). Therefore, you can use incx = 0 to initialize all elements to a constant. If incy = 0, the computation is a time-consuming way of setting y(1) = x(n), the last referenced element of the vector x. If incy = -incx, the vector x is stored in reverse order in y. In this case, the call format is as follows: CALL SCOPY (N,X,INCX,Y,-INCX) If any element of x shares a memory location with an element of y, the results are unpredictable, except for the following special case. It is possible to move the contents of a vector up or down within itself and not cause unpredictable results even though the same memory location is shared between input and output. To do this when i > j, call the subroutine with incx = incy > 0 as follows: CALL SCOPY (N,X(I),INCX,X(J),INCX) The call to SCOPY moves elements of the array X x(i),x(i+1*incx), ...,x(i+(n-1)*incx) to new elements of the array X x(j),x(j+1*incx), ..., x(j+(n-1)*incx). If i < j, specify a negative value for incx and incy in the call to the subroutine, as follows. The parts that do not overlap are unchanged. CALL SCOPY (N,X(I),-INCX,X(J),-INCX)
INTEGER*4 N, INCX, INCY REAL*4 X(20), Y(20) INCX = 1 INCY = 1 N = 20 CALL SCOPY(N,X,INCX,Y,INCY) The preceding FORTRAN code copies a vector x to a vector y. CALL SCOPY(N,X,-2,X(3),-2)) The preceding call moves the contents of X(1),X(3),X(5), ... , X(2N-1) to X(3),X(5), ... , X(2N+1) and leaves the vector x unchanged. CALL SCOPY(99,X(2),1,X,1)) The preceding call moves the contents of X(2),X(3), ... , X(100) to X(1),X(2), ... , X(99) and leaves x(100) unchanged. CALL SCOPY(N,X,1,Y,-1)) The preceding call moves the contents of X(1),X(2),X(3), ... , X(N) to Y(N),Y(N-1), ... , Y.