OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
sortcl.f
Go to the documentation of this file.
1  SUBROUTINE sortcl
2  i (numclm, numstr, ifxclm,
3  o lblclm, timclm, briclm, gciclm, vrmclm, vrpclm, nobclm,
4  o mrkclm, idfclm, nrfclm, mapclm, skyclm, klmstr, idfhst)
5 C-----------------------------------------------------------------------
6 C MODULE NAME: STSORTCL
7 C
8 C PURPOSE:TO BUBBLE SORT THE CLUMP TABLE IN INCREASING ORDER BY NUMBER
9 C OF DIRECT MATCH REFERENCE STAR MATCHES, AND ALTER THE STAR
10 C OBSERVATION TABLE ACCORDINGLY.
11 C
12 C
13 C ARGUMENT LIST:
14 C ARGUMENT I/O TYPE DIMENS DESCRIPTION
15 C -------- --- ---- ------ -----------
16 C NUMCLM I I*4 NUMBER OF CLUMPS
17 C NUMSTR I I*4 NUMBER OF OBSERVATIONS
18 C IFXCLM I I*4 MAX NUMBER OF REF STAR MATCHES PER CLUMP
19 C LBLCLM I O I*4 * CLUMP LABLES
20 C TIMCLM I O R*8 * AVERAGE CLUMP TIMES
21 C BRICLM I O R*4 * AVERAGE CLUMP MAGNITUDES
22 C GCICLM I O R*4 3,* AVERAGE CLUMP POSITIONS (GCI)
23 C VRMCLM I O R*4 * CLUMP MAGNITUDE VARIANCES
24 C VRPCLM I O R*4 * CLUMP POSITION VARIANCES
25 C NOBCLM I O I*4 * NUMBER OF OBSERVATIONS IN EACH CLUMP
26 C MRKCLM I O I*4 * STATUS FLAG FOR EACH CLUMP
27 C IDFCLM I O I*4 * IDENTIFICATION FLAG FOR EACH CLUMP
28 C NRFCLM I O I*4 * # OF REFERENCE STAR MATCHES FOR EACH CLUMP
29 C MAPCLM I O I*4 10,* SKYMAP ID NUMBERS OF REFERENCE STAR MATCHES
30 C SKYCLM I O R*4 10,3,* LIST OF CORRECTED REFERENCE STAR POSITIONS
31 C (MATCH#,AXIS,CLUMP#)
32 C KLMSTR I O I*4 * CLUMP NUMBER FOR EACH OBSERVATION
33 C IDFHST I O I*4 * FHST NUMBER FOR EACH CLUMP
34 C
35 C COMMON BLOCK VARIABLES USED:
36 C COMMON VAR I/O VAR I/O VAR I/O VAR I/O
37 C ------ --- --- --- --- --- --- --- ---
38 C CMDEBG LEVDBG I LUDBUG I
39 C
40  IMPLICIT NONE
41 C ++INCLUDE STCMDEBG
42  INTEGER*4 LEVDBG(8),LUDBUG
43  COMMON /cmdebg/levdbg,ludbug
44 C
45 C EXTERNAL FILES REFERENCED:
46 C FILENAME OPERATION FORTRAN UNIT ID
47 C -------- --------- ---------------
48 C NONE
49 C
50 C EXTERNAL REFERENCES:
51 C --------------------------------------------------------------------
52 C STSWAPCL - SWAP ALL CLUMP ELEMENTS
53 C
54 C
55 C SUBROUTINE CALLED FROM:
56 C --------------------------------------------------------------------
57 C STIDENTY - STAR MATCHING DRIVER
58 C
59 C
60 C CONSTRAINTS, RESTRICTIONS, MESSAGES, NOTES:
61 C --------------------------------------------------------------------
62 C NONE
63 C
64 C REQUIREMENTS REFERENCES:
65 C --------------------------------------------------------------------
66 C NONE
67 C
68 C DEVELOPMENT HISTORY:
69 C DATE AUTHOR DESCRIPTION
70 C -------- ------ -----------
71 C 8/ 3/88 R.J. BURLEY DESIGN
72 C 5/16/89 R.J. BURLEY CODED
73 C 11/06/89 R.J. BURLEY ADD LBLCLM GESS ARRAYS
74 C 02/04/92 C.C. YEH ADD IDFHST (MTASS-11)
75 C-----------------------------------------------------------------------
76 C METHOD:
77 C SORTED = .FALSE.
78 C DO WHILE NOT YET SORTED
79 C SORTED = .TRUE.
80 C DO FOR CLUMP# = 2, NUMCLM
81 C IF (#DIRECT MATCHES FOR CURRENT CLUMP IS LESS THAN
82 C #DIRECT MATCHES FOR PREVIOUS CLUMP)
83 C SORTED = .FALSE.
84 C CALL SWAPCL TO SWAP ALL CLUMP ELEMENTS FROM PREVIOUS
85 C CLUMP TO CURRENT CLUMP
86 C DO FOR ALL OBSERVATIONS
87 C IF (OBSERVATION IS IN PREVIOUS CLUMP) THEN
88 C MARK IT AS IN CLUMP
89 C ELSE IF (OBSERVATION IS IN CLUMP) THEN
90 C MARK IT AS IN PREVIOUS CLUMP
91 C ENDIF
92 C ENDDO FOR
93 C ENDIF
94 C ENDDO FOR
95 C ENDDO WHILE
96 C RETURN
97 C-----------------------------------------------------------------------
98 C
99 C * DEFINE PARAMETER VARIABLES
100  real*8 timclm(*)
101 C
102  real*4 briclm(*), gciclm(3,*), vrmclm(*) , vrpclm(*)
103  real*4 skyclm(10,3,*)
104 C
105  INTEGER*4 NUMCLM , NUMSTR , IFXCLM , LBLCLM(*)
106  INTEGER*4 NOBCLM(*) , MRKCLM(*), IDFCLM(*) , NRFCLM(*)
107  INTEGER*4 MAPCLM(10,*), KLMSTR(*), IDFHST(*)
108 C
109 C * DECLARE LOCAL VARIABLES
110  INTEGER*4 ICLM , IPREV, IOBS, ITEMP
111  LOGICAL*4 L_DONE
112 C
113 C INITIALIZE ROUTINE
114  WRITE(*,*) 'ENTERING SORTCL'
115  IF (levdbg(7) .NE. 0) WRITE (ludbug,1000)
116 C
117 C
118 C SORT CLUMPS BY # OF MATCHES
119  l_done = .false.
120 100 CONTINUE
121  IF (.NOT. l_done) THEN
122  l_done = .true.
123  DO 300 iclm = 2,numclm
124  iprev = iclm - 1
125  IF (nrfclm(iclm) .LE. nrfclm(iprev)) THEN
126  IF ((nrfclm(iclm) .LT. nrfclm(iprev)).OR.
127  * (vrpclm(iclm) .LT. vrpclm(iprev))) THEN
128 C
129 C NOT IN ORDER, SWAP CLUMPS
130  itemp = idfhst(iclm)
131  idfhst(iclm) = idfhst(iprev)
132  idfhst(iprev) = itemp
133  l_done = .false.
134  CALL swapcl (iclm , iprev , ifxclm,
135  1 lblclm, timclm, briclm, gciclm, vrmclm, vrpclm,
136  2 nobclm, mrkclm, idfclm, nrfclm, mapclm, skyclm)
137 C
138 C UPDATE OBSERVATION CLUMP #'S
139  DO 200 iobs = 1,numstr
140  IF (klmstr(iobs) .EQ. iprev) THEN
141  klmstr(iobs) = iclm
142  ELSE IF (klmstr(iobs) .EQ. iclm) THEN
143  klmstr(iobs) = iprev
144  ENDIF
145 200 CONTINUE
146  ENDIF
147  ENDIF
148 300 CONTINUE
149  GO TO 100
150  ENDIF
151 C
152 C NORMAL TERMINATION
153  IF (levdbg(7) .NE. 0) WRITE (ludbug,2000)
154  WRITE(*,*) 'EXIT SORTCL'
155  RETURN
156 C
157 C FORMAT SECTION
158 1000 FORMAT(' *** ENTER SORTCL *** ')
159 2000 FORMAT(' *** EXIT SORTCL *** ')
160  END
161 
subroutine swapcl(ICLMP1, ICLMP2, IFXCLM, LBLCLM, TIMCLM, BRICLM, GCICLM, VRMCLM, VRPCLM, NOBCLM, MRKCLM, IDFCLM, NRFCLM, MAPCLM, SKYCLM)
Definition: swapcl.f:5
#define real
Definition: DbAlgOcean.cpp:26
subroutine sortcl(NUMCLM, NUMSTR, IFXCLM, LBLCLM, TIMCLM, BRICLM, GCICLM, VRMCLM, VRPCLM, NOBCLM, MRKCLM, IDFCLM, NRFCLM, MAPCLM, SKYCLM, KLMSTR, IDFHST)
Definition: sortcl.f:5