diff options
| author | stainer_t <thomas.stainer@oecd-nea.org> | 2025-09-08 13:48:49 +0200 |
|---|---|---|
| committer | stainer_t <thomas.stainer@oecd-nea.org> | 2025-09-08 13:48:49 +0200 |
| commit | 7dfcc480ba1e19bd3232349fc733caef94034292 (patch) | |
| tree | 03ee104eb8846d5cc1a981d267687a729185d3f3 /Utilib/src/SORTRE.f | |
Initial commit from Polytechnique Montreal
Diffstat (limited to 'Utilib/src/SORTRE.f')
| -rw-r--r-- | Utilib/src/SORTRE.f | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Utilib/src/SORTRE.f b/Utilib/src/SORTRE.f new file mode 100644 index 0000000..645a520 --- /dev/null +++ b/Utilib/src/SORTRE.f @@ -0,0 +1,51 @@ +*DECK SORTRE + SUBROUTINE SORTRE(N,ARRAY) +* +*----------------------------------------------------------------------- +* +*Purpose: +* Sort an array of reals by increasing order using the "Insertion sort" +* method. Based on the C routine available at +* http://linux.wku.edu/~lamonml/algor/sort/insertion.html +* +*Copyright: +* Copyright (C) 2002 Ecole Polytechnique de Montreal +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version +* +*Author(s): R. Le Tellier +* +*Parameters: input +* N size of the array. +* +*Parameters: input/output +* ARRAY array of reals. +* +*----------------------------------------------------------------------- +* + IMPLICIT NONE +*--- +* SUBROUTINE ARGUMENTS +*--- + INTEGER N + REAL ARRAY(N) +*--- +* LOCAL VARIABLES +*--- + INTEGER I,J + REAL WORK +* + DO I = 2, N + WORK = ARRAY(I) + J = I + DO WHILE ((J.GT.1).AND.(ARRAY(J-1).GT.WORK)) + ARRAY(J) = ARRAY(J-1) + J = J - 1 + ENDDO + ARRAY(J) = WORK + ENDDO +* + RETURN + END |
