Skip to content

Commit

Permalink
Extend cp_context_type to cp_blacs_env_type, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederick Stein authored and fstein93 committed Feb 28, 2023
1 parent 0b78d42 commit 7bbee7e
Show file tree
Hide file tree
Showing 30 changed files with 342 additions and 304 deletions.
5 changes: 2 additions & 3 deletions src/almo_scf.F
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ MODULE almo_scf
Scheiber2018,&
Staub2019,&
cite_reference
USE cp_blacs_env, ONLY: cp_blacs_env_release,&
cp_blacs_env_retain
USE cp_blacs_env, ONLY: cp_blacs_env_release
USE cp_control_types, ONLY: dft_control_type
USE cp_dbcsr_diag, ONLY: cp_dbcsr_syevd
USE cp_dbcsr_operations, ONLY: copy_dbcsr_to_fm
Expand Down Expand Up @@ -224,7 +223,7 @@ SUBROUTINE almo_scf_init(qs_env, almo_scf_env, calc_forces)
blacs_env=almo_scf_env%blacs_env, &
nelectron_spin=almo_scf_env%nelectrons_spin)
CALL cp_para_env_retain(almo_scf_env%para_env)
CALL cp_blacs_env_retain(almo_scf_env%blacs_env)
CALL almo_scf_env%blacs_env%retain()
! copy basic quantities
almo_scf_env%nspins = dft_control%nspins
Expand Down
5 changes: 2 additions & 3 deletions src/cp_dbcsr_operations.F
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
! **************************************************************************************************
MODULE cp_dbcsr_operations
USE mathlib, ONLY: lcm, gcd
USE cp_blacs_env, ONLY: cp_blacs_env_type, &
get_blacs_info
USE cp_blacs_env, ONLY: cp_blacs_env_type
USE cp_cfm_types, ONLY: cp_cfm_type
USE dbcsr_api, ONLY: dbcsr_distribution_get, &
dbcsr_convert_sizes_to_offsets, dbcsr_add, &
Expand Down Expand Up @@ -428,7 +427,7 @@ SUBROUTINE cp_dbcsr_dist2d_to_dist(dist2d, dist)
row_distribution=row_dist_data, &
col_distribution=col_dist_data, &
blacs_env=blacs_env)
CALL get_blacs_info(blacs_env, para_env=para_env, blacs2mpi=pgrid)
CALL blacs_env%get(para_env=para_env, blacs2mpi=pgrid)

