Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We tried many changes in the file, but many of them were not effective, as this code is a coded implementation of a physical formula.
So we are trying to use parallel computing to accelerate its running speed.
We added "$ acc loop" before most of the loops to run code in parallel.
Secondly, we found that the argsort function is essentially a selection sorting algorithm with high complexity. We changed it to a fast sorting algorithm to reduce its time complexity, in order to achieve optimization goals.
Primitive function:
pure function argsort(a) result(b)
implicit none
real(rk8) , intent(in) :: a(:)
integer(ik4) , dimension(size(a)) :: b
integer :: n , i , imin , temp1
real(rk8) :: temp2
real(rk8) , dimension(size(a)) :: a2
a2 = a
n = size(a)
do i = 1 , n
b(i) = i
end do
if ( n == 1 ) return
do i = 1 , n-1
imin = minloc(a2(i:),1) + i - 1
if ( imin /= i ) then
temp2 = a2(i)
a2(i) = a2(imin)
a2(imin) = temp2
temp1 = b(i)
b(i) = b(imin)
b(imin) = temp1
end if
end do
end function argsort
Modified function:
pure function argsort(a) result(b)
implicit none
real(rk8), intent(in) :: a(:)
integer(ik4), dimension(size(a)) :: b
integer :: n
end subroutine nogtom