1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
*DECK NXTTNS
SUBROUTINE NXTTNS(IFTRK ,IFTEMP,IPRINT,RENO ,NFSUR ,NFREG ,
> NDIM ,MAXSUB, MAXSGL,NTLINE,NBDR ,IFMT ,
> KEYMRG,DVNOR)
*
*-----------------------------------------------------------------------
*
*Purpose:
* To normalize tracking lines and save track volume
* normalisation factors on tracking data structure.
*
*Copyright:
* Copyright (C) 2005 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):
* G. Marleau
*
*Parameters: input
* IFTRK pointer to the TRACKING file in
* creation mode.
* IFTEMP pointer to a temporary TRACKING data structure in
* update or creation mode.
* IPRINT print level.
* RENO track normalisation option. A value RENO=-1 implies
* a direction dependent normalization of the tracks
* for the volume while a value RENO=0, implies
* a global normalisation.
* NFSUR number of surfaces.
* NFREG number of regions.
* NDIM problem dimensions.
* MAXSUB maximum number of subtracks in a track.
* MAXSGL maximum number of segments in a track.
* NTLINE number of track generated.
* NBDR number of directions for track normalization.
* IFMT track format: =0 short; =1 long.
* KEYMRG index array for surface and volume renumbering.
* DVNOR track volume normalisation factors.
*
*Reference:
* G. Marleau,
* New Geometries Processing in DRAGON: The NXT: Module,
* Report IGE-260, Polytechnique Montreal,
* Montreal, 2005.
* \\\\
* Based on the XELTI2 and XELTI3 routines.
*
*----------
*
IMPLICIT NONE
*----
* Subroutine arguments
*----
INTEGER IFTRK,IFTEMP
INTEGER IPRINT,RENO,NFSUR,NFREG,NDIM,MAXSUB,
> MAXSGL,NTLINE,NBDR,IFMT
INTEGER KEYMRG(-NFSUR:NFREG)
DOUBLE PRECISION DVNOR(NFREG,NBDR)
*----
* Local parameters
*----
INTEGER IOUT
CHARACTER NAMSBR*6
PARAMETER (IOUT=6,NAMSBR='NXTTNS')
*----
* Local variables
*----
INTEGER IRLINE,NSUB,NBSEG,ISEG,IREG,JSEG,JREG,II
DOUBLE PRECISION WEIGHT
INTEGER IRA,IADD(4),INREG,JNREG,ITDIR,IND
LOGICAL LNEW
*----
* Allocatable arrays
*----
INTEGER, ALLOCATABLE, DIMENSION(:) :: NUMERO,IANGL
DOUBLE PRECISION , ALLOCATABLE, DIMENSION(:) :: LENGTH
DOUBLE PRECISION , ALLOCATABLE, DIMENSION(:,:) :: DADD
*----
* Scratch storage allocation
* NUMERO region/surface identification number for segment.
* LENGTH segment length.
*----
ALLOCATE(NUMERO(MAXSGL),LENGTH(MAXSGL),IANGL(MAXSUB),
> DADD(NDIM,MAXSUB))
*----
* Processing starts:
* print routine opening output header if required
* and initialize various parameters.
*----
IF(IPRINT .GE. 100) THEN
WRITE(IOUT,6000) NAMSBR
ENDIF
IRLINE=0
100 CONTINUE
IF(IFMT .EQ. 1) THEN
READ(IFTEMP,END=105) NSUB,NBSEG,WEIGHT,
> (IANGL(II),II=1,NSUB),
> (NUMERO(ISEG),ISEG=1,NBSEG),
> (LENGTH(ISEG),ISEG=1,NBSEG),
> (IADD(IRA),IRA=1,4),
> ((DADD(IRA,II),IRA=1,NDIM),II=1,NSUB)
ELSE
READ(IFTEMP,END=105) NSUB,NBSEG,WEIGHT,
> (IANGL(II),II=1,NSUB),
> (NUMERO(ISEG),ISEG=1,NBSEG),
> (LENGTH(ISEG),ISEG=1,NBSEG)
ENDIF
IRLINE=IRLINE+1
*----
* Normalize track LENGTH globally
*----
IF((RENO .EQ. -1) .AND. (NSUB .GT. 1)) THEN
* Angular-dependent normalization of a cyclic multi-track
IND=0
LNEW=.TRUE.
DO ISEG=1,NBSEG
IREG=NUMERO(ISEG)
IF(IREG .GT. NFREG) THEN
WRITE(IOUT,9001) NAMSBR,(NUMERO(JSEG),JSEG=1,NBSEG)
CALL XABORT(NAMSBR//
> ': Region number larger than maximum permitted')
ELSE IF(IREG .GT. 0) THEN
IF(LNEW) THEN
IND=IND+1
IF(IND.GT.NSUB) CALL XABORT(NAMSBR//': NSUB overflow')
LNEW=.FALSE.
ENDIF
ITDIR=IANGL(IND)
LENGTH(ISEG)=LENGTH(ISEG)*DVNOR(IREG,ITDIR+1)
ELSE
LNEW=.TRUE.
ENDIF
ENDDO
IF(IND.NE.NSUB) CALL XABORT(NAMSBR//': Algorithm failure')
ELSE IF(RENO .LE. 0) THEN
DO ISEG=1,NBSEG
IREG=NUMERO(ISEG)
IF(IREG .GT. NFREG) THEN
WRITE(IOUT,9001) NAMSBR,(NUMERO(JSEG),JSEG=1,NBSEG)
CALL XABORT(NAMSBR//
> ': Region number larger than maximum permitted')
ELSE IF(IREG .GT. 0) THEN
IF(RENO .EQ. -1) THEN
ITDIR=IANGL(1)
LENGTH(ISEG)=LENGTH(ISEG)*DVNOR(IREG,ITDIR+1)
ELSE
LENGTH(ISEG)=LENGTH(ISEG)*DVNOR(IREG,1)
ENDIF
ENDIF
ENDDO
ENDIF
*----
* Change region and surface numbering and
* compress track line for successive segment with same region
*----
JSEG=1
JREG=NUMERO(1)
JNREG=KEYMRG(JREG)
NUMERO(1)=JNREG
DO ISEG=2,NBSEG
IREG=NUMERO(ISEG)
INREG=KEYMRG(IREG)
NUMERO(ISEG)=INREG
IF(INREG .LT. 0 .OR. INREG .NE. JNREG) THEN
JSEG=JSEG+1
NUMERO(JSEG)=NUMERO(ISEG)
LENGTH(JSEG)=LENGTH(ISEG)
JNREG=INREG
ELSE
LENGTH(JSEG)=LENGTH(JSEG)+LENGTH(ISEG)
ENDIF
ENDDO
NBSEG=JSEG
IF(IFMT .EQ. 1) THEN
WRITE(IFTRK) NSUB,NBSEG,WEIGHT,
> (IANGL(II),II=1,NSUB),
> (NUMERO(ISEG),ISEG=1,NBSEG),
> (LENGTH(ISEG),ISEG=1,NBSEG),
> (IADD(IRA),IRA=1,4),
> ((DADD(IRA,II),IRA=1,NDIM),II=1,NSUB)
ELSE
WRITE(IFTRK) NSUB,NBSEG,WEIGHT,
> (IANGL(II),II=1,NSUB),
> (NUMERO(ISEG),ISEG=1,NBSEG),
> (LENGTH(ISEG),ISEG=1,NBSEG)
ENDIF
GO TO 100
105 CONTINUE
IF(IRLINE .NE. NTLINE) THEN
WRITE(IOUT,9000) NAMSBR,IRLINE,NTLINE
CALL XABORT(NAMSBR//
>': Problem with number of lines on tracking file')
ENDIF
IF(IPRINT .GE. 100) THEN
WRITE(IOUT,6001) NAMSBR
ENDIF
*----
* Scratch storage deallocation
*----
DEALLOCATE(DADD,IANGL,LENGTH,NUMERO)
RETURN
*----
* Output formats
*----
6000 FORMAT('(* Output from --',A6,'-- follows ')
6001 FORMAT(' Output from --',A6,'-- completed *)')
9000 FORMAT(' ***** Error in ',A6,' *****'/,
> ' Number of lines : ',I10,' and ',I10)
9001 FORMAT(' ***** Error in ',A6,' *****'/,
> ' Regions crossed by line segment :'/10I10)
END
|