[MAP Logo]

Materials Algorithms Project
Program Library



Subroutine MAP_UTIL_SORT3

  1. Provenance of code.
  2. Purpose of code.
  3. Specification.
  4. Description of subroutine's operation.
  5. References.
  6. Parameter descriptions.
  7. Error indicators.
  8. Accuracy estimate.
  9. Any additional information.
  10. Example of code
  11. Auxiliary subroutines required.
  12. Keywords.
  13. Download source code.
  14. Links.

Provenance of Source Code

G.I. Rees,
Phase Transformations Group,
Department of Materials Science and Metallurgy,
University of Cambridge,
Cambridge, U.K.

Top | Next

Purpose

Sorts the elements of a two dimensional array.

Top | Next | Prev

Specification

Language:FORTRAN
Product form:Source code

SUBROUTINE MAP_UTIL_SORT3(IVAR, IVAL, LST)

DOUBLE PRECISION LST(IVAR, IVAL)

INTEGER IVAL, IVAR

Top | Next | Prev

Description

An array LST(I,J) is sorted so that the second column is ordered to give LST(IVAR,J) in ascending order, where IVAR is the dimension of the first column.

Top | Next | Prev

References

  1. W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling, Numerical Recipes, Cambridge University Press, Cambridge, U.K., (1986).

Top | Next | Prev

Parameters

Input parameters

IVAR - integer
IVAR is the first dimension of the array LST.

IVAL - integer
IVAL is the second dimension of the array LST.

LST - real array of dimension IVAR by IVAL
LST contains the unsorted data.

Output parameters

LST - real array of dimension IVAR by IVAL.
LST contains the sorted data.

Top | Next | Prev

Error Indicators

None.

Top | Next | Prev

Accuracy

No information supplied.

Top | Next | Prev

Further Comments

None.

Top | Next | Prev

Example

1. Program text

       INTEGER IVAR, IVAL, J1, J2
       PARAMETER (IVAR = 2, IVAL = 12)
       DOUBLE PRECISION LST(IVAR, IVAL)
       DO 10 J1=1,IVAL
        READ (5,*) LST(1, J1), LST(2, J1)
10     CONTINUE
       CALL MAP_UTIL_SORT3(IVAR, IVAL, LST)
       DO 20 J2=1,IVAL
        WRITE (6,30) LST(1,J2), LST(2,J2)
20     CONTINUE
30     FORMAT(2F8.3)
       STOP
       END

2. Program data

 1.00   0.5
 2.00   0.2
 3.00   0.8
 4.00   2.0
 5.00   1.0
 6.00   3.0
 7.00   0.4
 8.00   0.5
 9.00  10.0
10.00   3.0
11.00   1.0
12.00   0.3

3. Program results

 
 2.00   0.2
12.00   0.3
 7.00   0.4
 1.00   0.5
 8.00   0.5
 3.00   0.8
 5.00   1.0
11.00   1.0
 4.00   2.0
 6.00   3.0
10.00   3.0
 9.00  10.0

Top | Next | Prev

Auxiliary Routines

None.

Top | Next | Prev

Keywords

sort

Top | Next | Prev

Download

Download source code

Top | Prev


MAP originated from a joint project of the National Physical Laboratory and the University of Cambridge.

MAP Website administration / map@msm.cam.ac.uk

Top | Index | MAP Homepage Valid HTML 3.2!