get_next_combination Subroutine

public pure subroutine get_next_combination(indices, k, n, has_next)

Generate next combination (updates indices in place) has_next = .true. if there’s a next combination

Arguments

Type IntentOptional Attributes Name
integer, intent(inout) :: indices(:)
integer, intent(in) :: k
integer, intent(in) :: n
logical, intent(out) :: has_next

Called by

proc~~get_next_combination~~CalledByGraph proc~get_next_combination get_next_combination proc~compute_mbe_delta compute_mbe_delta proc~compute_mbe_delta->proc~get_next_combination proc~compute_mbe_dipole compute_mbe_dipole proc~compute_mbe_dipole->proc~get_next_combination proc~compute_mbe_dipole_derivatives compute_mbe_dipole_derivatives proc~compute_mbe_dipole_derivatives->proc~get_next_combination proc~compute_mbe_gradient compute_mbe_gradient proc~compute_mbe_gradient->proc~get_next_combination proc~compute_mbe_hessian compute_mbe_hessian proc~compute_mbe_hessian->proc~get_next_combination proc~fragment_should_be_screened fragment_should_be_screened proc~fragment_should_be_screened->proc~get_next_combination proc~apply_distance_screening apply_distance_screening proc~apply_distance_screening->proc~fragment_should_be_screened proc~compute_mbe compute_mbe proc~compute_mbe->proc~compute_mbe_delta proc~compute_mbe->proc~compute_mbe_dipole proc~compute_mbe->proc~compute_mbe_dipole_derivatives proc~compute_mbe->proc~compute_mbe_gradient proc~compute_mbe->proc~compute_mbe_hessian proc~global_coordinator global_coordinator proc~global_coordinator->proc~compute_mbe proc~run_fragmented_calculation run_fragmented_calculation proc~run_fragmented_calculation->proc~apply_distance_screening proc~serial_fragment_processor serial_fragment_processor proc~serial_fragment_processor->proc~compute_mbe interface~global_coordinator global_coordinator interface~global_coordinator->proc~global_coordinator interface~serial_fragment_processor serial_fragment_processor interface~serial_fragment_processor->proc~serial_fragment_processor proc~run_calculation run_calculation proc~run_calculation->proc~run_fragmented_calculation proc~compute_energy_and_forces compute_energy_and_forces proc~compute_energy_and_forces->proc~run_calculation proc~mbe_run_distributed mbe_context_t%mbe_run_distributed proc~mbe_run_distributed->interface~global_coordinator proc~mbe_run_serial mbe_context_t%mbe_run_serial proc~mbe_run_serial->interface~serial_fragment_processor proc~run_multi_molecule_calculations run_multi_molecule_calculations proc~run_multi_molecule_calculations->proc~run_calculation program~main main program~main->proc~run_calculation

Variables

Type Visibility Attributes Name Initial
integer, private :: i

Source Code

   pure subroutine get_next_combination(indices, k, n, has_next)
      !! Generate next combination (updates indices in place)
      !! has_next = .true. if there's a next combination
      integer, intent(inout) :: indices(:)
      integer, intent(in)    :: k, n
      logical, intent(out)   :: has_next
      integer                :: i

      has_next = .true.

      i = k
      do while (i >= 1)
         if (indices(i) < n - k + i) then
            indices(i) = indices(i) + 1
            do while (i < k)
               i = i + 1
               indices(i) = indices(i - 1) + 1
            end do
            return
         end if
         i = i - 1
      end do

      has_next = .false.
   end subroutine get_next_combination