polgroup11_to_mm2pg Subroutine

private subroutine polgroup11_to_mm2pg(polgroup_neigh, mm2pol)

Uses

  • proc~~polgroup11_to_mm2pg~~UsesGraph proc~polgroup11_to_mm2pg polgroup11_to_mm2pg module~mod_memory mod_memory proc~polgroup11_to_mm2pg->module~mod_memory module~mod_io mod_io module~mod_memory->module~mod_io module~mod_constants mod_constants module~mod_memory->module~mod_constants iso_c_binding iso_c_binding module~mod_memory->iso_c_binding module~mod_io->module~mod_constants module~mod_constants->iso_c_binding

Take as input a matrix in which the n-th row stores the atoms that are in the same polarization group as the n-th atom (rows are padded with zeros) and assign to each atom a group index, according to the input information. This is a way of compressing and making more clear the handling of polarization groups.

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: polgroup_neigh(:,:)
integer(kind=ip), intent(out) :: mm2pol(:)

Calls

proc~~polgroup11_to_mm2pg~~CallsGraph proc~polgroup11_to_mm2pg polgroup11_to_mm2pg proc~fatal_error fatal_error proc~polgroup11_to_mm2pg->proc~fatal_error proc~ommp_message ommp_message proc~fatal_error->proc~ommp_message proc~close_output close_output proc~fatal_error->proc~close_output proc~close_output->proc~ommp_message

Called by

proc~~polgroup11_to_mm2pg~~CalledByGraph proc~polgroup11_to_mm2pg polgroup11_to_mm2pg proc~mmpol_init_from_mmp mmpol_init_from_mmp proc~mmpol_init_from_mmp->proc~polgroup11_to_mm2pg proc~ommp_init_mmp ommp_init_mmp proc~ommp_init_mmp->proc~mmpol_init_from_mmp proc~c_ommp_init_mmp C_ommp_init_mmp proc~c_ommp_init_mmp->proc~ommp_init_mmp

Contents

Source Code


Source Code

    subroutine polgroup11_to_mm2pg(polgroup_neigh, mm2pol)
        !! Take as input a matrix in which the n-th row stores the atoms
        !! that are in the same polarization group as the n-th atom (rows are 
        !! padded with zeros) and assign to each atom a group index, according to
        !! the input information. This is a way of compressing and making more 
        !! clear the handling of polarization groups.

        use mod_memory, only : ip
        
        implicit none

        integer(ip), intent(in) :: polgroup_neigh(:,:)
        integer(ip), intent(out) :: mm2pol(:)

        integer(ip) :: i, j, maxn, ipg, mm_atoms

        mm2pol = 0
        ipg = 1
        maxn = size(polgroup_neigh, 1)
        mm_atoms = size(polgroup_neigh, 2)

        do i=1, mm_atoms
            if(mm2pol(i) == 0) then
                ! This is a new group
                do j=1, maxn
                    if(polgroup_neigh(j,i) == 0) exit
                    if(mm2pol(polgroup_neigh(j,i)) /= 0) then
                        call fatal_error("Unexpected error in polgroup11_to_mm2pg")
                    end if
                    mm2pol(polgroup_neigh(j,i)) = ipg
                end do

                ipg = ipg + 1
            end if
        end do

        if( any(mm2pol == 0) ) then
            call fatal_error("Unexpected error in polgroup11_to_mm2pg")
        end if

    end subroutine polgroup11_to_mm2pg