Skip to content

Commit

Permalink
done the systematic refactoring for several codes in src/m_common/
Browse files Browse the repository at this point in the history
  • Loading branch information
kousuke-nakano committed Sep 26, 2023
1 parent 8dbda5f commit 56b3dff
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 194 deletions.
13 changes: 11 additions & 2 deletions src/m_common/cell.f90
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,10 @@ subroutine ApplyPBC(s, howmany)
end subroutine ApplyPBC

function map(x, cell_period)
real(8) :: x, cell_period
implicit none
! argument variables
real(8), intent(in) :: x, cell_period
! local variables
real(8) :: map
if (cell_period .eq. 0.d0) then
map = x
Expand All @@ -409,6 +412,7 @@ function map(x, cell_period)
end function map

function dmap(x, cell_period)
implicit none
real(8) :: x, cell_period
real(8) :: dmap
! dmap=dcos(x/cell_period)
Expand All @@ -420,6 +424,7 @@ function dmap(x, cell_period)
end function dmap

function ddmap(x, cell_period)
implicit none
real(8) :: x, cell_period
real(8) :: ddmap
if (cell_period .eq. 0.d0) then
Expand All @@ -430,7 +435,11 @@ function ddmap(x, cell_period)
end function ddmap

function map0(x)
real(8) :: x, xc, map0
implicit none
! argument variables
real(8), intent(in) :: x
! local variables
real(8) xc, map0
integer p
! this function depend only on x and is such that f'=1 and f(1/2)=0
select case (case_map)
Expand Down
16 changes: 8 additions & 8 deletions src/m_common/rotate_tools.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.

subroutine ruota_xyz(alpha, xrot, yrot, zrot, &
& nion_1, rion_1, rion_2)
subroutine ruota_xyz(alpha, xrot, yrot, zrot, nion_1, rion_1, rion_2)
implicit none
real(8) u(3, 3)
real(8), dimension(:, :), allocatable :: emme
integer nion_1, i, j, ii

real(8) alpha, xrot, yrot, zrot, &
& rion_1(3, nion_1), rion_2(3, nion_1)
real(8) alpha, xrot, yrot, zrot, rion_1(3, nion_1), rion_2(3, nion_1)

