5.4 Program Execution

Next: 6 Daylighting Example Up: 5 Monte Carlo Code-Exercise Previous: 5.3 Code Details

## 5.4 Program Execution

The code is well commented (refer to the Postscript two-column listing for line numbers). Here, we go through the process, subroutine by subroutine.

Subroutine input

1. First, the geometry is calculated (lines 182 through 219).
2. Next, the material properties are computed and stored (lines 220 through 232).
3. Finally, the analytical answers are calculated and stored (lines 233 through 263).

Next, the solution phase is invoked. Line 54 initiates the loop over surfaces. For each surface, we loop over nstop full surface emissions (line 58), each of np particles (here, 10,000). Within this loop, we invoke the following subroutines:

Subroutine emit

1. The ``starting'' coordinate is defined for the first particle of this vector of np particles (lines 292-298).
2. The emission coordinates are defined in lines 299-306. The student must supply the right sides of lines 305 and 306.
3. The outgoing local spherical angles (lines 307 through 318), local Cartesian components (lines 319 through 325) and global Cartesian components (lines 326-333) are obtained. The student must supply the right sides of lines 313, 318, 324, 325, 332 and 333.

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 3 and 4.)

Next: 6 Daylighting Example Up: 5 Monte Carlo Code-Exercise Previous: 5.3 Code Details

verena@csep1.phy.ornl.gov