Skip to content

Commit

Permalink
Merge pw_grid_create and pw_grid_setup
Browse files Browse the repository at this point in the history
  • Loading branch information
fstein93 committed May 7, 2024
1 parent 20da4d9 commit 1295dfb
Show file tree
Hide file tree
Showing 14 changed files with 179 additions and 175 deletions.
4 changes: 2 additions & 2 deletions src/cp_ddapc_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ SUBROUTINE cp_ddapc_ewald_create(cp_ddapc_ewald, qmmm_decoupl, qm_cell, &
CALL Setup_Ewald_Spline(pw_grid=cp_ddapc_ewald%pw_grid_qm, pw_pool=cp_ddapc_ewald%pw_pool_qm, &
coeff=cp_ddapc_ewald%coeff_qm, LG=LG, gx=gx, gy=gy, gz=gz, hmat=hmat, npts=npts, &
param_section=multipole_section, tag="ddapc", &
para_env=para_env, print_section=grid_print_section)
print_section=grid_print_section)
DEALLOCATE (LG)
DEALLOCATE (gx)
DEALLOCATE (gy)
Expand All @@ -320,7 +320,7 @@ SUBROUTINE cp_ddapc_ewald_create(cp_ddapc_ewald, qmmm_decoupl, qm_cell, &
grid_print_section => section_vals_get_subs_vals(force_env_section, "PRINT%GRID_INFORMATION")
CALL Setup_Ewald_Spline(pw_grid=cp_ddapc_ewald%pw_grid_mm, pw_pool=cp_ddapc_ewald%pw_pool_mm, &
coeff=cp_ddapc_ewald%coeff_mm, LG=LG, gx=gx, gy=gy, gz=gz, hmat=hmat, npts=npts, &
param_section=multipole_section, tag="ddapc", para_env=para_env, &
param_section=multipole_section, tag="ddapc", &
print_section=grid_print_section)
DEALLOCATE (LG)
DEALLOCATE (gx)
Expand Down
17 changes: 6 additions & 11 deletions src/ewald_pw_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ MODULE ewald_pw_types
USE pw_grid_types, ONLY: HALFSPACE,&
pw_grid_type
USE pw_grids, ONLY: pw_grid_create,&
pw_grid_release,&
pw_grid_setup
pw_grid_release
USE pw_poisson_methods, ONLY: pw_poisson_set
USE pw_poisson_read_input, ONLY: pw_poisson_read_parameters
USE pw_poisson_types, ONLY: do_ewald_ewald,&
Expand Down Expand Up @@ -173,15 +172,14 @@ SUBROUTINE ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
! set up Classic EWALD sum
logger => cp_get_default_logger()
output_unit = cp_print_key_unit_nr(logger, print_section, "", extension=".Log")
CALL pw_grid_create(pw_big_grid, mp_comm_self)

IF (ANY(gmax == 2*(gmax/2))) THEN
CPABORT("gmax has to be odd.")
END IF
bo(1, :) = -gmax/2
bo(2, :) = +gmax/2
CALL pw_grid_setup(cell_ref%hmat, pw_big_grid, grid_span=HALFSPACE, bounds=bo, spherical=.TRUE., &
fft_usage=.FALSE., iounit=output_unit)
CALL pw_grid_create(pw_big_grid, mp_comm_self, cell_ref%hmat, grid_span=HALFSPACE, bounds=bo, spherical=.TRUE., &
fft_usage=.FALSE., iounit=output_unit)
NULLIFY (pw_pool)
CALL pw_pool_create(pw_pool, pw_grid=pw_big_grid)
ewald_pw%pw_big_pool => pw_pool
Expand All @@ -196,8 +194,6 @@ SUBROUTINE ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
ALLOCATE (ewald_pw%poisson_env)
CALL ewald_pw%poisson_env%create()
END IF
CALL pw_grid_create(pw_small_grid, mp_comm_self)
CALL pw_grid_create(pw_big_grid, para_env)
IF (ns_max == 2*(ns_max/2)) THEN
CPABORT("ns_max has to be odd.")
END IF
Expand All @@ -208,7 +204,7 @@ SUBROUTINE ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
cutoff_radius = exp_radius(0, 2.0_dp*alphasq, epsilon, norm)

CALL dg_pme_grid_setup(cell_ref%hmat, npts_s, cutoff_radius, &
pw_small_grid, pw_big_grid, rs_dims=(/para_env%num_pe, 1/), &
pw_small_grid, pw_big_grid, para_env, rs_dims=(/para_env%num_pe, 1/), &
iounit=output_unit, fft_usage=.TRUE.)
! Write some useful info
IF (output_unit > 0) THEN
Expand Down Expand Up @@ -260,10 +256,9 @@ SUBROUTINE ewald_pw_init(ewald_pw, ewald_env, cell, cell_ref, print_section)
ALLOCATE (ewald_pw%poisson_env)
CALL ewald_pw%poisson_env%create()
END IF
CALL pw_grid_create(pw_big_grid, para_env)
npts_s = gmax
CALL pw_grid_setup(cell_ref%hmat, pw_big_grid, grid_span=HALFSPACE, npts=npts_s, spherical=.TRUE., &
rs_dims=(/para_env%num_pe, 1/), iounit=output_unit, fft_usage=.TRUE.)
CALL pw_grid_create(pw_big_grid, para_env, cell_ref%hmat, grid_span=HALFSPACE, npts=npts_s, spherical=.TRUE., &
rs_dims=(/para_env%num_pe, 1/), iounit=output_unit, fft_usage=.TRUE.)

! pw pools initialized
NULLIFY (pw_pool)
Expand Down
12 changes: 4 additions & 8 deletions src/ewald_spline_util.F
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ MODULE ewald_spline_util
section_vals_type,&
section_vals_val_get
USE kinds, ONLY: dp
USE message_passing, ONLY: mp_para_env_type
USE message_passing, ONLY: mp_comm_self
USE pw_grid_types, ONLY: HALFSPACE,&
pw_grid_type
USE pw_grids, ONLY: pw_grid_create,&
pw_grid_setup
USE pw_grids, ONLY: pw_grid_create
USE pw_methods, ONLY: pw_zero
USE pw_pool_types, ONLY: pw_pool_create,&
pw_pool_type
Expand Down Expand Up @@ -63,13 +62,12 @@ MODULE ewald_spline_util
!> \param param_section ...
!> \param tag ...
!> \param print_section ...
!> \param para_env ...
!> \par History
!> 12.2005 created [tlaino]
!> \author Teodoro Laino
! **************************************************************************************************
SUBROUTINE Setup_Ewald_Spline(pw_grid, pw_pool, coeff, LG, gx, gy, gz, hmat, npts, &
param_section, tag, print_section, para_env)
param_section, tag, print_section)
TYPE(pw_grid_type), POINTER :: pw_grid
TYPE(pw_pool_type), POINTER :: pw_pool
TYPE(pw_r3d_rs_type), POINTER :: coeff
Expand All @@ -79,7 +77,6 @@ SUBROUTINE Setup_Ewald_Spline(pw_grid, pw_pool, coeff, LG, gx, gy, gz, hmat, npt
TYPE(section_vals_type), POINTER :: param_section
CHARACTER(LEN=*), INTENT(IN) :: tag
TYPE(section_vals_type), POINTER :: print_section
TYPE(mp_para_env_type), POINTER :: para_env

INTEGER :: bo(2, 3), iounit
TYPE(cell_type), POINTER :: cell
Expand All @@ -96,13 +93,12 @@ SUBROUTINE Setup_Ewald_Spline(pw_grid, pw_pool, coeff, LG, gx, gy, gz, hmat, npt
NULLIFY (cell)

CALL cell_create(cell, hmat=hmat, periodic=(/1, 1, 1/))
CALL pw_grid_create(pw_grid, para_env, local=.TRUE.)
logger => cp_get_default_logger()
iounit = cp_print_key_unit_nr(logger, print_section, "", &
extension=".Log")
bo(1, 1:3) = 0
bo(2, 1:3) = npts(1:3) - 1
CALL pw_grid_setup(cell%hmat, pw_grid, grid_span=HALFSPACE, bounds=bo, iounit=iounit)
CALL pw_grid_create(pw_grid, mp_comm_self, cell%hmat, grid_span=HALFSPACE, bounds=bo, iounit=iounit)

CALL cp_print_key_finished_output(iounit, logger, print_section, &
"")
Expand Down
14 changes: 5 additions & 9 deletions src/library_tests.F
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ MODULE library_tests
HALFSPACE,&
pw_grid_type
USE pw_grids, ONLY: pw_grid_create,&
pw_grid_release,&
pw_grid_setup
pw_grid_release
USE pw_methods, ONLY: pw_transfer,&
pw_zero
USE pw_types, ONLY: pw_c1d_gs_type,&
Expand Down Expand Up @@ -735,8 +734,7 @@ SUBROUTINE rs_pw_transfer_test(para_env, iw, globenv, rs_pw_transfer_section)
NULLIFY (grid)
CALL section_vals_val_get(rs_pw_transfer_section, "GRID", i_vals=i_vals)
np = i_vals
CALL pw_grid_create(grid, para_env)
CALL pw_grid_setup(box%hmat, grid, grid_span=FULLSPACE, npts=np, fft_usage=.TRUE., iounit=iw)
CALL pw_grid_create(grid, para_env, box%hmat, grid_span=FULLSPACE, npts=np, fft_usage=.TRUE., iounit=iw)
no = grid%npts

CALL ca%create(grid)
Expand Down Expand Up @@ -894,8 +892,6 @@ SUBROUTINE pw_fft_test(para_env, iw, globenv, pw_transfer_section)

distribution_layout = layouts(:, i_layout)

CALL pw_grid_create(grid, para_env)

CALL section_vals_val_get(pw_transfer_section, "PW_GRID", i_rep_section=i_rep, i_val=itmp)

! from cp_control_utils
Expand Down Expand Up @@ -927,9 +923,9 @@ SUBROUTINE pw_fft_test(para_env, iw, globenv, pw_transfer_section)
END IF

! actual setup
CALL pw_grid_setup(box%hmat, grid, grid_span=grid_span, odd=odd, spherical=spherical, &
blocked=blocked_id, npts=np, fft_usage=.TRUE., &
rs_dims=distribution_layout, iounit=iw)
CALL pw_grid_create(grid, para_env, box%hmat, grid_span=grid_span, odd=odd, spherical=spherical, &
blocked=blocked_id, npts=np, fft_usage=.TRUE., &
rs_dims=distribution_layout, iounit=iw)

IF (iw > 0) CALL m_flush(iw)

Expand Down
16 changes: 7 additions & 9 deletions src/mixed_cdft_utils.F
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ MODULE mixed_cdft_utils
pw_grid_type
USE pw_grids, ONLY: do_pw_grid_blocked_false,&
pw_grid_create,&
pw_grid_release,&
pw_grid_setup
pw_grid_release
USE pw_pool_types, ONLY: pw_pool_create,&
pw_pool_p_type,&
pw_pool_type
Expand Down Expand Up @@ -688,7 +687,6 @@ SUBROUTINE mixed_cdft_init_structures(force_env, force_env_qs, mixed_env, mixed_
! Init structures only needed when the CDFT states are treated in parallel
IF (mixed_cdft%run_type == mixed_cdft_parallel) THEN
! Start building the mixed auxbas_pw_pool
CALL pw_grid_create(pw_grid, force_env%para_env)
CALL pw_env_create(mixed_cdft%pw_env)
! Decide what kind of layout to use and setup the grid
! Processor mappings currently supported:
Expand Down Expand Up @@ -727,12 +725,12 @@ SUBROUTINE mixed_cdft_init_structures(force_env, force_env_qs, mixed_env, mixed_
CALL get_qs_env(force_env_qs%qmmm_env%qs_env, &
cell=cell_mix)
END IF
CALL pw_grid_setup(cell_mix%hmat, pw_grid, grid_span=settings%grid_span(1), &
npts=settings%npts(:, 1), cutoff=settings%cutoff(1), &
spherical=settings%is_spherical, odd=settings%is_odd, &
fft_usage=.TRUE., ncommensurate=0, icommensurate=1, &
blocked=do_pw_grid_blocked_false, rs_dims=mixed_rs_dims, &
iounit=iounit)
CALL pw_grid_create(pw_grid, force_env%para_env, cell_mix%hmat, grid_span=settings%grid_span(1), &
npts=settings%npts(:, 1), cutoff=settings%cutoff(1), &
spherical=settings%is_spherical, odd=settings%is_odd, &
fft_usage=.TRUE., ncommensurate=0, icommensurate=1, &
blocked=do_pw_grid_blocked_false, rs_dims=mixed_rs_dims, &
iounit=iounit)
! Check if the layout was successfully created
IF (mixed_cdft%is_special) THEN
IF (.NOT. pw_grid%para%rs_dims(2) /= 1) is_match = .FALSE.
Expand Down
14 changes: 6 additions & 8 deletions src/pw/dct.F
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ MODULE dct
mp_request_type,&
mp_waitall
USE pw_grid_types, ONLY: pw_grid_type
USE pw_grids, ONLY: pw_grid_create,&
pw_grid_setup
USE pw_grids, ONLY: pw_grid_create
USE pw_types, ONLY: pw_r3d_rs_type
#include "../base/base_uses.f90"

Expand Down Expand Up @@ -214,7 +213,6 @@ SUBROUTINE setup_dct_pw_grids(pw_grid, cell_hmat, neumann_directions, dct_pw_gri
dests_shrink, srcs_shrink)
CALL expansion_bounds(pw_grid, neumann_directions, srcs_expand, flipg_stat, &
bounds_shftd, bounds_local_shftd, recv_msgs_bnds, bounds_new, bounds_local_new)
CALL pw_grid_create(dct_pw_grid, pw_grid%para%rs_group, local=.FALSE.)

hmat2 = 0.0_dp
hmat2(1, 1) = scfac(1)*cell_hmat(1, 1)
Expand All @@ -230,11 +228,11 @@ SUBROUTINE setup_dct_pw_grids(pw_grid, cell_hmat, neumann_directions, dct_pw_gri
blocked = 0
END IF

CALL pw_grid_setup(hmat2, dct_pw_grid, &
bounds=bounds_new, &
rs_dims=pw_grid%para%rs_dims, &
blocked=blocked, &
bounds_local=bounds_local_new)
CALL pw_grid_create(dct_pw_grid, pw_grid%para%rs_group, hmat2, &
bounds=bounds_new, &
rs_dims=pw_grid%para%rs_dims, &
blocked=blocked, &
bounds_local=bounds_local_new)

DEALLOCATE (flipg_stat, dests_expand, srcs_expand, dests_shrink, recv_msgs_bnds)

Expand Down
Loading

0 comments on commit 1295dfb

Please sign in to comment.