From c4784e66735e6c364ee0555f8e2816ba1f4a8ad4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 13 Apr 2019 15:34:51 +0200 Subject: [PATCH] better readable --- src/crystallite.f90 | 70 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/src/crystallite.f90 b/src/crystallite.f90 index 69c7839c7..d97763ef3 100644 --- a/src/crystallite.f90 +++ b/src/crystallite.f90 @@ -1163,64 +1163,62 @@ subroutine crystallite_results !-------------------------------------------------------------------------------------------------- !> @brief select tensors for output !-------------------------------------------------------------------------------------------------- - function select_tensors(dataset,instance) + function select_tensors(dataset,instance) use material, only: & homogenization_maxNgrains, & material_phaseAt - integer, intent(in) :: instance - real(pReal), dimension(:,:,:,:,:), intent(in) :: dataset - real(pReal), allocatable, dimension(:,:,:) :: select_tensors - integer :: e,i,c,j - - allocate(select_tensors(3,3,count(material_phaseAt==instance)*homogenization_maxNgrains)) + integer, intent(in) :: instance + real(pReal), dimension(:,:,:,:,:), intent(in) :: dataset + real(pReal), allocatable, dimension(:,:,:) :: select_tensors + integer :: e,i,c,j + + allocate(select_tensors(3,3,count(material_phaseAt==instance)*homogenization_maxNgrains)) - j=1 - do e = 1, size(material_phaseAt,2) - do i = 1, homogenization_maxNgrains !ToDo: this needs to be changed for varying Ngrains - do c = 1, size(material_phaseAt,1) - if (material_phaseAt(c,e) == instance) then - select_tensors(1:3,1:3,j) = dataset(1:3,1:3,c,i,e) + j=0 + do e = 1, size(material_phaseAt,2) + do i = 1, homogenization_maxNgrains !ToDo: this needs to be changed for varying Ngrains + do c = 1, size(material_phaseAt,1) + if (material_phaseAt(c,e) == instance) then j = j + 1 - endif - enddo + select_tensors(1:3,1:3,j) = dataset(1:3,1:3,c,i,e) + endif + enddo + enddo enddo - enddo - - end function select_tensors + end function select_tensors !-------------------------------------------------------------------------------------------------- !> @brief select rotations for output !-------------------------------------------------------------------------------------------------- - function select_rotations(dataset,instance) + function select_rotations(dataset,instance) use material, only: & homogenization_maxNgrains, & material_phaseAt - integer, intent(in) :: instance - type(rotation), dimension(:,:,:), intent(in) :: dataset - type(rotation), allocatable, dimension(:) :: select_rotations - integer :: e,i,c,j - - allocate(select_rotations(count(material_phaseAt==instance)*homogenization_maxNgrains)) + integer, intent(in) :: instance + type(rotation), dimension(:,:,:), intent(in) :: dataset + type(rotation), allocatable, dimension(:) :: select_rotations + integer :: e,i,c,j + + allocate(select_rotations(count(material_phaseAt==instance)*homogenization_maxNgrains)) - j=1 - do e = 1, size(material_phaseAt,2) - do i = 1, homogenization_maxNgrains !ToDo: this needs to be changed for varying Ngrains - do c = 1, size(material_phaseAt,1) - if (material_phaseAt(c,e) == instance) then - select_rotations(j) = dataset(c,i,e) + j=0 + do e = 1, size(material_phaseAt,2) + do i = 1, homogenization_maxNgrains !ToDo: this needs to be changed for varying Ngrains + do c = 1, size(material_phaseAt,1) + if (material_phaseAt(c,e) == instance) then j = j + 1 - endif - enddo - enddo - enddo + select_rotations(j) = dataset(c,i,e) + endif + enddo + enddo + enddo - end function select_rotations #endif