From aa34b83978994f0e9825706e3449a552653cfa93 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 5 Oct 2018 10:36:44 +0200 Subject: [PATCH] avoid array out of bounds allows to handle un- or partly defined non schmid coefficients --- src/lattice.f90 | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/lattice.f90 b/src/lattice.f90 index 46f243561..a963d947d 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -2237,7 +2237,7 @@ function lattice_nonSchmidMatrix(Nslip,nonSchmidCoefficients,sense) result(nonSc math_axisAngleToR implicit none integer(pInt), dimension(:), intent(in) :: Nslip !< number of active slip systems per family - real(pReal), dimension(6), intent(in) :: nonSchmidCoefficients + real(pReal), dimension(:), intent(in) :: nonSchmidCoefficients integer(pInt), intent(in) :: sense !< sense (-1,+1) real(pReal), dimension(1:3,1:3,sum(Nslip)) :: nonSchmidMatrix @@ -2256,15 +2256,19 @@ function lattice_nonSchmidMatrix(Nslip,nonSchmidCoefficients,sense) result(nonSc direction = coordinateSystem(1:3,1,i) normal = coordinateSystem(1:3,2,i) np = math_mul33x3(math_axisAngleToR(direction,60.0_pReal*INRAD), normal) - nonSchmidMatrix(1:3,1:3,i) & - = nonSchmidMatrix(1:3,1:3,i) & - + nonSchmidCoefficients(1) * math_tensorproduct33(direction, np) & - + nonSchmidCoefficients(2) * math_tensorproduct33(math_crossproduct(normal, direction), normal) & - + nonSchmidCoefficients(3) * math_tensorproduct33(math_crossproduct(np, direction), np) & - + nonSchmidCoefficients(4) * math_tensorproduct33(normal, normal) & - + nonSchmidCoefficients(5) * math_tensorproduct33(math_crossproduct(normal, direction), & - math_crossproduct(normal, normal)) & - + nonSchmidCoefficients(6) * math_tensorproduct33(direction, direction) + if (size(nonSchmidCoefficients)>1) nonSchmidMatrix(1:3,1:3,i) = nonSchmidMatrix(1:3,1:3,i) & + + nonSchmidCoefficients(1) * math_tensorproduct33(direction, np) + if (size(nonSchmidCoefficients)>2) nonSchmidMatrix(1:3,1:3,i) = nonSchmidMatrix(1:3,1:3,i) & + + nonSchmidCoefficients(2) * math_tensorproduct33(math_crossproduct(normal, direction), normal) + if (size(nonSchmidCoefficients)>3) nonSchmidMatrix(1:3,1:3,i) = nonSchmidMatrix(1:3,1:3,i) & + + nonSchmidCoefficients(3) * math_tensorproduct33(math_crossproduct(np, direction), np) + if (size(nonSchmidCoefficients)>4) nonSchmidMatrix(1:3,1:3,i) = nonSchmidMatrix(1:3,1:3,i) & + + nonSchmidCoefficients(4) * math_tensorproduct33(normal, normal) + if (size(nonSchmidCoefficients)>5) nonSchmidMatrix(1:3,1:3,i) = nonSchmidMatrix(1:3,1:3,i) & + + nonSchmidCoefficients(5) * math_tensorproduct33(math_crossproduct(normal, direction), & + math_crossproduct(normal, normal)) + if (size(nonSchmidCoefficients)>6) nonSchmidMatrix(1:3,1:3,i) = nonSchmidMatrix(1:3,1:3,i) & + + nonSchmidCoefficients(6) * math_tensorproduct33(direction, direction) enddo end function lattice_nonSchmidMatrix