5.4 Program Execution     continued...

Subroutine intsec

1. First, the cross products for all particles in the particle vector are obtained (lines 367--371). The student is required to supply the right-hand sides of lines 370 and 371.
2. Next, the loop over potential surfaces for intersection is executed (lines 372 through 444). The student must supply the right sides of lines 397, 413, 414, 415, 420, 421, 422, 423, 430, 431 and 432. The loop begins by calculating variables constant within the loop (for storage in registers) (lines 372--390).
3. The dot product is calculated in lines 394 through 397. The dot product test is performed by the Cray SCILIB routine whenflt, which returns the indices of those elements for which dotp is less than 0 (note, the first argument is the number of elements to be searched, the second is the input vector, the third is the increment for the search---use 1 as we wish every element to be searched, the fourth is the conditional against which the input vector is tested, the fifth is the returned vector of indices for those elements which pass the test and the last is the returned number of elements which pass the test [i.e., the length of the vector of indices]).
4. In lines 409 through 415, the elements of the original vectors for which the test was passed are compressed (gathered). Intersection points are calculated in lines 416--425 for the compressed vectors. The squares of distances form the surface endpoints to the intersection points are calculated in lines 430 and 430 and differenced to the square of the surface length in line 431. This difference is then used in line 439 to test those elements of the compressed vector which lie within the surface. In line 441, the number which pass the test ( npa) is accumulated in the matrix e(ns,ns).

(See exercises 7 and 7.)