call dscal(9, 0.d0, u(1, 1), 1)
call make_u(alpha, xrot, yrot, zrot, u)
Expand All @@ -43,8 +41,9 @@ subroutine ruota_xyz(alpha, xrot, yrot, zrot, &

end subroutine ruota_xyz

subroutine ruota_molec(ipc, alpha, xrot, yrot, zrot, iesupr_1&
&, dupr_1, ioptorb_1, nparam_1, nshell_1, ioptorb, nshell, nelorb, dupr_2)
subroutine ruota_molec(ipc, alpha, xrot, yrot, zrot, iesupr_1, &
& dupr_1, ioptorb_1, nparam_1, nshell_1, &
& ioptorb, nshell, nelorb, dupr_2)
use constants, only: zzero, zone
implicit none
integer nshell_1, indpar, nelorb, nshell, shift, i, j, ii, iesupr_1, ipc
Expand Down Expand Up @@ -93,8 +92,9 @@ subroutine ruota_molec(ipc, alpha, xrot, yrot, zrot, iesupr_1&
end subroutine ruota_molec

subroutine ruota_lambda(ipc, ipf, alpha, xrot, yrot, zrot, &
& ix_1, iy_1, detmat_1, nnozero_1, occ_1, nelcol, &
& ioptorb_1, nshell_1, nnozero_2, ix_2, iy_2, detmat_2, symmagp)
& ix_1, iy_1, detmat_1, nnozero_1, occ_1, nelcol, &
& ioptorb_1, nshell_1, nnozero_2, ix_2, iy_2, detmat_2, &
& symmagp)
use allio, only: yes_hermite
use constants, only: zone, zzero
! INPUT
Expand Down
5 changes: 3 additions & 2 deletions src/m_common/save_jall_fn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ subroutine save_jall(yesfn, jastrowall_ee, winvjbar, winvjbarsz, winvj, psip)
use allio, only: nel, nelup, neldo, indt, indt4j, nelorbj, nelorbjh, iessz

implicit none
! input
! argument variables
real(8), intent(inout) :: jastrowall_ee(nelup + neldo, nelup + neldo, 0:indt4j), psip(nel, nel)
real(8), intent(in) :: winvj(max(nelorbjh, 1), 0:indt4j, *), winvjbar(*), winvjbarsz(*)

! local variables
integer :: nelused
! local
integer :: i, k, nelorbj5
logical yesfn

Expand Down
7 changes: 5 additions & 2 deletions src/m_common/scalevect.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
subroutine scalevect(n, cellfat, vect)
use cell, only: map
implicit none
integer n, i
real*8 cellfat(3), vect(3*n)
integer, intent(in) :: n
real*8, intent(in) :: cellfat(3)
real*8, intent(inout) :: vect(3*n)

integer i
!$omp parallel do default(shared) private(i)
do i = 1, 3*n, 3
vect(i) = map(vect(i), cellfat(1))
Expand Down
2 changes: 1 addition & 1 deletion src/m_common/slaterorb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
function slaterorb(ioptorb)
use constants, only: iflagerr
implicit none
integer ioptorb
integer, intent(in) :: ioptorb
logical slaterorb
select case (ioptorb)
! case(34,10,12,28,57,80) ! Slater s
Expand Down
12 changes: 8 additions & 4 deletions src/m_common/sub_comm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ module sub_comm
integer comm, parent
logical yesin
end type

contains

subroutine mpi_sub_comm_create(parent_comm, new_size, child, ierror)
implicit none
#ifdef PARALLEL
include 'mpif.h'
#endif
integer parent_comm, new_size, ierror
type(mpi_sub_comm) :: child
integer, intent(in) :: parent_comm
integer, intent(inout) :: new_size
integer, intent(inout) :: ierror ! intent(out)?
type(mpi_sub_comm), intent(inout) :: child

integer orig_group, sub_group, i
integer, dimension(:), allocatable :: ranks
Expand Down Expand Up @@ -74,8 +78,8 @@ end subroutine mpi_sub_comm_create

subroutine mpi_sub_comm_free(child, ierror)
implicit none
integer ierror
type(mpi_sub_comm) :: child
integer, intent(inout) :: ierror ! intent(out)?
type(mpi_sub_comm), intent(inout) :: child
#ifdef PARALLEL
include 'mpif.h'

Expand Down
22 changes: 14 additions & 8 deletions src/m_common/symmetrize_agp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ subroutine symmetrizeagp(nnozero_c, nozero_c, jbradet, jbradetn, dsw&
&, symmagp, yes_hermite)
use constants, only: ipc, ipf, deps
use cell, only: cellscale, phase2pi
use allio, only: rank, rion, yes_crystal, real_agp, molyes&
&, pfaffup, kiontot
use allio, only: rank, rion, yes_crystal, real_agp, molyes, pfaffup, kiontot
implicit none
integer nnozero_c, iessw0, iesswt, ii, jj, kk, ind, ix, iy&
&, nelorb_c, nelcol_c, indc, iessw, nelorb_at, iyr, ierr, ndim
integer nozero_c(*), itouch(*), jbradet(*), jbradetn(*)
real*8 dsw(*), dsw0, detmat_c(ipc*nelorb_c*nelcol_c), scale_c(*)
real*8 dswc(2), riondiff(3), cosphihalf, sinphihalf, cost, detr, deti
logical symmagp, yes_hermite

! argument variables
integer, intent(in) :: nnozero_c, iessw0, nelorb_c, nelcol_c, nelorb_at, &
& nozero_c(*), jbradet(*), jbradetn(*)
integer, intent(inout) :: itouch(*)
real*8, intent(inout) :: dsw(*)
real*8, intent(inout) :: detmat_c(ipc*nelorb_c*nelcol_c), scale_c(*)
logical, intent(in) :: symmagp, yes_hermite

! local variables
integer ii, jj, kk, ind, indc, iessw, iesswt, ix, iy, iyr, ierr, ndim
real*8 dsw0, dswc(2), riondiff(3), cosphihalf, sinphihalf, cost, detr, deti

! Input detmat_c output detmat_c symmetrized
do ii = 1, nnozero_c
scale_c(ipc*(ii - 1) + 1:ipc*ii) = detmat_c(ipc*(nozero_c(ii) - 1) + 1:ipc*nozero_c(ii))
Expand Down
60 changes: 48 additions & 12 deletions src/m_common/update_jastrowall.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
! -----------------------------------------
subroutine upjastrowall(nel, jastrowall, psip)
implicit none
integer j, k, nel
real*8 psip(nel, *), jastrowall(nel, *)

! argument variables
integer, intent(in) :: nel
real*8, intent(in) :: psip(nel, *)
real*8, intent(inout) :: jastrowall(nel, *)

! local variables
integer j, k

do j = 1, nel
do k = 1, nel
Expand All @@ -31,8 +37,14 @@ end subroutine upjastrowall

subroutine upjastrowall_sz(nel, nelup, jastrowall, psip)
implicit none
integer j, k, nel, nelup
real*8 psip(nel, *), jastrowall(nel, *)

! argument variables
integer, intent(in) :: nel, nelup
real*8, intent(in) :: psip(nel, *)
real*8, intent(inout) :: jastrowall(nel, *)

! local variables
integer j, k

do j = 1, nelup
do k = 1, nelup
Expand All @@ -59,8 +71,14 @@ end subroutine upjastrowall_sz
! -----------------------------------------
subroutine upjastrowallfat(nel, jastrowall, psipmu)
implicit none
integer nel, i, j
real*8 jastrowall(nel, *), psipmu(nel, *)

! argument variables
integer, intent(in) :: nel
real*8, intent(in) :: psipmu(nel, *)
real*8, intent(inout) :: jastrowall(nel, *)

! local variables
integer i, j

do i = 1, nel
do j = 1, nel
Expand All @@ -73,8 +91,14 @@ end subroutine upjastrowallfat

subroutine upjastrowallfat_sz(nel, nelup, jastrowall, psipmu)
implicit none
integer nel, nelup, i, j
real*8 jastrowall(nel, *), psipmu(nel, *)

! argument variables
integer, intent(in) :: nel, nelup
real*8, intent(in) :: psipmu(nel, *)
real*8, intent(inout) :: jastrowall(nel, *)

! local variables
integer i, j

do i = 1, nelup
do j = 1, nelup
Expand Down Expand Up @@ -103,8 +127,14 @@ end subroutine upjastrowallfat_sz
! ------------------------------------------
subroutine upjastrowallpsi(nel, jastrowall, psip)
implicit none
integer j, k, nel
real*8 psip(nel, *), jastrowall(nel, *)

! argument variables
integer, intent(in) :: nel
real*8, intent(in) :: psip(nel, *)
real*8, intent(inout) :: jastrowall(nel, *)

! local variables
integer j, k

do j = 1, nel
do k = 1, nel
Expand All @@ -117,8 +147,14 @@ end subroutine upjastrowallpsi

subroutine upjastrowallpsi_sz(nel, nelup, jastrowall, psip)
implicit none
integer j, k, nel, nelup
real*8 psip(nel, *), jastrowall(nel, *)

! argument variables
integer, intent(in) :: nel, nelup
real*8, intent(in) :: psip(nel, *)
real*8, intent(inout) :: jastrowall(nel, *)

! local variables
integer j, k

do j = 1, nelup
do k = j + 1, nelup
Expand Down
Loading

0 comments on commit 56b3dff

Please sign in to comment.