From 7764b842a03fe2628762156f106a2d3be322be67 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Sun, 31 Jan 2016 20:58:53 -0500 Subject: [PATCH] Fix OpenMP fails --- src/input_xml.F90 | 11 ++++++++++- src/state_point.F90 | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/input_xml.F90 b/src/input_xml.F90 index 0a90b53176..be6610224d 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -2349,6 +2349,11 @@ contains filename = trim(path_input) // "tallies.xml" inquire(FILE=filename, EXIST=file_exists) if (.not. file_exists) then + ! We need each thread to allocate tally_derivs to avoid segfaults +!$omp parallel + allocate(tally_derivs(0)) +!$omp end parallel + ! Since a tallies.xml file is optional, no error is issued here return end if @@ -2533,8 +2538,12 @@ contains ! Get pointer list to XML . call get_node_list(doc, "derivative", node_deriv_list) - ! Allocate TallyDerivative array. + ! Allocate TallyDerivative array on each thread. The attributes of the + ! TallyDerivatives will be set on the master thread and then 'copyin'ed + ! in simulate.F90 +!$omp parallel allocate(tally_derivs(get_list_size(node_deriv_list))) +!$omp end parallel ! Read derivative attributes. do i = 1, get_list_size(node_deriv_list) diff --git a/src/state_point.F90 b/src/state_point.F90 index 84a2a18930..7991719c84 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -195,7 +195,7 @@ contains call close_group(meshes_group) ! Write information for derivatives. - if (allocated(tally_derivs) .and. size(tally_derivs) > 0) then + if (size(tally_derivs) > 0) then derivs_group = create_group(tallies_group, "derivatives") do i = 1, size(tally_derivs) associate(deriv => tally_derivs(i))