~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to applic/plot/libsrc/sort2.for

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
C @(#)sort2.for 19.1 (ES0-DMD) 02/25/03 13:19:39
 
2
C===========================================================================
 
3
C Copyright (C) 1995 European Southern Observatory (ESO)
 
4
C
 
5
C This program is free software; you can redistribute it and/or 
 
6
C modify it under the terms of the GNU General Public License as 
 
7
C published by the Free Software Foundation; either version 2 of 
 
8
C the License, or (at your option) any later version.
 
9
C
 
10
C This program is distributed in the hope that it will be useful,
 
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
C GNU General Public License for more details.
 
14
C
 
15
C You should have received a copy of the GNU General Public 
 
16
C License along with this program; if not, write to the Free 
 
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
18
C MA 02139, USA.
 
19
C
 
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
 
21
C       Internet e-mail: midas@eso.org
 
22
C       Postal address: European Southern Observatory
 
23
C                       Data Management Division 
 
24
C                       Karl-Schwarzschild-Strasse 2
 
25
C                       D 85748 Garching bei Muenchen 
 
26
C                       GERMANY
 
27
C===========================================================================
 
28
C
 
29
      SUBROUTINE SORT2(RA,RB,N)                                                 
 
30
C+++                                                                            
 
31
C.IDENTIFICATION                                                                
 
32
C.AUTHOR:   M.Rosa, ESO-Garching, 831105                                        
 
33
C.PURPOSE:  Sort string of values into ascending sequence of values             
 
34
C.ALGORITM: The art of scientific computing                                     
 
35
C           Press et al., Cambridge university Press, 1986                      
 
36
C.USE:      CALL SORT2(XC,YC,N)                                                 
 
37
C.VERSION:  910115 RHW IMPLICIT NONE added
 
38
C---                                                                            
 
39
C     
 
40
      IMPLICIT   NONE
 
41
      INTEGER    N
 
42
      REAL       RA(N)
 
43
      REAL       RB(N)                                                         
 
44
C
 
45
      INTEGER    I, IR
 
46
      INTEGER    J
 
47
      INTEGER    L
 
48
      REAL       RRA, RRB
 
49
                                                                                
 
50
      L  = N/2 + 1                                                              
 
51
      IR = N                                                                    
 
52
                                                                                
 
53
10    CONTINUE                                                                  
 
54
      IF (L.GT.1) THEN                                                          
 
55
         L      = L - 1                                                         
 
56
         RRA    = RA(L)                                                         
 
57
         RRB    = RB(L)                                                         
 
58
      ELSE                                                                      
 
59
         RRA    = RA(IR)                                                        
 
60
         RRB    = RB(IR)                                                        
 
61
         RA(IR) = RA(1)                                                         
 
62
         RB(IR) = RB(1)                                                         
 
63
         IR     = IR - 1                                                        
 
64
                                                                                
 
65
         IF (IR.EQ.1) THEN                                                      
 
66
            RA(1) = RRA                                                         
 
67
            RB(1) = RRB                                                         
 
68
            RETURN                                                              
 
69
         ENDIF                                                                  
 
70
      ENDIF                                                                     
 
71
                                                                                
 
72
      I = L                                                                     
 
73
      J = L+L                                                                   
 
74
                                                                                
 
75
20    CONTINUE                                                                  
 
76
      IF (J.LE.IR) THEN                                                         
 
77
         IF (J.LT.IR) THEN                                                      
 
78
            IF (RA(J).LT.RA(J+1)) THEN                                          
 
79
               J = J + 1                                                        
 
80
            ENDIF                                                               
 
81
         ENDIF                                                                  
 
82
                                                                                
 
83
         IF (RRA.LT.RA(J)) THEN                                                 
 
84
            RA(I) = RA(J)                                                       
 
85
            RB(I) = RB(J)                                                       
 
86
            I     = J                                                           
 
87
            J     = J + J                                                       
 
88
         ELSE                                                                   
 
89
            J     = IR + 1                                                      
 
90
         ENDIF                                                                  
 
91
         GO TO 20                                                               
 
92
      ENDIF                                                                     
 
93
                                                                                
 
94
      RA(I) = RRA                                                               
 
95
      RB(I) = RRB                                                               
 
96
      GO TO 10                                                                  
 
97
      END