From e4054c116d52803b57ba6da6f097c5193a2de058 Mon Sep 17 00:00:00 2001 From: Christoph Kords Date: Tue, 9 Oct 2012 12:34:57 +0000 Subject: [PATCH] fixed problem with gnu compiler: allocation of variables in constitutive_nonlocal_stateInit was not safe when not using any nonlocal constitution put header of debugging output in constitutive_init at the start of the function in order to make debugging easier --- code/constitutive.f90 | 42 ++++++++++++++++------------------ code/constitutive_nonlocal.f90 | 19 ++++++++++++++- 2 files changed, 38 insertions(+), 23 deletions(-) diff --git a/code/constitutive.f90 b/code/constitutive.f90 index 805dc235b..9d93d5ae9 100644 --- a/code/constitutive.f90 +++ b/code/constitutive.f90 @@ -144,6 +144,10 @@ call constitutive_dislotwin_init(fileunit) call constitutive_nonlocal_init(fileunit) close(fileunit) +write(6,*) +write(6,*) '<<<+- constitutive init -+>>>' +write(6,*) '$Id$' +#include "compilation_info.f90" ! --- WRITE DESCRIPTION FILE FOR CONSTITUTIVE PHASE OUTPUT --- @@ -435,29 +439,23 @@ constitutive_maxSizeState = maxval(constitutive_sizeState) constitutive_maxSizeDotState = maxval(constitutive_sizeDotState) constitutive_maxSizePostResults = maxval(constitutive_sizePostResults) -!$OMP CRITICAL (write2out) +if (iand(debug_level(debug_constitutive),debug_levelBasic) /= 0_pInt) then + write(6,'(a32,1x,7(i8,1x))') 'constitutive_state0: ', shape(constitutive_state0) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_partionedState0: ', shape(constitutive_partionedState0) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_subState0: ', shape(constitutive_subState0) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_state: ', shape(constitutive_state) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_aTolState: ', shape(constitutive_aTolState) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_dotState: ', shape(constitutive_dotState) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_deltaState: ', shape(constitutive_deltaState) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_sizeState: ', shape(constitutive_sizeState) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_sizeDotState: ', shape(constitutive_sizeDotState) + write(6,'(a32,1x,7(i8,1x))') 'constitutive_sizePostResults: ', shape(constitutive_sizePostResults) write(6,*) - write(6,*) '<<<+- constitutive init -+>>>' - write(6,*) '$Id$' -#include "compilation_info.f90" - if (iand(debug_level(debug_constitutive),debug_levelBasic) /= 0_pInt) then - write(6,'(a32,1x,7(i8,1x))') 'constitutive_state0: ', shape(constitutive_state0) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_partionedState0: ', shape(constitutive_partionedState0) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_subState0: ', shape(constitutive_subState0) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_state: ', shape(constitutive_state) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_aTolState: ', shape(constitutive_aTolState) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_dotState: ', shape(constitutive_dotState) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_deltaState: ', shape(constitutive_deltaState) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_sizeState: ', shape(constitutive_sizeState) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_sizeDotState: ', shape(constitutive_sizeDotState) - write(6,'(a32,1x,7(i8,1x))') 'constitutive_sizePostResults: ', shape(constitutive_sizePostResults) - write(6,*) - write(6,'(a32,1x,7(i8,1x))') 'maxSizeState: ', constitutive_maxSizeState - write(6,'(a32,1x,7(i8,1x))') 'maxSizeDotState: ', constitutive_maxSizeDotState - write(6,'(a32,1x,7(i8,1x))') 'maxSizePostResults: ', constitutive_maxSizePostResults - endif - call flush(6) -!$OMP END CRITICAL (write2out) + write(6,'(a32,1x,7(i8,1x))') 'maxSizeState: ', constitutive_maxSizeState + write(6,'(a32,1x,7(i8,1x))') 'maxSizeDotState: ', constitutive_maxSizeDotState + write(6,'(a32,1x,7(i8,1x))') 'maxSizePostResults: ', constitutive_maxSizePostResults +endif +call flush(6) end subroutine constitutive_init diff --git a/code/constitutive_nonlocal.f90 b/code/constitutive_nonlocal.f90 index 538dca340..354759b6d 100644 --- a/code/constitutive_nonlocal.f90 +++ b/code/constitutive_nonlocal.f90 @@ -942,7 +942,7 @@ type(p_vec), dimension(1,mesh_maxNips,mesh_NcpElems), intent(inout) :: & state ! microstructural state !*** local variables -real(pReal), dimension(maxval(constitutive_nonlocal_totalNslip)) :: & +real(pReal), dimension(:), allocatable :: & rhoSglEdgePos, & ! positive edge dislocation density rhoSglEdgeNeg, & ! negative edge dislocation density rhoSglScrewPos, & ! positive screw dislocation density @@ -971,6 +971,14 @@ real(pReal) meanDensity, & maxNinstance = int(count(phase_plasticity == constitutive_nonlocal_label),pInt) +if (maxNinstance > 0_pInt) then + allocate(rhoSglEdgePos(maxval(constitutive_nonlocal_totalNslip))) + allocate(rhoSglEdgeNeg(maxval(constitutive_nonlocal_totalNslip))) + allocate(rhoSglScrewPos(maxval(constitutive_nonlocal_totalNslip))) + allocate(rhoSglScrewNeg(maxval(constitutive_nonlocal_totalNslip))) + allocate(rhoDipEdge(maxval(constitutive_nonlocal_totalNslip))) + allocate(rhoDipScrew(maxval(constitutive_nonlocal_totalNslip))) +endif do myInstance = 1_pInt,maxNinstance ns = constitutive_nonlocal_totalNslip(myInstance) @@ -1045,6 +1053,15 @@ do myInstance = 1_pInt,maxNinstance endif enddo +if (maxNinstance > 0_pInt) then + deallocate(rhoSglEdgePos) + deallocate(rhoSglEdgeNeg) + deallocate(rhoSglScrewPos) + deallocate(rhoSglScrewNeg) + deallocate(rhoDipEdge) + deallocate(rhoDipScrew) +endif + endsubroutine