Merge branch 'MiscImprovements' into 'development'
Misc improvements See merge request damask/DAMASK!58
This commit is contained in:
commit
fa1c946d06
|
@ -445,6 +445,33 @@ elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
|||
|
||||
# Additional options
|
||||
# -fdefault-integer-8: Use it to set precision to 8 bytes for integer, don't use it for the standard case of pInt=4 (there is no -fdefault-integer-4)
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# PGI Compiler
|
||||
###################################################################################################
|
||||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
|
||||
|
||||
if (OPTIMIZATION STREQUAL "OFF")
|
||||
set (OPTIMIZATION_FLAGS "-O0" )
|
||||
elseif (OPTIMIZATION STREQUAL "DEFENSIVE")
|
||||
set (OPTIMIZATION_FLAGS "-O2")
|
||||
elseif (OPTIMIZATION STREQUAL "AGGRESSIVE")
|
||||
set (OPTIMIZATION_FLAGS "-O3")
|
||||
endif ()
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# Fine tuning compilation options
|
||||
set (COMPILE_FLAGS "${COMPILE_FLAGS} -Mpreprocess")
|
||||
# preprocessor
|
||||
|
||||
set (STANDARD_CHECK "-Mallocatable=03")
|
||||
|
||||
#------------------------------------------------------------------------------------------------
|
||||
# Runtime debugging
|
||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -g")
|
||||
# Includes debugging information in the object module; sets the optimization level to zero unless a -O option is present on the command line
|
||||
else ()
|
||||
message (FATAL_ERROR "Compiler type (CMAKE_Fortran_COMPILER_ID) not recognized")
|
||||
endif ()
|
||||
|
|
|
@ -162,7 +162,6 @@ subroutine utilities_init()
|
|||
|
||||
character(len=1024) :: petsc_optionsPhysics
|
||||
integer(pInt) :: dimPlex
|
||||
integer(pInt) :: headerID = 205_pInt
|
||||
PetscInt, allocatable :: nEntities(:), nOutputCells(:), nOutputNodes(:)
|
||||
PetscInt :: dim
|
||||
PetscErrorCode :: ierr
|
||||
|
@ -213,13 +212,6 @@ subroutine utilities_init()
|
|||
nOutputCells(worldrank+1) = count(material_homog > 0_pInt)
|
||||
call MPI_Allreduce(MPI_IN_PLACE,nOutputNodes,worldsize,MPI_INT,MPI_SUM,PETSC_COMM_WORLD,ierr)
|
||||
call MPI_Allreduce(MPI_IN_PLACE,nOutputCells,worldsize,MPI_INT,MPI_SUM,PETSC_COMM_WORLD,ierr)
|
||||
if (worldrank == 0_pInt) then
|
||||
open(unit=headerID, file=trim(getSolverJobName())//'.header', &
|
||||
form='FORMATTED', status='REPLACE')
|
||||
write(headerID, '(a,i0)') 'dimension : ', dimPlex
|
||||
write(headerID, '(a,i0)') 'number of nodes : ', sum(nOutputNodes)
|
||||
write(headerID, '(a,i0)') 'number of cells : ', sum(nOutputCells)
|
||||
endif
|
||||
|
||||
end subroutine utilities_init
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,9 +1,13 @@
|
|||
! https://github.com/jeffhammond/HPCInfo/blob/master/docs/Preprocessor-Macros.md
|
||||
#if defined(__GFORTRAN__) || __INTEL_COMPILER >= 1800
|
||||
write(6,*) 'Compiled with ', compiler_version()
|
||||
write(6,*) 'With options ', compiler_options()
|
||||
#else
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
write(6,'(a,i4.4,a,i8.8)') ' Compiled with Intel fortran version ', __INTEL_COMPILER,&
|
||||
', build date ', __INTEL_COMPILER_BUILD_DATE
|
||||
#elif defined(__PGI)
|
||||
write(6,'(a,i4.4,a,i8.8)') ' Compiled with PGI fortran version ', __PGIC__,&
|
||||
'.', __PGIC_MINOR__
|
||||
#endif
|
||||
write(6,*) 'Compiled on ', __DATE__,' at ',__TIME__
|
||||
write(6,*)
|
||||
|
|
93
src/math.f90
93
src/math.f90
|
@ -118,6 +118,9 @@ module math
|
|||
!---------------------------------------------------------------------------------------------------
|
||||
|
||||
public :: &
|
||||
#if defined(__PGI)
|
||||
norm2, &
|
||||
#endif
|
||||
math_init, &
|
||||
math_qsort, &
|
||||
math_expand, &
|
||||
|
@ -351,20 +354,38 @@ end subroutine math_check
|
|||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief Quicksort algorithm for two-dimensional integer arrays
|
||||
! Sorting is done with respect to array(1,:)
|
||||
! and keeps array(2:N,:) linked to it.
|
||||
! Sorting is done with respect to array(sort,:) and keeps array(/=sort,:) linked to it.
|
||||
! default: sort=1
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
recursive subroutine math_qsort(a, istart, iend)
|
||||
recursive subroutine math_qsort(a, istart, iend, sortDim)
|
||||
|
||||
implicit none
|
||||
integer(pInt), dimension(:,:), intent(inout) :: a
|
||||
integer(pInt), intent(in) :: istart,iend
|
||||
integer(pInt) :: ipivot
|
||||
|
||||
if (istart < iend) then
|
||||
ipivot = qsort_partition(a,istart, iend)
|
||||
call math_qsort(a, istart, ipivot-1_pInt)
|
||||
call math_qsort(a, ipivot+1_pInt, iend)
|
||||
integer(pInt), intent(in),optional :: istart,iend, sortDim
|
||||
integer(pInt) :: ipivot,s,e,d
|
||||
|
||||
if(present(istart)) then
|
||||
s = istart
|
||||
else
|
||||
s = lbound(a,2)
|
||||
endif
|
||||
|
||||
if(present(iend)) then
|
||||
e = iend
|
||||
else
|
||||
e = ubound(a,2)
|
||||
endif
|
||||
|
||||
if(present(sortDim)) then
|
||||
d = sortDim
|
||||
else
|
||||
d = 1
|
||||
endif
|
||||
|
||||
if (s < e) then
|
||||
ipivot = qsort_partition(a,s, e, d)
|
||||
call math_qsort(a, s, ipivot-1_pInt, d)
|
||||
call math_qsort(a, ipivot+1_pInt, e, d)
|
||||
endif
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
|
@ -373,37 +394,34 @@ recursive subroutine math_qsort(a, istart, iend)
|
|||
!-------------------------------------------------------------------------------------------------
|
||||
!> @brief Partitioning required for quicksort
|
||||
!-------------------------------------------------------------------------------------------------
|
||||
integer(pInt) function qsort_partition(a, istart, iend)
|
||||
integer(pInt) function qsort_partition(a, istart, iend, sort)
|
||||
|
||||
implicit none
|
||||
integer(pInt), dimension(:,:), intent(inout) :: a
|
||||
integer(pInt), intent(in) :: istart,iend
|
||||
integer(pInt) :: i,j,k,tmp
|
||||
integer(pInt), intent(in) :: istart,iend,sort
|
||||
integer(pInt), dimension(size(a,1)) :: tmp
|
||||
integer(pInt) :: i,j
|
||||
|
||||
do
|
||||
! find the first element on the right side less than or equal to the pivot point
|
||||
! find the first element on the right side less than or equal to the pivot point
|
||||
do j = iend, istart, -1_pInt
|
||||
if (a(1,j) <= a(1,istart)) exit
|
||||
if (a(sort,j) <= a(sort,istart)) exit
|
||||
enddo
|
||||
! find the first element on the left side greater than the pivot point
|
||||
! find the first element on the left side greater than the pivot point
|
||||
do i = istart, iend
|
||||
if (a(1,i) > a(1,istart)) exit
|
||||
if (a(sort,i) > a(sort,istart)) exit
|
||||
enddo
|
||||
if (i < j) then ! if the indexes do not cross, exchange values
|
||||
do k = 1_pInt, int(size(a,1_pInt), pInt)
|
||||
tmp = a(k,i)
|
||||
a(k,i) = a(k,j)
|
||||
a(k,j) = tmp
|
||||
enddo
|
||||
else ! if they do cross, exchange left value with pivot and return with the partition index
|
||||
do k = 1_pInt, int(size(a,1_pInt), pInt)
|
||||
tmp = a(k,istart)
|
||||
a(k,istart) = a(k,j)
|
||||
a(k,j) = tmp
|
||||
enddo
|
||||
cross: if (i >= j) then ! if the indices cross, exchange left value with pivot and return with the partition index
|
||||
tmp = a(:,istart)
|
||||
a(:,istart) = a(:,j)
|
||||
a(:,j) = tmp
|
||||
qsort_partition = j
|
||||
return
|
||||
endif
|
||||
else cross ! if they do not cross, exchange values
|
||||
tmp = a(:,i)
|
||||
a(:,i) = a(:,j)
|
||||
a(:,j) = tmp
|
||||
endif cross
|
||||
enddo
|
||||
|
||||
end function qsort_partition
|
||||
|
@ -2707,4 +2725,19 @@ real(pReal) pure elemental function math_clip(a, left, right)
|
|||
|
||||
end function math_clip
|
||||
|
||||
|
||||
#if defined(__PGI)
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief substitute for the norm2 intrinsic which is not available in PGI 18.10
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
real(pReal) pure function norm2(v)
|
||||
|
||||
implicit none
|
||||
real(pReal), intent(in), dimension(3) :: v
|
||||
|
||||
norm2 = sqrt(sum(v**2))
|
||||
|
||||
end function norm2
|
||||
#endif
|
||||
|
||||
end module math
|
||||
|
|
Loading…
Reference in New Issue