# utils

Contains general purpose utilities (sorting, maps, etc).

## Providers

`binom`

  File : `utils/util.irp.f`

      double precision, allocatable   :: binom        (0:40,0:40)
      double precision, allocatable   :: binom_transp (0:40,0:40)

  Binomial coefficients

  Needed by:

  `binom_int` |  |

`binom_int`

  File : `utils/util.irp.f`

      integer*8, allocatable  :: binom_int    (0:40,0:40)
      integer*8, allocatable  :: binom_int_transp     (0:40,0:40)

  Binomial coefficients, as integers*8

  Needs:

  `binom` |  |

`binom_int_transp`

  File : `utils/util.irp.f`

      integer*8, allocatable  :: binom_int    (0:40,0:40)
      integer*8, allocatable  :: binom_int_transp     (0:40,0:40)

  Binomial coefficients, as integers*8

  Needs:

  `binom` |  |

`binom_transp`

  File : `utils/util.irp.f`

      double precision, allocatable   :: binom        (0:40,0:40)
      double precision, allocatable   :: binom_transp (0:40,0:40)

  Binomial coefficients

  Needed by:

  `binom_int` |  |

`degree_max_integration_lebedev`

  File : `utils/angular_integration.irp.f`

      integer :: degree_max_integration_lebedev

  integrate correctly a polynom of order “degree_max_integration_lebedev” needed for the angular integration according to LEBEDEV formulae

  Needed by:

  `n_points_integration_angular_lebedev` | `theta_angular_integration_lebedev` |

`dtranspose:`()

  File : `utils/transpose.irp.f`

      recursive subroutine dtranspose(A,LDA,B,LDB,d1,d2)

  Transpose input matrix A into output matrix B

  Called by:

  `dtranspose()` `h_s2_u_0_nstates_openmp()` | `h_s2_u_0_nstates_zmq()` | `h_s2_u_0_two_e_nstates_openmp()`

  Calls:

  `dtranspose()` |  |

`fact_inv`

  File : `utils/util.irp.f`

      double precision, allocatable   :: fact_inv     (128)

  1/n!

`i2radix_sort:`()

  File : `utils/sort.irp.f_template_644`

      recursive subroutine i2radix_sort(x,iorder,isize,iradix)

  Sort integer array x(isize) using the radix sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. iradix should be -1 in input.

  Called by:

  `get_mo_two_e_integrals_erf_i1j1()` `get_mo_two_e_integrals_erf_ij()` | `get_mo_two_e_integrals_i1j1()` `get_mo_two_e_integrals_ij()` | `i2radix_sort()`

  Calls:

  `i2radix_sort()` | `insertion_i2sort()` |

`i8radix_sort:`()

  File : `utils/sort.irp.f_template_644`

      recursive subroutine i8radix_sort(x,iorder,isize,iradix)

  Sort integer array x(isize) using the radix sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. iradix should be -1 in input.

  Called by:

  `get_mo_two_e_integrals_erf_i1j1()` `get_mo_two_e_integrals_erf_ij()` | `get_mo_two_e_integrals_i1j1()` `get_mo_two_e_integrals_ij()` | `i8radix_sort()` `psi_bilinear_matrix_transp_values`

  Calls:

  `i8radix_sort()` | `insertion_i8sort()` |

`i8radix_sort_big:`()

  File : `utils/sort.irp.f_template_644`

      recursive subroutine i8radix_sort_big(x,iorder,isize,iradix)

  Sort integer array x(isize) using the radix sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. iradix should be -1 in input.

  Called by:

  `i8radix_sort_big()` |  |

  Calls:

  `i8radix_sort_big()` | `insertion_i8sort_big()` |

`inv_int`

  File : `utils/util.irp.f`

      double precision, allocatable   :: inv_int      (128)

  1/i

`iradix_sort:`()

  File : `utils/sort.irp.f_template_644`

      recursive subroutine iradix_sort(x,iorder,isize,iradix)

  Sort integer array x(isize) using the radix sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. iradix should be -1 in input.

  Called by:

  `get_mo_two_e_integrals_erf_i1j1()` `get_mo_two_e_integrals_erf_ij()` | `get_mo_two_e_integrals_i1j1()` `get_mo_two_e_integrals_ij()` | `iradix_sort()`

  Calls:

  `insertion_isort()` | `iradix_sort()` |

`iradix_sort_big:`()

  File : `utils/sort.irp.f_template_644`

      recursive subroutine iradix_sort_big(x,iorder,isize,iradix)

  Sort integer array x(isize) using the radix sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. iradix should be -1 in input.

  Called by:

  `iradix_sort_big()` |  |

  Calls:

  `insertion_isort_big()` | `iradix_sort_big()` |

