5 * Revision 1.1.1.1 1995/10/24 10:20:49 cernlib
9 #include "geant321/pilot.h"
10 *CMZ : 3.21/02 29/03/94 15.41.28 by S.Giani
12 SUBROUTINE GGORDQ (IVO)
14 C. *****************************************************************
16 C. * Find and order the boundaries of the contents of the *
17 C. * IVOth volume, with respect to coordinate IAX : *
23 C. * IAX = 6 PHI (PHI=0 => X axis) *
24 C. * IAX = 7 THETA (THETA=0 => Z axis) *
25 C. * All values of IAX will be tried and then that value is *
26 C. * chosen, that results in the smallest number of volumes per *
28 C. * Called by : GGCLOS *
29 C. * Author: Stephan Egli (large parts are copies of GGORD) *
31 C. *****************************************************************
33 #include "geant321/gcbank.inc"
34 #include "geant321/gcunit.inc"
37 DIMENSION CLOW(500),CHIGH(500),CORD(1000),ITYPE(1000),
38 +ICONT(500),ICON(1000),ICONS(500)
39 EQUIVALENCE (CLOW(1),WS(1)),(CHIGH(1),WS(501))
40 EQUIVALENCE (CORD(1),WS(1001)),(ITYPE(1),WS(2001))
41 EQUIVALENCE (ICONT(1),WS(3001)),(ICON(1),WS(3501))
42 EQUIVALENCE (ICONS(1),WS(4501))
46 C. ------------------------------------------------------------------
49 CALL UHTOC(IQ(JVOLUM+IVO),4,NAME,4)
52 IF(IQ(JVO-2).EQ.NIN+2) THEN
54 * *** This is to allow re-entry in the routine from the interactive
67 * assume that ordering can not be done unless proven otherwise
71 * try all possible axes
75 * count number of additional words needed and total number of volumes
80 * *** Find the upper and lower coordinates of each content
83 CALL GFCLIM (JVO, IN, IAX, CLOW(IN), CHIGH(IN), IERR)
87 * *** Order the coordinate limits, keeping track of the associated
90 CALL GFCORD (NIN, CLOW, CHIGH, CORD, ITYPE, ICON)
93 * ** Count and load up the distinct boundaries
98 IF (IBO.EQ.1) GO TO 60
99 IF (CORD(IC)-CORD(IC-1).LT.1.E-4) IBO = IBO -1
102 IF (IAX.EQ.6) NDIV = IBO
104 * * Load up number of contents in each section
109 IF (IAX.NE.6) GO TO 70
114 IF (CHIGH(IN).GT.CLOW(IN)) GO TO 65
115 * (this content straddles PHI=0.)
118 IF (ICON(1).EQ.IN) GO TO 65
119 * (IN is in 1st division as well)
124 IF (ITYPE(1).EQ.2) GO TO 70
125 * (first boundary is a low, add the new content)
127 ICONT(NCONT) = ICON(1)
133 IF (CORD(IC)-CORD(IC-1).LT.1.E-4) GO TO 90
135 * New division, load up last division
137 IF (NCONT.LE.0) GO TO 100
145 * Update contents of current division
147 IF (ITYPE(IC).EQ.1) GO TO 120
149 * This boundary was a high, so one less content
152 DO 110 ICNT = 1,NCONT
153 IF (ICONT(ICNT).EQ.ICON(IC)) ICP=1
154 IF (ICP.EQ.1) ICONT(ICNT) = ICONT(ICNT+1)
161 * This boundary was a low, so one extra content
164 ICONT(NCONT) = ICON(IC)
168 IF(IAX.EQ.6) NCOALL = NCOALL+NSTOR
169 RNOW=FLOAT(NCOALL)/NDIV
170 IF(RNOW.LT.RBEST)THEN
176 * end of loop over IAX
181 * now the best axis is selected - compare with axis requested by CALL
186 WRITE (CHMAIL,1002) NAME,NIN,IAXOPT,NDIVB,RBEST,IAXNOW
188 1002 FORMAT(' GGORDQ : Volume ',A4,2X,'NIN=',I4,' IAX=',I2,2X,
189 + 'NDIV=',I3,2X,'NVOL/DIV=',F5.1,2X,'IAX wanted by user:',I2)
193 WRITE (CHMAIL,1003) NAME,NIN,IAXOPT,NDIVB,RBEST
195 1003 FORMAT(' GGORDQ : Volume ',A4,2X,'NIN=',I4,' IAX=',I2,2X,
196 + 'NDIV=',I3,2X,'NVOL/DIV=',F5.1)
200 * overwrite old axis and store sorting information for new axis