sort_ivec Subroutine

public subroutine sort_ivec(iv, ov)

Uses

  • proc~~sort_ivec~~UsesGraph proc~sort_ivec sort_ivec module~mod_memory mod_memory proc~sort_ivec->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

This is a simple -- and unefficient -- routine to sort a vector of integers. It is just used during some output to simplify comparisons with older version of the code.

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in), dimension(:) :: iv

Input vector

integer(kind=ip), intent(out), allocatable :: ov(:)

Output, sorted vector


Calls

proc~~sort_ivec~~CallsGraph proc~sort_ivec sort_ivec interface~mfree mfree proc~sort_ivec->interface~mfree interface~mallocate mallocate proc~sort_ivec->interface~mallocate proc~r_free1 r_free1 interface~mfree->proc~r_free1 proc~i_free2 i_free2 interface~mfree->proc~i_free2 proc~i_free1 i_free1 interface~mfree->proc~i_free1 proc~r_free2 r_free2 interface~mfree->proc~r_free2 proc~r_free3 r_free3 interface~mfree->proc~r_free3 proc~i_free3 i_free3 interface~mfree->proc~i_free3 proc~l_free1 l_free1 interface~mfree->proc~l_free1 proc~l_free2 l_free2 interface~mfree->proc~l_free2 proc~r_alloc3 r_alloc3 interface~mallocate->proc~r_alloc3 proc~i_alloc1 i_alloc1 interface~mallocate->proc~i_alloc1 proc~l_alloc2 l_alloc2 interface~mallocate->proc~l_alloc2 proc~i_alloc3 i_alloc3 interface~mallocate->proc~i_alloc3 proc~r_alloc2 r_alloc2 interface~mallocate->proc~r_alloc2 proc~r_alloc1 r_alloc1 interface~mallocate->proc~r_alloc1 proc~i_alloc2 i_alloc2 interface~mallocate->proc~i_alloc2 proc~l_alloc1 l_alloc1 interface~mallocate->proc~l_alloc1 proc~memory_init memory_init proc~r_alloc3->proc~memory_init proc~chk_alloc chk_alloc proc~r_alloc3->proc~chk_alloc proc~i_alloc1->proc~memory_init proc~i_alloc1->proc~chk_alloc proc~l_alloc2->proc~memory_init proc~l_alloc2->proc~chk_alloc proc~i_alloc3->proc~memory_init proc~i_alloc3->proc~chk_alloc proc~r_alloc2->proc~memory_init proc~r_alloc2->proc~chk_alloc proc~chk_free chk_free proc~r_free1->proc~chk_free proc~i_free2->proc~chk_free proc~i_free1->proc~chk_free proc~r_free2->proc~chk_free proc~r_free3->proc~chk_free proc~i_free3->proc~chk_free proc~l_free1->proc~chk_free proc~l_free2->proc~chk_free proc~r_alloc1->proc~memory_init proc~r_alloc1->proc~chk_alloc proc~i_alloc2->proc~memory_init proc~i_alloc2->proc~chk_alloc proc~l_alloc1->proc~memory_init proc~l_alloc1->proc~chk_alloc proc~fatal_error fatal_error proc~chk_alloc->proc~fatal_error proc~chk_free->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~~sort_ivec~~CalledByGraph proc~sort_ivec sort_ivec proc~sort_ivec_inplace sort_ivec_inplace proc~sort_ivec_inplace->proc~sort_ivec proc~mmpol_ommp_print_summary mmpol_ommp_print_summary proc~mmpol_ommp_print_summary->proc~sort_ivec proc~adj_mat_from_conn adj_mat_from_conn proc~adj_mat_from_conn->proc~sort_ivec_inplace proc~c_ommp_print_summary_to_file C_ommp_print_summary_to_file proc~c_ommp_print_summary_to_file->proc~mmpol_ommp_print_summary proc~mmpol_init_from_mmp mmpol_init_from_mmp proc~mmpol_init_from_mmp->proc~adj_mat_from_conn proc~mmpol_init_from_xyz mmpol_init_from_xyz proc~mmpol_init_from_xyz->proc~adj_mat_from_conn proc~guess_connectivity guess_connectivity proc~guess_connectivity->proc~adj_mat_from_conn proc~ommp_init_mmp ommp_init_mmp proc~ommp_init_mmp->proc~mmpol_init_from_mmp proc~qm_helper_update_coord qm_helper_update_coord proc~qm_helper_update_coord->proc~guess_connectivity proc~qm_helper_init qm_helper_init proc~qm_helper_init->proc~guess_connectivity proc~ommp_init_xyz ommp_init_xyz proc~ommp_init_xyz->proc~mmpol_init_from_xyz proc~c_ommp_init_mmp C_ommp_init_mmp proc~c_ommp_init_mmp->proc~ommp_init_mmp proc~ommp_update_link_atoms_position ommp_update_link_atoms_position proc~ommp_update_link_atoms_position->proc~qm_helper_update_coord proc~ommp_qm_helper_update_coord ommp_qm_helper_update_coord proc~ommp_qm_helper_update_coord->proc~qm_helper_update_coord proc~ommp_init_qm_helper ommp_init_qm_helper proc~ommp_init_qm_helper->proc~qm_helper_init proc~ommp_create_link_atom ommp_create_link_atom proc~ommp_create_link_atom->proc~qm_helper_update_coord proc~c_ommp_init_xyz C_ommp_init_xyz proc~c_ommp_init_xyz->proc~ommp_init_xyz proc~c_ommp_update_link_atoms_position C_ommp_update_link_atoms_position proc~c_ommp_update_link_atoms_position->proc~ommp_update_link_atoms_position proc~c_ommp_init_qm_helper C_ommp_init_qm_helper proc~c_ommp_init_qm_helper->proc~ommp_init_qm_helper proc~c_ommp_qm_helper_update_coord C_ommp_qm_helper_update_coord proc~c_ommp_qm_helper_update_coord->proc~ommp_qm_helper_update_coord proc~c_ommp_create_link_atom C_ommp_create_link_atom proc~c_ommp_create_link_atom->proc~ommp_create_link_atom

Contents

Source Code


Source Code

    subroutine sort_ivec(iv, ov)
        !! This is a simple -- and unefficient -- routine to sort a vector of 
        !! integers.
        !! It is just used during some output to simplify comparisons with older 
        !! version of the code.   
        !! @warning This function should not be used in efficiency-critical
        !! part of the code!
        use mod_memory, only: mallocate, mfree

        implicit none

        integer(ip), dimension(:), intent(in) :: iv
        !! Input vector
        integer(ip), allocatable, intent(out) :: ov(:)
        !! Output, sorted vector
        
        integer(ip) :: i, imin(1)
        logical, allocatable :: mask(:)

        if(allocated(ov)) call mfree('sort_ivec', ov)
        call mallocate('sort_ivec', int(size(iv), ip), ov)
        allocate(mask(size(iv)))
        mask = .true.

        do i = 1, size(iv)
            imin = minloc(iv, mask)
            ov(i) = iv(imin(1))
            mask(imin(1)) = .false.
        end do

        deallocate(mask)

    end subroutine sort_ivec