Sorts an integer array by algebraically increasing value.
IA — Integer vector of length N containing the array to be sorted. (Input)
IB — Integer
vector of length N containing the
sorted array. (Output)
If IA is not needed,
IA and IB can share the same
storage locations.
N — Number of
elements in the array to be sorted. (Input)
Default: N = size
(IA,1).
Generic: CALL SVIGN (IA, IB [,…])
Specific: The specific interface name is S_SVIGN .
Single: CALL SVIGN (N, IA, IB)
Routine SVIGN sorts the elements of an integer array, A, into ascending order by algebraic value. The routine SVIGN uses the algorithm discussed in SVRGN. On completion, Aj ≤ Ai for j < i.
This example sorts the 10-element array IA algebraically.
USE SVIGN_INT
USE UMACH_INT
IMPLICIT NONE
! Declare variables
INTEGER N, NOUT, J
PARAMETER (N=10)
INTEGER IA(N), IB(N)
! Set values for IA
! IA = ( -1 2 -3 4 -5 6 -7 8 -9 10 )
!
DATA IA/-1, 2, -3, 4, -5, 6, -7, 8, -9, 10/
! Sort IA by algebraic value into IB
CALL SVIGN (IA, IB)
! Print results
CALL UMACH (2,NOUT)
WRITE (NOUT, 99999) (IB(J),J=1,N)
!
99999 FORMAT (' The output vector is:', /, 10(1X,I5))
END
The Output vector
is:
-9 -7 -5
-3 -1 2
4 6 8 10
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |