Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI Fortran modernization #328

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/basis.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ subroutine readbasis(natomxiao,natomstart,natomfinal,nbasisstart,nbasisfinal,ier
use allmod
use quick_gridpoints_module
use quick_exception_module
#ifdef MPIV
use mpi
#endif
!
implicit double precision(a-h,o-z)
character(len=120) :: line
Expand All @@ -30,11 +33,6 @@ subroutine readbasis(natomxiao,natomstart,natomfinal,nbasisstart,nbasisfinal,ier
integer, intent(inout) :: ierr
logical :: blngr_test


#ifdef MPIV
include 'mpif.h'
#endif

! initialize the arra

! =============MPI/ MASTER========================
Expand Down
3 changes: 1 addition & 2 deletions src/calMP2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,9 @@ subroutine MPI_calmp2
use allmod
use quick_gaussian_class_module
use quick_cutoff_module, only: cshell_density_cutoff
use mpi
implicit double precision(a-h,o-z)

include "mpif.h"

double precision cutoffTest,testtmp,testCutoff
double precision, allocatable:: temp4d(:,:,:,:)
integer II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2,total_ntemp
Expand Down
2 changes: 1 addition & 1 deletion src/dlfind/dlf_mpi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
!! SOURCE
!!****
module dlf_mpi_module
include 'mpif.h'
use mpi
save

integer :: global_comm ! set to, and use instead of, mpi_comm_world
Expand Down
2 changes: 1 addition & 1 deletion src/dnc/dnc_hfoperator.f90
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ subroutine mpi_hfoperatordc(oneElecO)
use quick_gaussian_class_module
use quick_cutoff_module, only: cshell_density_cutoff
use quick_cshell_eri_module, only: getCshellEriEnergy
use mpi
implicit double precision(a-h,o-z)

include "mpif.h"
double precision testtmp,cutoffTest,oneElecO(nbasis,nbasis)
integer II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
common /hrrstore/II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
Expand Down
7 changes: 3 additions & 4 deletions src/dnc/dnc_scf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
! this is dii for div & con
subroutine electdiisdc(jscf,PRMS)
use allmod
#ifdef MPIV
use mpi
#endif
implicit double precision(a-h,o-z)

logical :: diisdone
Expand All @@ -22,10 +25,6 @@ subroutine electdiisdc(jscf,PRMS)
double precision efermi(10),oneElecO(nbasis,nbasis)
integer :: lsolerr = 0

#ifdef MPIV
include "mpif.h"
#endif

!===========================================================
! The purpose of this subroutine is to utilize Pulay's accelerated
! scf convergence as detailed in J. Comp. Chem, Vol 3, #4, pg 566-60, 1982.
Expand Down
7 changes: 3 additions & 4 deletions src/dnc/inidivcon.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

subroutine inidivcon(natomsaved)
use allmod
#ifdef MPIV
use mpi
#endif
implicit double precision (a-h,o-z)

double precision rbuffer1,rbuffer2
Expand All @@ -55,10 +58,6 @@ subroutine inidivcon(natomsaved)
integer natomt,natomsaved
logical bEliminate ! if elimination step needed(test only)

#ifdef MPIV
include 'mpif.h'
#endif

natomt=natomsaved ! avoid modification of important variable natomsaved
bEliminate=.true.

Expand Down
7 changes: 3 additions & 4 deletions src/finalize.f90
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,13 @@ end subroutine finalize
subroutine quick_exit(io, ierr)

use allmod
#ifdef MPIV
use mpi
#endif
implicit none
integer io ! close this unit if greater than zero
integer, intent(inout) :: ierr

#ifdef MPIV
include 'mpif.h'
#endif


if (ierr /= 0) then
call flush(io)
Expand Down
7 changes: 3 additions & 4 deletions src/getEnergy.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ subroutine getEnergy(isGuess, ierr)
#ifdef CEW
use quick_cew_module, only : quick_cew
#endif
#ifdef MPIV
use mpi
#endif

implicit none

Expand All @@ -30,10 +33,6 @@ subroutine getEnergy(isGuess, ierr)
integer, intent(inout) :: ierr
logical :: verbose

#ifdef MPIV
include "mpif.h"
#endif

verbose = .true.
if ( isGuess .and. (.not. quick_method%writeSAD) ) verbose = .false.

Expand Down
7 changes: 3 additions & 4 deletions src/getMol.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ subroutine getMol(ierr)
use allmod
use quick_gridpoints_module
use quick_exception_module

implicit none

#ifdef MPIV
include 'mpif.h'
use mpi
#endif

implicit none

logical :: present
integer :: i,j,k,itemp
integer, intent(inout) :: ierr
Expand Down
7 changes: 3 additions & 4 deletions src/main.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ program quick
use quick_sad_guess_module, only: getSadGuess
use quick_molden_module, only : quick_molden, initializeExport, exportCoordinates, exportBasis, &
exportMO, exportSCF, exportOPT

implicit none

#ifdef MPIV
include 'mpif.h'
use mpi
#endif

implicit none

#if defined CUDA || defined HIP
integer :: gpu_device_id = -1
#endif
Expand Down
5 changes: 2 additions & 3 deletions src/modules/include/eri.fh
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ subroutine get_eri_precomputables
!__________________________________________________________________

use allmod
implicit none

#ifdef MPIV
include 'mpif.h'
use mpi
#endif
implicit none

integer ics,ips,jcs,jps,itemp,itemp2,i
integer NA,NB
Expand Down
41 changes: 18 additions & 23 deletions src/modules/include/gradient.fh
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ contains

use allmod
use quick_lri_grad_module
#ifdef MPIV
use mpi
#endif
implicit double precision(a-h,o-z)

integer, intent(inout) :: ierr
character(len=1) cartsym(3)
double precision :: c_coords(3),c_zeta,c_chg ! for testing lri gradients
integer :: c_idx ! for testing lri gradients

#ifdef MPIV
include "mpif.h"
#endif

! Curently, only analytical gradients are available. This should be changed later.
quick_method%analgrad=.true.
Expand Down Expand Up @@ -187,14 +186,14 @@ contains
#endif
#ifdef OSHELL
use quick_cshell_gradient_module
#endif
#ifdef MPIV
use mpi
#endif
implicit double precision(a-h,o-z)

integer II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2,ierr
common /hrrstore/II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
#ifdef MPIV
include "mpif.h"
#endif

!---------------------------------------------------------------------
! The purpose of this subroutine is to calculate the gradient of
Expand Down Expand Up @@ -523,12 +522,11 @@ contains
#else
use quick_cutoff_module, only: cshell_density_cutoff
#endif
implicit none
integer :: Iatm, Imomentum, IIsh, JJsh, i, j, nshell_mpi

#ifdef MPIV
include "mpif.h"
use mpi
#endif
implicit none
integer :: Iatm, Imomentum, IIsh, JJsh, i, j, nshell_mpi

!---------------------------------------------------------------------
! 1) The derivative of the kinetic term
Expand Down Expand Up @@ -691,15 +689,14 @@ contains
#ifdef OSHELL
use quick_cshell_gradient_module, only:get_ijbas_derivative
#endif

#ifdef MPIV
use mpi
#endif
implicit double precision(a-h,o-z)

integer II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
common /hrrstore/II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
logical :: ijcon
#ifdef MPIV
include "mpif.h"
#endif

! 1) The negative of the energy weighted density matrix element i j
! with the derivative of the ij overlap.
Expand Down Expand Up @@ -838,15 +835,14 @@ contains
#else
use quick_cutoff_module, only:cshell_density_cutoff, cshell_dnscreen
use quick_cshell_eri_grad_module, only: cshell_eri_grad
#endif
#ifdef MPIV
use mpi
#endif
implicit double precision(a-h,o-z)

