introduced racing condition breaker for the case of multithreaded CPFEM init.

This commit is contained in:
Philip Eisenlohr 2010-02-02 15:00:08 +00:00
parent 101d4c6bb4
commit f186c83068
1 changed files with 30 additions and 17 deletions

View File

@ -15,8 +15,9 @@ real(pReal), dimension (:,:,:), allocatable :: CPFEM_cs
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_dcsdE ! Cauchy stress tangent real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_dcsdE ! Cauchy stress tangent
real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_dcsdE_knownGood ! known good tangent real(pReal), dimension (:,:,:,:), allocatable :: CPFEM_dcsdE_knownGood ! known good tangent
logical :: CPFEM_init_done = .false., & ! remember whether init has been done already logical :: CPFEM_init_done = .false., & ! remember whether init has been done already
CPFEM_calc_done = .false. ! remember whether first IP has already calced the results CPFEM_init_inProgress = .false., & ! remember whether first IP is currently performing init
CPFEM_calc_done = .false. ! remember whether first IP has already calced the results
CONTAINS CONTAINS
@ -169,21 +170,33 @@ subroutine CPFEM_general(mode, ffn, ffn1, Temperature, dt, element, IP, cauchySt
! initialization step (three dimensional stress state check missing?) ! initialization step (three dimensional stress state check missing?)
if (.not. CPFEM_init_done) then if (.not. CPFEM_init_done) then
call prec_init() call random_number(rnd)
call IO_init() do i=1,int(256.0*rnd)
call numerics_init() n = n+1_pInt ! wasting random amount of time...
call debug_init() enddo ! ...to break potential race in multithreading
call math_init() n = n+1_pInt
call FE_init() if (.not. CPFEM_init_inProgress) then ! yes my thread won!
call mesh_init(IP, element) ! pass on coordinates to alter calcMode of first ip CPFEM_init_inProgress = .true.
call lattice_init() call prec_init()
call material_init() call IO_init()
call constitutive_init() call numerics_init()
call crystallite_init(Temperature) ! (have to) use temperature of first IP for whole model call debug_init()
call homogenization_init(Temperature) call math_init()
call CPFEM_init() call FE_init()
call mpie_cpfem_init() call mesh_init(IP, element) ! pass on coordinates to alter calcMode of first ip
CPFEM_init_done = .true. call lattice_init()
call material_init()
call constitutive_init()
call crystallite_init(Temperature) ! (have to) use temperature of first IP for whole model
call homogenization_init(Temperature)
call CPFEM_init()
call mpie_cpfem_init()
CPFEM_init_done = .true.
CPFEM_init_inProgress = .false.
else ! loser, loser...
do while (CPFEM_init_inProgress)
end do
endif
endif endif
cp_en = mesh_FEasCP('elem',element) cp_en = mesh_FEasCP('elem',element)