From 31db2828022caeabd60ec8a04561ba8ceab4edf7 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Fri, 16 Aug 2013 17:31:56 -0500 Subject: [PATCH] Changed all atomics to criticals. gfortran now produce correct k-effective. --- src/physics.F90 | 6 ++++-- src/tally.F90 | 42 ++++++++++++++++++++++++++++-------------- src/tracking.F90 | 9 ++++++--- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/src/physics.F90 b/src/physics.F90 index 500d32477a..e475655e3d 100644 --- a/src/physics.F90 +++ b/src/physics.F90 @@ -254,20 +254,22 @@ contains p % last_wgt = p % wgt ! Score implicit absorption estimate of keff -!$omp atomic +!$omp critical global_tallies(K_ABSORPTION) % value = & global_tallies(K_ABSORPTION) % value + p % absorb_wgt * & micro_xs(i_nuclide) % nu_fission / micro_xs(i_nuclide) % absorption +!$omp end critical else ! See if disappearance reaction happens if (micro_xs(i_nuclide) % absorption > & prn() * micro_xs(i_nuclide) % total) then ! Score absorption estimate of keff -!$omp atomic +!$omp critical global_tallies(K_ABSORPTION) % value = & global_tallies(K_ABSORPTION) % value + p % wgt * & micro_xs(i_nuclide) % nu_fission / micro_xs(i_nuclide) % absorption +!$omp end critical p % alive = .false. p % event = EVENT_ABSORB diff --git a/src/tally.F90 b/src/tally.F90 index 49a06140bb..2fafacf320 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -202,9 +202,10 @@ contains ! get the score and tally it score = last_wgt * calc_pn(n, mu) -!$omp atomic +!$omp critical t % results(score_index, filter_index) % value = & t % results(score_index, filter_index) % value + score +!$omp end critical end do j = j + t % scatt_order(j) cycle SCORE_LOOP @@ -341,9 +342,10 @@ contains end select ! Add score to tally -!$omp atomic +!$omp critical t % results(score_index, filter_index) % value = & t % results(score_index, filter_index) % value + score +!$omp end critical end do SCORE_LOOP @@ -415,9 +417,10 @@ contains i_filter = sum((t % matching_bins - 1) * t % stride) + 1 ! Add score to tally -!$omp atomic +!$omp critical t % results(i_score, i_filter) % value = & t % results(i_score, i_filter) % value + score +!$omp end critical end do ! reset outgoing energy bin and score index @@ -704,9 +707,10 @@ contains score_index = (k - 1)*t % n_score_bins + j ! Add score to tally -!$omp atomic +!$omp critical t % results(score_index, filter_index) % value = & t % results(score_index, filter_index) % value + score +!$omp end critical end do SCORE_LOOP @@ -848,9 +852,10 @@ contains score_index = (i_nuclide - 1)*t % n_score_bins + j ! Add score to tally -!$omp atomic +!$omp critical t % results(score_index, filter_index) % value = & t % results(score_index, filter_index) % value + score +!$omp end critical end do SCORE_LOOP @@ -947,9 +952,10 @@ contains score_index = n_nuclides_total*t % n_score_bins + j ! Add score to tally -!$omp atomic +!$omp critical t % results(score_index, filter_index) % value = & t % results(score_index, filter_index) % value + score +!$omp end critical end do MATERIAL_SCORE_LOOP @@ -1256,9 +1262,10 @@ contains score_index = (b - 1)*t % n_score_bins + j ! Add score to tally -!$omp atomic +!$omp critical t % results(score_index, filter_index) % value = & t % results(score_index, filter_index) % value + score +!$omp end critical end do SCORE_LOOP @@ -1489,9 +1496,10 @@ contains t % matching_bins(i_filter_mesh) = & mesh_indices_to_bin(m, ijk0 + 1, .true.) filter_index = sum((t % matching_bins - 1) * t % stride) + 1 -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if end do else @@ -1502,9 +1510,10 @@ contains t % matching_bins(i_filter_mesh) = & mesh_indices_to_bin(m, ijk0 + 1, .true.) filter_index = sum((t % matching_bins - 1) * t % stride) + 1 -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if end do end if @@ -1519,9 +1528,10 @@ contains t % matching_bins(i_filter_mesh) = & mesh_indices_to_bin(m, ijk0 + 1, .true.) filter_index = sum((t % matching_bins - 1) * t % stride) + 1 -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if end do else @@ -1532,9 +1542,10 @@ contains t % matching_bins(i_filter_mesh) = & mesh_indices_to_bin(m, ijk0 + 1, .true.) filter_index = sum((t % matching_bins - 1) * t % stride) + 1 -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if end do end if @@ -1549,9 +1560,10 @@ contains t % matching_bins(i_filter_mesh) = & mesh_indices_to_bin(m, ijk0 + 1, .true.) filter_index = sum((t % matching_bins - 1) * t % stride) + 1 -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if end do else @@ -1562,9 +1574,10 @@ contains t % matching_bins(i_filter_mesh) = & mesh_indices_to_bin(m, ijk0 + 1, .true.) filter_index = sum((t % matching_bins - 1) * t % stride) + 1 -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if end do end if @@ -1687,9 +1700,10 @@ contains end if ! Add to surface current tally -!$omp atomic +!$omp critical t % results(1, filter_index) % value = & t % results(1, filter_index) % value + p % wgt +!$omp end critical end if ! Calculate new coordinates diff --git a/src/tracking.F90 b/src/tracking.F90 index 6080b2bae1..0ceb5d7e8f 100644 --- a/src/tracking.F90 +++ b/src/tracking.F90 @@ -60,8 +60,9 @@ contains n_event = 0 ! Add paricle's starting weight to count for normalizing tallies later -!$omp atomic +!$omp critical total_weight = total_weight + p % wgt +!$omp end critical ! Force calculation of cross-sections by setting last energy to zero micro_xs % last_E = ZERO @@ -101,10 +102,11 @@ contains call score_tracklength_tally(p, distance) ! Score track-length estimate of k-eff -!$omp atomic +!$omp critical global_tallies(K_TRACKLENGTH) % value = & global_tallies(K_TRACKLENGTH) % value + p % wgt * distance * & material_xs % nu_fission +!$omp end critical if (d_collision > d_boundary) then ! ==================================================================== @@ -128,10 +130,11 @@ contains ! PARTICLE HAS COLLISION ! Score collision estimate of keff -!$omp atomic +!$omp critical global_tallies(K_COLLISION) % value = & global_tallies(K_COLLISION) % value + p % wgt * & material_xs % nu_fission / material_xs % total +!$omp end critical ! score surface current tallies -- this has to be done before the collision ! since the direction of the particle will change and we need to use the