33 SUBROUTINE detcord(DETONATOR_CORD,X,XC,YC,ZC,VDET,VDET2,ALT,BT,TB,HAS_DETONATOR,IOPT)
48#include "implicit_f.inc"
53#include "vect01_c.inc"
59 my_real :: x(3,*),xc(mvsiz),yc(mvsiz),zc(mvsiz),bt(mvsiz),vdet,vdet2,alt,tb(mvsiz)
61 LOGICAL HAS_DETONATOR(MVSIZ)
65 INTEGER :: J, I1,I2, II,K, iTdet, i, NPTS, NSEG,IDIST(MVSIZ),NDETCORD,NNOD
66 my_real :: ddmx, dtos, xlp2, ylp2, xlp1 , zlp2 ,ylp1,
67 . zlp1, xl0 , yl0 , zl0 , xl1 , yl1 ,zl1 , xl2 ,yl2 ,zl2,
68 . ps1 , ps2 , dl1 , dl2 , dl(mvsiz), s1 ,s2 , s3, tdetc, tp1, tp2, th, th1,th2,
69 . tc1,tc2,tc0,tc,p1p2,dh,
alpha,knots(4),zp(3),
70 . zh1(3),dist1,t1,zh2(3),dist2,t2,dist(mvsiz),xx,yy,zz,d,local_pt(4,3),c(3),t,dd,
75 my_real,
ALLOCATABLE,
DIMENSION(:,:) :: control_point
76 my_real,
ALLOCATABLE,
DIMENSION(:) :: length
77 my_real,
ALLOCATABLE,
DIMENSION(:) :: cumulative_length
78 my_real,
ALLOCATABLE,
DIMENSION(:,:) :: knots
81 type(spline_path),
TARGET :: USER_SPLINE_PATH
83 my_real,
POINTER,
DIMENSION(:,:) :: ptr
88 nnod = detonator_cord%NUMNOD
95 ii = detonator_cord%NODES(j)
100 ii = detonator_cord%NODES(j+1)
116 ps1 = xl1*xl0+yl1*yl0+zl1*zl0
117 ps2 = xl2*xl0+yl2*yl0+zl2*zl0
118 IF(ps1*ps2 > zero)
THEN
120 dl1 = sqrt(xl1**2+yl1**2+zl1**2)
121 dl2 = sqrt(xl2**2+yl2**2+zl2**2)
125 s1 = yl1*zl0 - zl1*yl0
126 s2 = zl1*xl0 - xl1*zl0
127 s3 = xl1*yl0 - yl1*xl0
128 dl(i)=sqrt((s1**2+s2**2+s3**2)/(xl0**2+yl0**2+zl0**2))
130 bt(i) =alt+dl(i)/vdet
131 IF(bt(i) < abs(tb(i))) tb(i)=-bt(i)
135 ELSEIF(iopt == 1)
THEN
139 ii = detonator_cord%NODES(j)
143 tp1 = detonator_cord%TDET_PATH(j)
145 ii = detonator_cord%NODES(j+1)
149 tp2 = detonator_cord%TDET_PATH(j+1)
162 ps1 = xl1*xl0+yl1*yl0+zl1
163 ps2 = xl2*xl0+yl2*yl0+zl2*zl0
164 dl1 = sqrt(xl1**2+yl1**2+zl1**2)
165 dl2 = sqrt(xl2**2+yl2**2+zl2**2)
166 tc1 = tp1 + dl1 /vdet
167 tc2 = tp2 + dl2 /vdet
169 IF(ps1*ps2 <= zero)
THEN
170 s1 = yl1*zl0 - zl1*yl0
171 s2 = zl1*xl0 - xl1*zl0
172 s3 = xl1*yl0 - yl1*xl0
174 p1p2 = (xl0**2+yl0**2+zl0**2)
175 dl2 = (s1**2+s2**2+s3**2)/p1p2
178 dh = sqrt((xl1**2+yl1**2+zl1**2)-dl2)
181 th2 = tp2 + (p1p2-dh)/vdet2
183 tc0 = th + dl(i)/vdet
187 IF(bt(i) < abs(tb(i))) tb(i)=-bt(i)
191 ELSEIF(iopt == 3)
THEN
199 IF(vdet2 == zero)vdet2=vdet
204 ALLOCATE(user_spline_path%control_point(0:npts+1,3))
205 ALLOCATE(user_spline_path%length(npts-1))
206 ALLOCATE(user_spline_path%cumulative_length(npts-1))
207 ALLOCATE(user_spline_path%knots(npts-1,4) )
213 ii = detonator_cord%NODES(j)
217 user_spline_path%control_point(j,1:3)=(/xlp1, ylp1, zlp1/)
221 ptr=>user_spline_path%control_point(0:npts+1,1:3)
223 ptr(1+0,1)=half*(five*ptr(1+1,1)-four*ptr(1+2,1)+ptr(1+3,1))
224 ptr(1+0,2)=half*(five*ptr(1+1,2)-four*ptr(1+2,2)+ptr(1+3,2))
225 ptr(1+0,3)=half*(five*ptr(1+1,3)-four*ptr(1+2,3)+ptr(1+3,3))
227 ptr(1+npts+1,1)=half*(1.*ptr(1+npts-2,1)-four*ptr(1+npts-1,1)+five*ptr(1+npts,1))
228 ptr(1+npts+1,2)=half*(1.*ptr(1+npts-2,2)-four*ptr(1+npts-1,2)+five*ptr(1+npts,2))
229 ptr(1+npts+1,3)=half*(1.*ptr(1+npts-2,3)-four*ptr(1+npts-1,3)+five*ptr(1+npts,3))
234 user_spline_path%knots(j,1:4)=knots(1:4)
243 xx = xc(j)-ptr(1+i,1)
244 yy = yc(j)-ptr(1+i,2)
245 zz = zc(j)-ptr(1+i,3)
246 dd = sqrt(xx*xx+yy*yy+zz*zz)
256 local_pt(1,1:3)=ptr(1+i-1,1:3)
257 local_pt(2,1:3)=ptr(1+i+0,1:3)
258 local_pt(3,1:3)=ptr(1+i+1,1:3)
259 local_pt(4,1:3)=ptr(1+i+2,1:3)
262 user_spline_path%length(i) = len
264 user_spline_path%cumulative_length(i) = user_spline_path%cumulative_length(i-1) + len
266 user_spline_path%cumulative_length(1) = len
279 local_pt(1,1:3)=ptr(1+i-1,1:3)
280 local_pt(2,1:3)=ptr(1+i+0,1:3)
281 local_pt(3,1:3)=ptr(1+i+1,1:3)
282 local_pt(4,1:3)=ptr(1+i+2,1:3)
283 zp(1:3) =(/xc(j),yc(j),zc(j)/)
292 local_pt(1,1:3)=ptr(1+i-1,1:3)
293 local_pt(2,1:3)=ptr(1+i+0,1:3)
294 local_pt(3,1:3)=ptr(1+i+1,1:3)
295 local_pt(4,1:3)=ptr(1+i+2,1:3)
298 IF(dist2 < dist1)
THEN
308 IF(k > 1)len=len+user_spline_path%cumulative_length(k-1)
309 bt(j) = detonator_cord%TDET_PATH(1) + len/vdet2
310 IF(bt(j) < abs(tb(j))) tb(j)=-bt(j)
316 has_detonator(i) = .true.