Skip to content

Commit

Permalink
First working version of MPI is oeproperties
Browse files Browse the repository at this point in the history
electronic ESP at external points is now MPI
parallelized over basis functions!!
  • Loading branch information
vtripath65 committed May 23, 2024
1 parent 176ed7a commit acecc55
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/modules/quick_oeproperties_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ subroutine compute_esp(ierr)
use quick_molspec_module, only : quick_molspec
use quick_files_module, only : ioutfile, iPropFile, propFileName
use quick_basis_module, only: jshell
use quick_mpi_module, only: master, mpirank
use quick_mpi_module, only: master

!#ifdef MPIV
! use mpi
!#endif
#ifdef MPIV
use mpi
use quick_basis_module, only: mpi_jshelln, mpi_jshell
use quick_mpi_module, only: mpirank, mpierror
#endif

implicit none
integer, intent(out) :: ierr
Expand All @@ -50,15 +52,19 @@ subroutine compute_esp(ierr)

double precision, allocatable :: esp_electronic(:)
double precision, allocatable :: esp_nuclear(:)
double precision, allocatable :: esp_electronic_aggregate(:)
integer :: i

ierr = 0

! Allocates & initiates ESP_NUC and ESP_ELEC arrays
allocate(esp_nuclear(quick_molspec%nextpoint))
allocate(esp_electronic(quick_molspec%nextpoint))
allocate(esp_electronic_aggregate(quick_molspec%nextpoint))

esp_nuclear(:) = 0.0d0
esp_electronic(:) = 0.0d0
esp_electronic_aggregate(:) = 0.0d0

RECORD_TIME(timer_begin%TESPGrid)

Expand All @@ -68,11 +74,21 @@ subroutine compute_esp(ierr)
end do

! Computes ESP_ELEC
#ifdef MPIV
do i=1,mpi_jshelln(mpirank)
IIsh=mpi_jshell(mpirank,i)
do JJsh=IIsh,jshell
call esp_shell_pair(IIsh, JJsh, esp_electronic)
enddo
enddo
call MPI_REDUCE(esp_electronic, esp_electronic_aggregate, quick_molspec%nextpoint, MPI_double_precision, MPI_SUM, 0, MPI_COMM_WORLD, mpierror)
#else
do IIsh = 1, jshell
do JJsh = IIsh, jshell
call esp_shell_pair(IIsh, JJsh, esp_electronic)
end do
end do
#endif

RECORD_TIME(timer_end%TESPGrid)
timer_cumer%TESPGrid=timer_cumer%TESPGrid+timer_end%TESPGrid-timer_begin%TESPGrid
Expand All @@ -81,12 +97,17 @@ subroutine compute_esp(ierr)
call quick_open(iPropFile,propFileName,'U','F','R',.false.,ierr)

! Calls print ESP
#ifdef MPIV
call print_esp(esp_nuclear,esp_electronic_aggregate, ierr)
#else
call print_esp(esp_nuclear,esp_electronic, ierr)
#endif
close(iPropFile)
endif

deallocate(esp_electronic)
deallocate(esp_nuclear)
deallocate(esp_electronic_aggregate)

end subroutine compute_esp

Expand Down

0 comments on commit acecc55

Please sign in to comment.