diff --git a/src/cross_section.F90 b/src/cross_section.F90 index db2aa0f1be..f58cf6d3cb 100644 --- a/src/cross_section.F90 +++ b/src/cross_section.F90 @@ -160,24 +160,6 @@ contains end if end if - kT = sqrtkT**2 - - select case (temperature_method) - case (TEMPERATURE_NEAREST) - i_temp = minloc(abs(nuclides(i_nuclide) % kTs - kT), dim=1) - - case (TEMPERATURE_INTERPOLATION) - ! Find temperatures that bound the actual temperature - do i_temp = 1, size(nuc % kTs) - 1 - if (nuc % kTs(i_temp) <= kT .and. kT < nuc % kTs(i_temp + 1)) exit - end do - - ! Randomly sample between temperature i and i+1 - f = (kT - nuc % kTs(i_temp)) / & - (nuc % kTs(i_temp + 1) - nuc % kTs(i_temp)) - if (f > prn()) i_temp = i_temp + 1 - end select - ! Evaluate multipole or interpolate if (use_mp) then ! Call multipole kernel @@ -202,22 +184,44 @@ contains ! 3. tally.F90 - score_general - For tallying on MTxxx reactions. ! 4. cross_section.F90 - calculate_urr_xs - For unresolved purposes. ! It is worth noting that none of these occur in the resolved - ! resonance range, so the value here does not matter. - micro_xs(i_nuclide) % index_temp = i_temp + ! resonance range, so the value here does not matter. index_temp is + ! set to -1 to force a segfault in case a developer messes up and tries + ! to use it with multipole. + micro_xs(i_nuclide) % index_temp = -1 micro_xs(i_nuclide) % index_grid = 0 micro_xs(i_nuclide) % interp_factor = ZERO + else + ! Find the appropriate temperature index. + kT = sqrtkT**2 + select case (temperature_method) + case (TEMPERATURE_NEAREST) + i_temp = minloc(abs(nuclides(i_nuclide) % kTs - kT), dim=1) + + case (TEMPERATURE_INTERPOLATION) + ! Find temperatures that bound the actual temperature + do i_temp = 1, size(nuc % kTs) - 1 + if (nuc % kTs(i_temp) <= kT .and. kT < nuc % kTs(i_temp + 1)) exit + end do + + ! Randomly sample between temperature i and i+1 + f = (kT - nuc % kTs(i_temp)) / & + (nuc % kTs(i_temp + 1) - nuc % kTs(i_temp)) + if (f > prn()) i_temp = i_temp + 1 + end select + associate (grid => nuc % grid(i_temp), xs => nuc % sum_xs(i_temp)) - ! Determine the energy grid index using a logarithmic mapping to reduce - ! the energy range over which a binary search needs to be performed + ! Determine the energy grid index using a logarithmic mapping to + ! reduce the energy range over which a binary search needs to be + ! performed if (E < grid % energy(1)) then i_grid = 1 elseif (E > grid % energy(size(grid % energy))) then i_grid = size(grid % energy) - 1 else - ! Determine bounding indices based on which equal log-spaced interval - ! the energy is in + ! Determine bounding indices based on which equal log-spaced + ! interval the energy is in i_low = grid % grid_index(i_log_union) i_high = grid % grid_index(i_log_union + 1) + 1