! ! License-Identifier: GPL ! ! Copyright (C) 2006 The Yambo Team ! ! Authors (see AUTHORS file for details): AM ! ! headers ! #include<y_memory.h> ! subroutine MATRIX_transfer( M_in, M_bse, M, M_out, INDEX_in, INDEX_out, SND, RCV, COMM, COMM_name) ! ! General, multi-purpose M <-> M transfer ! use parallel_m, ONLY:yMPI_comm,PAR_COM_WORLD,COMM_copy,COMM_reset,l_par_X_G,l_par_X_G_finite_q use interfaces, ONLY:MATRIX_duplicate use pars, ONLY:SP use BS, ONLY:BS_block use X_m, ONLY:X_FILL_UP_matrix_only use D_lattice, ONLY:i_space_inv use matrix, ONLY:PAR_matrix,I_do_SND,I_do_RCV,TRANSFER_world,PAR_to_PAR_comm_NAME use timing_m, ONLY:timing use y_memory_alloc ! implicit none ! type(PAR_matrix), optional :: M_in type(PAR_matrix), optional :: M_out type(BS_block), optional :: M_bse(:) integer, optional :: INDEX_in integer, optional :: INDEX_out complex(SP), optional :: M(:,:) logical, optional :: SND logical, optional :: RCV type(yMPI_comm), optional :: COMM character(*), optional :: COMM_name ! ! Work Space ! integer :: Nr,Nc character(3) :: M_in_kind, M_out_kind logical :: l_MAT_ARRAY type(PAR_matrix) :: M_Xdn ! ! KIND of the I/O matrices ! l_MAT_ARRAY=.FALSE. if (present(M)) then l_MAT_ARRAY=.TRUE. Nr=size(M,1) Nc=size(M,2) endif ! M_in_kind = "NAN" if (present(M_in) ) M_in_kind = M_in%kind if (present(M_bse)) M_in_kind = "BSE" if (l_MAT_ARRAY.and.present(M_out)) M_in_kind = "SER" ! M_out_kind = "NAN" if (present(M_out)) M_out_kind = M_out%kind if (l_MAT_ARRAY.and.present(M_in)) M_out_kind = "SER" ! if (M_in_kind=="NAN".or.M_out_kind=="NAN") return ! ! INDEXes ! if (present(M_in) .and.present(INDEX_in) ) M_in%I =INDEX_in if (present(M_out).and.present(INDEX_out)) M_out%I=INDEX_out ! ! Local SND/RCV ! I_do_SND=.TRUE. if (present(SND)) I_do_SND=SND ! I_do_RCV=.TRUE. if (present(RCV)) I_do_RCV=RCV ! ! PAR 2 PAR COMM ! if (present(COMM_name)) then if (l_par_X_G_finite_q) PAR_to_PAR_comm_NAME="X_G_finite_q_"//trim(COMM_name) if (l_par_X_G) PAR_to_PAR_comm_NAME="X_G_"//trim(COMM_name) else PAR_to_PAR_comm_NAME="NONE" endif ! call timing('MATRIX transfer ('//trim(PAR_to_PAR_comm_NAME)//')',OPR='start') ! ! Transfer World ! if (present(COMM)) then call COMM_copy(COMM,TRANSFER_world) else call COMM_copy(PAR_COM_WORLD,TRANSFER_world) endif ! ! Actual Interface ! ========= ! if (M_in_kind=="BSE") then ! if (M_out_kind=="SLK") call MATRIX_BSE_to_PAR(M_bse,M_out) ! else if (l_MAT_array) then ! if (present(M_in)) then call MATRIX_PAR_to_from_PAR(M_in%blc(M_in%rows(1):M_in%rows(2),M_in%cols(1):M_in%cols(2),M_in%I) ,& & M_in%rows, M_in%cols,& & M , (/1,Nr/), (/1,Nc/)) else if (present(M_out)) then call MATRIX_PAR_to_from_PAR(M , (/1,Nr/), (/1,Nc/),& & M_out%blc(M_out%rows(1):M_out%rows(2),M_out%cols(1):M_out%cols(2),M_out%I),& & M_out%rows,M_out%cols) endif ! else ! call MATRIX_PAR_to_from_PAR(M_in%blc(M_in%rows(1):M_in%rows(2),M_in%cols(1):M_in%cols(2),M_in%I) ,& & M_in%rows, M_in%cols,& & M_out%blc(M_out%rows(1):M_out%rows(2),M_out%cols(1):M_out%cols(2),M_out%I),& & M_out%rows,M_out%cols) ! endif ! call COMM_reset(TRANSFER_world) ! call timing('MATRIX transfer ('//trim(PAR_to_PAR_comm_NAME)//')',OPR='stop') ! end subroutine