integer II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
common /hrrstore/II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2

#ifdef MPIV
include "mpif.h"
#endif

! This subroutine calculates the derivative of 4center 2e-
! terms with respect to X times the coefficient found in the energy.
Expand Down Expand Up @@ -993,6 +989,9 @@ contains
use quick_dft_module, only: b3lypf, b3lyp_e, becke, becke_e, lyp, lyp_e
use xc_f90_types_m
use xc_f90_lib_m
#ifdef MPIV
use mpi
#endif
implicit none

integer :: iatm, ibas, ibin, icount, ifunc, igp, jbas, jcount, ibasstart, irad_init, &
Expand All @@ -1014,10 +1013,6 @@ contains
double precision :: tgrd(3), tsum(3)
integer :: i,k,oi
double precision,allocatable :: dp(:,:)

#ifdef MPIV
include "mpif.h"
#endif

if ( quick_method%HF ) then
! If we don't return for HF+CEW, then the unitialized data will enter
Expand Down
3 changes: 1 addition & 2 deletions src/modules/quick_api_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -818,15 +818,14 @@ end subroutine set_quick_mpi
! broadcasts results from master to slaves

subroutine broadcast_quick_mpi_results(self,ierr)
use mpi

implicit none

type(quick_api_type), intent(inout) :: self
integer :: mpierror
integer, intent(inout) :: ierr