! map to 1D arrays
row_dist => row_dist_data(:, 1)
Expand Down
10 changes: 4 additions & 6 deletions src/distribution_2d_types.F
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ MODULE distribution_2d_types
USE cp_array_utils, ONLY: cp_1d_i_p_type,&
cp_1d_i_write
USE cp_blacs_env, ONLY: cp_blacs_env_release,&
cp_blacs_env_retain,&
cp_blacs_env_type,&
cp_blacs_env_write
cp_blacs_env_type
USE cp_log_handling, ONLY: cp_get_default_logger,&
cp_logger_type
USE machine, ONLY: m_flush
Expand Down Expand Up @@ -207,7 +205,7 @@ SUBROUTINE distribution_2d_create(distribution_2d, blacs_env, &
END IF

distribution_2d%blacs_env => blacs_env
CALL cp_blacs_env_retain(distribution_2d%blacs_env)
CALL distribution_2d%blacs_env%retain()

END SUBROUTINE distribution_2d_create

Expand Down Expand Up @@ -434,10 +432,10 @@ SUBROUTINE distribution_2d_write(distribution_2d, unit_nr, local, &
IF (ASSOCIATED(distribution_2d%blacs_env)) THEN
IF (my_long_description) THEN
WRITE (unit=unit_nr, fmt="(' blacs_env=')", advance="no")
CALL cp_blacs_env_write(distribution_2d%blacs_env, unit_nr=unit_nr)
CALL distribution_2d%blacs_env%write(unit_nr)
ELSE
WRITE (unit=unit_nr, fmt="(' blacs_env=<blacs_env id=',i6,'>')") &
distribution_2d%blacs_env%group%get_handle()
distribution_2d%blacs_env%get_handle()
END IF
ELSE
WRITE (unit=unit_nr, fmt="(' blacs_env=*null*')")
Expand Down
20 changes: 10 additions & 10 deletions src/et_coupling_proj.F
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ SUBROUTINE get_fm_matrix_array(mat, arr)

IF ((c_row_f == c_row) .AND. (c_col_f == c_col)) THEN
arr(i, j) = mat%local_data(i_p_row, i_p_col)
CALL dgebs2d(mat%matrix_struct%context%group, 'All', ' ', 1, 1, arr(i, j), 1)
CALL mat%matrix_struct%context%dgebs2d('All', ' ', 1, 1, arr(i, j), 1)
ELSE
CALL dgebr2d(mat%matrix_struct%context%group, 'All', ' ', 1, 1, arr(i, j), 1, c_row_f, c_col_f)
CALL mat%matrix_struct%context%dgebr2d('All', ' ', 1, 1, arr(i, j), 1, c_row_f, c_col_f)
END IF

END DO
Expand Down Expand Up @@ -531,14 +531,14 @@ SUBROUTINE reorder_hamiltonian_matrix(ec, mat_h, mat_w)
! Local H element
IF ((ch_row_f == ch_row) .AND. (ch_col_f == ch_col)) THEN
xh = mat_h%local_data(ih_p_row, ih_p_col)
CALL dgebs2d(mat_h%matrix_struct%context%group, 'All', ' ', 1, 1, xh, 1)
CALL mat_h%matrix_struct%context%dgebs2d('All', ' ', 1, 1, xh, 1)
IF ((cw_row_f == cw_row) .AND. (cw_col_f == cw_col)) THEN
mat_w%local_data(iw_p_row, iw_p_col) = xh
END IF
! Remote H element
ELSE
CALL dgebr2d(mat_h%matrix_struct%context%group, &
'All', ' ', 1, 1, xh, 1, ch_row_f, ch_col_f)
CALL mat_h%matrix_struct%context%dgebr2d( &
'All', ' ', 1, 1, xh, 1, ch_row_f, ch_col_f)
IF ((cw_row_f == cw_row) .AND. (cw_col_f == cw_col)) THEN
mat_w%local_data(iw_p_row, iw_p_col) = xh
END IF
Expand Down Expand Up @@ -865,10 +865,10 @@ FUNCTION get_mo_c2_sum(blk_at, mo, id, atom) RESULT(c2)
! local element
IF ((c_row_f == c_row) .AND. (c_col_f == c_col)) THEN
c = mo%local_data(i_p_row, i_p_col)
CALL dgebs2d(mo%matrix_struct%context%group, 'All', ' ', 1, 1, c, 1)
CALL mo%matrix_struct%context%dgebs2d('All', ' ', 1, 1, c, 1)
! remote element
ELSE
CALL dgebr2d(mo%matrix_struct%context%group, 'All', ' ', 1, 1, c, 1, c_row_f, c_col_f)
CALL mo%matrix_struct%context%dgebr2d('All', ' ', 1, 1, c, 1, c_row_f, c_col_f)
END IF
#else
c = mo%local_data(blk_at(j)%ao_pos + k - 1, id)
Expand Down Expand Up @@ -1408,14 +1408,14 @@ SUBROUTINE set_mo_coefficients(qs_env, ec, id, mo, mat_u, n_ao, n_mo)
! Local U element
IF ((cu_row_f == cu_row) .AND. (cu_col_f == cu_col)) THEN
xu = mat_u%local_data(iu_p_row, iu_p_col)
CALL dgebs2d(mat_u%matrix_struct%context%group, 'All', ' ', 1, 1, xu, 1)
CALL mat_u%matrix_struct%context%dgebs2d('All', ' ', 1, 1, xu, 1)
IF ((cs_row_f == cs_row) .AND. (cs_col_f == cs_col)) THEN
mat_w%local_data(is_p_row, is_p_col) = xu
END IF
! Remote U element
ELSE
CALL dgebr2d(mat_u%matrix_struct%context%group, &
'All', ' ', 1, 1, xu, 1, cu_row_f, cu_col_f)
CALL mat_u%matrix_struct%context%dgebr2d( &
'All', ' ', 1, 1, xu, 1, cu_row_f, cu_col_f)
IF ((cs_row_f == cs_row) .AND. (cs_col_f == cs_col)) THEN
mat_w%local_data(is_p_row, is_p_col) = xu
END IF
Expand Down

0 comments on commit 7bbee7e

Please sign in to comment.