grow_pie_storage Subroutine

private subroutine grow_pie_storage(atom_sets, coefficients, max_terms, max_atoms, error)

Grow PIE term storage arrays when capacity is exceeded.

Arguments

Type IntentOptional Attributes Name
integer, intent(inout), allocatable :: atom_sets(:,:)
integer, intent(inout), allocatable :: coefficients(:)
integer(kind=int64), intent(inout) :: max_terms
integer, intent(in) :: max_atoms
type(error_t), intent(inout) :: error

Calls

proc~~grow_pie_storage~~CallsGraph proc~grow_pie_storage grow_pie_storage proc~error_set error_t%error_set proc~grow_pie_storage->proc~error_set to_char to_char proc~grow_pie_storage->to_char

Called by

proc~~grow_pie_storage~~CalledByGraph proc~grow_pie_storage grow_pie_storage proc~dfs_pie_accumulate dfs_pie_accumulate proc~dfs_pie_accumulate->proc~grow_pie_storage proc~dfs_pie_accumulate->proc~dfs_pie_accumulate proc~gmbe_enumerate_pie_terms gmbe_enumerate_pie_terms proc~gmbe_enumerate_pie_terms->proc~dfs_pie_accumulate proc~run_fragmented_calculation run_fragmented_calculation proc~run_fragmented_calculation->proc~gmbe_enumerate_pie_terms 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~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(kind=int64), private :: max_default_int
integer, private, allocatable :: new_atom_sets(:,:)
integer, private, allocatable :: new_coefficients(:)
integer(kind=int64), private :: new_max_terms
integer(kind=default_int), private :: new_terms_i
integer(kind=default_int), private :: old_terms_i

Source Code

   subroutine grow_pie_storage(atom_sets, coefficients, max_terms, max_atoms, error)
      !! Grow PIE term storage arrays when capacity is exceeded.
      integer, allocatable, intent(inout) :: atom_sets(:, :)
      integer, allocatable, intent(inout) :: coefficients(:)
      integer(int64), intent(inout) :: max_terms
      integer, intent(in) :: max_atoms
      type(error_t), intent(inout) :: error

      integer(int64) :: new_max_terms
      integer(default_int) :: old_terms_i, new_terms_i
      integer, allocatable :: new_atom_sets(:, :)
      integer, allocatable :: new_coefficients(:)
      integer(int64) :: max_default_int

      max_default_int = int(huge(0_default_int), int64)
      new_max_terms = max_terms*2_int64
      if (new_max_terms <= max_terms) then
         call error%set(ERROR_VALIDATION, "PIE term capacity overflow")
         return
      end if

      if (new_max_terms > max_default_int) then
         new_max_terms = max_default_int
      end if

      if (new_max_terms == max_terms) then
         call error%set(ERROR_VALIDATION, "Exceeded maximum PIE terms ("//to_char(max_terms)//")")
         return
      end if

      old_terms_i = int(max_terms, default_int)
      new_terms_i = int(new_max_terms, default_int)

      allocate (new_atom_sets(max_atoms, new_terms_i))
      new_atom_sets = -1
      new_atom_sets(:, 1:old_terms_i) = atom_sets(:, 1:old_terms_i)

      allocate (new_coefficients(new_terms_i))
      new_coefficients = 0
      new_coefficients(1:old_terms_i) = coefficients(1:old_terms_i)

      call move_alloc(new_atom_sets, atom_sets)
      call move_alloc(new_coefficients, coefficients)
      max_terms = new_max_terms
   end subroutine grow_pie_storage