`n_points_integration_angular_lebedev`

  File : `utils/angular_integration.irp.f`

      integer :: n_points_integration_angular_lebedev

  Number of points needed for the angular integral

  Needs:

  `degree_max_integration_lebedev` |  |

  Needed by:

  `theta_angular_integration_lebedev` |  |

`nproc`

  File : `utils/util.irp.f`

      integer :: nproc

  Number of current OpenMP threads

  Needed by:

  `ao_two_e_integrals_erf_in_map` `ao_two_e_integrals_in_map` | `h_apply_buffer_allocated` `n_det` | `nthreads_davidson` `nthreads_pt2`

`overlap_gaussian_xyz:`()

  File : `utils/one_e_integration.irp.f`

        subroutine overlap_gaussian_xyz(A_center,B_center,alpha,beta,power_A,&
      power_B,overlap_x,overlap_y,overlap_z,overlap,dim)

  \[\begin{split}S_x = \int (x-A_x)^{a_x} exp(-\alpha(x-A_x)^2) (x-B_x)^{b_x} exp(-beta(x-B_x)^2) dx \\ S = S_x S_y S_z\end{split}\]

  Called by:

  `ao_coef_normalization_libint_factor` `ao_coef_normalized` `ao_deriv2_x` | `ao_deriv_1_x` `ao_dipole_x` | `ao_overlap` `ao_spread_x`

  Calls:

  `gaussian_product_x()` | `give_explicit_poly_and_gaussian()` |

`phi_angular_integration_lebedev`

  File : `utils/angular_integration.irp.f`

      double precision, allocatable   :: theta_angular_integration_lebedev    (n_points_integration_angular_lebedev)
      double precision, allocatable   :: phi_angular_integration_lebedev      (n_points_integration_angular_lebedev)
      double precision, allocatable   :: weights_angular_integration_lebedev  (n_points_integration_angular_lebedev)

  Theta phi values together with the weights values for the angular integration : integral [dphi,dtheta] f(x,y,z) = 4 * pi * sum (1<i<n_points_integration_angular_lebedev) f(xi,yi,zi) Note that theta and phi are in DEGREES !!

  Needs:

  `degree_max_integration_lebedev` | `n_points_integration_angular_lebedev` |

`qp_max_mem`

  File : `utils/memory.irp.f`

      integer :: qp_max_mem

  Maximum memory in Gb

  Needs:

  `mpi_master` |  |

  Needed by:

  `pt2_j` | `pt2_w` |

`rec__quicksort:`()

  File : `utils/sort.irp.f_template_261`

      recursive subroutine rec__quicksort(x, iorder, isize, first, last, level)

  Called by:

  `quick_sort()` | `rec__quicksort()` |

  Calls:

  `rec__quicksort()` |  |

`rec_d_quicksort:`()

  File : `utils/sort.irp.f_template_261`

      recursive subroutine rec_d_quicksort(x, iorder, isize, first, last, level)

  Called by:

  `quick_dsort()` | `rec_d_quicksort()` |

  Calls:

  `rec_d_quicksort()` |  |

`rec_i2_quicksort:`()

  File : `utils/sort.irp.f_template_261`

      recursive subroutine rec_i2_quicksort(x, iorder, isize, first, last, level)

  Called by:

  `quick_i2sort()` | `rec_i2_quicksort()` |

  Calls:

  `rec_i2_quicksort()` |  |

`rec_i8_quicksort:`()

  File : `utils/sort.irp.f_template_261`

      recursive subroutine rec_i8_quicksort(x, iorder, isize, first, last, level)

  Called by:

  `quick_i8sort()` | `rec_i8_quicksort()` |

  Calls:

  `rec_i8_quicksort()` |  |

`rec_i_quicksort:`()

  File : `utils/sort.irp.f_template_261`

      recursive subroutine rec_i_quicksort(x, iorder, isize, first, last, level)

  Called by:

  `quick_isort()` | `rec_i_quicksort()` |

  Calls:

  `rec_i_quicksort()` |  |

`theta_angular_integration_lebedev`

  File : `utils/angular_integration.irp.f`

      double precision, allocatable   :: theta_angular_integration_lebedev    (n_points_integration_angular_lebedev)
      double precision, allocatable   :: phi_angular_integration_lebedev      (n_points_integration_angular_lebedev)
      double precision, allocatable   :: weights_angular_integration_lebedev  (n_points_integration_angular_lebedev)

  Theta phi values together with the weights values for the angular integration : integral [dphi,dtheta] f(x,y,z) = 4 * pi * sum (1<i<n_points_integration_angular_lebedev) f(xi,yi,zi) Note that theta and phi are in DEGREES !!

  Needs:

  `degree_max_integration_lebedev` | `n_points_integration_angular_lebedev` |

