84 SUBROUTINE complete_gamma(mp2_env, B_ia_Q, dimen_RI, homo, virtual, para_env, para_env_sub, ngroup, &
85 my_group_L_size, my_group_L_start, my_group_L_end, &
86 my_B_size, my_B_virtual_start, gd_array, gd_B_virtual, kspin)
89 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :, :), &
90 INTENT(INOUT) :: b_ia_q
91 INTEGER,
INTENT(IN) :: dimen_ri, homo, virtual
93 INTEGER,
INTENT(IN) :: ngroup, my_group_l_size, &
94 my_group_l_start, my_group_l_end, &
95 my_b_size, my_b_virtual_start
97 INTEGER,
INTENT(IN) :: kspin
99 CHARACTER(LEN=*),
PARAMETER :: routinen =
'complete_gamma'
101 INTEGER :: dimen_ia, handle, i, ispin, kkb, my_ia_end, my_ia_size, my_ia_start, my_p_end, &
102 my_p_size, my_p_start, nspins, pos_group, pos_sub
103 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: pos_info
104 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: group_grid_2_mepos, mepos_2_grid_group
105 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: bib_c_2d, gamma_2d, gamma_pq
108 TYPE(
cp_fm_type) :: fm_gamma, fm_gamma_pq, fm_gamma_pq_2, fm_gamma_pq_temp, &
109 fm_gamma_pq_temp_2, fm_ia_p, fm_y, operator_half, pq_half
113 CALL timeset(routinen, handle)
118 dimen_ia = homo*virtual
120 CALL get_group_dist(gd_ia, para_env_sub%mepos, my_ia_start, my_ia_end, my_ia_size)
122 CALL mat_3d_to_2d(b_ia_q, bib_c_2d, homo, my_b_size, virtual, my_b_virtual_start, &
123 my_ia_start, my_ia_end, my_ia_size, my_group_l_size, para_env_sub, gd_b_virtual)
125 CALL mat_3d_to_2d_gamma(mp2_env%ri_grad%Gamma_P_ia(kspin)%array, gamma_2d, homo, my_b_size, virtual, my_b_virtual_start, &
126 my_ia_start, my_ia_end, my_ia_size, my_group_l_size, para_env_sub, gd_b_virtual)
134 CALL get_group_dist(gd_p, para_env_sub%mepos, my_p_start, my_p_end, my_p_size)
137 group_grid_2_mepos, mepos_2_grid_group, pos_info=pos_info)
139 DO i = 0, para_env%num_pe - 1
141 pos_group = i/para_env_sub%num_pe
143 pos_sub = pos_info(i)
154 NULLIFY (fm_struct_ia)
156 ncol_global=dimen_ri, para_env=para_env)
159 CALL array2fm(gamma_2d, fm_struct_ia, my_ia_start, my_ia_end, &
160 my_group_l_start, my_group_l_end, &
161 gd_ia_new, gd_array_new, &
162 group_grid_2_mepos, para_env_sub%num_pe, ngroup, &
165 CALL array2fm(bib_c_2d, fm_struct_ia, my_ia_start, my_ia_end, &
166 my_group_l_start, my_group_l_end, &
167 gd_ia_new, gd_array_new, &
168 group_grid_2_mepos, para_env_sub%num_pe, ngroup, &
171 NULLIFY (fm_struct_ri)
173 ncol_global=dimen_ri, para_env=para_env)
176 CALL array2fm(mp2_env%ri_grad%PQ_half, fm_struct_ri, my_p_start, my_p_end, &
177 my_group_l_start, my_group_l_end, &
178 gd_p_new, gd_array_new, &
179 group_grid_2_mepos, para_env_sub%num_pe, ngroup, &
180 pq_half, do_release_mat=.false.)
183 CALL array2fm(mp2_env%ri_grad%operator_half, fm_struct_ri, my_p_start, my_p_end, &
184 my_group_l_start, my_group_l_end, &
185 gd_p_new, gd_array_new, &
186 group_grid_2_mepos, para_env_sub%num_pe, ngroup, &
187 operator_half, do_release_mat=.false.)
196 CALL cp_fm_create(fm_gamma, fm_struct_ia, name=
"fm_Gamma")
199 CALL parallel_gemm(transa=
"N", transb=
"T", m=dimen_ia, n=dimen_ri, k=dimen_ri, alpha=1.0_dp, &
200 matrix_a=fm_y, matrix_b=pq_half, beta=0.0_dp, &
207 CALL cp_fm_create(fm_gamma_pq_temp, fm_struct_ri, name=
"fm_Gamma_PQ_temp")
208 CALL parallel_gemm(transa=
"T", transb=
"N", m=dimen_ri, n=dimen_ri, k=dimen_ia, alpha=1.0_dp, &
209 matrix_a=fm_gamma, matrix_b=fm_ia_p, beta=0.0_dp, &
210 matrix_c=fm_gamma_pq_temp)
213 CALL cp_fm_create(fm_gamma_pq, fm_struct_ri, name=
"fm_Gamma_PQ")
216 CALL parallel_gemm(transa=
"N", transb=
"T", m=dimen_ri, n=dimen_ri, k=dimen_ri, alpha=1.0_dp, &
217 matrix_a=fm_gamma_pq_temp, matrix_b=pq_half, beta=0.0_dp, &
218 matrix_c=fm_gamma_pq)
224 CALL cp_fm_create(fm_gamma_pq_temp, fm_struct_ri, name=
"fm_Gamma_PQ_temp")
225 CALL parallel_gemm(transa=
"T", transb=
"N", m=dimen_ri, n=dimen_ri, k=dimen_ia, alpha=1.0_dp, &
226 matrix_a=fm_y, matrix_b=fm_ia_p, beta=0.0_dp, &
227 matrix_c=fm_gamma_pq_temp)
230 CALL cp_fm_create(fm_gamma, fm_struct_ia, name=
"fm_Gamma")
233 CALL parallel_gemm(transa=
"N", transb=
"T", m=dimen_ia, n=dimen_ri, k=dimen_ri, alpha=1.0_dp, &
234 matrix_a=fm_y, matrix_b=pq_half, beta=0.0_dp, &
238 CALL cp_fm_create(fm_gamma_pq_temp_2, fm_struct_ri, name=
"fm_Gamma_PQ_temp_2")
239 CALL parallel_gemm(transa=
"N", transb=
"T", m=dimen_ri, n=dimen_ri, k=dimen_ri, alpha=1.0_dp, &
240 matrix_a=fm_gamma_pq_temp, matrix_b=operator_half, beta=0.0_dp, &
241 matrix_c=fm_gamma_pq_temp_2)
243 CALL cp_fm_create(fm_gamma_pq_2, fm_struct_ri, name=
"fm_Gamma_PQ_2")
244 CALL parallel_gemm(transa=
"N", transb=
"N", m=dimen_ri, n=dimen_ri, k=dimen_ri, alpha=1.0_dp, &
245 matrix_a=pq_half, matrix_b=fm_gamma_pq_temp_2, beta=0.0_dp, &
246 matrix_c=fm_gamma_pq_temp)
248 CALL cp_fm_geadd(1.0_dp,
"T", fm_gamma_pq_temp, 1.0_dp, fm_gamma_pq_2)
254 CALL parallel_gemm(transa=
"N", transb=
"N", m=dimen_ri, n=dimen_ri, k=dimen_ri, alpha=-1.0_dp, &
255 matrix_a=operator_half, matrix_b=fm_gamma_pq_temp_2, beta=0.0_dp, &
256 matrix_c=fm_gamma_pq)
263 CALL fm2array(gamma_2d, my_ia_start, my_ia_end, &
264 my_group_l_start, my_group_l_end, &
265 group_grid_2_mepos, mepos_2_grid_group, &
266 para_env_sub%num_pe, ngroup, &
269 ALLOCATE (gamma_pq(my_p_size, my_group_l_size))
270 CALL fm2array(gamma_pq, my_p_start, my_p_end, &
271 my_group_l_start, my_group_l_end, &
272 group_grid_2_mepos, mepos_2_grid_group, &
273 para_env_sub%num_pe, ngroup, &
275 IF (.NOT.
ALLOCATED(mp2_env%ri_grad%Gamma_PQ))
THEN
276 CALL move_alloc(gamma_pq, mp2_env%ri_grad%Gamma_PQ)
278 mp2_env%ri_grad%Gamma_PQ(:, :) = mp2_env%ri_grad%Gamma_PQ + gamma_pq
279 DEALLOCATE (gamma_pq)
283 ALLOCATE (gamma_pq(my_p_size, my_group_l_size))
284 CALL fm2array(gamma_pq, my_p_start, my_p_end, &
285 my_group_l_start, my_group_l_end, &
286 group_grid_2_mepos, mepos_2_grid_group, &
287 para_env_sub%num_pe, ngroup, &
289 IF (.NOT.
ALLOCATED(mp2_env%ri_grad%Gamma_PQ_2))
THEN
290 CALL move_alloc(gamma_pq, mp2_env%ri_grad%Gamma_PQ_2)
292 mp2_env%ri_grad%Gamma_PQ_2(:, :) = mp2_env%ri_grad%Gamma_PQ_2 + gamma_pq
293 DEALLOCATE (gamma_pq)
298 IF (.NOT.
ALLOCATED(mp2_env%ri_grad%G_P_ia))
THEN
299 nspins =
SIZE(mp2_env%ri_grad%mo_coeff_o)
300 ALLOCATE (mp2_env%ri_grad%G_P_ia(my_group_l_size, nspins))
302 DO kkb = 1, my_group_l_size
303 NULLIFY (mp2_env%ri_grad%G_P_ia(kkb, ispin)%matrix)
310 my_ia_start, my_ia_end, my_group_l_size, gd_ia, &
311 mp2_env%ri_grad%G_P_ia(:, kspin), mp2_env%ri_grad%mo_coeff_o(1)%matrix)
313 DEALLOCATE (pos_info)
314 DEALLOCATE (group_grid_2_mepos, mepos_2_grid_group)
321 CALL timestop(handle)
493 SUBROUTINE array2fm(mat2D, fm_struct, my_start_row, my_end_row, &
494 my_start_col, my_end_col, &
496 group_grid_2_mepos, ngroup_row, ngroup_col, &
497 fm_mat, integ_group_size, color_group, do_release_mat)
499 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :), &
500 INTENT(INOUT) :: mat2d
502 INTEGER,
INTENT(IN) :: my_start_row, my_end_row, my_start_col, &
505 INTEGER,
ALLOCATABLE,
DIMENSION(:, :),
INTENT(IN) :: group_grid_2_mepos
506 INTEGER,
INTENT(IN) :: ngroup_row, ngroup_col
508 INTEGER,
INTENT(IN),
OPTIONAL :: integ_group_size, color_group
509 LOGICAL,
INTENT(IN),
OPTIONAL :: do_release_mat
511 CHARACTER(LEN=*),
PARAMETER :: routinen =
'array2fm'
513 INTEGER :: dummy_proc, end_col_block, end_row_block, handle, handle2, i_global, i_local, &
514 i_sub, iib, iii, itmp(2), j_global, j_local, j_sub, jjb, my_num_col_blocks, &
515 my_num_row_blocks, mypcol, myprow, ncol_local, npcol, nprow, nrow_local, num_cols, &
516 num_rec_cols, num_rows, number_of_rec, number_of_send, proc_receive, proc_send, &
517 proc_shift, rec_col_end, rec_col_size, rec_col_start, rec_counter, rec_pcol, rec_prow, &
518 rec_row_end, rec_row_size, rec_row_start, ref_send_pcol, ref_send_prow, send_counter, &
519 send_pcol, send_prow, size_rec_buffer, size_send_buffer, start_col_block, start_row_block
520 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iii_vet, index_col_rec, map_rec_size, &
522 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: blocks_ranges_col, blocks_ranges_row, &
523 grid_2_mepos, grid_ref_2_send_pos, &
525 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
526 LOGICAL :: convert_pos, my_do_release_mat
527 REAL(kind=
dp) :: part_col, part_row
529 DIMENSION(:) :: buffer_rec, buffer_send
533 CALL timeset(routinen, handle)
535 my_do_release_mat = .true.
536 IF (
PRESENT(do_release_mat)) my_do_release_mat = do_release_mat
538 CALL cp_fm_struct_get(fm_struct, para_env=para_env, nrow_global=num_rows, ncol_global=num_cols)
547 nrow_local=nrow_local, &
548 ncol_local=ncol_local, &
549 row_indices=row_indices, &
550 col_indices=col_indices)
551 myprow = fm_mat%matrix_struct%context%mepos(1)
552 mypcol = fm_mat%matrix_struct%context%mepos(2)
553 nprow = fm_mat%matrix_struct%context%num_pe(1)
554 npcol = fm_mat%matrix_struct%context%num_pe(2)
559 CALL timeset(routinen//
"_info", handle2)
560 ALLOCATE (grid_2_mepos(0:nprow - 1, 0:npcol - 1))
562 ALLOCATE (mepos_2_grid(2, 0:para_env%num_pe - 1))
563 grid_2_mepos(myprow, mypcol) = para_env%mepos
565 CALL para_env%sum(grid_2_mepos)
566 CALL para_env%allgather([myprow, mypcol], mepos_2_grid)
569 ALLOCATE (map_send_size(0:para_env%num_pe - 1))
572 DO jjb = my_start_col, my_end_col
573 send_pcol = fm_mat%matrix_struct%g2p_col(jjb)
574 DO iib = my_start_row, my_end_row
575 send_prow = fm_mat%matrix_struct%g2p_row(iib)
576 proc_send = grid_2_mepos(send_prow, send_pcol)
577 map_send_size(proc_send) = map_send_size(proc_send) + 1
582 ALLOCATE (map_rec_size(0:para_env%num_pe - 1))
584 part_row = real(num_rows, kind=
dp)/real(ngroup_row, kind=
dp)
585 part_col = real(num_cols, kind=
dp)/real(ngroup_col, kind=
dp)
588 convert_pos = .false.
589 IF (
PRESENT(integ_group_size) .AND.
PRESENT(color_group)) convert_pos = .true.
591 DO jjb = 1, nrow_local
592 j_global = row_indices(jjb)
595 rec_prow = int(real(j_global - 1, kind=
dp)/part_row)
596 rec_prow = max(0, rec_prow)
597 rec_prow = min(rec_prow, ngroup_row - 1)
599 itmp =
get_limit(num_rows, ngroup_row, rec_prow)
600 IF (j_global >= itmp(1) .AND. j_global <= itmp(2))
EXIT
601 IF (j_global < itmp(1)) rec_prow = rec_prow - 1
602 IF (j_global > itmp(2)) rec_prow = rec_prow + 1
605 IF (convert_pos)
THEN
607 IF ((rec_prow/integ_group_size) .NE. color_group) cycle
609 rec_prow = mod(rec_prow, integ_group_size)
612 DO iib = 1, ncol_local
613 i_global = col_indices(iib)
615 rec_pcol = int(real(i_global - 1, kind=
dp)/part_col)
616 rec_pcol = max(0, rec_pcol)
617 rec_pcol = min(rec_pcol, ngroup_col - 1)
619 itmp =
get_limit(num_cols, ngroup_col, rec_pcol)
620 IF (i_global >= itmp(1) .AND. i_global <= itmp(2))
EXIT
621 IF (i_global < itmp(1)) rec_pcol = rec_pcol - 1
622 IF (i_global > itmp(2)) rec_pcol = rec_pcol + 1
625 proc_receive = group_grid_2_mepos(rec_prow, rec_pcol)
627 map_rec_size(proc_receive) = map_rec_size(proc_receive) + 1
633 IF (map_rec_size(para_env%mepos) > 0)
THEN
634 DO jjb = 1, ncol_local
635 j_global = col_indices(jjb)
636 IF (j_global >= my_start_col .AND. j_global <= my_end_col)
THEN
637 DO iib = 1, nrow_local
638 i_global = row_indices(iib)
639 IF (i_global >= my_start_row .AND. i_global <= my_end_row)
THEN
640 fm_mat%local_data(iib, jjb) = mat2d(i_global - my_start_row + 1, j_global - my_start_col + 1)
646 CALL timestop(handle2)
649 CALL timeset(routinen//
"_buffer_send", handle2)
652 DO proc_shift = 1, para_env%num_pe - 1
653 proc_send =
modulo(para_env%mepos + proc_shift, para_env%num_pe)
654 IF (map_send_size(proc_send) > 0)
THEN
655 number_of_send = number_of_send + 1
659 ALLOCATE (buffer_send(number_of_send))
663 ALLOCATE (grid_ref_2_send_pos(0:nprow - 1, 0:npcol - 1))
664 grid_ref_2_send_pos = 0
668 DO proc_shift = 1, para_env%num_pe - 1
669 proc_send =
modulo(para_env%mepos + proc_shift, para_env%num_pe)
670 size_send_buffer = map_send_size(proc_send)
671 IF (map_send_size(proc_send) > 0)
THEN
672 send_counter = send_counter + 1
674 ALLOCATE (buffer_send(send_counter)%msg(size_send_buffer))
675 buffer_send(send_counter)%msg = 0.0_dp
676 buffer_send(send_counter)%proc = proc_send
679 ref_send_prow = mepos_2_grid(1, proc_send)
680 ref_send_pcol = mepos_2_grid(2, proc_send)
682 grid_ref_2_send_pos(ref_send_prow, ref_send_pcol) = send_counter
689 ALLOCATE (iii_vet(number_of_send))
691 DO iib = my_start_row, my_end_row
692 send_prow = fm_mat%matrix_struct%g2p_row(iib)
693 DO jjb = my_start_col, my_end_col
694 send_pcol = fm_mat%matrix_struct%g2p_col(jjb)
696 IF (grid_2_mepos(send_prow, send_pcol) == para_env%mepos) cycle
698 send_counter = grid_ref_2_send_pos(send_prow, send_pcol)
699 iii_vet(send_counter) = iii_vet(send_counter) + 1
700 iii = iii_vet(send_counter)
701 buffer_send(send_counter)%msg(iii) = mat2d(iib - my_start_row + 1, jjb - my_start_col + 1)
706 DEALLOCATE (grid_ref_2_send_pos)
707 IF (my_do_release_mat)
DEALLOCATE (mat2d)
708 CALL timestop(handle2)
713 CALL timeset(routinen//
"_isendrecv", handle2)
716 DO proc_shift = 1, para_env%num_pe - 1
717 proc_receive =
modulo(para_env%mepos - proc_shift, para_env%num_pe)
718 IF (map_rec_size(proc_receive) > 0)
THEN
719 number_of_rec = number_of_rec + 1
723 ALLOCATE (buffer_rec(number_of_rec))
726 DO proc_shift = 1, para_env%num_pe - 1
727 proc_receive =
modulo(para_env%mepos - proc_shift, para_env%num_pe)
728 size_rec_buffer = map_rec_size(proc_receive)
729 IF (map_rec_size(proc_receive) > 0)
THEN
730 rec_counter = rec_counter + 1
732 ALLOCATE (buffer_rec(rec_counter)%msg(size_rec_buffer))
733 buffer_rec(rec_counter)%msg = 0.0_dp
734 buffer_rec(rec_counter)%proc = proc_receive
736 CALL para_env%irecv(buffer_rec(rec_counter)%msg, proc_receive, &
737 buffer_rec(rec_counter)%msg_req)
742 ALLOCATE (req_send(number_of_send))
744 DO proc_shift = 1, para_env%num_pe - 1
745 proc_send =
modulo(para_env%mepos + proc_shift, para_env%num_pe)
746 IF (map_send_size(proc_send) > 0)
THEN
747 send_counter = send_counter + 1
748 CALL para_env%isend(buffer_send(send_counter)%msg, proc_send, &
749 buffer_send(send_counter)%msg_req)
750 req_send(send_counter) = buffer_send(send_counter)%msg_req
753 CALL timestop(handle2)
757 CALL timeset(routinen//
"_fill", handle2)
761 my_num_row_blocks = 1
762 DO iib = 1, nrow_local - 1
763 IF (abs(row_indices(iib + 1) - row_indices(iib)) == 1) cycle
764 my_num_row_blocks = my_num_row_blocks + 1
766 ALLOCATE (blocks_ranges_row(2, my_num_row_blocks))
767 blocks_ranges_row = 0
768 blocks_ranges_row(1, 1) = row_indices(1)
770 DO iib = 1, nrow_local - 1
771 IF (abs(row_indices(iib + 1) - row_indices(iib)) == 1) cycle
773 blocks_ranges_row(2, iii - 1) = row_indices(iib)
774 blocks_ranges_row(1, iii) = row_indices(iib + 1)
776 blocks_ranges_row(2, my_num_row_blocks) = row_indices(max(nrow_local, 1))
778 my_num_col_blocks = 1
779 DO jjb = 1, ncol_local - 1
780 IF (abs(col_indices(jjb + 1) - col_indices(jjb)) == 1) cycle
781 my_num_col_blocks = my_num_col_blocks + 1
783 ALLOCATE (blocks_ranges_col(2, my_num_col_blocks))
784 blocks_ranges_col = 0
785 blocks_ranges_col(1, 1) = col_indices(1)
787 DO jjb = 1, ncol_local - 1
788 IF (abs(col_indices(jjb + 1) - col_indices(jjb)) == 1) cycle
790 blocks_ranges_col(2, iii - 1) = col_indices(jjb)
791 blocks_ranges_col(1, iii) = col_indices(jjb + 1)
793 blocks_ranges_col(2, my_num_col_blocks) = col_indices(max(ncol_local, 1))
796 DO proc_shift = 1, para_env%num_pe - 1
797 proc_receive =
modulo(para_env%mepos - proc_shift, para_env%num_pe)
798 size_rec_buffer = map_rec_size(proc_receive)
800 IF (map_rec_size(proc_receive) > 0)
THEN
801 rec_counter = rec_counter + 1
803 CALL get_group_dist(gd_col, proc_receive, rec_col_start, rec_col_end, rec_col_size)
807 DO jjb = 1, my_num_col_blocks
808 start_col_block = max(blocks_ranges_col(1, jjb), rec_col_start)
809 end_col_block = min(blocks_ranges_col(2, jjb), rec_col_end)
810 DO j_sub = start_col_block, end_col_block
811 num_rec_cols = num_rec_cols + 1
814 ALLOCATE (index_col_rec(num_rec_cols))
817 DO jjb = 1, my_num_col_blocks
818 start_col_block = max(blocks_ranges_col(1, jjb), rec_col_start)
819 end_col_block = min(blocks_ranges_col(2, jjb), rec_col_end)
820 DO j_sub = start_col_block, end_col_block
822 j_local = fm_mat%matrix_struct%g2l_col(j_sub)
823 index_col_rec(iii) = j_local
827 CALL get_group_dist(gd_row, proc_receive, rec_row_start, rec_row_end, rec_row_size)
830 CALL buffer_rec(rec_counter)%msg_req%wait()
834 DO iib = 1, my_num_row_blocks
835 start_row_block = max(blocks_ranges_row(1, iib), rec_row_start)
836 end_row_block = min(blocks_ranges_row(2, iib), rec_row_end)
837 DO i_sub = start_row_block, end_row_block
838 i_local = fm_mat%matrix_struct%g2l_row(i_sub)
839 DO jjb = 1, num_rec_cols
841 j_local = index_col_rec(jjb)
842 fm_mat%local_data(i_local, j_local) = buffer_rec(rec_counter)%msg(iii)
847 DEALLOCATE (buffer_rec(rec_counter)%msg)
848 DEALLOCATE (index_col_rec)
851 DEALLOCATE (buffer_rec)
853 DEALLOCATE (blocks_ranges_row)
854 DEALLOCATE (blocks_ranges_col)
856 CALL timestop(handle2)
859 CALL timeset(routinen//
"_waitall", handle2)
861 DO send_counter = 1, number_of_send
862 DEALLOCATE (buffer_send(send_counter)%msg)
864 DEALLOCATE (buffer_send)
865 CALL timestop(handle2)
867 DEALLOCATE (map_send_size)
868 DEALLOCATE (map_rec_size)
869 DEALLOCATE (grid_2_mepos)
870 DEALLOCATE (mepos_2_grid)
872 CALL timestop(handle)
889 SUBROUTINE fm2array(mat2D, my_start_row, my_end_row, &
890 my_start_col, my_end_col, &
891 group_grid_2_mepos, mepos_2_grid_group, &
892 ngroup_row, ngroup_col, &
895 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :), &
897 INTEGER,
INTENT(IN) :: my_start_row, my_end_row, my_start_col, &
899 INTEGER,
ALLOCATABLE,
DIMENSION(:, :),
INTENT(IN) :: group_grid_2_mepos, mepos_2_grid_group
900 INTEGER,
INTENT(IN) :: ngroup_row, ngroup_col
903 CHARACTER(LEN=*),
PARAMETER :: routinen =
'fm2array'
905 INTEGER :: dummy_proc, handle, handle2, i_global, iib, iii, itmp(2), j_global, jjb, my_cols, &
906 my_rows, mypcol, myprow, ncol_local, npcol, nprow, nrow_local, num_cols, num_rec_rows, &
907 num_rows, number_of_rec, number_of_send, proc_receive, proc_send, proc_shift, &
908 rec_col_size, rec_counter, rec_pcol, rec_prow, rec_row_size, ref_send_pcol, &
909 ref_send_prow, send_counter, send_pcol, send_prow, size_rec_buffer, size_send_buffer
910 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iii_vet, index_row_rec, map_rec_size, &
912 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: grid_2_mepos, grid_ref_2_send_pos, &
914 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
915 REAL(kind=
dp) :: part_col, part_row
917 DIMENSION(:) :: buffer_rec, buffer_send
921 CALL timeset(routinen, handle)
924 my_rows = my_end_row - my_start_row + 1
925 my_cols = my_end_col - my_start_col + 1
928 ALLOCATE (mat2d(my_rows, my_cols))
934 nrow_local=nrow_local, &
935 ncol_local=ncol_local, &
936 row_indices=row_indices, &
937 col_indices=col_indices, &
938 nrow_global=num_rows, &
939 ncol_global=num_cols, &
941 myprow = fm_mat%matrix_struct%context%mepos(1)
942 mypcol = fm_mat%matrix_struct%context%mepos(2)
943 nprow = fm_mat%matrix_struct%context%num_pe(1)
944 npcol = fm_mat%matrix_struct%context%num_pe(2)
949 CALL timeset(routinen//
"_info", handle2)
950 ALLOCATE (grid_2_mepos(0:nprow - 1, 0:npcol - 1))
952 ALLOCATE (mepos_2_grid(2, 0:para_env%num_pe - 1))
955 grid_2_mepos(myprow, mypcol) = para_env%mepos
958 CALL para_env%sum(grid_2_mepos)
959 CALL para_env%allgather([myprow, mypcol], mepos_2_grid)
962 ALLOCATE (map_send_size(0:para_env%num_pe - 1))
964 part_row = real(num_rows, kind=
dp)/real(ngroup_row, kind=
dp)
965 part_col = real(num_cols, kind=
dp)/real(ngroup_col, kind=
dp)
967 DO jjb = 1, ncol_local
968 j_global = col_indices(jjb)
971 send_pcol = int(real(j_global - 1, kind=
dp)/part_col)
972 send_pcol = max(0, send_pcol)
973 send_pcol = min(send_pcol, ngroup_col - 1)
975 itmp =
get_limit(num_cols, ngroup_col, send_pcol)
976 IF (j_global >= itmp(1) .AND. j_global <= itmp(2))
EXIT
977 IF (j_global < itmp(1)) send_pcol = send_pcol - 1
978 IF (j_global > itmp(2)) send_pcol = send_pcol + 1
981 DO iib = 1, nrow_local
982 i_global = row_indices(iib)
984 send_prow = int(real(i_global - 1, kind=
dp)/part_row)
985 send_prow = max(0, send_prow)
986 send_prow = min(send_prow, ngroup_row - 1)
988 itmp =
get_limit(num_rows, ngroup_row, send_prow)
989 IF (i_global >= itmp(1) .AND. i_global <= itmp(2))
EXIT
990 IF (i_global < itmp(1)) send_prow = send_prow - 1
991 IF (i_global > itmp(2)) send_prow = send_prow + 1
994 proc_send = group_grid_2_mepos(send_prow, send_pcol)
996 map_send_size(proc_send) = map_send_size(proc_send) + 1
1002 ALLOCATE (map_rec_size(0:para_env%num_pe - 1))
1005 DO jjb = my_start_col, my_end_col
1006 rec_pcol = fm_mat%matrix_struct%g2p_col(jjb)
1007 DO iib = my_start_row, my_end_row
1008 rec_prow = fm_mat%matrix_struct%g2p_row(iib)
1009 proc_receive = grid_2_mepos(rec_prow, rec_pcol)
1010 map_rec_size(proc_receive) = map_rec_size(proc_receive) + 1
1015 IF (map_rec_size(para_env%mepos) > 0)
THEN
1016 DO jjb = 1, ncol_local
1017 j_global = col_indices(jjb)
1018 IF (j_global >= my_start_col .AND. j_global <= my_end_col)
THEN
1019 DO iib = 1, nrow_local
1020 i_global = row_indices(iib)
1021 IF (i_global >= my_start_row .AND. i_global <= my_end_row)
THEN
1022 mat2d(i_global - my_start_row + 1, j_global - my_start_col + 1) = fm_mat%local_data(iib, jjb)
1028 CALL timestop(handle2)
1031 CALL timeset(routinen//
"_buffer_send", handle2)
1034 DO proc_shift = 1, para_env%num_pe - 1
1035 proc_send =
modulo(para_env%mepos + proc_shift, para_env%num_pe)
1036 IF (map_send_size(proc_send) > 0)
THEN
1037 number_of_send = number_of_send + 1
1041 ALLOCATE (buffer_send(number_of_send))
1046 ALLOCATE (grid_ref_2_send_pos(0:ngroup_row - 1, 0:ngroup_col - 1))
1047 grid_ref_2_send_pos = 0
1052 DO proc_shift = 1, para_env%num_pe - 1
1053 proc_send =
modulo(para_env%mepos + proc_shift, para_env%num_pe)
1054 size_send_buffer = map_send_size(proc_send)
1055 IF (map_send_size(proc_send) > 0)
THEN
1056 send_counter = send_counter + 1
1058 ALLOCATE (buffer_send(send_counter)%msg(size_send_buffer))
1059 buffer_send(send_counter)%msg = 0.0_dp
1060 buffer_send(send_counter)%proc = proc_send
1063 ref_send_prow = mepos_2_grid_group(1, proc_send)
1064 ref_send_pcol = mepos_2_grid_group(2, proc_send)
1066 grid_ref_2_send_pos(ref_send_prow, ref_send_pcol) = send_counter
1073 ALLOCATE (iii_vet(number_of_send))
1075 DO jjb = 1, ncol_local
1076 j_global = col_indices(jjb)
1079 send_pcol = int(real(j_global - 1, kind=
dp)/part_col)
1080 send_pcol = max(0, send_pcol)
1081 send_pcol = min(send_pcol, ngroup_col - 1)
1083 itmp =
get_limit(num_cols, ngroup_col, send_pcol)
1084 IF (j_global >= itmp(1) .AND. j_global <= itmp(2))
EXIT
1085 IF (j_global < itmp(1)) send_pcol = send_pcol - 1
1086 IF (j_global > itmp(2)) send_pcol = send_pcol + 1
1089 DO iib = 1, nrow_local
1090 i_global = row_indices(iib)
1092 send_prow = int(real(i_global - 1, kind=
dp)/part_row)
1093 send_prow = max(0, send_prow)
1094 send_prow = min(send_prow, ngroup_row - 1)
1096 itmp =
get_limit(num_rows, ngroup_row, send_prow)
1097 IF (i_global >= itmp(1) .AND. i_global <= itmp(2))
EXIT
1098 IF (i_global < itmp(1)) send_prow = send_prow - 1
1099 IF (i_global > itmp(2)) send_prow = send_prow + 1
1102 IF (group_grid_2_mepos(send_prow, send_pcol) == para_env%mepos) cycle
1104 send_counter = grid_ref_2_send_pos(send_prow, send_pcol)
1105 iii_vet(send_counter) = iii_vet(send_counter) + 1
1106 iii = iii_vet(send_counter)
1107 buffer_send(send_counter)%msg(iii) = fm_mat%local_data(iib, jjb)
1111 DEALLOCATE (iii_vet)
1112 DEALLOCATE (grid_ref_2_send_pos)
1113 CALL timestop(handle2)
1118 CALL timeset(routinen//
"_isendrecv", handle2)
1121 DO proc_shift = 1, para_env%num_pe - 1
1122 proc_receive =
modulo(para_env%mepos - proc_shift, para_env%num_pe)
1123 IF (map_rec_size(proc_receive) > 0)
THEN
1124 number_of_rec = number_of_rec + 1
1128 ALLOCATE (buffer_rec(number_of_rec))
1131 DO proc_shift = 1, para_env%num_pe - 1
1132 proc_receive =
modulo(para_env%mepos - proc_shift, para_env%num_pe)
1133 size_rec_buffer = map_rec_size(proc_receive)
1134 IF (map_rec_size(proc_receive) > 0)
THEN
1135 rec_counter = rec_counter + 1
1137 ALLOCATE (buffer_rec(rec_counter)%msg(size_rec_buffer))
1138 buffer_rec(rec_counter)%msg = 0.0_dp
1139 buffer_rec(rec_counter)%proc = proc_receive
1141 CALL para_env%irecv(buffer_rec(rec_counter)%msg, proc_receive, &
1142 buffer_rec(rec_counter)%msg_req)
1147 ALLOCATE (req_send(number_of_send))
1149 DO proc_shift = 1, para_env%num_pe - 1
1150 proc_send =
modulo(para_env%mepos + proc_shift, para_env%num_pe)
1151 IF (map_send_size(proc_send) > 0)
THEN
1152 send_counter = send_counter + 1
1153 CALL para_env%isend(buffer_send(send_counter)%msg, proc_send, &
1154 buffer_send(send_counter)%msg_req)
1155 req_send(send_counter) = buffer_send(send_counter)%msg_req
1158 CALL timestop(handle2)
1162 CALL timeset(routinen//
"_fill", handle2)
1164 nrow_local=nrow_local, &
1165 ncol_local=ncol_local)
1166 ALLOCATE (sizes(2, 0:para_env%num_pe - 1))
1167 CALL para_env%allgather([nrow_local, ncol_local], sizes)
1168 iib = maxval(sizes(1, :))
1169 ALLOCATE (index_row_rec(iib))
1172 DO proc_shift = 1, para_env%num_pe - 1
1173 proc_receive =
modulo(para_env%mepos - proc_shift, para_env%num_pe)
1174 size_rec_buffer = map_rec_size(proc_receive)
1176 IF (map_rec_size(proc_receive) > 0)
THEN
1177 rec_counter = rec_counter + 1
1179 rec_col_size = sizes(2, proc_receive)
1180 rec_row_size = sizes(1, proc_receive)
1184 DO iib = 1, rec_row_size
1185 i_global = fm_mat%matrix_struct%l2g_row(iib, mepos_2_grid(1, proc_receive))
1186 IF (i_global >= my_start_row .AND. i_global <= my_end_row)
THEN
1187 num_rec_rows = num_rec_rows + 1
1188 index_row_rec(num_rec_rows) = i_global
1192 CALL buffer_rec(rec_counter)%msg_req%wait()
1195 DO jjb = 1, rec_col_size
1196 j_global = fm_mat%matrix_struct%l2g_col(jjb, mepos_2_grid(2, proc_receive))
1197 IF (j_global >= my_start_col .AND. j_global <= my_end_col)
THEN
1198 DO iib = 1, num_rec_rows
1199 i_global = index_row_rec(iib)
1201 mat2d(i_global - my_start_row + 1, j_global - my_start_col + 1) = buffer_rec(rec_counter)%msg(iii)
1206 DEALLOCATE (buffer_rec(rec_counter)%msg)
1209 DEALLOCATE (buffer_rec)
1210 DEALLOCATE (index_row_rec)
1212 CALL timestop(handle2)
1215 CALL timeset(routinen//
"_waitall", handle2)
1217 DO send_counter = 1, number_of_send
1218 DEALLOCATE (buffer_send(send_counter)%msg)
1220 DEALLOCATE (buffer_send)
1221 CALL timestop(handle2)
1223 CALL timestop(handle)
1242 my_ia_start, my_ia_end, my_group_L_size, &
1243 gd_ia, dbcsr_Gamma, mo_coeff_o)
1244 REAL(kind=
dp),
ALLOCATABLE,
DIMENSION(:, :) :: gamma_2d
1245 INTEGER,
INTENT(IN) :: homo, virtual, dimen_ia
1247 INTEGER,
INTENT(IN) :: my_ia_start, my_ia_end, my_group_l_size
1249 TYPE(
dbcsr_p_type),
DIMENSION(:),
INTENT(INOUT) :: dbcsr_gamma
1250 TYPE(
dbcsr_type),
INTENT(INOUT) :: mo_coeff_o
1252 CHARACTER(LEN=*),
PARAMETER :: routinen =
'create_dbcsr_gamma'
1254 INTEGER :: dummy_proc, handle, i_global, i_local, iaia, iib, iii, itmp(2), j_global, &
1255 j_local, jjb, jjj, kkb, mypcol, myprow, ncol_local, npcol, nprow, nrow_local, &
1256 number_of_rec, number_of_send, proc_receive, proc_send, proc_shift, rec_counter, &
1257 rec_iaia_end, rec_iaia_size, rec_iaia_start, rec_pcol, rec_prow, ref_send_pcol, &
1258 ref_send_prow, send_counter, send_pcol, send_prow, size_rec_buffer, size_send_buffer
1259 INTEGER,
ALLOCATABLE,
DIMENSION(:) :: iii_vet, map_rec_size, map_send_size
1260 INTEGER,
ALLOCATABLE,
DIMENSION(:, :) :: grid_2_mepos, grid_ref_2_send_pos, &
1261 indeces_map_my, mepos_2_grid
1262 INTEGER,
DIMENSION(:),
POINTER :: col_indices, row_indices
1263 REAL(kind=
dp) :: part_ia
1267 TYPE(index_map),
ALLOCATABLE,
DIMENSION(:) :: indeces_rec
1269 DIMENSION(:) :: buffer_rec, buffer_send
1272 CALL timeset(routinen, handle)
1281 ncol_global=virtual, para_env=para_env_sub)
1290 nrow_local=nrow_local, &
1291 ncol_local=ncol_local, &
1292 row_indices=row_indices, &
1293 col_indices=col_indices)
1294 myprow = fm_ia%matrix_struct%context%mepos(1)
1295 mypcol = fm_ia%matrix_struct%context%mepos(2)
1296 nprow = fm_ia%matrix_struct%context%num_pe(1)
1297 npcol = fm_ia%matrix_struct%context%num_pe(2)
1300 ALLOCATE (grid_2_mepos(0:nprow - 1, 0:npcol - 1))
1302 ALLOCATE (mepos_2_grid(2, 0:para_env_sub%num_pe - 1))
1304 grid_2_mepos(myprow, mypcol) = para_env_sub%mepos
1306 CALL para_env_sub%sum(grid_2_mepos)
1307 CALL para_env_sub%allgather([myprow, mypcol], mepos_2_grid)
1310 ALLOCATE (map_send_size(0:para_env_sub%num_pe - 1))
1313 DO iaia = my_ia_start, my_ia_end
1314 i_global = (iaia - 1)/virtual + 1
1315 j_global = mod(iaia - 1, virtual) + 1
1316 send_prow = fm_ia%matrix_struct%g2p_row(i_global)
1317 send_pcol = fm_ia%matrix_struct%g2p_col(j_global)
1318 proc_send = grid_2_mepos(send_prow, send_pcol)
1319 map_send_size(proc_send) = map_send_size(proc_send) + 1
1323 ALLOCATE (map_rec_size(0:para_env_sub%num_pe - 1))
1325 part_ia = real(dimen_ia, kind=
dp)/real(para_env_sub%num_pe, kind=
dp)
1327 DO iib = 1, nrow_local
1328 i_global = row_indices(iib)
1329 DO jjb = 1, ncol_local
1330 j_global = col_indices(jjb)
1331 iaia = (i_global - 1)*virtual + j_global
1332 proc_receive = int(real(iaia - 1, kind=
dp)/part_ia)
1333 proc_receive = max(0, proc_receive)
1334 proc_receive = min(proc_receive, para_env_sub%num_pe - 1)
1336 itmp =
get_limit(dimen_ia, para_env_sub%num_pe, proc_receive)
1337 IF (iaia >= itmp(1) .AND. iaia <= itmp(2))
EXIT
1338 IF (iaia < itmp(1)) proc_receive = proc_receive - 1
1339 IF (iaia > itmp(2)) proc_receive = proc_receive + 1
1341 map_rec_size(proc_receive) = map_rec_size(proc_receive) + 1
1347 DO proc_shift = 1, para_env_sub%num_pe - 1
1348 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
1349 IF (map_send_size(proc_send) > 0)
THEN
1350 number_of_send = number_of_send + 1
1354 ALLOCATE (buffer_send(number_of_send))
1356 ALLOCATE (grid_ref_2_send_pos(0:nprow - 1, 0:npcol - 1))
1357 grid_ref_2_send_pos = 0
1360 DO proc_shift = 1, para_env_sub%num_pe - 1
1361 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
1362 size_send_buffer = map_send_size(proc_send)
1363 IF (map_send_size(proc_send) > 0)
THEN
1364 send_counter = send_counter + 1
1366 ALLOCATE (buffer_send(send_counter)%msg(size_send_buffer))
1367 buffer_send(send_counter)%proc = proc_send
1370 ref_send_prow = mepos_2_grid(1, proc_send)
1371 ref_send_pcol = mepos_2_grid(2, proc_send)
1373 grid_ref_2_send_pos(ref_send_prow, ref_send_pcol) = send_counter
1379 DO proc_shift = 1, para_env_sub%num_pe - 1
1380 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
1381 IF (map_rec_size(proc_receive) > 0)
THEN
1382 number_of_rec = number_of_rec + 1
1387 ALLOCATE (buffer_rec(number_of_rec))
1388 ALLOCATE (indeces_rec(number_of_rec))
1391 DO proc_shift = 1, para_env_sub%num_pe - 1
1392 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
1393 size_rec_buffer = map_rec_size(proc_receive)
1394 IF (map_rec_size(proc_receive) > 0)
THEN
1395 rec_counter = rec_counter + 1
1397 ALLOCATE (buffer_rec(rec_counter)%msg(size_rec_buffer))
1398 buffer_rec(rec_counter)%proc = proc_receive
1400 ALLOCATE (indeces_rec(rec_counter)%map(2, size_rec_buffer))
1401 indeces_rec(rec_counter)%map = 0
1402 CALL get_group_dist(gd_ia, proc_receive, rec_iaia_start, rec_iaia_end, rec_iaia_size)
1404 DO iaia = rec_iaia_start, rec_iaia_end
1405 i_global = (iaia - 1)/virtual + 1
1406 j_global = mod(iaia - 1, virtual) + 1
1407 rec_prow = fm_ia%matrix_struct%g2p_row(i_global)
1408 rec_pcol = fm_ia%matrix_struct%g2p_col(j_global)
1409 IF (grid_2_mepos(rec_prow, rec_pcol) /= para_env_sub%mepos) cycle
1411 i_local = fm_ia%matrix_struct%g2l_row(i_global)
1412 j_local = fm_ia%matrix_struct%g2l_col(j_global)
1413 indeces_rec(rec_counter)%map(1, iii) = i_local
1414 indeces_rec(rec_counter)%map(2, iii) = j_local
1419 IF (map_rec_size(para_env_sub%mepos) > 0)
THEN
1420 size_rec_buffer = map_rec_size(para_env_sub%mepos)
1421 ALLOCATE (indeces_map_my(2, size_rec_buffer))
1424 DO iaia = my_ia_start, my_ia_end
1425 i_global = (iaia - 1)/virtual + 1
1426 j_global = mod(iaia - 1, virtual) + 1
1427 rec_prow = fm_ia%matrix_struct%g2p_row(i_global)
1428 rec_pcol = fm_ia%matrix_struct%g2p_col(j_global)
1429 IF (grid_2_mepos(rec_prow, rec_pcol) /= para_env_sub%mepos) cycle
1431 i_local = fm_ia%matrix_struct%g2l_row(i_global)
1432 j_local = fm_ia%matrix_struct%g2l_col(j_global)
1433 indeces_map_my(1, iii) = i_local
1434 indeces_map_my(2, iii) = j_local
1439 ALLOCATE (iii_vet(number_of_send))
1441 ALLOCATE (req_send(number_of_send))
1444 DO kkb = 1, my_group_l_size
1448 DO proc_shift = 1, para_env_sub%num_pe - 1
1449 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
1450 IF (map_rec_size(proc_receive) > 0)
THEN
1451 rec_counter = rec_counter + 1
1452 buffer_rec(rec_counter)%msg = 0.0_dp
1453 CALL para_env_sub%irecv(buffer_rec(rec_counter)%msg, proc_receive, &
1454 buffer_rec(rec_counter)%msg_req)
1458 DO send_counter = 1, number_of_send
1459 buffer_send(send_counter)%msg = 0.0_dp
1463 DO iaia = my_ia_start, my_ia_end
1464 i_global = (iaia - 1)/virtual + 1
1465 j_global = mod(iaia - 1, virtual) + 1
1466 send_prow = fm_ia%matrix_struct%g2p_row(i_global)
1467 send_pcol = fm_ia%matrix_struct%g2p_col(j_global)
1468 proc_send = grid_2_mepos(send_prow, send_pcol)
1470 IF (grid_2_mepos(send_prow, send_pcol) == para_env_sub%mepos)
THEN
1473 i_local = indeces_map_my(1, jjj)
1474 j_local = indeces_map_my(2, jjj)
1475 fm_ia%local_data(i_local, j_local) = gamma_2d(iaia - my_ia_start + 1, kkb)
1477 send_counter = grid_ref_2_send_pos(send_prow, send_pcol)
1478 iii_vet(send_counter) = iii_vet(send_counter) + 1
1479 iii = iii_vet(send_counter)
1480 buffer_send(send_counter)%msg(iii) = gamma_2d(iaia - my_ia_start + 1, kkb)
1485 DO proc_shift = 1, para_env_sub%num_pe - 1
1486 proc_send =
modulo(para_env_sub%mepos + proc_shift, para_env_sub%num_pe)
1487 IF (map_send_size(proc_send) > 0)
THEN
1488 send_counter = send_counter + 1
1489 CALL para_env_sub%isend(buffer_send(send_counter)%msg, proc_send, &
1490 buffer_send(send_counter)%msg_req)
1491 req_send(send_counter) = buffer_send(send_counter)%msg_req
1497 DO proc_shift = 1, para_env_sub%num_pe - 1
1498 proc_receive =
modulo(para_env_sub%mepos - proc_shift, para_env_sub%num_pe)
1499 size_rec_buffer = map_rec_size(proc_receive)
1500 IF (map_rec_size(proc_receive) > 0)
THEN
1501 rec_counter = rec_counter + 1
1503 CALL buffer_rec(rec_counter)%msg_req%wait()
1504 DO iii = 1, size_rec_buffer
1505 i_local = indeces_rec(rec_counter)%map(1, iii)
1506 j_local = indeces_rec(rec_counter)%map(2, iii)
1507 fm_ia%local_data(i_local, j_local) = buffer_rec(rec_counter)%msg(iii)
1516 ALLOCATE (dbcsr_gamma(kkb)%matrix)
1518 template=mo_coeff_o, &
1519 m=homo, n=virtual, sym=dbcsr_type_no_symmetry)
1520 CALL copy_fm_to_dbcsr(fm_ia, dbcsr_gamma(kkb)%matrix, keep_sparsity=.false.)
1525 DEALLOCATE (gamma_2d)
1526 DEALLOCATE (iii_vet)
1527 DEALLOCATE (req_send)
1528 IF (map_rec_size(para_env_sub%mepos) > 0)
THEN
1529 DEALLOCATE (indeces_map_my)
1531 DO rec_counter = 1, number_of_rec
1532 DEALLOCATE (indeces_rec(rec_counter)%map)
1533 DEALLOCATE (buffer_rec(rec_counter)%msg)
1535 DEALLOCATE (indeces_rec)
1536 DEALLOCATE (buffer_rec)
1537 DO send_counter = 1, number_of_send
1538 DEALLOCATE (buffer_send(send_counter)%msg)
1540 DEALLOCATE (buffer_send)
1541 DEALLOCATE (map_send_size)
1542 DEALLOCATE (map_rec_size)
1543 DEALLOCATE (grid_2_mepos)
1544 DEALLOCATE (mepos_2_grid)
1549 CALL timestop(handle)