include 'mpif.h'

call MPI_BCAST(self%tot_ene,1,mpi_double_precision,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%gradient,3*self%natoms,mpi_double_precision,0,MPI_COMM_WORLD,mpierror)
call MPI_BCAST(self%ptchg_grad,3*self%nxt_ptchg,mpi_double_precision,0,MPI_COMM_WORLD,mpierror)
Expand Down
6 changes: 2 additions & 4 deletions src/modules/quick_api_test_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,12 @@ end subroutine load_test_data
! initialize mpi library and save mpirank and mpisize
subroutine mpi_initialize(mpisize, mpirank, master, mpierror)

use mpi
implicit none

integer, intent(inout) :: mpisize, mpirank, mpierror
logical, intent(inout) :: master

include 'mpif.h'

call MPI_INIT(mpierror)
call MPI_COMM_RANK(MPI_COMM_WORLD,mpirank,mpierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD,mpisize,mpierror)
Expand Down Expand Up @@ -144,11 +143,10 @@ end subroutine printQuickMPIOutput

subroutine mpi_exit

use mpi
implicit none
integer :: mpierror

include 'mpif.h'

call MPI_FINALIZE(mpierror)
call exit(0)

Expand Down
2 changes: 1 addition & 1 deletion src/modules/quick_calculated_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ subroutine broadcast_quick_qm_struct(self)
use quick_mpi_module
use quick_method_module,only: quick_method
use quick_molspec_module,only: quick_molspec
use mpi
implicit none
include "mpif.h"
type (quick_qm_struct_type) self
integer natom
integer nbasis,nbasis2
Expand Down
15 changes: 6 additions & 9 deletions src/modules/quick_cew_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,11 @@ subroutine quick_cew_prescf()
use quick_method_module, only: quick_method
#ifdef MPIV
use quick_mpi_module
use mpi
#endif

implicit none

#ifdef MPIV
include "mpif.h"
#endif

double precision :: E
double precision :: pot
double precision :: qa,qb
Expand Down Expand Up @@ -413,11 +410,10 @@ subroutine quick_cew_prescf_quad()
use xc_f90_lib_m
use quick_gridpoints_module, only : quick_dft_grid
use quick_molspec_module, only : quick_molspec
implicit none

#ifdef MPIV
include "mpif.h"
use mpi
#endif
implicit none

!integer II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2, I, J
!common /hrrstore/II,JJ,KK,LL,NBI1,NBI2,NBJ1,NBJ2,NBK1,NBK2,NBL1,NBL2
Expand Down Expand Up @@ -905,6 +901,9 @@ subroutine quick_cew_grad_quad()
!use quick_api_module, only : quick_api
use quick_calculated_module, only : quick_qm_struct
use quick_molspec_module, only : quick_molspec
#ifdef MPIV
use mpi
#endif

implicit double precision(a-h,o-z)

Expand All @@ -930,8 +929,6 @@ subroutine quick_cew_grad_quad()

#ifdef MPIV
integer :: irad_init, irad_end

include "mpif.h"
#endif

#if defined MPIV && !defined CUDA_MPIV && !defined HIP_MPIV
Expand Down
Loading
Loading