`transpose:`()

  File : `utils/transpose.irp.f`

      recursive subroutine transpose(A,LDA,B,LDB,d1,d2)

  Transpose input matrix A into output matrix B

  Called by:

  `transpose()` |  |

  Calls:

  `transpose()` |  |

`weights_angular_integration_lebedev`

  File : `utils/angular_integration.irp.f`

      double precision, allocatable   :: theta_angular_integration_lebedev    (n_points_integration_angular_lebedev)
      double precision, allocatable   :: phi_angular_integration_lebedev      (n_points_integration_angular_lebedev)
      double precision, allocatable   :: weights_angular_integration_lebedev  (n_points_integration_angular_lebedev)

  Theta phi values together with the weights values for the angular integration : integral [dphi,dtheta] f(x,y,z) = 4 * pi * sum (1<i<n_points_integration_angular_lebedev) f(xi,yi,zi) Note that theta and phi are in DEGREES !!

  Needs:

  `degree_max_integration_lebedev` | `n_points_integration_angular_lebedev` |

## Subroutines / functions

`a_coef:`()

  File : `utils/need.irp.f`

      double precision function a_coef(n)

`add_poly:`()

  File : `utils/integration.irp.f`

      subroutine add_poly(b,nb,c,nc,d,nd)

  Add two polynomials D(t) =! D(t) +( B(t)+C(t))

`add_poly_multiply:`()

  File : `utils/integration.irp.f`

      subroutine add_poly_multiply(b,nb,cst,d,nd)

  Add a polynomial multiplied by a constant D(t) =! D(t) +( cst * B(t))

  Called by:

  `general_primitive_integral()` | `general_primitive_integral_erf()` |

`apply_rotation:`()

  File : `utils/linear_algebra.irp.f`

      subroutine apply_rotation(A,LDA,R,LDR,B,LDB,m,n)

  Apply the rotation found by find_rotation

  Calls:

  `dgemm()` |  |

`approx_dble:`()

  File : `utils/util.irp.f`

      double precision function approx_dble(a,n)

`b_coef:`()

  File : `utils/need.irp.f`

      double precision function b_coef(n,u)

`binom_func:`()

  File : `utils/util.irp.f`

      double precision function binom_func(i,j)

`check_mem:`()

  File : `utils/memory.irp.f`

      subroutine check_mem(rss_in,routine)

  Checks if n gigabytes can be allocated. If not, exit the run.

  Needs:

  `qp_max_mem` |  |

  Called by:

  `create_selection_buffer()` `davidson_diag_hjj_sjj()` `make_selection_buffer_s2()` `merge_selection_buffers()` `pt2_collector()` `pt2_j` | `pt2_w` `remove_duplicates_in_selection_buffer()` `run_cipsi()` `run_pt2_slave()` `run_stochastic_cipsi()` | `select_singles_and_doubles()` `selection_collector()` `sort_selection_buffer()` `testteethbuilding()` `zmq_pt2()`

  Calls:

  `resident_memory()` |  |

`dble_fact:`()

  File : `utils/util.irp.f`

      double precision function dble_fact(n)

`dble_fact_even:`()

  File : `utils/util.irp.f`

      double precision function dble_fact_even(n) result(fact2)

  n!!

`dble_fact_odd:`()

  File : `utils/util.irp.f`

      double precision function dble_fact_odd(n) result(fact2)

  n!!

`dble_logfact:`()

  File : `utils/util.irp.f`

      double precision function dble_logfact(n) result(logfact2)

  n!!

`ddfact2:`()

  File : `utils/need.irp.f`

      double precision function ddfact2(n)

`dset_order:`()

  File : `utils/sort.irp.f_template_347`

      subroutine dset_order(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A.

  Called by:

  `ao_coef_normalized_ordered` `h_s2_u_0_nstates_openmp()` | `h_s2_u_0_nstates_zmq()` `h_s2_u_0_two_e_nstates_openmp()` | `psi_bilinear_matrix_transp_values` `psi_bilinear_matrix_values`

`dset_order_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine dset_order_big(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A. This is a version for very large arrays where the indices need to be in integer*8 format

`dsort:`()

  File : `utils/sort.irp.f_template_293`

      subroutine dsort(x,iorder,isize)

  Sort array x(isize). iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `ao_coef_normalized_ordered` `make_selection_buffer_s2()` | `psi_det_sorted` `reorder_core_orb()` | `sort_selection_buffer()`

  Calls:

  `insertion_dsort()` | `quick_dsort()` |

`erf0:`()

  File : `utils/need.irp.f`

      double precision function erf0(x)

`extrapolate_data:`()

  File : `utils/extrapolation.irp.f`

      subroutine extrapolate_data(N_data, data, pt2, output)

  Extrapolate the data to the FCI limit

  Called by:

  `extrapolated_energy` |  |

  Calls:

  `get_pseudo_inverse()` |  |

`f_integral:`()

  File : `utils/integration.irp.f`

      double precision function F_integral(n,p)

  function that calculates the following integral int_{-infty}^{+infty} x^n exp(-p x^2) dx

`fact:`()

  File : `utils/util.irp.f`

      double precision function fact(n)

  n!

`find_rotation:`()

  File : `utils/linear_algebra.irp.f`

      subroutine find_rotation(A,LDA,B,m,C,n)

  Find A.C = B

  Calls:

  `dgemm()` | `get_pseudo_inverse()` |

`gammln:`()

  File : `utils/need.irp.f`

      double precision function gammln(xx)

`gammp:`()

  File : `utils/need.irp.f`

      double precision function gammp(a,x)

  Calls:

  `gcf()` | `gser()` |

`gaussian_product:`()

  File : `utils/integration.irp.f`

      subroutine gaussian_product(a,xa,b,xb,k,p,xp)

  Gaussian product in 1D. e^{-a (x-x_A)^2} e^{-b (x-x_B)^2} = K_{ab}^x e^{-p (x-x_P)^2}

  Called by:

  `give_explicit_poly_and_gaussian()` | `give_explicit_poly_and_gaussian_double()` |

`gaussian_product_x:`()

  File : `utils/integration.irp.f`

      subroutine gaussian_product_x(a,xa,b,xb,k,p,xp)

  Gaussian product in 1D. e^{-a (x-x_A)^2} e^{-b (x-x_B)^2} = K_{ab}^x e^{-p (x-x_P)^2}

  Called by:

  `overlap_gaussian_xyz()` |  |

`gcf:`()

  File : `utils/need.irp.f`

      subroutine gcf(gammcf,a,x,gln)

  Called by:

  `gammp()` |  |

`get_inverse:`()

  File : `utils/linear_algebra.irp.f`

      subroutine get_inverse(A,LDA,m,C,LDC)

  Returns the inverse of the square matrix A

  Called by:

  `ao_ortho_canonical_coef_inv` |  |

  Calls:

  `dgetrf()` | `dgetri()` |

`get_pseudo_inverse:`()

  File : `utils/linear_algebra.irp.f`

      subroutine get_pseudo_inverse(A,LDA,m,n,C,LDC)

  Find C = A^-1

  Called by:

  `ao_cart_to_sphe_inv` `extrapolate_data()` | `find_rotation()` | `s_inv`

  Calls:

  `dgesvd()` |  |

`give_explicit_poly_and_gaussian:`()

  File : `utils/integration.irp.f`

      subroutine give_explicit_poly_and_gaussian(P_new,P_center,p,fact_k,iorder,alpha,beta,a,b,A_center,B_center,dim)

  Transforms the product of
    (x-x_A)^a(1) (x-x_B)^b(1) (x-x_A)^a(2) (y-y_B)^b(2) (z-z_A)^a(3) (z-z_B)^b(3) exp(-(r-A)^2 alpha) exp(-(r-B)^2 beta)
  into
    fact_k * [ sum (l_x = 0,i_order(1)) P_new(l_x,1) * (x-P_center(1))^l_x ] exp (- p (x-P_center(1))^2 )
      - [ sum (l_y = 0,i_order(2)) P_new(l_y,2) * (y-P_center(2))^l_y ] exp (- p (y-P_center(2))^2 )
      - [ sum (l_z = 0,i_order(3)) P_new(l_z,3) * (z-P_center(3))^l_z ] exp (- p (z-P_center(3))^2 )

  Called by:

  `ao_two_e_integral()` `ao_two_e_integral_erf()` | `ao_two_e_integral_schwartz_accel()` `ao_two_e_integral_schwartz_accel_erf()` | `give_explicit_poly_and_gaussian_double()` `overlap_gaussian_xyz()`

  Calls:

  `gaussian_product()` | `multiply_poly()` | `recentered_poly2()`

`give_explicit_poly_and_gaussian_double:`()

  File : `utils/integration.irp.f`

      subroutine give_explicit_poly_and_gaussian_double(P_new,P_center,p,fact_k,iorder,alpha,beta,gama,a,b,A_center,B_center,Nucl_center,dim)

  Transforms the product of
    (x-x_A)^a(1) (x-x_B)^b(1) (x-x_A)^a(2) (y-y_B)^b(2) (z-z_A)^a(3) (z-z_B)^b(3) exp(-(r-A)^2 alpha) exp(-(r-B)^2 beta) exp(-(r-Nucl_center)^2 gama
  into
    fact_k * [ sum (l_x = 0,i_order(1)) P_new(l_x,1) * (x-P_center(1))^l_x ] exp (- p (x-P_center(1))^2 )
      - [ sum (l_y = 0,i_order(2)) P_new(l_y,2) * (y-P_center(2))^l_y ] exp (- p (y-P_center(2))^2 )
      - [ sum (l_z = 0,i_order(3)) P_new(l_z,3) * (z-P_center(3))^l_z ] exp (- p (z-P_center(3))^2 )

  Calls:

  `gaussian_product()` | `give_explicit_poly_and_gaussian()` |

`give_explicit_poly_and_gaussian_x:`()

  File : `utils/integration.irp.f`

      subroutine give_explicit_poly_and_gaussian_x(P_new,P_center,p,fact_k,iorder,alpha,beta,a,b,A_center,B_center,dim)

  Transform the product of
    (x-x_A)^a(1) (x-x_B)^b(1) (x-x_A)^a(2) (y-y_B)^b(2) (z-z_A)^a(3) (z-z_B)^b(3) exp(-(r-A)^2 alpha) exp(-(r-B)^2 beta)
  into
    fact_k (x-x_P)^iorder(1) (y-y_P)^iorder(2) (z-z_P)^iorder(3) exp(-p(r-P)^2)

  Called by:

  `overlap_gaussian_x()` |  |

  Calls:

  `multiply_poly()` | `recentered_poly2()` |

`gser:`()

  File : `utils/need.irp.f`

      subroutine gser(gamser,a,x,gln)

  Called by:

  `gammp()` |  |

`heap_dsort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_dsort(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

`heap_dsort_big:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_dsort_big(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`heap_i2sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_i2sort(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

`heap_i2sort_big:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_i2sort_big(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`heap_i8sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_i8sort(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

`heap_i8sort_big:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_i8sort_big(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`heap_isort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_isort(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

`heap_isort_big:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_isort_big(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`heap_sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_sort(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

`heap_sort_big:`()

  File : `utils/sort.irp.f_template_261`

      subroutine heap_sort_big(x,iorder,isize)

  Sort array x(isize) using the heap sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`hermite:`()

  File : `utils/integration.irp.f`

      double precision function hermite(n,x)

  Hermite polynomial

`i2set_order:`()

  File : `utils/sort.irp.f_template_347`

      subroutine i2set_order(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A.

`i2set_order_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine i2set_order_big(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A. This is a version for very large arrays where the indices need to be in integer*8 format

`i2sort:`()

  File : `utils/sort.irp.f_template_315`

      subroutine i2sort(x,iorder,isize)

  Sort array x(isize). iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Calls:

  `quick_i2sort()` |  |

`i8set_order:`()

  File : `utils/sort.irp.f_template_347`

      subroutine i8set_order(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A.

`i8set_order_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine i8set_order_big(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A. This is a version for very large arrays where the indices need to be in integer*8 format

`i8sort:`()

  File : `utils/sort.irp.f_template_315`

      subroutine i8sort(x,iorder,isize)

  Sort array x(isize). iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `make_selection_buffer_s2()` `psi_bilinear_matrix_values` `psi_det_alpha_unique` | `psi_det_beta_unique` `psi_occ_pattern` | `remove_duplicates_in_selection_buffer()` `sort_dets_by_det_search_key()`

  Calls:

  `quick_i8sort()` |  |

`insertion_dsort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine insertion_dsort (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `dsort()` |  |

`insertion_dsort_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine insertion_dsort_big (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`insertion_i2sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine insertion_i2sort (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `i2radix_sort()` |  |

`insertion_i2sort_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine insertion_i2sort_big (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`insertion_i8sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine insertion_i8sort (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `i8radix_sort()` |  |

`insertion_i8sort_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine insertion_i8sort_big (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

  Called by:

  `i8radix_sort_big()` |  |

`insertion_isort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine insertion_isort (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `iradix_sort()` |  |

`insertion_isort_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine insertion_isort_big (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

  Called by:

  `iradix_sort_big()` |  |

`insertion_sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine insertion_sort (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `sort()` |  |

`insertion_sort_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine insertion_sort_big (x,iorder,isize)

  Sort array x(isize) using the insertion sort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements. This is a version for very large arrays where the indices need to be in integer*8 format

`iset_order:`()

  File : `utils/sort.irp.f_template_347`

      subroutine iset_order(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A.

  Called by:

  `psi_bilinear_matrix_transp_values` | `psi_bilinear_matrix_values` |

`iset_order_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine iset_order_big(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A. This is a version for very large arrays where the indices need to be in integer*8 format

`isort:`()

  File : `utils/sort.irp.f_template_315`

      subroutine isort(x,iorder,isize)

  Sort array x(isize). iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Called by:

  `select_singles_and_doubles()` |  |

  Calls:

  `quick_isort()` |  |

`lapack_diag:`()

  File : `utils/linear_algebra.irp.f`

      subroutine lapack_diag(eigvalues,eigvectors,H,nmax,n)

  Diagonalize matrix H

  H is untouched between input and ouptut

  eigevalues(i) = ith lowest eigenvalue of the H matrix

  eigvectors(i,j) = <i|psi_j> where i is the basis function and psi_j is the j th eigenvector

  Called by:

  `ci_electronic_energy` `davidson_diag_hjj_sjj()` | `mo_as_eigvectors_of_mo_matrix()` | `psi_coef_cas_diagonalized`

  Calls:

  `dsyev()` |  |

`lapack_diagd:`()

  File : `utils/linear_algebra.irp.f`

      subroutine lapack_diagd(eigvalues,eigvectors,H,nmax,n)

  Diagonalize matrix H

  H is untouched between input and ouptut

  eigevalues(i) = ith lowest eigenvalue of the H matrix

  eigvectors(i,j) = <i|psi_j> where i is the basis function and psi_j is the j th eigenvector

  Called by:

  `inertia_tensor_eigenvectors` |  |

  Calls:

  `dsyevd()` |  |

`logfact:`()

  File : `utils/util.irp.f`

      double precision function logfact(n)

  n!

`lowercase:`()

  File : `utils/util.irp.f`

      subroutine lowercase(txt,n)

  Transform to lower case

  Called by:

  `end_parallel_job()` | `new_parallel_job()` |

`map_load_from_disk:`()

  File : `utils/map_functions.irp.f`

      subroutine map_load_from_disk(filename,map)

  Called by:

  `ao_two_e_integrals_erf_in_map` `ao_two_e_integrals_in_map` | `mo_two_e_integrals_erf_in_map` | `mo_two_e_integrals_in_map`

  Calls:

  `c_f_pointer()` | `mmap()` |

`map_save_to_disk:`()

  File : `utils/map_functions.irp.f`

      subroutine map_save_to_disk(filename,map)

  Called by:

  `ao_two_e_integrals_erf_in_map` `ao_two_e_integrals_in_map` `mo_two_e_integrals_erf_in_map` | `mo_two_e_integrals_in_map` `save_erf_two_e_integrals_ao()` `save_erf_two_e_integrals_mo()` | `save_erf_two_e_ints_ao_into_ints_ao()` `save_erf_two_e_ints_mo_into_ints_mo()`

  Calls:

  `c_f_pointer()` `map_sort()` | `mmap()` | `msync()`

`memory_of_double:`()

  File : `utils/memory.irp.f`

      double precision function memory_of_double(n)

  Computes the memory required for n double precision elements in gigabytes.

`memory_of_int:`()

  File : `utils/memory.irp.f`

      double precision function memory_of_int(n)

  Computes the memory required for n double precision elements in gigabytes.

`multiply_poly:`()

  File : `utils/integration.irp.f`

      subroutine multiply_poly(b,nb,c,nc,d,nd)

  Multiply two polynomials D(t) =! D(t) +( B(t)*C(t))

  Called by:

  `general_primitive_integral()` `general_primitive_integral_erf()` `give_explicit_poly_and_gaussian()` `give_explicit_poly_and_gaussian_x()` `give_polynomial_mult_center_one_e()` | `give_polynomial_mult_center_one_e_erf()` `give_polynomial_mult_center_one_e_erf_opt()` `i_x1_pol_mult_a1()` `i_x1_pol_mult_a2()` | `i_x1_pol_mult_one_e()` `i_x1_pol_mult_recurs()` `i_x2_pol_mult()` `i_x2_pol_mult_one_e()`

`normalize:`()

  File : `utils/util.irp.f`

      subroutine normalize(u,sze)

  Normalizes vector u

  Called by:

  `copy_h_apply_buffer_to_wf()` | `davidson_diag_hjj_sjj()` | `save_wavefunction_general()`

  Calls:

  `dscal()` |  |

`ortho_canonical:`()

  File : `utils/linear_algebra.irp.f`

      subroutine ortho_canonical(overlap,LDA,N,C,LDC,m)

  Compute C_new=C_old.U.s^-1/2 canonical orthogonalization.

  overlap : overlap matrix

  LDA : leftmost dimension of overlap array

  N : Overlap matrix is NxN (array is (LDA,N) )

  C : Coefficients of the vectors to orthogonalize. On exit,
    orthogonal vectors

  LDC : leftmost dimension of C

  m : Coefficients matrix is MxN, ( array is (LDC,N) )

  Called by:

  `ao_ortho_canonical_coef` |  |

  Calls:

  `dgemm()` | `svd()` |

`ortho_lowdin:`()

  File : `utils/linear_algebra.irp.f`

      subroutine ortho_lowdin(overlap,LDA,N,C,LDC,m)

  Compute C_new=C_old.S^-1/2 orthogonalization.

  overlap : overlap matrix

  LDA : leftmost dimension of overlap array

  N : Overlap matrix is NxN (array is (LDA,N) )

  C : Coefficients of the vectors to orthogonalize. On exit,
    orthogonal vectors

  LDC : leftmost dimension of C

  M : Coefficients matrix is MxN, ( array is (LDC,N) )

  Called by:

  `ao_ortho_lowdin_coef` | `orthonormalize_mos()` |

  Calls:

  `dgemm()` | `svd()` |

`ortho_qr:`()

  File : `utils/linear_algebra.irp.f`

      subroutine ortho_qr(A,LDA,m,n)

  Orthogonalization using Q.R factorization

  A : matrix to orthogonalize

  LDA : leftmost dimension of A

  n : Number of rows of A

  m : Number of columns of A

  Called by:

  `davidson_diag_hjj_sjj()` |  |

  Calls:

  `dgeqrf()` | `dorgqr()` |

`ortho_qr_unblocked:`()

  File : `utils/linear_algebra.irp.f`

      subroutine ortho_qr_unblocked(A,LDA,m,n)

  Orthogonalization using Q.R factorization

  A : matrix to orthogonalize

  LDA : leftmost dimension of A

  n : Number of rows of A

  m : Number of columns of A

  Calls:

  `dgeqr2()` | `dorg2r()` |

`overlap_gaussian_x:`()

  File : `utils/one_e_integration.irp.f`

      double precision function overlap_gaussian_x(A_center,B_center,alpha,beta,power_A,power_B,dim)

  \[\sum_{-infty}^{+infty} (x-A_x)^ax (x-B_x)^bx exp(-alpha(x-A_x)^2) exp(-beta(x-B_X)^2) dx\]

  Calls:

  `give_explicit_poly_and_gaussian_x()` |  |

`overlap_x_abs:`()

  File : `utils/one_e_integration.irp.f`

      subroutine overlap_x_abs(A_center,B_center,alpha,beta,power_A,power_B,overlap_x,lower_exp_val,dx,nx)

  Called by:

  `ao_overlap_abs` |  |

`print_memory_usage:`()

  File : `utils/memory.irp.f`

      subroutine print_memory_usage()

  Prints the memory usage in the output

  Called by:

  `write_time()` |  |

  Calls:

  `resident_memory()` | `total_memory()` |

`quick_dsort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine quick_dsort(x, iorder, isize)

  Sort array x(isize) using the quicksort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Needs:

  `nproc` |  |

  Called by:

  `dsort()` |  |

  Calls:

  `rec_d_quicksort()` |  |

`quick_i2sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine quick_i2sort(x, iorder, isize)

  Sort array x(isize) using the quicksort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Needs:

  `nproc` |  |

  Called by:

  `i2sort()` |  |

  Calls:

  `rec_i2_quicksort()` |  |

`quick_i8sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine quick_i8sort(x, iorder, isize)

  Sort array x(isize) using the quicksort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Needs:

  `nproc` |  |

  Called by:

  `i8sort()` |  |

  Calls:

  `rec_i8_quicksort()` |  |

`quick_isort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine quick_isort(x, iorder, isize)

  Sort array x(isize) using the quicksort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Needs:

  `nproc` |  |

  Called by:

  `isort()` |  |

  Calls:

  `rec_i_quicksort()` |  |

`quick_sort:`()

  File : `utils/sort.irp.f_template_261`

      subroutine quick_sort(x, iorder, isize)

  Sort array x(isize) using the quicksort algorithm. iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Needs:

  `nproc` |  |

  Called by:

  `sort()` |  |

  Calls:

  `rec__quicksort()` |  |

`recentered_poly2:`()

  File : `utils/integration.irp.f`

      subroutine recentered_poly2(P_new,x_A,x_P,a,P_new2,x_B,x_Q,b)

  Recenter two polynomials

  Needs:

  `binom` |  |

  Called by:

  `give_explicit_poly_and_gaussian()` | `give_explicit_poly_and_gaussian_x()` |

`resident_memory:`()

  File : `utils/memory.irp.f`

      subroutine resident_memory(value)

  Returns the current used memory in gigabytes used by the current process.

  Needs:

  `file_lock` |  |

  Called by:

  `check_mem()` `davidson_diag_hjj_sjj()` | `print_memory_usage()` | `zmq_pt2()`

  Calls:

  `omp_set_lock()` | `omp_unset_lock()` |

`rint:`()

  File : `utils/integration.irp.f`

      double precision function rint(n,rho)

  \[\int_0^1 dx \exp(-p x^2) x^n\]

`rint1:`()

  File : `utils/integration.irp.f`

      double precision function rint1(n,rho)

  Standard version of rint

  Needs:

  `inv_int` | `fact_inv` |

`rint_large_n:`()

  File : `utils/integration.irp.f`

      double precision function rint_large_n(n,rho)

  Version of rint for large values of n

`rint_sum:`()

  File : `utils/integration.irp.f`

      double precision function rint_sum(n_pt_out,rho,d1)

  Needed for the calculation of two-electron integrals.

`rinteg:`()

  File : `utils/need.irp.f`

      double precision function rinteg(n,u)

`rintgauss:`()

  File : `utils/need.irp.f`

      double precision function rintgauss(n)

`sabpartial:`()

  File : `utils/need.irp.f`

      double precision function SABpartial(zA,zB,A,B,nA,nB,gamA,gamB,l)

  Needs:

  `binom` |  |

`set_order:`()

  File : `utils/sort.irp.f_template_347`

      subroutine set_order(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A.

`set_order_big:`()

  File : `utils/sort.irp.f_template_412`

      subroutine set_order_big(x,iorder,isize)

  array A has already been sorted, and iorder has contains the new order of elements of A. This subroutine changes the order of x to match the new order of A. This is a version for very large arrays where the indices need to be in integer*8 format

`sort:`()

  File : `utils/sort.irp.f_template_293`

      subroutine sort(x,iorder,isize)

  Sort array x(isize). iorder in input should be (1,2,3,…,isize), and in output contains the new order of the elements.

  Calls:

  `insertion_sort()` | `quick_sort()` |

`sorted_dnumber:`()

  File : `utils/sort.irp.f_template_261`

      subroutine sorted_dnumber(x,isize,n)

  Returns the number of sorted elements

`sorted_i2number:`()

  File : `utils/sort.irp.f_template_261`

      subroutine sorted_i2number(x,isize,n)

  Returns the number of sorted elements

`sorted_i8number:`()

  File : `utils/sort.irp.f_template_261`

      subroutine sorted_i8number(x,isize,n)

  Returns the number of sorted elements

`sorted_inumber:`()

  File : `utils/sort.irp.f_template_261`

      subroutine sorted_inumber(x,isize,n)

  Returns the number of sorted elements

`sorted_number:`()

  File : `utils/sort.irp.f_template_261`

      subroutine sorted_number(x,isize,n)

  Returns the number of sorted elements

`svd:`()

  File : `utils/linear_algebra.irp.f`

      subroutine svd(A,LDA,U,LDU,D,Vt,LDVt,m,n)

  Compute A = U.D.Vt

  LDx : leftmost dimension of x

  Dimsneion of A is m x n

  Called by:

  `mo_as_svd_vectors_of_mo_matrix()` `mo_as_svd_vectors_of_mo_matrix_eig()` | `ortho_canonical()` `ortho_lowdin()` | `s_half` `s_half_inv`

  Calls:

  `dgesvd()` |  |

`total_memory:`()

  File : `utils/memory.irp.f`

      subroutine total_memory(value)

  Returns the current used memory in gigabytes used by the current process.

  Called by:

  `print_memory_usage()` |  |

`u_dot_u:`()

  File : `utils/util.irp.f`

      double precision function u_dot_u(u,sze)

  Compute <u|u>

`u_dot_v:`()

  File : `utils/util.irp.f`

      double precision function u_dot_v(u,v,sze)

  Compute <u|v>

`wall_time:`()

  File : `utils/util.irp.f`

      subroutine wall_time(t)

  The equivalent of cpu_time, but for the wall time.

  Called by:

  `add_integrals_to_map()` `add_integrals_to_map_erf()` `add_integrals_to_map_no_exit_34()` `add_integrals_to_map_three_indices()` `ao_pseudo_integrals_local` | `ao_pseudo_integrals_non_local` `ao_two_e_integrals_erf_in_map` `ao_two_e_integrals_in_map` `davidson_converged()` `davidson_diag_hjj_sjj()` | `output_wall_time_0` `pt2_collector()` `run_pt2_slave()` `run_slave_main()` `write_time()`

  Calls:

  `system_clock()` |  |

`write_git_log:`()

  File : `utils/util.irp.f`

      subroutine write_git_log(iunit)

  Write the last git commit in file iunit.