diff --git a/Citations.bib b/Citations.bib index 9d350358..7fd59d70 100644 --- a/Citations.bib +++ b/Citations.bib @@ -143,3 +143,32 @@ @article{exner2002comparison year={2002}, publisher={ACS Publications} } + +@article{ozaki2001efficient, + title={Efficient recursion method for inverting an overlap matrix}, + author={Ozaki, T}, + journal={Physical Review B}, + volume={64}, + number={19}, + pages={195110}, + year={2001}, + publisher={APS} +} + +@book{boisvert1996matrix, + title={The matrix market exchange formats: Initial design}, + author={Boisvert, Ronald F and Boisvert, Ronald F and Remington, Karin A}, + year={1996}, + publisher={US Department of Commerce, National Institute of Standards and Technology} +} + +@article{jansik2007linear, + title={Linear-scaling symmetric square-root decomposition of the overlap matrix}, + author={Jans{\'\i}k, Branislav and H{\o}st, Stinne and J{\o}rgensen, Poul and Olsen, Jeppe and Helgaker, Trygve}, + journal={The Journal of chemical physics}, + volume={126}, + number={12}, + pages={124104}, + year={2007}, + publisher={AIP} +} diff --git a/Doxyfile.in b/Doxyfile.in index 4e848154..aadc8d9c 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -771,7 +771,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = @CMAKE_SOURCE_DIR@/Source @CMAKE_SOURCE_DIR@/UnitTests @CMAKE_SOURCE_DIR@/ReadMe.md +INPUT = @CMAKE_SOURCE_DIR@/Source/Fortran @CMAKE_SOURCE_DIR@/Source/CPlusPlus @CMAKE_SOURCE_DIR@/ReadMe.md # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv diff --git a/Source/CPlusPlus/DensityMatrixSolvers.h b/Source/CPlusPlus/DensityMatrixSolvers.h index b654eb96..695e3d2b 100644 --- a/Source/CPlusPlus/DensityMatrixSolvers.h +++ b/Source/CPlusPlus/DensityMatrixSolvers.h @@ -11,9 +11,7 @@ class DistributedSparseMatrix; class DensityMatrixSolvers : public SolverBase { public: //! Compute the density matrix from a Hamiltonian using the TRS2 method. - //! Based on the TRS2 algorithm presented in: - //! Niklasson, Anders MN. "Expansion algorithm for the density matrix." - //! Physical Review B 66, no. 15 (2002): 155115. + //! Based on the TRS2 algorithm presented in: \cite niklasson2002. //!\param Hamiltonian the matrix to compute the corresponding density from. //!\param InverseSquareRoot of the overlap matrix. //!\param nel the number of electrons. @@ -26,9 +24,7 @@ class DensityMatrixSolvers : public SolverBase { double &chemical_potential_out, const IterativeSolverParameters &solver_parameters); //! Compute the density matrix from a Hamiltonian using the TRS4 method. - //! Based on the TRS4 algorithm presented in: - //! Niklasson, Anders MN. "Expansion algorithm for the density matrix." - //! Physical Review B 66, no. 15 (2002): 155115. + //! Based on the TRS4 algorithm presented in: \cite niklasson2002 . //!\param Hamiltonian the matrix to compute the corresponding density from. //!\param InverseSquareRoot of the overlap matrix. //!\param nel the number of electrons. @@ -40,11 +36,8 @@ class DensityMatrixSolvers : public SolverBase { DistributedSparseMatrix &Density, double &chemical_potential_out, const IterativeSolverParameters &solver_parameters); - //! Compute the density matrix from a Hamiltonian using the TDB method. - //! Based on the algorithm presented in: - //! Truflandier, Lionel A., Rivo M. Dianzinga, and David R. Bowler. - //! "Communication: Generalized canonical purification for density matrix - //! minimization." The Journal of chemical physics 144, no. 9 (2016): 091102 + //! Compute the density matrix from a Hamiltonian using the HPCP method. + //! Based on the algorithm presented in: \cite truflandier2016communication //!\param Hamiltonian the matrix to compute the corresponding density from. //!\param InverseSquareRoot of the overlap matrix. //!\param nel the number of electrons. diff --git a/Source/CPlusPlus/DistributedMatrixMemoryPool.h b/Source/CPlusPlus/DistributedMatrixMemoryPool.h index 402149a1..bded7197 100644 --- a/Source/CPlusPlus/DistributedMatrixMemoryPool.h +++ b/Source/CPlusPlus/DistributedMatrixMemoryPool.h @@ -13,7 +13,7 @@ class DistributedMatrixMemoryPool { public: // Standard constructor. DistributedMatrixMemoryPool(); - // STandard destructor. + // Standard destructor. ~DistributedMatrixMemoryPool(); private: diff --git a/Source/CPlusPlus/EigenBounds.h b/Source/CPlusPlus/EigenBounds.h index 29ce6c7b..cfbb1e0c 100644 --- a/Source/CPlusPlus/EigenBounds.h +++ b/Source/CPlusPlus/EigenBounds.h @@ -20,7 +20,7 @@ class EigenBounds : public SolverBase { //! Compute a bounds on and maximum eigenvalue of a matrix. //! Uses The Power Method. //!\param matrix the matrix to compute the min/max of. - //!\param max_power_eig an uppder bound on the eigenspectrum. + //!\param max_power_eig an upper bound on the eigenspectrum. //!\param solver_parameters parameters for the solver static void PowerBounds(const DistributedSparseMatrix &matrix, double * max_power_eig, diff --git a/Source/CPlusPlus/FixedSolversParameters.h b/Source/CPlusPlus/FixedSolversParameters.h index 5fa2e9eb..a7f3eaf7 100644 --- a/Source/CPlusPlus/FixedSolversParameters.h +++ b/Source/CPlusPlus/FixedSolversParameters.h @@ -14,7 +14,7 @@ class FixedSolverParameters { public: //! Constructor. FixedSolverParameters(); - //! Where to have a verbose calculation. + //! Whether to have a verbose calculation. //!\param new_value void SetVerbosity(bool new_value); //! Threshold for flushing small values. diff --git a/Source/CPlusPlus/IterativeSolversParameters.h b/Source/CPlusPlus/IterativeSolversParameters.h index 1fa7011e..72ea85ba 100644 --- a/Source/CPlusPlus/IterativeSolversParameters.h +++ b/Source/CPlusPlus/IterativeSolversParameters.h @@ -20,7 +20,7 @@ class IterativeSolverParameters { //! Max iterations to perform. //!\param new_value void SetMaxIterations(int new_value); - //! Where to have a verbose calculation. + //! Whether to have a verbose calculation. //!\param new_value void SetVerbosity(bool new_value); //! Threshold for flushing small values. diff --git a/Source/CPlusPlus/LinearSolvers.h b/Source/CPlusPlus/LinearSolvers.h index 5931d460..17afcb8a 100644 --- a/Source/CPlusPlus/LinearSolvers.h +++ b/Source/CPlusPlus/LinearSolvers.h @@ -10,7 +10,7 @@ class DistributedSparseMatrix; //! A class for solving matrix equations. class LinearSolvers : public SolverBase { public: - //! Solve the matrix equation AX = B using conjugate gradient. + //! Solve the matrix equation AX = B using conjugate gradient method. //!\param AMat the matrix A, must be symmetric, positive definite. //!\param XMat the solved for matrix X. //!\param BMat the right hand side. diff --git a/Source/CPlusPlus/MinimizerSolvers.h b/Source/CPlusPlus/MinimizerSolvers.h index f4a439ac..6d248d5a 100644 --- a/Source/CPlusPlus/MinimizerSolvers.h +++ b/Source/CPlusPlus/MinimizerSolvers.h @@ -12,14 +12,9 @@ class DistributedSparseMatrix; class MinimizerSolvers : public SolverBase { public: //! Compute the density matrix from a Hamiltonian using the CG method. - //! Based on two papers. The first by Scuseria: - //! Millam, John M., and Gustavo E. Scuseria. "Linear scaling conjugate - //! gradient density matrix search as an alternative to diagonalization for - //! first principles electronic structure calculations." The Journal of - //! chemical physics 106, no. 13 (1997): 5569-5577. The second one by - //! Chalacombe: Challacombe, Matt. "A simplified density matrix minimization - //! for linear scaling self-consistent field theory." The Journal of chemical - //! physics 110, no. 5 (1999): 2332-2342. + //! Based on two papers. Based on two papers. The first by Scuseria + //! \cite millam1997linear and then Challacombe + //! \cite challacombe1999simplified //!\param Hamiltonian the matrix to compute the corresponding density from. //!\param InverseSquareRoot of the overlap matrix. //!\param nel the number of electrons. diff --git a/Source/Fortran/ChebyshevSolversModule.f90 b/Source/Fortran/ChebyshevSolversModule.f90 index cc5090c7..cba9992a 100644 --- a/Source/Fortran/ChebyshevSolversModule.f90 +++ b/Source/Fortran/ChebyshevSolversModule.f90 @@ -33,8 +33,8 @@ MODULE ChebyshevSolversModule !! @param[in] degree of the polynomial. PURE SUBROUTINE ConstructChebyshevPolynomial(this, degree) !! Parameters - TYPE(ChebyshevPolynomial_t), INTENT(inout) :: this - INTEGER, INTENT(in) :: degree + TYPE(ChebyshevPolynomial_t), INTENT(INOUT) :: this + INTEGER, INTENT(IN) :: degree ALLOCATE(this%coefficients(degree)) this%coefficients = 0 @@ -44,7 +44,7 @@ END SUBROUTINE ConstructChebyshevPolynomial !! @param[inout] this the polynomial to destruct. PURE SUBROUTINE DestructChebyshevPolynomial(this) !! Parameters - TYPE(ChebyshevPolynomial_t), INTENT(inout) :: this + TYPE(ChebyshevPolynomial_t), INTENT(INOUT) :: this IF (ALLOCATED(this%coefficients)) THEN DEALLOCATE(this%coefficients) END IF @@ -56,9 +56,9 @@ END SUBROUTINE DestructChebyshevPolynomial !! @param[in] coefficient value. SUBROUTINE SetChebyshevCoefficient(this, degree, coefficient) !! Parameters - TYPE(ChebyshevPolynomial_t), INTENT(inout) :: this - INTEGER, INTENT(in) :: degree - REAL(NTREAL), INTENT(in) :: coefficient + TYPE(ChebyshevPolynomial_t), INTENT(INOUT) :: this + INTEGER, INTENT(IN) :: degree + REAL(NTREAL), INTENT(IN) :: coefficient this%coefficients(degree) = coefficient END SUBROUTINE SetChebyshevCoefficient @@ -67,14 +67,14 @@ END SUBROUTINE SetChebyshevCoefficient !! This method uses the standard Chebyshev Polynomial expansion. !! @param[in] InputMat the input matrix !! @param[out] OutputMat = poly(InputMat) - !! @param[in] poly polynomial to compute. + !! @param[in] poly the Chebyshev polynomial to compute. !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ChebyshevCompute(InputMat, OutputMat, poly, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - TYPE(ChebyshevPolynomial_t), INTENT(in) :: poly - TYPE(FixedSolverParameters_t), INTENT(in), OPTIONAL :: solver_parameters_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + TYPE(ChebyshevPolynomial_t), INTENT(IN) :: poly + TYPE(FixedSolverParameters_t), INTENT(IN), OPTIONAL :: solver_parameters_in !! Handling Solver Parameters TYPE(FixedSolverParameters_t) :: solver_parameters !! Local Matrices @@ -178,7 +178,7 @@ END SUBROUTINE ChebyshevCompute !! version of the first method in \cite liang2003improved . !! @param[in] InputMat the input matrix !! @param[out] OutputMat = poly(InputMat) - !! @param[in] poly polynomial to compute. + !! @param[in] poly the Chebyshev polynomial to compute. !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE FactorizedChebyshevCompute(InputMat, OutputMat, poly, & & solver_parameters_in) @@ -292,17 +292,18 @@ END SUBROUTINE FactorizedChebyshevCompute !! @param[in] T_Powers the precomputed Chebyshev polynomials. !! @param[in] poly polynomial coefficients. !! @param[out] OutputMat = poly(InputMat) - !! @param[in] depth_in the depth of recursion. - !! @param[in] solver_parameters_in parameters for the solver. + !! @param[inout] pool the memory pool. + !! @param[in] depth the depth of recursion. + !! @param[in] solver_parameters parameters for the solver. RECURSIVE SUBROUTINE ComputeRecursive(T_Powers, poly, OutputMat, pool, & & depth, solver_parameters) !! Parameters - TYPE(DistributedSparseMatrix_t), DIMENSION(:), INTENT(in) :: T_Powers - TYPE(ChebyshevPolynomial_t), INTENT(in) :: poly - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat + TYPE(DistributedSparseMatrix_t), DIMENSION(:), INTENT(IN) :: T_Powers + TYPE(ChebyshevPolynomial_t), INTENT(IN) :: poly + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat INTEGER, INTENT(in) :: depth - TYPE(FixedSolverParameters_t), INTENT(in) :: solver_parameters - TYPE(DistributedMatrixMemoryPool_t), INTENT(inout) :: pool + TYPE(FixedSolverParameters_t), INTENT(IN) :: solver_parameters + TYPE(DistributedMatrixMemoryPool_t), INTENT(INOUT) :: pool !! Local Data INTEGER :: coefficient_midpoint INTEGER :: left_length, right_length @@ -359,4 +360,5 @@ RECURSIVE SUBROUTINE ComputeRecursive(T_Powers, poly, OutputMat, pool, & END IF END SUBROUTINE ComputeRecursive +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! END MODULE ChebyshevSolversModule diff --git a/Source/Fortran/DataTypesModule.f90 b/Source/Fortran/DataTypesModule.f90 index c25888b4..380b595d 100644 --- a/Source/Fortran/DataTypesModule.f90 +++ b/Source/Fortran/DataTypesModule.f90 @@ -12,13 +12,10 @@ MODULE DataTypesModule !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> The precision of floating point numbers we will use in this program. INTEGER, PARAMETER, PUBLIC :: NTREAL = c_double - !integer, parameter, public :: NTREAL = selected_real_kind( & - ! & BITSPERDOUBLE) !> MPI floating point datatype with the precision we will use in this program. INTEGER, PUBLIC :: MPINTREAL !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PUBLIC :: MPITypeInfoInit -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A subroutine to make a double precision MPI type with the requested !! precision. Must be called before MPINTREAL is used. diff --git a/Source/Fortran/DenseMatrixModule.f90 b/Source/Fortran/DenseMatrixModule.f90 index 1e54453d..a0030fe2 100644 --- a/Source/Fortran/DenseMatrixModule.f90 +++ b/Source/Fortran/DenseMatrixModule.f90 @@ -1,8 +1,8 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> This (currently under construction) module allows one to convert -!! a sparse matrix to a dense matrix. It also supports dense the dense -!! versions of core matrix routines. This module will be used in situations -!! where matrices become too dense for good sparse matrix performance. +!> This module allows one to convert a sparse matrix to a dense matrix. It also +!! supports dense the dense versions of core matrix routines. This module is +!! used in situations where matrices become too dense for good sparse matrix +!! performance. MODULE DenseMatrixModule USE DataTypesModule USE SparseMatrixModule @@ -16,8 +16,8 @@ MODULE DenseMatrixModule CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A function that converts a sparse matrix to a dense matrix. !! @param[in] sparse_matrix a sparse matrix to convert. - !! @param[inout] dense_matrix a preallocated - PURE SUBROUTINE ConstructDenseFromSparse(sparse_matrix,dense_matrix) + !! @param[inout] dense_matrix output. Must be preallocated. + PURE SUBROUTINE ConstructDenseFromSparse(sparse_matrix, dense_matrix) !! Parameters TYPE(SparseMatrix_t), INTENT(IN) :: sparse_matrix REAL(NTREAL), DIMENSION(:,:), INTENT(INOUT) :: dense_matrix @@ -46,8 +46,8 @@ END SUBROUTINE ConstructDenseFromSparse !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A function that converts a dense matrix to a sparse matrix. !! @param[in] dense_matrix to convert. - !! @param[out] sparse_matrix to build. - !! @param[in] threshold value for pruning. + !! @param[out] sparse_matrix output matrix. + !! @param[in] threshold value for pruning values to zero. PURE SUBROUTINE ConstructSparseFromDense(dense_matrix,sparse_matrix,threshold) !! Parameters REAL(NTREAL), DIMENSION(:,:), INTENT(IN) :: dense_matrix @@ -80,7 +80,7 @@ END SUBROUTINE ConstructSparseFromDense !> A wrapper for multiplying two dense matrices. !! @param[in] MatA the first matrix. !! @param[in] MatB the second matrix. - !! @param[inout] MatC = MatA*MatB. Preallocated. + !! @param[inout] MatC = MatA*MatB. MatC must be preallocated. PURE SUBROUTINE MultiplyDense(MatA,MatB,MatC) !! Parameters REAL(NTREAL), DIMENSION(:,:), INTENT(IN) :: MatA diff --git a/Source/Fortran/DensityMatrixSolversModule.f90 b/Source/Fortran/DensityMatrixSolversModule.f90 index ca404434..38618593 100644 --- a/Source/Fortran/DensityMatrixSolversModule.f90 +++ b/Source/Fortran/DensityMatrixSolversModule.f90 @@ -27,12 +27,13 @@ MODULE DensityMatrixSolversModule !! @param[in] InverseSquareRoot of the overlap matrix. !! @param[in] nel the number of electrons. !! @param[out] Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] solver_parameters_in parameters for the solver + !! @param[out] chemical_potential_out the chemical potential (optional). + !! @param[in] solver_parameters_in parameters for the solver (optional) SUBROUTINE TRS2(Hamiltonian, InverseSquareRoot, nel, Density, & & chemical_potential_out, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(IN) :: Hamiltonian, InverseSquareRoot + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: Hamiltonian + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InverseSquareRoot INTEGER, INTENT(IN) :: nel TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: Density REAL(NTREAL), INTENT(OUT), OPTIONAL :: chemical_potential_out @@ -233,8 +234,8 @@ END SUBROUTINE TRS2 !! @param[in] InverseSquareRoot of the overlap matrix. !! @param[in] nel the number of electrons. !! @param[out] Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] solver_parameters_in parameters for the solver + !! @param[out] chemical_potential_out the chemical potential (optional). + !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE TRS4(Hamiltonian, InverseSquareRoot, nel, Density, & & chemical_potential_out, solver_parameters_in) !! Parameters @@ -466,12 +467,12 @@ END SUBROUTINE TRS4 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the density matrix from a Hamiltonian using the HPCP method. !! Based on the algorithm presented in \cite truflandier2016communication - !! @param[in] Hamiltonian the matrix to compute the corresponding density from. + !! @param[in] Hamiltonian the matrix to compute the corresponding density from !! @param[in] InverseSquareRoot of the overlap matrix. !! @param[in] nel the number of electrons. !! @param[out] Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] solver_parameters_in parameters for the solver + !! @param[out] chemical_potential_out the chemical potential (optional). + !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE HPCP(Hamiltonian, InverseSquareRoot, nel, Density, & & chemical_potential_out, solver_parameters_in) !! Parameters @@ -697,8 +698,8 @@ END SUBROUTINE HPCP !! @param[in] InverseSquareRoot of the overlap matrix. !! @param[in] nel the number of electrons. !! @param[out] Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] solver_parameters_in parameters for the solver + !! @param[out] chemical_potential_out the chemical potential (optional). + !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE HPCPPlus(Hamiltonian, InverseSquareRoot, nel, Density, & & chemical_potential_out, solver_parameters_in) !! Parameters diff --git a/Source/Fortran/DistributedMatrixMemoryPoolModule.f90 b/Source/Fortran/DistributedMatrixMemoryPoolModule.f90 index 3805299e..d6d70ecd 100644 --- a/Source/Fortran/DistributedMatrixMemoryPoolModule.f90 +++ b/Source/Fortran/DistributedMatrixMemoryPoolModule.f90 @@ -23,7 +23,7 @@ MODULE DistributedMatrixMemoryPoolModule !> @param[out] this a constructed Matrix Memory Pool object. PURE SUBROUTINE ConstructDistributedMatrixMemoryPool(this) !! Parameters - TYPE(DistributedMatrixMemoryPool_t), INTENT(out) :: this + TYPE(DistributedMatrixMemoryPool_t), INTENT(INOUT) :: this !! Allocate CALL DestructDistributedMatrixMemoryPool(this) @@ -34,7 +34,7 @@ END SUBROUTINE ConstructDistributedMatrixMemoryPool !> @param[out] this Distributed Matrix Memory Pool object to destroy. PURE SUBROUTINE DestructDistributedMatrixMemoryPool(this) !! Parameters - TYPE(DistributedMatrixMemoryPool_t), INTENT(out) :: this + TYPE(DistributedMatrixMemoryPool_t), INTENT(INOUT) :: this !! Local Data INTEGER :: row_counter, column_counter @@ -54,10 +54,9 @@ END SUBROUTINE DestructDistributedMatrixMemoryPool !! handle the given parameters. !> @param[in] this the memory pool to check. !> @return true if the memory pool is valid. - PURE FUNCTION CheckDistributedMemoryPoolValidity(this) & - & RESULT(isvalid) + PURE FUNCTION CheckDistributedMemoryPoolValidity(this) RESULT(isvalid) !! Parameters - TYPE(DistributedMatrixMemoryPool_t), INTENT(in) :: this + TYPE(DistributedMatrixMemoryPool_t), INTENT(IN) :: this LOGICAL :: isvalid isvalid = .TRUE. diff --git a/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 b/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 index 86f07003..755bb090 100644 --- a/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 +++ b/Source/Fortran/DistributedSparseMatrixAlgebraModule.f90 @@ -42,16 +42,15 @@ MODULE DistributedSparseMatrixAlgebraModule PUBLIC :: Trace CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute sigma for the inversion method. - !! @todo describe this better. + !! See \cite ozaki2001efficient for details. !! @param[in] this the matrix to compute the sigma value of. !! @param[out] sigma_value sigma. - SUBROUTINE ComputeSigma(this,sigma_value) + SUBROUTINE ComputeSigma(this, sigma_value) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: this - REAL(NTREAL), INTENT(out) :: sigma_value + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this + REAL(NTREAL), INTENT(OUT) :: sigma_value !! Local Data - REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: & - & column_sigma_contribution + REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: column_sigma_contribution !! Counters/Temporary INTEGER :: inner_counter, outer_counter TYPE(SparseMatrix_t) :: merged_local_data @@ -87,18 +86,17 @@ END SUBROUTINE ComputeSigma !! @param[out] matC = alpha*matA*matB + beta*matC !! @param[in] alpha_in scales the multiplication !! @param[in] beta_in scales matrix we sum on to - !! @param[in] threshold_in for flushing values to zero. Default value is 0.0. - !! @param[inout] memory_pool_in a memory pool that can be used for the - !! calculation. - SUBROUTINE DistributedGemm(matA,matB,matC,alpha_in,beta_in,threshold_in, & + !! @param[in] threshold_in for flushing values to zero (Optional, default=0). + !! @param[inout] memory_pool_in a memory pool for the calculation (Optional). + SUBROUTINE DistributedGemm(matA, matB ,matC, alpha_in, beta_in, threshold_in,& & memory_pool_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matA - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matB - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: matC - REAL(NTREAL), OPTIONAL, INTENT(in) :: alpha_in - REAL(NTREAL), OPTIONAL, INTENT(in) :: beta_in - REAL(NTREAL), OPTIONAL, INTENT(in) :: threshold_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matA + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matB + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: matC + REAL(NTREAL), OPTIONAL, INTENT(IN) :: alpha_in + REAL(NTREAL), OPTIONAL, INTENT(IN) :: beta_in + REAL(NTREAL), OPTIONAL, INTENT(IN) :: threshold_in TYPE(DistributedMatrixMemoryPool_t), OPTIONAL, INTENT(inout) :: & & memory_pool_in !! Local Versions of Optional Parameter @@ -475,7 +473,7 @@ SUBROUTINE DistributedGemm(matA,matB,matC,alpha_in,beta_in,threshold_in, & CALL StopTimer("GEMM") END SUBROUTINE DistributedGemm !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Sum up the elements in a matrix. + !> Sum up the elements in a matrix into a single value. !! @param[in] matA Matrix A. !! @result sum the sum of all elements. FUNCTION DistributedGrandSum(matA) RESULT(sum) @@ -499,16 +497,16 @@ FUNCTION DistributedGrandSum(matA) RESULT(sum) & MPI_SUM, within_slice_comm, grid_error) END FUNCTION DistributedGrandSum !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Elementwise multiplication. C_ij = A_ij * B_ij. Also known as a Hadamard - !! product. + !> Elementwise multiplication. C_ij = A_ij * B_ij. + !! Also known as a Hadamard product. !! @param[in] matA Matrix A. !! @param[in] matB Matrix B. - !! @param[in,out] matC = MatA mult MatB. + !! @param[inout] matC = MatA mult MatB. SUBROUTINE DistributedPairwiseMultiply(matA, matB, matC) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matA - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matB - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: matC + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matA + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matB + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: matC !! Local Data INTEGER :: row_counter, column_counter @@ -534,7 +532,7 @@ END SUBROUTINE DistributedPairwiseMultiply !! @return the norm value of the full distributed sparse matrix. FUNCTION DistributedSparseNorm(this) RESULT(norm_value) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: this + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this REAL(NTREAL) :: norm_value !! Local Data REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: local_norm @@ -558,13 +556,15 @@ FUNCTION DistributedSparseNorm(this) RESULT(norm_value) END FUNCTION DistributedSparseNorm !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> product = dot(Matrix A,Matrix B) + !! Note that a dot product is the sum of elementwise multiplication, not + !! traditional matrix multiplication. !! @param[in] matA Matrix A. !! @param[in,out] matB Matrix B. !! @result product the dot product. FUNCTION DotDistributedSparseMatrix(matA, matB) RESULT(product) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matA - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matB + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matA + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matB REAL(NTREAL) :: product !! Local Data TYPE(DistributedSparseMatrix_t) :: matC @@ -577,15 +577,15 @@ END FUNCTION DotDistributedSparseMatrix !> Matrix B = alpha*Matrix A + Matrix B (AXPY) !! This will utilize the sparse vector increment routine. !! @param[in] matA Matrix A. - !! @param[in,out] matB Matrix B. - !! @param[in] alpha_in multiplier. Default value is 1.0 - !! @param[in] threshold_in for flushing values to zero. Default value is 0.0 + !! @param[inout] matB Matrix B. + !! @param[in] alpha_in multiplier. (Optional, default= 1.0) + !! @param[in] threshold_in for flushing values to zero. (Optional, default=0) SUBROUTINE IncrementDistributedSparseMatrix(matA, matB, alpha_in,threshold_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: matA - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: matB - REAL(NTREAL), OPTIONAL, INTENT(in) :: alpha_in - REAL(NTREAL), OPTIONAL, INTENT(in) :: threshold_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: matA + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: matB + REAL(NTREAL), OPTIONAL, INTENT(IN) :: alpha_in + REAL(NTREAL), OPTIONAL, INTENT(IN) :: threshold_in !! Local Data REAL(NTREAL) :: alpha REAL(NTREAL) :: threshold @@ -621,8 +621,8 @@ END SUBROUTINE IncrementDistributedSparseMatrix !! @param[in] constant scale factor. SUBROUTINE ScaleDistributedSparseMatrix(this,constant) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: this - REAL(NTREAL), INTENT(in) :: constant + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: this + REAL(NTREAL), INTENT(IN) :: constant INTEGER :: row_counter, column_counter !$omp parallel @@ -638,11 +638,11 @@ SUBROUTINE ScaleDistributedSparseMatrix(this,constant) END SUBROUTINE ScaleDistributedSparseMatrix !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the trace of the matrix. - !! @param[in] this the matrix to compute the norm of. + !! @param[in] this the matrix to compute the trace of. !! @return the trace value of the full distributed sparse matrix. FUNCTION Trace(this) RESULT(trace_value) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: this + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this REAL(NTREAL) :: trace_value !! Local data TYPE(TripletList_t) :: triplet_list diff --git a/Source/Fortran/DistributedSparseMatrixModule.f90 b/Source/Fortran/DistributedSparseMatrixModule.f90 index 9897794e..dc45ab96 100644 --- a/Source/Fortran/DistributedSparseMatrixModule.f90 +++ b/Source/Fortran/DistributedSparseMatrixModule.f90 @@ -113,8 +113,8 @@ PURE SUBROUTINE ConstructEmptyDistributedSparseMatrix(this, matrix_dim_) CALL DestructSparseMatrix(zeromatrix) END SUBROUTINE ConstructEmptyDistributedSparseMatrix !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Destruct a distributed sparse matrix - !! @param[in,out] this the matrix to destruct + !> Destruct a distributed sparse matrix. + !! @param[inout] this the matrix to destruct. PURE SUBROUTINE DestructDistributedSparseMatrix(this) !! Parameters TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: this @@ -145,11 +145,12 @@ PURE SUBROUTINE CopyDistributedSparseMatrix(matA, matB) END SUBROUTINE CopyDistributedSparseMatrix !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct distributed sparse matrix from a matrix market file in parallel. + !! Read \cite boisvert1996matrix for the details. !! @param[out] this the file being constructed. !! @param[in] file_name name of the file to read. SUBROUTINE ConstructFromMatrixMarket(this, file_name) !! Parameters - TYPE(DistributedSparseMatrix_t) :: this + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: this CHARACTER(len=*), INTENT(IN) :: file_name INTEGER, PARAMETER :: MAX_LINE_LENGTH = 100 !! File Handles @@ -306,11 +307,12 @@ SUBROUTINE ConstructFromMatrixMarket(this, file_name) END SUBROUTINE ConstructFromMatrixMarket !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct a distributed sparse matrix from a binary file in parallel. + !! Faster than text, so this is good for check pointing. !! @param[out] this the file being constructed. !! @param[in] file_name name of the file to read. SUBROUTINE ConstructFromBinary(this, file_name) !! Parameters - TYPE(DistributedSparseMatrix_t) :: this + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: this CHARACTER(len=*), INTENT(IN) :: file_name !! File Handles INTEGER :: mpi_file_handler @@ -376,12 +378,13 @@ SUBROUTINE ConstructFromBinary(this, file_name) CALL DestructTripletList(triplet_list) END SUBROUTINE ConstructFromBinary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Save a distributed sparse matrix to a file. + !> Save a distributed sparse matrix to a binary file. + !! Faster than text, so this is good for check pointing. !! @param[in] this the Matrix to write. !! @param[in] file_name name of the file to write to. SUBROUTINE WriteToBinary(this,file_name) !! Parameters - TYPE(DistributedSparseMatrix_t) :: this + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this CHARACTER(len=*), INTENT(IN) :: file_name !! Local Data TYPE(TripletList_t) :: triplet_list @@ -462,11 +465,12 @@ SUBROUTINE WriteToBinary(this,file_name) END SUBROUTINE WriteToBinary !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Write a distributed sparse matrix to a matrix market file. + !! Read \cite boisvert1996matrix for the details. !! @param[in] this the Matrix to write. !! @param[in] file_name name of the file to write to. SUBROUTINE WriteToMatrixMarket(this,file_name) !! Parameters - TYPE(DistributedSparseMatrix_t) :: this + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this CHARACTER(len=*), INTENT(IN) :: file_name INTEGER, PARAMETER :: MAX_LINE_LENGTH = 1024 !! Local MPI Variables @@ -598,8 +602,8 @@ END SUBROUTINE WriteToMatrixMarket !! where each triplet is stored, as long as global coordinates are given. !! @param[inout] this the matrix to fill. !! @param[in] triplet_list the triplet list of values. - !! @param[in] preduplicated_in (optional) if lists are preduplicated across - !! slices set this to true. + !! @param[in] preduplicated_in if lists are preduplicated across + !! slices set this to true (optional, default=False). SUBROUTINE FillFromTripletList(this,triplet_list,preduplicated_in) !! Parameters TYPE(DistributedSparseMatrix_t) :: this @@ -611,7 +615,7 @@ SUBROUTINE FillFromTripletList(this,triplet_list,preduplicated_in) TYPE(SparseMatrix_t) :: local_matrix TYPE(SparseMatrix_t) :: gathered_matrix TYPE(GatherHelper_t) :: gather_helper - REAL(ntreal), PARAMETER :: threshold = 0.0 + REAL(NTREAL), PARAMETER :: threshold = 0.0 CALL StartTimer("FillFromTriplet") !! First we redistribute the triplet list to get all the local data @@ -773,7 +777,7 @@ END SUBROUTINE FillDistributedPermutation !! Data is returned with absolute coordinates. !! @param[in] this the distributed sparse matrix. !! @param[inout] triplet_list the list to fill. - PURE SUBROUTINE GetTripletList(this,triplet_list) + PURE SUBROUTINE GetTripletList(this, triplet_list) !! Parameters TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this TYPE(TripletList_t), INTENT(INOUT) :: triplet_list @@ -971,6 +975,7 @@ PURE FUNCTION GetActualDimension(this) RESULT(DIMENSION) END FUNCTION GetActualDimension !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the logical dimension of the matrix. + !! Includes padding. !! @param[in] this the matrix. !! @result dimension of the matrix; PURE FUNCTION GetLogicalDimension(this) RESULT(DIMENSION) @@ -981,6 +986,7 @@ PURE FUNCTION GetLogicalDimension(this) RESULT(DIMENSION) END FUNCTION GetLogicalDimension !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Print out information about a distributed sparse matrix. + !! Sparsity, and load balancing information. !! @param[in] this the matrix to print information about. SUBROUTINE PrintMatrixInformation(this) !! Parameters @@ -1001,6 +1007,8 @@ SUBROUTINE PrintMatrixInformation(this) END SUBROUTINE PrintMatrixInformation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Print out a distributed sparse matrix. + !! This is a serial print routine, and should probably only be used for debug + !! purposes. !! @param[in] this the matrix to print. !! @param[in] file_name_in optionally, you can pass a file to print to. SUBROUTINE PrintDistributedSparseMatrix(this, file_name_in) @@ -1286,8 +1294,6 @@ PURE FUNCTION CalculateScaledDimension(matrix_dim, block_multiplier) & lcm = block_multiplier*num_process_slices* & & num_process_columns*num_process_rows - !lcm = ComputeLCM(ComputeLCM(ComputeLCM(num_process_rows, & - ! & num_process_columns),num_process_slices),block_multiplier) size_ratio = matrix_dim/lcm IF (size_ratio * lcm .EQ. matrix_dim) THEN diff --git a/Source/Fortran/EigenBoundsModule.f90 b/Source/Fortran/EigenBoundsModule.f90 index a822932c..6c494727 100644 --- a/Source/Fortran/EigenBoundsModule.f90 +++ b/Source/Fortran/EigenBoundsModule.f90 @@ -24,8 +24,8 @@ MODULE EigenBoundsModule !! @param[out] max_value an uppder bound on the eigenspectrum. SUBROUTINE GershgorinBounds(this,min_value,max_value) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: this - REAL(NTREAL), INTENT(out) :: min_value, max_value + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this + REAL(NTREAL), INTENT(OUT) :: min_value, max_value !! Local Data REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: per_column_min REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: per_column_max @@ -85,9 +85,9 @@ END SUBROUTINE GershgorinBounds !! @param[inout] solver_parameters_in solver parameters (optional). SUBROUTINE PowerBounds(this,max_value,solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: this - REAL(NTREAL), INTENT(out) :: max_value - TYPE(IterativeSolverParameters_t), INTENT(in), OPTIONAL :: & + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: this + REAL(NTREAL), INTENT(OUT) :: max_value + TYPE(IterativeSolverParameters_t), INTENT(IN), OPTIONAL :: & & solver_parameters_in !! Handling Optional Parameters TYPE(IterativeSolverParameters_t) :: solver_parameters diff --git a/Source/Fortran/ExponentialSolversModule.f90 b/Source/Fortran/ExponentialSolversModule.f90 index 545017e5..96bbc517 100644 --- a/Source/Fortran/ExponentialSolversModule.f90 +++ b/Source/Fortran/ExponentialSolversModule.f90 @@ -34,9 +34,9 @@ MODULE ExponentialSolversModule !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ComputeExponential(InputMat, OutputMat, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - TYPE(FixedSolverParameters_t), INTENT(in), OPTIONAL :: solver_parameters_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + TYPE(FixedSolverParameters_t), INTENT(IN), OPTIONAL :: solver_parameters_in !! Handling Solver Parameters TYPE(FixedSolverParameters_t) :: solver_parameters TYPE(FixedSolverParameters_t) :: sub_solver_parameters @@ -161,14 +161,15 @@ SUBROUTINE ComputeExponential(InputMat, OutputMat, solver_parameters_in) END SUBROUTINE ComputeExponential !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the exponential of a matrix using a pade approximation. + !! Be warned, the pade method can result in a lot of intermediate fill. !! @param[in] InputMat the input matrix !! @param[out] OutputMat = exp(InputMat) !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ComputeExponentialPade(InputMat, OutputMat, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - TYPE(IterativeSolverParameters_t), INTENT(in), OPTIONAL :: & + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + TYPE(IterativeSolverParameters_t), INTENT(IN), OPTIONAL :: & & solver_parameters_in !! Handling Solver Parameters TYPE(IterativeSolverParameters_t) :: solver_parameters @@ -289,14 +290,16 @@ SUBROUTINE ComputeExponentialPade(InputMat, OutputMat, solver_parameters_in) END SUBROUTINE ComputeExponentialPade !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the exponential of a matrix using a taylor series expansion. + !! This is only really useful if you have a very small spectrum, because + !! quite a bit of scaling is required. !! @param[in] InputMat the input matrix !! @param[out] OutputMat = exp(InputMat) !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ComputeExponentialTaylor(InputMat, OutputMat, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - TYPE(FixedSolverParameters_t), INTENT(in), OPTIONAL :: solver_parameters_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + TYPE(FixedSolverParameters_t), INTENT(IN), OPTIONAL :: solver_parameters_in REAL(NTREAL), PARAMETER :: NEGATIVE_ONE = -1.0 !! Handling Solver Parameters TYPE(FixedSolverParameters_t) :: solver_parameters @@ -389,7 +392,7 @@ END SUBROUTINE ComputeExponentialTaylor !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the logarithm of a matrix. !! @param[in] InputMat the input matrix - !! @param[out] OutputMat = exp(InputMat) + !! @param[out] OutputMat = log(InputMat) !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ComputeLogarithm(InputMat, OutputMat, solver_parameters_in) !! Parameters @@ -549,9 +552,9 @@ END SUBROUTINE ComputeLogarithm !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ComputeLogarithmTaylor(InputMat, OutputMat, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - TYPE(FixedSolverParameters_t), INTENT(in), OPTIONAL :: solver_parameters_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + TYPE(FixedSolverParameters_t), INTENT(IN), OPTIONAL :: solver_parameters_in REAL(NTREAL), PARAMETER :: NEGATIVE_ONE = -1.0 !! Handling Solver Parameters TYPE(FixedSolverParameters_t) :: solver_parameters diff --git a/Source/Fortran/FixedSolversModule.f90 b/Source/Fortran/FixedSolversModule.f90 index fefe1b8b..3ee6ffff 100644 --- a/Source/Fortran/FixedSolversModule.f90 +++ b/Source/Fortran/FixedSolversModule.f90 @@ -28,13 +28,17 @@ MODULE FixedSolversModule PUBLIC :: SetFixedLoadBalance PUBLIC :: PrintFixedSolverParameters CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! Handle the parameters + !> Construct a fixed solver parameteres data structure. + !! @param[in] threshold_in the zero threshold value (optional, default=0). + !! @param[in] be_verbose_in whether to print during the solve + !! (optional, default=False) + !! @param[in] BalancePermutation_in a permutation for load balancing. PURE FUNCTION FixedSolverParameters_init(threshold_in, & & be_verbose_in, BalancePermutation_in) RESULT(this) !! Parameters - REAL(NTREAL), INTENT(in), OPTIONAL :: threshold_in - LOGICAL, INTENT(in), OPTIONAL :: be_verbose_in - TYPE(Permutation_t), INTENT(in), OPTIONAL :: BalancePermutation_in + REAL(NTREAL), INTENT(IN), OPTIONAL :: threshold_in + LOGICAL, INTENT(IN), OPTIONAL :: be_verbose_in + TYPE(Permutation_t), INTENT(IN), OPTIONAL :: BalancePermutation_in TYPE(FixedSolverParameters_t) :: this !! Optional Parameters @@ -60,8 +64,8 @@ END FUNCTION FixedSolverParameters_init !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetFixedThreshold(this,new_value) - TYPE(FixedSolverParameters_t), INTENT(inout) :: this - REAL(NTREAL), INTENT(in) :: new_value + TYPE(FixedSolverParameters_t), INTENT(INOUT) :: this + REAL(NTREAL), INTENT(IN) :: new_value this%threshold = new_value END SUBROUTINE SetFixedThreshold @@ -70,8 +74,8 @@ END SUBROUTINE SetFixedThreshold !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetFixedBeVerbose(this,new_value) - TYPE(FixedSolverParameters_t), INTENT(inout) :: this - LOGICAL, INTENT(in) :: new_value + TYPE(FixedSolverParameters_t), INTENT(INOUT) :: this + LOGICAL, INTENT(IN) :: new_value this%be_verbose = new_value END SUBROUTINE SetFixedBeVerbose @@ -80,17 +84,17 @@ END SUBROUTINE SetFixedBeVerbose !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetFixedLoadBalance(this,new_value) - TYPE(FixedSolverParameters_t), INTENT(inout) :: this - TYPE(Permutation_t), INTENT(in) :: new_value + TYPE(FixedSolverParameters_t), INTENT(INOUT) :: this + TYPE(Permutation_t), INTENT(IN) :: new_value this%do_load_balancing = .TRUE. this%BalancePermutation = new_value END SUBROUTINE SetFixedLoadBalance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Print out the convergence values. + !> Print out the fixed solver parameter values. !! @param[inout] this the parameter object. SUBROUTINE PrintFixedSolverParameters(this) - TYPE(FixedSolverParameters_t), INTENT(in) :: this + TYPE(FixedSolverParameters_t), INTENT(IN) :: this CALL WriteHeader("Fixed Solver Parameters") CALL EnterSubLog CALL WriteListElement(key="be_verbose",bool_value_in=this%be_verbose) diff --git a/Source/Fortran/HermiteSolversModule.f90 b/Source/Fortran/HermiteSolversModule.f90 index 59aabeae..91819e98 100644 --- a/Source/Fortran/HermiteSolversModule.f90 +++ b/Source/Fortran/HermiteSolversModule.f90 @@ -15,7 +15,7 @@ MODULE HermiteSolversModule IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> A datatype that represents a Chebyshev polynomial. + !> A datatype that represents a Hermite polynomial. TYPE, PUBLIC :: HermitePolynomial_t !> Coefficients of the polynomial. REAL(NTREAL), DIMENSION(:), ALLOCATABLE :: coefficients @@ -28,7 +28,7 @@ MODULE HermiteSolversModule !! Solvers PUBLIC :: HermiteCompute CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Construct a Chebyshev polynomial object. + !> Construct a Hermite polynomial object. !! @param[inout] this the polynomial to construct. !! @param[in] degree of the polynomial. PURE SUBROUTINE ConstructHermitePolynomial(this, degree) @@ -40,7 +40,7 @@ PURE SUBROUTINE ConstructHermitePolynomial(this, degree) this%coefficients = 0 END SUBROUTINE ConstructHermitePolynomial !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Destruct a polynomial object. + !> Destruct a Hermite polynomial object. !! @param[inout] this the polynomial to destruct. PURE SUBROUTINE DestructHermitePolynomial(this) !! Parameters @@ -50,7 +50,7 @@ PURE SUBROUTINE DestructHermitePolynomial(this) END IF END SUBROUTINE DestructHermitePolynomial !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Set a coefficient of a Chebyshev polynomial. + !> Set a coefficient of a Hermite polynomial. !! @param[inout] this the polynomial to set. !! @param[in] degree for which to set the coefficient. !! @param[in] coefficient value. diff --git a/Source/Fortran/InverseSolversModule.f90 b/Source/Fortran/InverseSolversModule.f90 index a017b441..bd501e7e 100644 --- a/Source/Fortran/InverseSolversModule.f90 +++ b/Source/Fortran/InverseSolversModule.f90 @@ -155,7 +155,6 @@ SUBROUTINE Invert(Mat1, InverseMat, solver_parameters_in) END SUBROUTINE Invert !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the pseudoinverse of a matrix. - !! This is still experimental. !! An implementation of Hotelling's method \cite palser1998canonical. !! We just change the convergence criteria. !! @param[in] Mat1 Matrix 1. diff --git a/Source/Fortran/IterativeSolversModule.f90 b/Source/Fortran/IterativeSolversModule.f90 index de0378dc..16eae2c4 100644 --- a/Source/Fortran/IterativeSolversModule.f90 +++ b/Source/Fortran/IterativeSolversModule.f90 @@ -38,14 +38,23 @@ MODULE IterativeSolversModule INTEGER, PARAMETER :: MAX_ITERATIONS_CONST = 1000 CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! Handle the parameters + !> Construct a data type which stores iterative solver parameters. + !! @param[in] converge_diff_in the difference between iterations to consider + !! a calculation converged (optional). + !! @param[in] threshold_in the zero threshold (optional). + !! @param[in] max_iterations_in the maximum number of iterations to perform + !! (optional). + !! @param[in] be_verbose_in whether to print during the calculation + !! (optional, default = False). + !! @param[in] BalancePermutation_in for load balancing (optional). PURE FUNCTION IterativeSolverParameters_init(converge_diff_in, threshold_in, & & max_iterations_in, be_verbose_in, BalancePermutation_in) RESULT(this) !! Parameters - REAL(NTREAL), INTENT(in), OPTIONAL :: converge_diff_in - REAL(NTREAL), INTENT(in), OPTIONAL :: threshold_in - INTEGER, INTENT(in), OPTIONAL :: max_iterations_in - LOGICAL, INTENT(in), OPTIONAL :: be_verbose_in - TYPE(Permutation_t), INTENT(in), OPTIONAL :: BalancePermutation_in + REAL(NTREAL), INTENT(IN), OPTIONAL :: converge_diff_in + REAL(NTREAL), INTENT(IN), OPTIONAL :: threshold_in + INTEGER, INTENT(IN), OPTIONAL :: max_iterations_in + LOGICAL, INTENT(IN), OPTIONAL :: be_verbose_in + TYPE(Permutation_t), INTENT(IN), OPTIONAL :: BalancePermutation_in TYPE(IterativeSolverParameters_t) :: this !! Optional Parameters @@ -81,8 +90,8 @@ END FUNCTION IterativeSolverParameters_init !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeConvergeDiff(this,new_value) - TYPE(IterativeSolverParameters_t), INTENT(inout) :: this - REAL(NTREAL), INTENT(in) :: new_value + TYPE(IterativeSolverParameters_t), INTENT(INOUT) :: this + REAL(NTREAL), INTENT(IN) :: new_value this%converge_diff = new_value END SUBROUTINE SetIterativeConvergeDiff @@ -91,8 +100,8 @@ END SUBROUTINE SetIterativeConvergeDiff !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeMaxIterations(this,new_value) - TYPE(IterativeSolverParameters_t), INTENT(inout) :: this - INTEGER, INTENT(in) :: new_value + TYPE(IterativeSolverParameters_t), INTENT(INOUT) :: this + INTEGER, INTENT(IN) :: new_value this%max_iterations = new_value END SUBROUTINE SetIterativeMaxIterations @@ -101,8 +110,8 @@ END SUBROUTINE SetIterativeMaxIterations !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeThreshold(this,new_value) - TYPE(IterativeSolverParameters_t), INTENT(inout) :: this - REAL(NTREAL), INTENT(in) :: new_value + TYPE(IterativeSolverParameters_t), INTENT(INOUT) :: this + REAL(NTREAL), INTENT(IN) :: new_value this%threshold = new_value END SUBROUTINE SetIterativeThreshold @@ -111,8 +120,8 @@ END SUBROUTINE SetIterativeThreshold !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeBeVerbose(this,new_value) - TYPE(IterativeSolverParameters_t), INTENT(inout) :: this - LOGICAL, INTENT(in) :: new_value + TYPE(IterativeSolverParameters_t), INTENT(INOUT) :: this + LOGICAL, INTENT(IN) :: new_value this%be_verbose = new_value END SUBROUTINE SetIterativeBeVerbose @@ -121,17 +130,17 @@ END SUBROUTINE SetIterativeBeVerbose !! @param[inout] this the parameter object. !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeLoadBalance(this,new_value) - TYPE(IterativeSolverParameters_t), INTENT(inout) :: this - TYPE(Permutation_t), INTENT(in) :: new_value + TYPE(IterativeSolverParameters_t), INTENT(INOUT) :: this + TYPE(Permutation_t), INTENT(IN) :: new_value this%do_load_balancing = .TRUE. this%BalancePermutation = new_value END SUBROUTINE SetIterativeLoadBalance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Print out the convergence values. + !> Print out the iterative solver parameter values. !! @param[inout] this the parameter object. SUBROUTINE PrintIterativeSolverParameters(this) - TYPE(IterativeSolverParameters_t), INTENT(in) :: this + TYPE(IterativeSolverParameters_t), INTENT(IN) :: this CALL WriteHeader("Iterative Solver Parameters") CALL EnterSubLog diff --git a/Source/Fortran/LinearSolversModule.f90 b/Source/Fortran/LinearSolversModule.f90 index c5eb511e..cce81c70 100644 --- a/Source/Fortran/LinearSolversModule.f90 +++ b/Source/Fortran/LinearSolversModule.f90 @@ -16,7 +16,7 @@ MODULE LinearSolversModule !! Solvers PUBLIC :: CGSolver CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Solve the matrix equation AX = B using conjugate gradient. + !> Solve the matrix equation AX = B using the conjugate gradient method. !! @param[in] AMat the matrix A, must be symmetric, positive definite. !! @param[out] XMat the solved for matrix X. !! @param[in] BMat the right hand side. diff --git a/Source/Fortran/LoadBalancerModule.f90 b/Source/Fortran/LoadBalancerModule.f90 index bb3b927d..a28fc63a 100644 --- a/Source/Fortran/LoadBalancerModule.f90 +++ b/Source/Fortran/LoadBalancerModule.f90 @@ -10,42 +10,41 @@ MODULE LoadBalancerModule !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PUBLIC :: PermuteMatrix PUBLIC :: UndoPermuteMatrix -CONTAINS -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Apply a permutation to a matrix. - !! @param[in] mat_in matrix to permute. + !! @param[in] mat matrix to permute. !! @param[out] mat_out permuted matrix. !! @param[in] permutation to apply. !! @param[inout] memorypool_in memory pool to use. Optional. - SUBROUTINE PermuteMatrix(mat_in, mat_out, permutation, memorypool_in) + SUBROUTINE PermuteMatrix(mat, mat_out, permutation, memorypool_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: mat_in - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: mat_out - TYPE(Permutation_t), INTENT(in) :: permutation - TYPE(DistributedMatrixMemoryPool_t), INTENT(inout),OPTIONAL :: memorypool_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: mat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: mat_out + TYPE(Permutation_t), INTENT(IN) :: permutation + TYPE(DistributedMatrixMemoryPool_t), INTENT(INOUT),OPTIONAL :: memorypool_in !! Local Variables TYPE(DistributedSparseMatrix_t) :: PermuteRows, PermuteColumns TYPE(DistributedSparseMatrix_t) :: Temp CALL ConstructEmptyDistributedSparseMatrix(PermuteRows, & - & mat_in%actual_matrix_dimension) + & mat%actual_matrix_dimension) CALL ConstructEmptyDistributedSparseMatrix(PermuteColumns, & - & mat_in%actual_matrix_dimension) + & mat%actual_matrix_dimension) CALL FillDistributedPermutation(PermuteRows, permutation%index_lookup, & & permuterows=.TRUE.) CALL FillDistributedPermutation(PermuteColumns, permutation%index_lookup, & & permuterows=.FALSE.) CALL ConstructEmptyDistributedSparseMatrix(Temp, & - mat_in%actual_matrix_dimension) + mat%actual_matrix_dimension) !! Permute Matrices. IF (PRESENT(memorypool_in)) THEN - CALL DistributedGemm(PermuteRows, mat_in, Temp, & + CALL DistributedGemm(PermuteRows, mat, Temp, & & memory_pool_in=memorypool_in) CALL DistributedGemm(Temp, PermuteColumns, mat_out, & & memory_pool_in=memorypool_in) ELSE - CALL DistributedGemm(PermuteRows, mat_in, Temp) + CALL DistributedGemm(PermuteRows, mat, Temp) CALL DistributedGemm(Temp, PermuteColumns, mat_out) END IF @@ -55,40 +54,40 @@ SUBROUTINE PermuteMatrix(mat_in, mat_out, permutation, memorypool_in) END SUBROUTINE PermuteMatrix !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Undo a permutation applied to a matrix. - !! @param[in] mat_in matrix to undo permutation of. + !! @param[in] mat matrix to undo permutation of. !! @param[out] mat_out unpermuted matrix. !! @param[in] permutation to remove. !! @param[inout] memorypool_in memory pool to use. Optional. - SUBROUTINE UndoPermuteMatrix(mat_in, mat_out, permutation, memorypool_in) + SUBROUTINE UndoPermuteMatrix(mat, mat_out, permutation, memorypool_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: mat_in - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: mat_out - TYPE(Permutation_t), INTENT(in) :: permutation - TYPE(DistributedMatrixMemoryPool_t), INTENT(inout),OPTIONAL :: memorypool_in + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: mat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: mat_out + TYPE(Permutation_t), INTENT(IN) :: permutation + TYPE(DistributedMatrixMemoryPool_t), INTENT(INOUT),OPTIONAL :: memorypool_in !! Local Variables TYPE(DistributedSparseMatrix_t) :: PermuteRows, PermuteColumns TYPE(DistributedSparseMatrix_t) :: Temp !! Build Permutation Matrices CALL ConstructEmptyDistributedSparseMatrix(PermuteRows, & - & mat_in%actual_matrix_dimension) + & mat%actual_matrix_dimension) CALL ConstructEmptyDistributedSparseMatrix(PermuteColumns, & - mat_in%actual_matrix_dimension) + mat%actual_matrix_dimension) CALL FillDistributedPermutation(PermuteRows, permutation%index_lookup, & & permuterows=.TRUE.) CALL FillDistributedPermutation(PermuteColumns, permutation%index_lookup, & & permuterows=.FALSE.) CALL ConstructEmptyDistributedSparseMatrix(Temp, & - & mat_in%actual_matrix_dimension) + & mat%actual_matrix_dimension) !! Permute Matrices. IF (PRESENT(memorypool_in)) THEN - CALL DistributedGemm(PermuteColumns, mat_in, Temp, & + CALL DistributedGemm(PermuteColumns, mat, Temp, & & memory_pool_in=memorypool_in) CALL DistributedGemm(Temp, PermuteRows, mat_out, & & memory_pool_in=memorypool_in) ELSE - CALL DistributedGemm(PermuteColumns, mat_in, Temp) + CALL DistributedGemm(PermuteColumns, mat, Temp) CALL DistributedGemm(Temp, PermuteRows, mat_out) END IF diff --git a/Source/Fortran/LoggingModule.f90 b/Source/Fortran/LoggingModule.f90 index a3ec68b9..fb1724ae 100644 --- a/Source/Fortran/LoggingModule.f90 +++ b/Source/Fortran/LoggingModule.f90 @@ -51,11 +51,12 @@ SUBROUTINE WriteHeader(header_value) END SUBROUTINE WriteHeader !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Write out a element. + !! Only specify one of the kinds of values. !! @param[in] key some text to write. - !! @param[in] text_value_in a text value to write. - !! @param[in] int_value_in an integer value to write. - !! @param[in] float_value_in an float value to write. - !! @param[in] bool_value_in a bool value to write. + !! @param[in] text_value_in a text value to write (optional). + !! @param[in] int_value_in an integer value to write (optional). + !! @param[in] float_value_in an float value to write (optional). + !! @param[in] bool_value_in a bool value to write (optional). SUBROUTINE WriteElement(key, text_value_in, int_value_in, float_value_in, & & bool_value_in) !! Parameters @@ -95,11 +96,12 @@ SUBROUTINE WriteElement(key, text_value_in, int_value_in, float_value_in, & END SUBROUTINE WriteElement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Write out a list element. + !! Only specify one of the kinds of values. !! @param[in] key some text to add to the list. - !! @param[in] text_value_in a text value to add to the list. - !! @param[in] int_value_in an integer value to add to the list. - !! @param[in] float_value_in a float value to add to the list. - !! @param[in] bool_value_in a bool value to add to the list. + !! @param[in] text_value_in a text value to add to the list (optional). + !! @param[in] int_value_in an integer value to add to the list (optional). + !! @param[in] float_value_in a float value to add to the list (optional). + !! @param[in] bool_value_in a bool value to add to the list (optional). SUBROUTINE WriteListElement(key, text_value_in, int_value_in, float_value_in,& bool_value_in) !! Parameters diff --git a/Source/Fortran/MatrixGatherModule.f90 b/Source/Fortran/MatrixGatherModule.f90 index 5a51ec66..db9c45b7 100644 --- a/Source/Fortran/MatrixGatherModule.f90 +++ b/Source/Fortran/MatrixGatherModule.f90 @@ -56,15 +56,15 @@ MODULE MatrixGatherModule PUBLIC :: TestInnerRequest PUBLIC :: TestDataRequest CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> First we gather the sizes of the data to be sent. + !> The first routine to call, gathers the sizes of the data to be sent. !! @param[in] matrix to send. !! @param[inout] communicator to send along. !! @param[inout] helper a helper associated with this gather. SUBROUTINE GatherSizes(matrix, communicator, helper) !! Parameters - TYPE(SparseMatrix_t), INTENT(in) :: matrix - INTEGER, INTENT(inout) :: communicator - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(SparseMatrix_t), INTENT(IN) :: matrix + INTEGER, INTENT(INOUT) :: communicator + TYPE(GatherHelper_t), INTENT(INOUT) :: helper !! Local Data INTEGER :: grid_error @@ -77,17 +77,18 @@ SUBROUTINE GatherSizes(matrix, communicator, helper) & helper%size_request, grid_error) END SUBROUTINE GatherSizes !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Next we gather the data. + !> Second function to call, will gather the data and align it one matrix + !! next to another. !! @param[in] matrix to send. !! @param[inout] communicator to send along. !! @param[inout] gathered_matrix the matrix we are gathering. !! @param[inout] helper a helper associated with this gather. SUBROUTINE GatherAndComposeData(matrix,communicator,gathered_matrix,helper) !! Parameters - TYPE(SparseMatrix_t), INTENT(in) :: matrix - INTEGER, INTENT(inout) :: communicator - TYPE(SparseMatrix_t), INTENT(inout) :: gathered_matrix - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(SparseMatrix_t), INTENT(IN) :: matrix + INTEGER, INTENT(INOUT) :: communicator + TYPE(SparseMatrix_t), INTENT(INOUT) :: gathered_matrix + TYPE(GatherHelper_t), INTENT(INOUT) :: helper !! Local Data INTEGER :: grid_error INTEGER :: counter @@ -124,15 +125,15 @@ SUBROUTINE GatherAndComposeData(matrix,communicator,gathered_matrix,helper) & grid_error) END SUBROUTINE GatherAndComposeData !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Finally we finish setting up the matrices are communication is done. + !> Third functiont o call, finishes setting up the matrices. !! @param[in] matrix to send. !! @param[in] gathered_matrix matrix we are gathering. !! @param[inout] helper a helper associated with this gather. PURE SUBROUTINE GatherAndComposeCleanup(matrix, gathered_matrix, helper) !! Parameters - TYPE(SparseMatrix_t), INTENT(in) :: matrix - TYPE(SparseMatrix_t), INTENT(inout) :: gathered_matrix - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(SparseMatrix_t), INTENT(IN) :: matrix + TYPE(SparseMatrix_t), INTENT(INOUT) :: gathered_matrix + TYPE(GatherHelper_t), INTENT(INOUT) :: helper !! Local Data INTEGER :: counter, inner_counter INTEGER :: temp_offset @@ -150,15 +151,15 @@ PURE SUBROUTINE GatherAndComposeCleanup(matrix, gathered_matrix, helper) DEALLOCATE(helper%displacement) END SUBROUTINE GatherAndComposeCleanup !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Next we gather the data. + !> Second routine to call for gathering and summing up the data. !! @param[in] matrix to send. !! @param[inout] communicator to send along. !! @param[inout] helper a helper associated with this gather. SUBROUTINE GatherAndSumData(matrix,communicator,helper) !! Parameters - TYPE(SparseMatrix_t), INTENT(in) :: matrix - INTEGER, INTENT(inout) :: communicator - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(SparseMatrix_t), INTENT(IN) :: matrix + INTEGER, INTENT(INOUT) :: communicator + TYPE(GatherHelper_t), INTENT(INOUT) :: helper !! Local Data INTEGER :: grid_error INTEGER :: counter @@ -193,17 +194,17 @@ SUBROUTINE GatherAndSumData(matrix,communicator,helper) & communicator, helper%outer_request, grid_error) END SUBROUTINE GatherAndSumData !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Finally we sum up the matrices are communication is done. + !> Finally routine to sum up the matrices. !! @param[in] matrix to send. !! @param[inout] gathered_matrix the matrix being gathered. !! @param[in] threshold the threshold for flushing values. !! @param[inout] helper a helper associated with this gather. PURE SUBROUTINE GatherAndSumCleanup(matrix,gathered_matrix, threshold, helper) !! Parameters - TYPE(SparseMatrix_t), INTENT(in) :: matrix - TYPE(SparseMatrix_t), INTENT(inout) :: gathered_matrix - REAL(NTREAL), INTENT(in) :: threshold - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(SparseMatrix_t), INTENT(IN) :: matrix + TYPE(SparseMatrix_t), INTENT(INOUT) :: gathered_matrix + REAL(NTREAL), INTENT(IN) :: threshold + TYPE(GatherHelper_t), INTENT(INOUT) :: helper !! Local Data TYPE(SparseMatrix_t) :: temporary_matrix INTEGER :: counter @@ -249,7 +250,7 @@ END SUBROUTINE GatherAndSumCleanup !! @return request_completed true if the request is finished. FUNCTION TestSizeRequest(helper) RESULT(request_completed) !! Parameters - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(GatherHelper_t), INTENT(INOUT) :: helper LOGICAL :: request_completed CALL MPI_Test(helper%size_request, request_completed, & @@ -261,7 +262,7 @@ END FUNCTION TestSizeRequest !! @return request_completed true if the request is finished. FUNCTION TestOuterRequest(helper) RESULT(request_completed) !! Parameters - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(GatherHelper_t), INTENT(INOUT) :: helper LOGICAL :: request_completed CALL MPI_Test(helper%outer_request, request_completed, & @@ -273,7 +274,7 @@ END FUNCTION TestOuterRequest !! @return request_completed true if the request is finished. FUNCTION TestInnerRequest(helper) RESULT(request_completed) !! Parameters - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(GatherHelper_t), INTENT(INOUT) :: helper LOGICAL :: request_completed CALL MPI_Test(helper%inner_request, request_completed, & @@ -285,7 +286,7 @@ END FUNCTION TestInnerRequest !! @return request_completed true if the request is finished. FUNCTION TestDataRequest(helper) RESULT(request_completed) !! Parameters - TYPE(GatherHelper_t), INTENT(inout) :: helper + TYPE(GatherHelper_t), INTENT(INOUT) :: helper LOGICAL :: request_completed CALL MPI_Test(helper%data_request, request_completed, & diff --git a/Source/Fortran/MinimizerSolversModule.f90 b/Source/Fortran/MinimizerSolversModule.f90 index 15c4b0ac..4a8f5d01 100644 --- a/Source/Fortran/MinimizerSolversModule.f90 +++ b/Source/Fortran/MinimizerSolversModule.f90 @@ -25,18 +25,17 @@ MODULE MinimizerSolversModule !! @param[in] InverseSquareRoot of the overlap matrix. !! @param[in] nel the number of electrons. !! @param[out] Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] solver_parameters_in parameters for the solver - !! @todo chemical potential doesn't work. + !! @param[out] chemical_potential_out the chemical potential (optional). + !! @param[in] solver_parameters_in parameters for the solver. SUBROUTINE ConjugateGradient(Hamiltonian, InverseSquareRoot, nel, Density, & & chemical_potential_out, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: Hamiltonian, & - & InverseSquareRoot - INTEGER, INTENT(in) :: nel - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: Density + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: Hamiltonian + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InverseSquareRoot + INTEGER, INTENT(IN) :: nel + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: Density REAL(NTREAL), INTENT(out), OPTIONAL :: chemical_potential_out - TYPE(IterativeSolverParameters_t), INTENT(in), OPTIONAL :: & + TYPE(IterativeSolverParameters_t), INTENT(IN), OPTIONAL :: & & solver_parameters_in !! Handling Optional Parameters TYPE(IterativeSolverParameters_t) :: solver_parameters diff --git a/Source/Fortran/RootSolversModule.f90 b/Source/Fortran/RootSolversModule.f90 index 197af35c..ac7acc9b 100644 --- a/Source/Fortran/RootSolversModule.f90 +++ b/Source/Fortran/RootSolversModule.f90 @@ -30,10 +30,10 @@ MODULE RootSolversModule !! @param[in] solver_parameters_in parameters for the solver (optional). SUBROUTINE ComputeRoot(InputMat, OutputMat, root, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - INTEGER, INTENT(in) :: root - TYPE(IterativeSolverParameters_t), INTENT(in), OPTIONAL :: & + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + INTEGER, INTENT(IN) :: root + TYPE(IterativeSolverParameters_t), INTENT(IN), OPTIONAL :: & & solver_parameters_in !! Handling Solver Parameters TYPE(IterativeSolverParameters_t) :: solver_parameters @@ -79,7 +79,7 @@ SUBROUTINE ComputeRoot(InputMat, OutputMat, root, solver_parameters_in) END SUBROUTINE ComputeRoot !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compute a general matrix root. + !> Actual implementation of computing a general matrix root. !! @param[in] InputMat the input matrix !! @param[out] OutputMat = InputMat^1/root. !! @param[in] root which root to compute. @@ -87,10 +87,10 @@ END SUBROUTINE ComputeRoot SUBROUTINE ComputeRootImplementation(InputMat, OutputMat, root, & & solver_parameters) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - INTEGER, INTENT(in) :: root - TYPE(IterativeSolverParameters_t), INTENT(in) :: solver_parameters + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + INTEGER, INTENT(IN) :: root + TYPE(IterativeSolverParameters_t), INTENT(IN) :: solver_parameters !! Handling Solver Parameters TYPE(FixedSolverParameters_t) :: fixed_parameters !! Local Variables @@ -133,13 +133,12 @@ END SUBROUTINE ComputeRootImplementation !! @param[out] OutputMat = InputMat^-1/root. !! @param[in] root which root to compute. !! @param[in] solver_parameters_in parameters for the solver (optional). - !! @todo the inverse cube root. SUBROUTINE ComputeInverseRoot(InputMat, OutputMat, root, solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - INTEGER, INTENT(in) :: root - TYPE(IterativeSolverParameters_t), INTENT(in), OPTIONAL :: & + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + INTEGER, INTENT(IN) :: root + TYPE(IterativeSolverParameters_t), INTENT(IN), OPTIONAL :: & & solver_parameters_in !! Handling Solver Parameters TYPE(IterativeSolverParameters_t) :: solver_parameters @@ -184,14 +183,13 @@ SUBROUTINE ComputeInverseRoot(InputMat, OutputMat, root, solver_parameters_in) END SUBROUTINE ComputeInverseRoot !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute a general inverse matrix root for root > 4. - !! Implementation details... SUBROUTINE ComputeInverseRootImplemention(InputMat, OutputMat, root, & & solver_parameters_in) !! Parameters - TYPE(DistributedSparseMatrix_t), INTENT(in) :: InputMat - TYPE(DistributedSparseMatrix_t), INTENT(inout) :: OutputMat - INTEGER, INTENT(in) :: root - TYPE(IterativeSolverParameters_t), INTENT(in), OPTIONAL :: & + TYPE(DistributedSparseMatrix_t), INTENT(IN) :: InputMat + TYPE(DistributedSparseMatrix_t), INTENT(INOUT) :: OutputMat + INTEGER, INTENT(IN) :: root + TYPE(IterativeSolverParameters_t), INTENT(IN), OPTIONAL :: & & solver_parameters_in REAL(NTREAL), PARAMETER :: NEGATIVE_ONE = -1.0 !! Handling Solver Parameters diff --git a/Source/Fortran/SignSolversModule.f90 b/Source/Fortran/SignSolversModule.f90 index 645ab90f..523e320c 100644 --- a/Source/Fortran/SignSolversModule.f90 +++ b/Source/Fortran/SignSolversModule.f90 @@ -56,7 +56,7 @@ END SUBROUTINE SignFunction !> Computes the polar decomposition of a matrix Mat1 = U*H. !! @param[in] Mat1 the input matrix. !! @param[out] Umat the unitary polar factor. - !! @param[out] Hmat (optional) the hermitian matrix factor. + !! @param[out] Hmat the hermitian matrix factor (optional). !! @param[in] solver_parameters_in optional parameters for the routine. SUBROUTINE PolarDecomposition(Mat1, Umat, Hmat, solver_parameters_in) !! Parameters @@ -98,6 +98,8 @@ SUBROUTINE PolarDecomposition(Mat1, Umat, Hmat, solver_parameters_in) END IF END SUBROUTINE PolarDecomposition !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !> This is the implementation routine for both the sign function and + !! polar decomposition. SUBROUTINE CoreComputation(Mat1, OutMat, solver_parameters, needs_transpose) !! Parameters TYPE(DistributedSparseMatrix_t), INTENT(IN) :: Mat1 diff --git a/Source/Fortran/SparseMatrixAlgebraModule.f90 b/Source/Fortran/SparseMatrixAlgebraModule.f90 index fb3c978f..b332f6c9 100644 --- a/Source/Fortran/SparseMatrixAlgebraModule.f90 +++ b/Source/Fortran/SparseMatrixAlgebraModule.f90 @@ -43,9 +43,8 @@ END SUBROUTINE ScaleSparseMatrix !! This will utilize the sparse vector addition routine. !! @param[in] matA Matrix A. !! @param[in,out] matB Matrix B. - !! @param[in] alpha_in multiplier. Optional, default is 1.0 - !! @param[in] threshold_in for flushing values to zero. Default value is 0.0. - !! @todo I don't like this hack where I have to check if MatrixB is allocated. + !! @param[in] alpha_in multiplier (optional, default=1.0) + !! @param[in] threshold_in for flushing values to zero. (Optional, default=0). PURE SUBROUTINE IncrementSparseMatrix(matA, matB, alpha_in, threshold_in) !! Parameters TYPE(SparseMatrix_t), INTENT(IN) :: matA @@ -203,11 +202,6 @@ END FUNCTION DotSparseMatrix !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Multiply two matrices together, and add to the third. !! C := alpha*matA*op( matB ) + beta*matC - !! This version is not really linear scaling, but it should be fast enough. - !! Basically, we create a big buffer region of zeros so that we can accumulate - !! in O(1) time. Then we scan over the buffer region and search for filled - !! values. For small enough matrices this is fine, but it definitely isn't - !! optimal. !! @param[in] matA Matrix A. !! @param[in] matB Matrix B. !! @param[out] matC = alpha*matA*op( matB ) + beta*matC. diff --git a/Source/Fortran/SparseMatrixIteratorModule.f90 b/Source/Fortran/SparseMatrixIteratorModule.f90 index bf73f575..392eab72 100644 --- a/Source/Fortran/SparseMatrixIteratorModule.f90 +++ b/Source/Fortran/SparseMatrixIteratorModule.f90 @@ -36,8 +36,8 @@ MODULE SparseMatrixIteratorModule !! @param[in] sparse_matrix the matrix to associate it with. PURE SUBROUTINE Start(this,sparse_matrix) !! Parameters - TYPE(SparseMatrixIterator_t), INTENT(inout) :: this - TYPE(SparseMatrix_t), INTENT(in) :: sparse_matrix + TYPE(SparseMatrixIterator_t), INTENT(INOUT) :: this + TYPE(SparseMatrix_t), INTENT(IN) :: sparse_matrix !! Set Inner Representation this%outer_counter = 1 @@ -57,13 +57,10 @@ END SUBROUTINE Start !> Gets the next element in a sparse matrix. !! @param[inout] this the sparse matrix iterator. !! @param[in] sparse_matrix the sparse matrix associated with the iterator. - !! @todo it's probably a pain to have to pass the sparse matrix here. But - !! Fortran's requirement that everything that is pointed to has the TARGET - !! attribute is problematic. PURE SUBROUTINE Next(this,sparse_matrix) !! Parameters - TYPE(SparseMatrixIterator_t), INTENT(inout) :: this - TYPE(SparseMatrix_t), INTENT(in) :: sparse_matrix + TYPE(SparseMatrixIterator_t), INTENT(INOUT) :: this + TYPE(SparseMatrix_t), INTENT(IN) :: sparse_matrix !! Update Inner Representation this%total_counter = this%total_counter + 1 diff --git a/Source/Fortran/SparseMatrixModule.f90 b/Source/Fortran/SparseMatrixModule.f90 index 4b91beb4..56ba8e44 100644 --- a/Source/Fortran/SparseMatrixModule.f90 +++ b/Source/Fortran/SparseMatrixModule.f90 @@ -184,8 +184,6 @@ PURE SUBROUTINE ConstructFromTripletList(this,triplet_list,rows,columns) END SUBROUTINE ConstructFromTripletList !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Explicitly destruct a sparse matrix. - !! This will always check if arrays are actually allocated, so you can feel - !! free to destruct a matrix even if it has no data. !! @param[inout] this the matrix to free up PURE SUBROUTINE DestructSparseMatrix(this) !! Parameters @@ -439,8 +437,6 @@ PURE SUBROUTINE MatrixToTripletList(this, triplet_list) END SUBROUTINE MatrixToTripletList !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Print out a sparse matrix. - !! We first create a triplet list, and then call the print triplet list - !! function. !! @param[in] this the matrix to be printed. !! @param[in] file_name_in optionally, you can pass a file to print to. SUBROUTINE PrintSparseMatrix(this, file_name_in) diff --git a/Source/Fortran/SparseVectorModule.f90 b/Source/Fortran/SparseVectorModule.f90 index 815bce70..65b8858a 100644 --- a/Source/Fortran/SparseVectorModule.f90 +++ b/Source/Fortran/SparseVectorModule.f90 @@ -29,15 +29,15 @@ MODULE SparseVectorModule PURE SUBROUTINE AddSparseVectors(inner_index_a,values_a,inner_index_b, & & values_b,inner_index_c,values_c,total_values_c, alpha_in, threshold_in) !! Parameters - INTEGER, DIMENSION(:), INTENT(in) :: inner_index_a - INTEGER, DIMENSION(:), INTENT(in) :: inner_index_b - INTEGER, DIMENSION(:), INTENT(out) :: inner_index_c - REAL(NTREAL), DIMENSION(:), INTENT(in) :: values_a - REAL(NTREAL), DIMENSION(:), INTENT(in) :: values_b - REAL(NTREAL), DIMENSION(:), INTENT(out) :: values_c - REAL(NTREAL), OPTIONAL, INTENT(in) :: alpha_in - REAL(NTREAL), OPTIONAL, INTENT(in) :: threshold_in - INTEGER, INTENT(out) :: total_values_c + INTEGER, DIMENSION(:), INTENT(IN) :: inner_index_a + INTEGER, DIMENSION(:), INTENT(IN) :: inner_index_b + INTEGER, DIMENSION(:), INTENT(OUT) :: inner_index_c + REAL(NTREAL), DIMENSION(:), INTENT(IN) :: values_a + REAL(NTREAL), DIMENSION(:), INTENT(IN) :: values_b + REAL(NTREAL), DIMENSION(:), INTENT(OUT) :: values_c + REAL(NTREAL), OPTIONAL, INTENT(IN) :: alpha_in + REAL(NTREAL), OPTIONAL, INTENT(IN) :: threshold_in + INTEGER, INTENT(OUT) :: total_values_c !! Local Data REAL(NTREAL) :: alpha REAL(NTREAL) :: threshold @@ -120,10 +120,10 @@ END SUBROUTINE AddSparseVectors PURE FUNCTION DotSparseVectors(inner_index_a,values_a,inner_index_b, & & values_b) RESULT(product) !! Parameters - INTEGER, DIMENSION(:), INTENT(in) :: inner_index_a - INTEGER, DIMENSION(:), INTENT(in) :: inner_index_b - REAL(NTREAL), DIMENSION(:), INTENT(in) :: values_a - REAL(NTREAL), DIMENSION(:), INTENT(in) :: values_b + INTEGER, DIMENSION(:), INTENT(IN) :: inner_index_a + INTEGER, DIMENSION(:), INTENT(IN) :: inner_index_b + REAL(NTREAL), DIMENSION(:), INTENT(IN) :: values_a + REAL(NTREAL), DIMENSION(:), INTENT(IN) :: values_b REAL(NTREAL) :: product !! Temporary Variables INTEGER :: working_index_a, working_index_b @@ -166,13 +166,13 @@ END FUNCTION DotSparseVectors PURE SUBROUTINE PairwiseMultiplyVectors(inner_index_a,values_a,inner_index_b, & & values_b,inner_index_c,values_c,total_values_c) !! Parameters - INTEGER, DIMENSION(:), INTENT(in) :: inner_index_a - INTEGER, DIMENSION(:), INTENT(in) :: inner_index_b - INTEGER, DIMENSION(:), INTENT(out) :: inner_index_c - REAL(NTREAL), DIMENSION(:), INTENT(in) :: values_a - REAL(NTREAL), DIMENSION(:), INTENT(in) :: values_b - REAL(NTREAL), DIMENSION(:), INTENT(out) :: values_c - INTEGER, INTENT(out) :: total_values_c + INTEGER, DIMENSION(:), INTENT(IN) :: inner_index_a + INTEGER, DIMENSION(:), INTENT(IN) :: inner_index_b + INTEGER, DIMENSION(:), INTENT(OUT) :: inner_index_c + REAL(NTREAL), DIMENSION(:), INTENT(IN) :: values_a + REAL(NTREAL), DIMENSION(:), INTENT(IN) :: values_b + REAL(NTREAL), DIMENSION(:), INTENT(OUT) :: values_c + INTEGER, INTENT(OUT) :: total_values_c !! Temporary Variables INTEGER :: working_index_a, working_index_b REAL(NTREAL) :: working_value_a, working_value_b diff --git a/Source/Fortran/SquareRootSolversModule.f90 b/Source/Fortran/SquareRootSolversModule.f90 index 2ab1c411..5f53ca37 100644 --- a/Source/Fortran/SquareRootSolversModule.f90 +++ b/Source/Fortran/SquareRootSolversModule.f90 @@ -54,10 +54,7 @@ SUBROUTINE InverseSquareRoot(InputMat, OutputMat, solver_parameters_in) END SUBROUTINE InverseSquareRoot !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the square root or inverse square root of a matrix. - !! Based on the Newton-Schultz algorithm presented in: - !! Jansík, Branislav, Stinne Høst, Poul Jørgensen, Jeppe Olsen, and - !! Trygve Helgaker. "Linear-scaling symmetric square-root decomposition of the - !! overlap matrix." The Journal of chemical physics 126, no. 12 (2007): 124104. + !! Based on the Newton-Schultz algorithm presented in: \cite jansik2007linear !! @param[in] Mat1 Matrix 1. !! @param[out] InverseSquareRootMat = Mat1^-1/2. !! @param[in] solver_parameters_in parameters for the solver diff --git a/Source/Fortran/TimerModule.f90 b/Source/Fortran/TimerModule.f90 index 45d9fac3..0958bcdb 100644 --- a/Source/Fortran/TimerModule.f90 +++ b/Source/Fortran/TimerModule.f90 @@ -19,7 +19,6 @@ MODULE TimerModule PUBLIC :: PrintAllTimersDistributed CONTAINS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Register a timer with the timer module. Call this before using that timer. - !! Basically this adds a timer with that name to the dictionary. !! @param[in] timer_name name of the timer. SUBROUTINE RegisterTimer(timer_name) !! Parameters @@ -106,7 +105,7 @@ SUBROUTINE PrintTimer(timer_name) CALL ExitSubLog END SUBROUTINE PrintTimer !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Print out the elapsed time for each timer + !> Print out the elapsed time for each timer on this process. SUBROUTINE PrintAllTimers() !! Local Data INTEGER :: timer_position @@ -120,7 +119,8 @@ SUBROUTINE PrintAllTimers() CALL ExitSubLog END SUBROUTINE PrintAllTimers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Print out the elapsed time for each timer + !> Print out the elapsed time for each timer based on the max value across + !! processes. SUBROUTINE PrintAllTimersDistributed() !! Local Data INTEGER :: timer_position diff --git a/Source/Fortran/TripletListModule.f90 b/Source/Fortran/TripletListModule.f90 index cb00df7d..75ba6d95 100644 --- a/Source/Fortran/TripletListModule.f90 +++ b/Source/Fortran/TripletListModule.f90 @@ -1,6 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A Module For Storing Lists of triplets. -!! Contains both a methods for sorting lists. MODULE TripletListModule USE DataTypesModule, ONLY : NTREAL, MPINTREAL USE MatrixMarketModule @@ -32,7 +31,7 @@ MODULE TripletListModule CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct a triplet list. !! @param[inout] this the triplet list to construct. - !! @param[in] size_in the length of the triplet list. + !! @param[in] size_in the length of the triplet list (optional, default=0). PURE SUBROUTINE ConstructTripletList(this,size_in) !! Parameters TYPE(TripletList_t), INTENT(INOUT) :: this @@ -129,7 +128,7 @@ PURE SUBROUTINE SetTripletAt(this,index,triplet_value) END SUBROUTINE SetTripletAt !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the value of a triplet at a particular index. - !! @param[in] this the triplet list to get teh value from. + !! @param[in] this the triplet list to get the value from. !! @param[in] index the index from which to get the triplet. !! @param[out] triplet_value the extracted triplet value. PURE SUBROUTINE GetTripletAt(this,index,triplet_value) diff --git a/Source/Fortran/TripletModule.f90 b/Source/Fortran/TripletModule.f90 index 78db2618..a033d7ca 100644 --- a/Source/Fortran/TripletModule.f90 +++ b/Source/Fortran/TripletModule.f90 @@ -1,6 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A Module For Storing Triplets of Integer, Integer, Double. -!! Contains a class Triplet and a means to compare them. MODULE TripletModule USE DataTypesModule, ONLY: NTREAL, MPINTREAL USE ErrorModule @@ -37,10 +36,10 @@ MODULE TripletModule !! @param[in] point_value the value at that point. PURE SUBROUTINE SetTriplet(this,index_column,index_row,point_value) !! Parameters - TYPE(Triplet_t), INTENT(inout) :: this - INTEGER, INTENT(in) :: index_column - INTEGER, INTENT(in) :: index_row - REAL(NTREAL), INTENT(in) :: point_value + TYPE(Triplet_t), INTENT(INOUT) :: this + INTEGER, INTENT(IN) :: index_column + INTEGER, INTENT(IN) :: index_row + REAL(NTREAL), INTENT(IN) :: point_value this%index_column = index_column this%index_row = index_row @@ -54,24 +53,25 @@ END SUBROUTINE SetTriplet !! @param[out] point_value actual stored value. PURE SUBROUTINE GetTripletValues(this,index_column,index_row,point_value) !! Parameters - TYPE(Triplet_t), INTENT(in) :: this - INTEGER, INTENT(out) :: index_column - INTEGER, INTENT(out) :: index_row - REAL(NTREAL), INTENT(out) :: point_value + TYPE(Triplet_t), INTENT(IN) :: this + INTEGER, INTENT(OUT) :: index_column + INTEGER, INTENT(OUT) :: index_row + REAL(NTREAL), INTENT(OUT) :: point_value index_column = this%index_column index_row = this%index_row point_value = this%point_value END SUBROUTINE GetTripletValues !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compare two triplets based on their index values. Returns A < B. + !> Compare two triplets based on their index values, first by column and + !! second by row. Returns A < B. !! Used for sorting. !! @param[in] tripA first triplet. !! @param[in] tripB second triplet. !! @return A < B. PURE FUNCTION CompareTriplets(tripA, tripB) RESULT(islessthan) !! Parameters - TYPE(Triplet_t), INTENT(in) :: tripA, tripB + TYPE(Triplet_t), INTENT(IN) :: tripA, tripB LOGICAL :: islessthan IF (tripA%index_column .GT. tripB%index_column) THEN diff --git a/Source/Wrapper/ChebyshevSolversModule_wrp.f90 b/Source/Wrapper/ChebyshevSolversModule_wrp.f90 index 7fd179f0..32bdd652 100644 --- a/Source/Wrapper/ChebyshevSolversModule_wrp.f90 +++ b/Source/Wrapper/ChebyshevSolversModule_wrp.f90 @@ -15,7 +15,6 @@ MODULE ChebyshevSolversModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the polynomial data type. TYPE, PUBLIC :: ChebyshevPolynomial_wrp - !> Actual data. TYPE(ChebyshevPolynomial_t), POINTER :: DATA END TYPE ChebyshevPolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -27,12 +26,10 @@ MODULE ChebyshevSolversModule_wrp PUBLIC :: ChebyshevCompute_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the empty polynomial constructor. - !! @param[out] ih_this handle to the polynomial being created. - !! @param[in] degree the degree of the polynomial. PURE SUBROUTINE ConstructChebyshevPolynomial_wrp(ih_this, degree) & & bind(c,name="ConstructChebyshevPolynomial_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: degree + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: degree TYPE(ChebyshevPolynomial_wrp) :: h_this ALLOCATE(h_this%data) @@ -41,10 +38,9 @@ PURE SUBROUTINE ConstructChebyshevPolynomial_wrp(ih_this, degree) & END SUBROUTINE ConstructChebyshevPolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Destruct a polynomial object. - !! @param[inout] ih_this handle to the polynomial to free up. PURE SUBROUTINE DestructChebyshevPolynomial_wrp(ih_this) & & bind(c,name="DestructChebyshevPolynomial_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) TYPE(ChebyshevPolynomial_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -53,14 +49,11 @@ PURE SUBROUTINE DestructChebyshevPolynomial_wrp(ih_this) & END SUBROUTINE DestructChebyshevPolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set coefficient of a polynomial. - !! @param[inout] ih_this handle to the polynomial to set. - !! @param[in] degree for which to set the coefficient. - !! @param[in] coefficient value. SUBROUTINE SetChebyshevCoefficient_wrp(ih_this, degree, coefficient) & & bind(c,name="SetChebyshevCoefficient_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: degree - REAL(NTREAL), INTENT(in) :: coefficient + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: degree + REAL(NTREAL), INTENT(IN) :: coefficient TYPE(ChebyshevPolynomial_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -68,16 +61,12 @@ SUBROUTINE SetChebyshevCoefficient_wrp(ih_this, degree, coefficient) & END SUBROUTINE SetChebyshevCoefficient_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute A Matrix Chebyshev Polynomial. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = poly(InputMat) - !! @param[in] ih_polynomial polynomial to compute. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE ChebyshevCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & & ih_solver_parameters) bind(c,name="ChebyshevCompute_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_polynomial(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_polynomial(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(ChebyshevPolynomial_wrp) :: h_polynomial @@ -93,17 +82,13 @@ SUBROUTINE ChebyshevCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & END SUBROUTINE ChebyshevCompute_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute A Matrix Chebyshev Polynomial By Factorization. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = poly(InputMat) - !! @param[in] ih_polynomial polynomial to compute. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE FactorizedChebyshevCompute_wrp(ih_InputMat, ih_OutputMat, & & ih_polynomial, ih_solver_parameters) & & bind(c,name="FactorizedChebyshevCompute_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_polynomial(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_polynomial(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(ChebyshevPolynomial_wrp) :: h_polynomial diff --git a/Source/Wrapper/DensityMatrixSolversModule_wrp.f90 b/Source/Wrapper/DensityMatrixSolversModule_wrp.f90 index 8a80e871..0102b280 100644 --- a/Source/Wrapper/DensityMatrixSolversModule_wrp.f90 +++ b/Source/Wrapper/DensityMatrixSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the density matrix solvers module for calling from other languages. MODULE DensityMatrixSolversModule_wrp USE DataTypesModule, ONLY : NTREAL USE DensityMatrixSolversModule, ONLY : TRS2, TRS4, HPCP @@ -17,22 +17,15 @@ MODULE DensityMatrixSolversModule_wrp ! PUBLIC :: HPCPPlus_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the density matrix from a Hamiltonian using the TRS2 method. - !! @param[in] ih_Hamiltonian the matrix to compute the corresponding density - !! from. - !! @param[in] ih_InverseSquareRoot of the overlap matrix. - !! @param[in] nel the number of electrons. - !! @param[out] ih_Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE TRS2_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & & nel, ih_Density, chemical_potential_out, ih_solver_parameters) & & bind(c,name="TRS2_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Hamiltonian(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_InverseSquareRoot(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: nel - INTEGER(kind=c_int), INTENT(inout) :: ih_Density(SIZE_wrp) - REAL(NTREAL), INTENT(out) :: chemical_potential_out - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Hamiltonian(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InverseSquareRoot(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: nel + INTEGER(kind=c_int), INTENT(INOUT) :: ih_Density(SIZE_wrp) + REAL(NTREAL), INTENT(OUT) :: chemical_potential_out + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Hamiltonian TYPE(DistributedSparseMatrix_wrp) :: h_InverseSquareRoot TYPE(DistributedSparseMatrix_wrp) :: h_Density @@ -48,22 +41,15 @@ SUBROUTINE TRS2_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & END SUBROUTINE TRS2_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the density matrix from a Hamiltonian using the TRS4 method. - !! @param[in] ih_Hamiltonian the matrix to compute the corresponding density - !! from. - !! @param[in] ih_InverseSquareRoot of the overlap matrix. - !! @param[in] nel the number of electrons. - !! @param[out] ih_Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE TRS4_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & & nel, ih_Density, chemical_potential_out, ih_solver_parameters) & & bind(c,name="TRS4_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Hamiltonian(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_InverseSquareRoot(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: nel - INTEGER(kind=c_int), INTENT(inout) :: ih_Density(SIZE_wrp) - REAL(NTREAL), INTENT(out) :: chemical_potential_out - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Hamiltonian(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InverseSquareRoot(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: nel + INTEGER(kind=c_int), INTENT(INOUT) :: ih_Density(SIZE_wrp) + REAL(NTREAL), INTENT(OUT) :: chemical_potential_out + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Hamiltonian TYPE(DistributedSparseMatrix_wrp) :: h_InverseSquareRoot TYPE(DistributedSparseMatrix_wrp) :: h_Density @@ -79,21 +65,15 @@ SUBROUTINE TRS4_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & END SUBROUTINE TRS4_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the density matrix from a Hamiltonian using the HPCP method. - !! @param[in] ih_Hamiltonian the matrix to compute the corresponding density. - !! @param[in] ih_InverseSquareRoot of the overlap matrix. - !! @param[in] nel the number of electrons. - !! @param[out] ih_Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE HPCP_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & & nel, ih_Density, chemical_potential_out, ih_solver_parameters) & & bind(c,name="HPCP_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Hamiltonian(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_InverseSquareRoot(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: nel - INTEGER(kind=c_int), INTENT(inout) :: ih_Density(SIZE_wrp) - REAL(NTREAL), INTENT(out) :: chemical_potential_out - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Hamiltonian(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InverseSquareRoot(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: nel + INTEGER(kind=c_int), INTENT(INOUT) :: ih_Density(SIZE_wrp) + REAL(NTREAL), INTENT(OUT) :: chemical_potential_out + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Hamiltonian TYPE(DistributedSparseMatrix_wrp) :: h_InverseSquareRoot TYPE(DistributedSparseMatrix_wrp) :: h_Density @@ -107,34 +87,4 @@ SUBROUTINE HPCP_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & CALL HPCP(h_Hamiltonian%data, h_InverseSquareRoot%data, nel, & & h_Density%data, chemical_potential_out, h_solver_parameters%data) END SUBROUTINE HPCP_wrp -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compute the density matrix from a Hamiltonian using the HPCP method. - !! @param[in] ih_Hamiltonian the matrix to compute the corresponding density. - !! @param[in] ih_InverseSquareRoot of the overlap matrix. - !! @param[in] nel the number of electrons. - !! @param[out] ih_Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] ih_solver_parameters parameters for the solver - ! SUBROUTINE HPCPPlus_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & - ! & nel, ih_Density, chemical_potential_out, ih_solver_parameters) & - ! & bind(c,name="HPCPPlus_wrp") - ! INTEGER(kind=c_int), INTENT(in) :: ih_Hamiltonian(SIZE_wrp) - ! INTEGER(kind=c_int), INTENT(in) :: ih_InverseSquareRoot(SIZE_wrp) - ! INTEGER(kind=c_int), INTENT(in) :: nel - ! INTEGER(kind=c_int), INTENT(inout) :: ih_Density(SIZE_wrp) - ! REAL(NTREAL), INTENT(out) :: chemical_potential_out - ! INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) - ! TYPE(DistributedSparseMatrix_wrp) :: h_Hamiltonian - ! TYPE(DistributedSparseMatrix_wrp) :: h_InverseSquareRoot - ! TYPE(DistributedSparseMatrix_wrp) :: h_Density - ! TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters - ! - ! h_Hamiltonian = TRANSFER(ih_Hamiltonian,h_Hamiltonian) - ! h_InverseSquareRoot = TRANSFER(ih_InverseSquareRoot,h_InverseSquareRoot) - ! h_Density = TRANSFER(ih_Density,h_Density) - ! h_solver_parameters = TRANSFER(ih_solver_parameters, h_solver_parameters) - ! - ! CALL HPCPPlus(h_Hamiltonian%data, h_InverseSquareRoot%data, nel, & - ! & h_Density%data, chemical_potential_out, h_solver_parameters%data) - ! END SUBROUTINE HPCPPlus_wrp END MODULE DensityMatrixSolversModule_wrp diff --git a/Source/Wrapper/DistributedMatrixMemoryPoolModule_wrp.f90 b/Source/Wrapper/DistributedMatrixMemoryPoolModule_wrp.f90 index 30efd9d7..34dd66b3 100644 --- a/Source/Wrapper/DistributedMatrixMemoryPoolModule_wrp.f90 +++ b/Source/Wrapper/DistributedMatrixMemoryPoolModule_wrp.f90 @@ -11,7 +11,6 @@ MODULE DistributedMatrixMemoryPoolModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrapper for the distributed matrix memory pool type TYPE, PUBLIC :: DistributedMatrixMemoryPool_wrp - !> Actual data. TYPE(DistributedMatrixMemoryPool_t), POINTER :: data END TYPE DistributedMatrixMemoryPool_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -19,7 +18,6 @@ MODULE DistributedMatrixMemoryPoolModule_wrp PUBLIC :: DestructDistributedMatrixMemoryPool_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct Distributed Matrix Memory Pool object. - !> @param[out] ih_this to a constructed Matrix Memory Pool object. PURE SUBROUTINE ConstructDistributedMatrixMemoryPool_wrp(ih_this) & & bind(c,name="ConstructDistributedMatrixMemoryPool_wrp") !! Parameters @@ -32,7 +30,6 @@ PURE SUBROUTINE ConstructDistributedMatrixMemoryPool_wrp(ih_this) & END SUBROUTINE ConstructDistributedMatrixMemoryPool_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Destruct a permutation object. - !! @param[inout] ih_this handle to the permutation to destruct. PURE SUBROUTINE DestructDistributedMatrixMemoryPool_wrp(ih_this) & & bind(c,name="DestructDistributedMatrixMemoryPool_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) diff --git a/Source/Wrapper/DistributedSparseMatrixModule_wrp.f90 b/Source/Wrapper/DistributedSparseMatrixModule_wrp.f90 index ba11b433..cd48f685 100644 --- a/Source/Wrapper/DistributedSparseMatrixModule_wrp.f90 +++ b/Source/Wrapper/DistributedSparseMatrixModule_wrp.f90 @@ -13,9 +13,8 @@ MODULE DistributedSparseMatrixModule_wrp IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> A wrapper for the sparse matrix data type. + !> A wrapper for the distributed sparse matrix data type. TYPE, PUBLIC :: DistributedSparseMatrix_wrp - !> Actual data. TYPE(DistributedSparseMatrix_t), POINTER :: DATA END TYPE DistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -43,8 +42,6 @@ MODULE DistributedSparseMatrixModule_wrp PUBLIC :: TransposeDistributedSparseMatrix_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the constructor of an empty sparse, distributed, matrix. - !! @param[inout] ih_this the matrix to be constructed. - !! @param[in] matrix_dim the dimension of the full matrix. PURE SUBROUTINE ConstructEmptyDistributedSparseMatrix_wrp(ih_this,matrix_dim) & & bind(c,name="ConstructEmptyDistributedSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -57,9 +54,6 @@ PURE SUBROUTINE ConstructEmptyDistributedSparseMatrix_wrp(ih_this,matrix_dim) & END SUBROUTINE ConstructEmptyDistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct distributed sparse matrix from a matrix market file in parallel. - !! @param[out] ih_this the file being constructed. - !! @param[in] file_name name of the file to read. - !! @param[in] name_size the number of characters in the file name. SUBROUTINE ConstructFromMatrixMarket_wrp(ih_this,file_name,name_size) & & bind(c,name="ConstructFromMatrixMarket_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -80,9 +74,6 @@ SUBROUTINE ConstructFromMatrixMarket_wrp(ih_this,file_name,name_size) & END SUBROUTINE ConstructFromMatrixMarket_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct a distributed sparse matrix from a binary file in parallel. - !! @param[out] ih_this the file being constructed. - !! @param[in] file_name name of the file to read. - !! @param[in] name_size the number of characters in the file name. SUBROUTINE ConstructFromBinary_wrp(ih_this,file_name,name_size) & & bind(c,name="ConstructFromBinary_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -103,8 +94,6 @@ SUBROUTINE ConstructFromBinary_wrp(ih_this,file_name,name_size) & END SUBROUTINE ConstructFromBinary_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Copy a distributed sparse matrix in a safe way. - !! @param[in] ih_matA matrix to copy - !! @param[inout] ih_matB = matA PURE SUBROUTINE CopyDistributedSparseMatrix_wrp(ih_matA,ih_matB) & & bind(c,name="CopyDistributedSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) @@ -118,7 +107,6 @@ PURE SUBROUTINE CopyDistributedSparseMatrix_wrp(ih_matA,ih_matB) & END SUBROUTINE CopyDistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Destruct a distributed sparse matrix - !! @param[in,out] ih_this the matrix to destruct PURE SUBROUTINE DestructDistributedSparseMatrix_wrp(ih_this) & & bind(c,name="DestructDistributedSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -131,9 +119,6 @@ PURE SUBROUTINE DestructDistributedSparseMatrix_wrp(ih_this) & END SUBROUTINE DestructDistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Save a distributed sparse matrix to a file. - !! @param[in] ih_this the Matrix to write. - !! @param[in] file_name name of the file to write to. - !! @param[in] name_size the number of characters in the file name. SUBROUTINE WriteToBinary_wrp(ih_this,file_name,name_size) & & bind(c,name="WriteToBinary_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -153,9 +138,6 @@ SUBROUTINE WriteToBinary_wrp(ih_this,file_name,name_size) & END SUBROUTINE WriteToBinary_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Save a distributed sparse matrix to a matrix market file. - !! @param[in] ih_this the Matrix to write. - !! @param[in] file_name name of the file to write to. - !! @param[in] name_size the number of characters in the file name. SUBROUTINE WriteToMatrixMarket_wrp(ih_this,file_name,name_size) & & bind(c,name="WriteToMatrixMarket_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -175,8 +157,6 @@ SUBROUTINE WriteToMatrixMarket_wrp(ih_this,file_name,name_size) & END SUBROUTINE WriteToMatrixMarket_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> This routine fills in a matrix based on local triplet lists. - !! @param[inout] ih_this the matrix being filled. - !! @param[in] ih_triplet_list the triplet list of values. SUBROUTINE FillFromTripletList_wrp(ih_this, ih_triplet_list) & & bind(c,name="FillFromTripletList_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -190,7 +170,6 @@ SUBROUTINE FillFromTripletList_wrp(ih_this, ih_triplet_list) & END SUBROUTINE FillFromTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Fill in the values of a distributed matrix with the identity matrix. - !! @param[inout] ih_this the matrix being filled. PURE SUBROUTINE FillDistributedIdentity_wrp(ih_this) & & bind(c,name="FillDistributedIdentity_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -201,9 +180,6 @@ PURE SUBROUTINE FillDistributedIdentity_wrp(ih_this) & END SUBROUTINE FillDistributedIdentity_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Fill in the values of a distributed matrix with a permutation matrix. - !! @param[inout] ih_this the matrix being filled. - !! @param[in] ih_permutation the perumutation to fill with. - !! @param[in] permute_rows whether to permute rows or columns. SUBROUTINE FillDistributedPermutation_wrp(ih_this, ih_permutation, & & permute_rows) bind(c,name="FillDistributedPermutation_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -220,8 +196,6 @@ SUBROUTINE FillDistributedPermutation_wrp(ih_this, ih_permutation, & END SUBROUTINE FillDistributedPermutation_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the Actual Dimension accessor. - !! @param[in] ih_this handle to the matrix. - !! @param[out] mat_dimension the size of the matrix. PURE SUBROUTINE GetActualDimension_wrp(ih_this, mat_dimension) & & bind(c,name="GetActualDimension_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -233,8 +207,6 @@ PURE SUBROUTINE GetActualDimension_wrp(ih_this, mat_dimension) & END SUBROUTINE GetActualDimension_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the Logical Dimension accessor. - !! @param[in] ih_this handle to the matrix. - !! @param[out] mat_dimension the size of the matrix. PURE SUBROUTINE GetLogicalDimension_wrp(ih_this, mat_dimension) & & bind(c,name="GetLogicalDimension_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -246,8 +218,6 @@ PURE SUBROUTINE GetLogicalDimension_wrp(ih_this, mat_dimension) & END SUBROUTINE GetLogicalDimension_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Extracts a triplet list of the data that is stored on this process. - !! @param[in] ih_this the distributed sparse matrix. - !! @param[inout] ih_triplet_list the list to fill. PURE SUBROUTINE GetTripletList_wrp(ih_this, ih_triplet_list) & & bind(c,name="GetTripletList_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -260,16 +230,7 @@ PURE SUBROUTINE GetTripletList_wrp(ih_this, ih_triplet_list) & CALL GetTripletList(h_this%data,h_triplet_list%data) END SUBROUTINE GetTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Extract an arbitrary block of a matrix into a triplet list. Block is - !! defined by the row/column start/end values. - !! This is slower than GetTripletList, because communication is required. - !! Data is returned with absolute coordinates. - !! @param[in] ih_this the distributed sparse matrix. - !! @param[inout] ih_triplet_list the list to fill. - !! @param[in] start_row the starting row for data to store on this process. - !! @param[in] end_row the ending row for data to store on this process - !! @param[in] start_column the starting col for data to store on this process. - !! @param[in] end_column the ending col for data to store on this process + !> Extract an arbitrary block of a matrix into a triplet list. SUBROUTINE GetMatrixBlock_wrp(ih_this, ih_triplet_list, start_row, & & end_row, start_column, end_column) bind(c,name="GetMatrixBlock_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -286,10 +247,6 @@ SUBROUTINE GetMatrixBlock_wrp(ih_this, ih_triplet_list, start_row, & END SUBROUTINE GetMatrixBlock_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Matrix B = alpha*Matrix A + Matrix B (AXPY) - !! @param[in] ih_matA Matrix A - !! @param[in,out] ih_matB Matrix B - !! @param[in] alpha_in multiplier. - !! @param[in] threshold_in for flushing values to zero. SUBROUTINE IncrementDistributedSparseMatrix_wrp(ih_matA, ih_matB,& & alpha_in,threshold_in) & & bind(c,name="IncrementDistributedSparseMatrix_wrp") @@ -307,9 +264,6 @@ SUBROUTINE IncrementDistributedSparseMatrix_wrp(ih_matA, ih_matB,& END SUBROUTINE IncrementDistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> product = dot(matA,matB) - !! @param[in] ih_matA Matrix A - !! @param[in] ih_matB Matrix B - !! @result product dot product of the two matrices FUNCTION DotDistributedSparseMatrix_wrp(ih_matA, ih_matB) RESULT(product)& & bind(c,name="DotDistributedSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) @@ -323,11 +277,7 @@ FUNCTION DotDistributedSparseMatrix_wrp(ih_matA, ih_matB) RESULT(product)& product = DotDistributedSparseMatrix(h_matA%data, h_matB%data) END FUNCTION DotDistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Elementwise multiplication. C_ij = A_ij * B_ij. Also known as a Hadamard - !! product. - !! @param[in] ih_matA Matrix A - !! @param[in] ih_matB Matrix B - !! @param[out] ih_matC = matA*matB + !> Elementwise multiplication. SUBROUTINE DistributedPairwiseMultiply_wrp(ih_matA, ih_matB, ih_matC) & & bind(c,name="DistributedPairwiseMultiply_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) @@ -345,14 +295,6 @@ SUBROUTINE DistributedPairwiseMultiply_wrp(ih_matA, ih_matB, ih_matC) & END SUBROUTINE DistributedPairwiseMultiply_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Multiply two matrices together, and add to the third. - !! @param[in] ih_matA Matrix A - !! @param[in] ih_matB Matrix B - !! @param[out] ih_matC = alpha*matA*matB + beta*matC - !! @param[in] alpha_in scales the multiplication - !! @param[in] beta_in scales matrix we sum on to - !! @param[in] threshold_in for flushing values to zero. - !! @param[inout] ih_memory_pool_in a memory pool that can be used for the - !! calculation. SUBROUTINE DistributedGemm_wrp(ih_matA, ih_matB, ih_matC, alpha_in, & & beta_in, threshold_in, ih_memory_pool_in) & & bind(c,name="DistributedGemm_wrp") @@ -378,8 +320,6 @@ SUBROUTINE DistributedGemm_wrp(ih_matA, ih_matB, ih_matC, alpha_in, & END SUBROUTINE DistributedGemm_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Will scale a distributed sparse matrix by a constant. - !! @param[inout] ih_this Matrix to scale. - !! @param[in] constant scale factor. SUBROUTINE ScaleDistributedSparseMatrix_wrp(ih_this, constant) & & bind(c,name="ScaleDistributedSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) @@ -391,8 +331,6 @@ SUBROUTINE ScaleDistributedSparseMatrix_wrp(ih_this, constant) & END SUBROUTINE ScaleDistributedSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the norm of a distributed sparse matrix along the rows. - !! @param[in] ih_this the matrix to compute the norm of. - !! @return the norm value of the full distributed sparse matrix. FUNCTION DistributedSparseNorm_wrp(ih_this) & & bind(c,name="DistributedSparseNorm_wrp") RESULT(norm_value) INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -404,8 +342,6 @@ FUNCTION DistributedSparseNorm_wrp(ih_this) & END FUNCTION DistributedSparseNorm_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the trace of the matrix. - !! @param[in] ih_this the matrix to compute the norm of. - !! @return the trace value of the full distributed sparse matrix. FUNCTION Trace_wrp(ih_this) & & bind(c,name="Trace_wrp") RESULT(trace_value) INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) @@ -417,8 +353,6 @@ FUNCTION Trace_wrp(ih_this) & END FUNCTION Trace_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Transpose a sparse matrix. - !! @param[in] ih_matA handle to matrix to transpose. - !! @param[inout] ih_transmat handle to the matrix transposed. SUBROUTINE TransposeDistributedSparseMatrix_wrp(ih_matA,ih_transmat) & & bind(c,name="TransposeDistributedSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) diff --git a/Source/Wrapper/EigenBoundsModule_wrp.f90 b/Source/Wrapper/EigenBoundsModule_wrp.f90 index 95cd303d..68e3fe7c 100644 --- a/Source/Wrapper/EigenBoundsModule_wrp.f90 +++ b/Source/Wrapper/EigenBoundsModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the matrix inversion module for calling from other languages. +!> Wraps the eigenbounds module for calling from other languages. MODULE EigenBoundsModule_wrp USE DataTypesModule, ONLY : NTREAL USE DistributedSparseMatrixModule_wrp, ONLY : & @@ -15,14 +15,11 @@ MODULE EigenBoundsModule_wrp PUBLIC :: PowerBounds_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute a bounds on the minimum and maximum eigenvalue of a matrix. - !! @param[in] ih_this Matrix. - !! @param[out] min_value min bounds on eigenspectrum. - !! @param[out] max_value max bounds on eigenspectrum. SUBROUTINE GershgorinBounds_wrp(ih_this, min_value,max_value) & & bind(c,name="GershgorinBounds_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - REAL(NTREAL), INTENT(inout) :: min_value - REAL(NTREAL), INTENT(inout) :: max_value + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + REAL(NTREAL), INTENT(INOUT) :: min_value + REAL(NTREAL), INTENT(INOUT) :: max_value TYPE(DistributedSparseMatrix_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -30,15 +27,12 @@ SUBROUTINE GershgorinBounds_wrp(ih_this, min_value,max_value) & CALL GershgorinBounds(h_this%data, min_value, max_value) END SUBROUTINE GershgorinBounds_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compute the largestest eigenvalue using the power method. - !! @param[in] ih_this Matrix. - !! @param[out] max_value max bounds on eigenspectrum. - !! @param[in] ih_solver_parameters parameters for the solver + !> Compute the largest eigenvalue using the power method. SUBROUTINE PowerBounds_wrp(ih_this, max_value, ih_solver_parameters) & & bind(c,name="PowerBounds_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - REAL(NTREAL), INTENT(inout) :: max_value - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + REAL(NTREAL), INTENT(INOUT) :: max_value + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_this TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters diff --git a/Source/Wrapper/ExponentialSolversModule_wrp.f90 b/Source/Wrapper/ExponentialSolversModule_wrp.f90 index db745a1e..77d503e0 100644 --- a/Source/Wrapper/ExponentialSolversModule_wrp.f90 +++ b/Source/Wrapper/ExponentialSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the exponential solvers module for calling from other languages. MODULE ExponentialSolversModule_wrp USE DistributedSparseMatrixModule_wrp, ONLY : & & DistributedSparseMatrix_wrp @@ -16,14 +16,11 @@ MODULE ExponentialSolversModule_wrp PUBLIC :: ComputeLogarithm_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the exponential of a matrix. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = exp(ih_InputMat) - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE ComputeExponential_wrp(ih_InputMat, ih_OutputMat, & & ih_solver_parameters) bind(c,name="ComputeExponential_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(FixedSolverParameters_wrp) :: h_solver_parameters @@ -36,15 +33,12 @@ SUBROUTINE ComputeExponential_wrp(ih_InputMat, ih_OutputMat, & & h_solver_parameters%data) END SUBROUTINE ComputeExponential_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Compute the exponential of a matrix. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = exp(ih_InputMat) - !! @param[in] ih_solver_parameters parameters for the solver. + !> Compute the exponential of a matrix with the pade approximation. SUBROUTINE ComputeExponentialPade_wrp(ih_InputMat, ih_OutputMat, & & ih_solver_parameters) bind(c,name="ComputeExponentialPade_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters @@ -58,14 +52,11 @@ SUBROUTINE ComputeExponentialPade_wrp(ih_InputMat, ih_OutputMat, & END SUBROUTINE ComputeExponentialPade_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the logarithm of a matrix. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = log(ih_InputMat) - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE ComputeLogarithm_wrp(ih_InputMat, ih_OutputMat, & & ih_solver_parameters) bind(c,name="ComputeLogarithm_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(FixedSolverParameters_wrp) :: h_solver_parameters diff --git a/Source/Wrapper/FixedSolversModule_wrp.f90 b/Source/Wrapper/FixedSolversModule_wrp.f90 index 85a6bc7c..8839fe0b 100644 --- a/Source/Wrapper/FixedSolversModule_wrp.f90 +++ b/Source/Wrapper/FixedSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> A wrapper for the chemistry solver parameters. +!> A wrapper for the fixed solver parameters. MODULE FixedSolversModule_wrp USE DataTypesModule, ONLY : NTREAL USE FixedSolversModule, ONLY : FixedSolverParameters_t, & @@ -10,9 +10,8 @@ MODULE FixedSolversModule_wrp IMPLICIT NONE PRIVATE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> A wrapper for the sparse matrix data type. + !> A wrapper for the fixed solver parameters data type. TYPE, PUBLIC :: FixedSolverParameters_wrp - !> Actual data. TYPE(FixedSolverParameters_t), POINTER :: data END TYPE FixedSolverParameters_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -23,8 +22,7 @@ MODULE FixedSolversModule_wrp PUBLIC :: SetFixedBeVerbose_wrp PUBLIC :: SetFixedLoadBalance_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Construct the chemistry solver parameters. - !! @param[inout] ih_this the solver parameter. + !> Construct the fixed solver parameters. PURE SUBROUTINE ConstructFixedSolverParameters_wrp(ih_this) & & bind(c,name="ConstructFixedSolverParameters_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -35,8 +33,7 @@ PURE SUBROUTINE ConstructFixedSolverParameters_wrp(ih_this) & ih_this = TRANSFER(h_this,ih_this) END SUBROUTINE ConstructFixedSolverParameters_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Destruct a chemistry solver parameter type. - !! @param[inout] ih_this the object to destruct. + !> Destruct a fixed solver parameter type. PURE SUBROUTINE DestructFixedSolverParameters_wrp(ih_this) & & bind(c,name="DestructFixedSolverParameters_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -48,8 +45,6 @@ PURE SUBROUTINE DestructFixedSolverParameters_wrp(ih_this) & END SUBROUTINE DestructFixedSolverParameters_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the threshold. - !! @param[inout] ih_this handle to this. - !! @param[in] new_value to set it to. PURE SUBROUTINE SetFixedThreshold_wrp(ih_this,new_value) & & bind(c,name="SetFixedThreshold_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -61,8 +56,6 @@ PURE SUBROUTINE SetFixedThreshold_wrp(ih_this,new_value) & END SUBROUTINE SetFixedThreshold_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the verbosity. - !! @param[inout] ih_this handle to this. - !! @param[in] new_value to set it to. PURE SUBROUTINE SetFixedBeVerbose_wrp(ih_this,new_value) & & bind(c,name="SetFixedBeVerbose_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -74,8 +67,6 @@ PURE SUBROUTINE SetFixedBeVerbose_wrp(ih_this,new_value) & END SUBROUTINE SetFixedBeVerbose_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the load balancing permutation. - !! @param[inout] ih_this handle to this. - !! @param[in] ih_new_value to set it to. PURE SUBROUTINE SetFixedLoadBalance_wrp(ih_this,ih_new_value) & & bind(c,name="SetFixedLoadBalance_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) diff --git a/Source/Wrapper/GeometryOptimizationModule_wrp.f90 b/Source/Wrapper/GeometryOptimizationModule_wrp.f90 index b738caa1..054617a1 100644 --- a/Source/Wrapper/GeometryOptimizationModule_wrp.f90 +++ b/Source/Wrapper/GeometryOptimizationModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the geometry optimization module for calling from other languages. MODULE GeometryOptimizationModule_wrp USE DataTypesModule, ONLY : NTREAL USE GeometryOptimizationModule, ONLY : PurificationExtrapolate, & @@ -16,20 +16,14 @@ MODULE GeometryOptimizationModule_wrp PUBLIC :: LowdinExtrapolate_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Create a new guess at the Density Matrix after updating the geometry. - !! Based on the purification algorithm in \cite niklasson2010trace . - !! @param[in] ih_PreviousDensity to extrapolate from. - !! @param[in] ih_Overlap the overlap matrix of the new geometry. - !! @param[in] nel the number of electrons. - !! @param[out] ih_NewDensity the extrapolated density. - !! @param[in] solver_parameters parameters for the solver SUBROUTINE PurificationExtrapolate_wrp(ih_PreviousDensity, ih_Overlap, & & nel, ih_NewDensity, ih_solver_parameters) & & bind(c,name="PurificationExtrapolate_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_PreviousDensity(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_Overlap(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: nel - INTEGER(kind=c_int), INTENT(inout) :: ih_NewDensity(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_PreviousDensity(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Overlap(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: nel + INTEGER(kind=c_int), INTENT(INOUT) :: ih_NewDensity(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_PreviousDensity TYPE(DistributedSparseMatrix_wrp) :: h_Overlap TYPE(DistributedSparseMatrix_wrp) :: h_NewDensity @@ -45,20 +39,14 @@ SUBROUTINE PurificationExtrapolate_wrp(ih_PreviousDensity, ih_Overlap, & END SUBROUTINE PurificationExtrapolate_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Create a new guess at the Density Matrix after updating the geometry. - !! Based on the lowdin algorithm in \cite exner2002comparison . - !! @param[in] ih_PreviousDensity to extrapolate from. - !! @param[in] ih_OldOverlap the overlap matrix of the old geometry. - !! @param[in] ih_NewOverlap the overlap matrix of the new geometry. - !! @param[out] ih_NewDensity the extrapolated density. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE LowdinExtrapolate_wrp(ih_PreviousDensity, ih_OldOverlap, & & ih_NewOverlap, ih_NewDensity, ih_solver_parameters) & & bind(c,name="LowdinExtrapolate_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_PreviousDensity(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_OldOverlap(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_NewOverlap(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_NewDensity(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_PreviousDensity(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_OldOverlap(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_NewOverlap(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_NewDensity(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_PreviousDensity TYPE(DistributedSparseMatrix_wrp) :: h_OldOverlap TYPE(DistributedSparseMatrix_wrp) :: h_NewOverlap diff --git a/Source/Wrapper/HermiteSolversModule_wrp.f90 b/Source/Wrapper/HermiteSolversModule_wrp.f90 index f427dae0..01b7334d 100644 --- a/Source/Wrapper/HermiteSolversModule_wrp.f90 +++ b/Source/Wrapper/HermiteSolversModule_wrp.f90 @@ -15,7 +15,6 @@ MODULE HermiteSolversModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the polynomial data type. TYPE, PUBLIC :: HermitePolynomial_wrp - !> Actual data. TYPE(HermitePolynomial_t), POINTER :: DATA END TYPE HermitePolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -26,13 +25,11 @@ MODULE HermiteSolversModule_wrp !! Solvers. PUBLIC :: HermiteCompute_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Wrap the empty polynomial constructor. - !! @param[out] ih_this handle to the polynomial being created. - !! @param[in] degree the degree of the polynomial. + !> Wrap the hermite polynomial constructor. PURE SUBROUTINE ConstructHermitePolynomial_wrp(ih_this, degree) & & bind(c,name="ConstructHermitePolynomial_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: degree + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: degree TYPE(HermitePolynomial_wrp) :: h_this ALLOCATE(h_this%data) @@ -41,7 +38,6 @@ PURE SUBROUTINE ConstructHermitePolynomial_wrp(ih_this, degree) & END SUBROUTINE ConstructHermitePolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Destruct a polynomial object. - !! @param[inout] ih_this handle to the polynomial to free up. PURE SUBROUTINE DestructHermitePolynomial_wrp(ih_this) & & bind(c,name="DestructHermitePolynomial_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -53,14 +49,11 @@ PURE SUBROUTINE DestructHermitePolynomial_wrp(ih_this) & END SUBROUTINE DestructHermitePolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set coefficient of a polynomial. - !! @param[inout] ih_this handle to the polynomial to set. - !! @param[in] degree for which to set the coefficient. - !! @param[in] coefficient value. SUBROUTINE SetHermiteCoefficient_wrp(ih_this, degree, coefficient) & & bind(c,name="SetHermiteCoefficient_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: degree - REAL(NTREAL), INTENT(in) :: coefficient + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: degree + REAL(NTREAL), INTENT(IN) :: coefficient TYPE(HermitePolynomial_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -68,16 +61,12 @@ SUBROUTINE SetHermiteCoefficient_wrp(ih_this, degree, coefficient) & END SUBROUTINE SetHermiteCoefficient_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute A Matrix Hermite Polynomial. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = poly(InputMat) - !! @param[in] ih_polynomial polynomial to compute. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE HermiteCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & & ih_solver_parameters) bind(c,name="HermiteCompute_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_polynomial(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_polynomial(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(HermitePolynomial_wrp) :: h_polynomial diff --git a/Source/Wrapper/InverseSolversModule_wrp.f90 b/Source/Wrapper/InverseSolversModule_wrp.f90 index 6aeb70cb..72a03e00 100644 --- a/Source/Wrapper/InverseSolversModule_wrp.f90 +++ b/Source/Wrapper/InverseSolversModule_wrp.f90 @@ -14,14 +14,11 @@ MODULE InverseSolversModule_wrp PUBLIC :: PseudoInverse_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the inverse of a matrix. - !! @param[in] ih_Mat1 Matrix 1. - !! @param[out] ih_InverseMat = Mat1^-1. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE Invert_wrp(ih_Mat1, ih_InverseMat, ih_solver_parameters) & & bind(c,name="Invert_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Mat1(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_InverseMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Mat1(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_InverseMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Mat1 TYPE(DistributedSparseMatrix_wrp) :: h_InverseMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters @@ -34,14 +31,11 @@ SUBROUTINE Invert_wrp(ih_Mat1, ih_InverseMat, ih_solver_parameters) & END SUBROUTINE Invert_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the pseudoinverse of a matrix. - !! @param[in] ih_Mat1 Matrix 1. - !! @param[out] ih_InverseMat = Mat1^-1. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE PseudoInverse_wrp(ih_Mat1, ih_InverseMat, ih_solver_parameters) & & bind(c,name="PseudoInverse_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Mat1(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_InverseMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Mat1(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_InverseMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Mat1 TYPE(DistributedSparseMatrix_wrp) :: h_InverseMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters diff --git a/Source/Wrapper/IterativeSolversModule_wrp.f90 b/Source/Wrapper/IterativeSolversModule_wrp.f90 index 17d78da9..a8588b51 100644 --- a/Source/Wrapper/IterativeSolversModule_wrp.f90 +++ b/Source/Wrapper/IterativeSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> A wrapper for the chemistry solver parameters. +!> A wrapper for the iterative solver parameters. MODULE IterativeSolversModule_wrp USE DataTypesModule, ONLY : NTREAL USE IterativeSolversModule, ONLY : IterativeSolverParameters_t, & @@ -13,7 +13,6 @@ MODULE IterativeSolversModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the sparse matrix data type. TYPE, PUBLIC :: IterativeSolverParameters_wrp - !> Actual data. TYPE(IterativeSolverParameters_t), POINTER :: data END TYPE IterativeSolverParameters_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -26,11 +25,10 @@ MODULE IterativeSolversModule_wrp PUBLIC :: SetIterativeBeVerbose_wrp PUBLIC :: SetIterativeLoadBalance_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Construct the chemistry solver parameters. - !! @param[inout] ih_this the solver parameter. + !> Construct the iterat solver parameters. PURE SUBROUTINE ConstructIterativeSolverParameters_wrp(ih_this) & & bind(c,name="ConstructIterativeSolverParameters_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) TYPE(IterativeSolverParameters_wrp) :: h_this ALLOCATE(h_this%data) @@ -38,11 +36,10 @@ PURE SUBROUTINE ConstructIterativeSolverParameters_wrp(ih_this) & ih_this = TRANSFER(h_this,ih_this) END SUBROUTINE ConstructIterativeSolverParameters_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !> Destruct a chemistry solver parameter type. - !! @param[inout] ih_this the object to destruct. + !> Destruct a iterative solver parameter type. PURE SUBROUTINE DestructIterativeSolverParameters_wrp(ih_this) & & bind(c,name="DestructIterativeSolverParameters_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) TYPE(IterativeSolverParameters_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -51,12 +48,10 @@ PURE SUBROUTINE DestructIterativeSolverParameters_wrp(ih_this) & END SUBROUTINE DestructIterativeSolverParameters_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the convergence difference. - !! @param[inout] ih_this handle to this. - !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeConvergeDiff_wrp(ih_this,new_value) & & bind(c,name="SetIterativeConvergeDiff_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - REAL(NTREAL), INTENT(in) :: new_value + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + REAL(NTREAL), INTENT(IN) :: new_value TYPE(IterativeSolverParameters_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -64,12 +59,10 @@ PURE SUBROUTINE SetIterativeConvergeDiff_wrp(ih_this,new_value) & END SUBROUTINE SetIterativeConvergeDiff_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the max iterations. - !! @param[inout] ih_this handle to this. - !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeMaxIterations_wrp(ih_this,new_value) & & bind(c,name="SetIterativeMaxIterations_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: new_value + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: new_value TYPE(IterativeSolverParameters_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -77,12 +70,10 @@ PURE SUBROUTINE SetIterativeMaxIterations_wrp(ih_this,new_value) & END SUBROUTINE SetIterativeMaxIterations_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the threshold. - !! @param[inout] ih_this handle to this. - !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeThreshold_wrp(ih_this,new_value) & & bind(c,name="SetIterativeThreshold_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - REAL(NTREAL), INTENT(in) :: new_value + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + REAL(NTREAL), INTENT(IN) :: new_value TYPE(IterativeSolverParameters_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -90,12 +81,10 @@ PURE SUBROUTINE SetIterativeThreshold_wrp(ih_this,new_value) & END SUBROUTINE SetIterativeThreshold_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the verbosity. - !! @param[inout] ih_this handle to this. - !! @param[in] new_value to set it to. PURE SUBROUTINE SetIterativeBeVerbose_wrp(ih_this,new_value) & & bind(c,name="SetIterativeBeVerbose_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - LOGICAL(kind=c_bool), INTENT(in) :: new_value + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + LOGICAL(kind=c_bool), INTENT(IN) :: new_value TYPE(IterativeSolverParameters_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -103,12 +92,10 @@ PURE SUBROUTINE SetIterativeBeVerbose_wrp(ih_this,new_value) & END SUBROUTINE SetIterativeBeVerbose_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of the load balancing permutation. - !! @param[inout] ih_this handle to this. - !! @param[in] ih_new_value to set it to. PURE SUBROUTINE SetIterativeLoadBalance_wrp(ih_this,ih_new_value) & & bind(c,name="SetIterativeLoadBalance_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_new_value(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_new_value(SIZE_wrp) TYPE(IterativeSolverParameters_wrp) :: h_this TYPE(Permutation_wrp) :: h_new_value @@ -116,4 +103,5 @@ PURE SUBROUTINE SetIterativeLoadBalance_wrp(ih_this,ih_new_value) & h_new_value = TRANSFER(ih_new_value,h_new_value) CALL SetIterativeLoadBalance(h_this%data,h_new_value%data) END SUBROUTINE SetIterativeLoadBalance_wrp +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! END MODULE IterativeSolversModule_wrp diff --git a/Source/Wrapper/LinearSolversModule_wrp.f90 b/Source/Wrapper/LinearSolversModule_wrp.f90 index a0a1353f..ea9516d3 100644 --- a/Source/Wrapper/LinearSolversModule_wrp.f90 +++ b/Source/Wrapper/LinearSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the matrix inversion module for calling from other languages. +!> Wraps the linear solvers module for calling from other languages. MODULE LinearSolversModule_wrp USE DistributedSparseMatrixModule_wrp, ONLY : & & DistributedSparseMatrix_wrp @@ -13,16 +13,12 @@ MODULE LinearSolversModule_wrp PUBLIC :: CGSolver_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Solve the matrix equation AX = B using conjugate gradient. - !! @param[in] ih_AMat the matrix A, must be symmetric, positive definite. - !! @param[out] ih_XMat the solved for matrix X. - !! @param[in] ih_BMat the right hand side. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE CGSolver_wrp(ih_AMat, ih_XMat, ih_BMat, ih_solver_parameters) & & bind(c,name="CGSolver_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_AMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_XMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_BMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_AMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_XMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_BMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_AMat TYPE(DistributedSparseMatrix_wrp) :: h_XMat TYPE(DistributedSparseMatrix_wrp) :: h_BMat diff --git a/Source/Wrapper/LoadBalancerModule_wrp.f90 b/Source/Wrapper/LoadBalancerModule_wrp.f90 index 84e7baad..635e2f6b 100644 --- a/Source/Wrapper/LoadBalancerModule_wrp.f90 +++ b/Source/Wrapper/LoadBalancerModule_wrp.f90 @@ -16,16 +16,12 @@ MODULE LoadBalancerModule_wrp PUBLIC :: UndoPermuteMatrix_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Apply a permutation to a matrix. - !! @param[in] ih_mat_in matrix to permute. - !! @param[out] ih_mat_out permuted matrix. - !! @param[in] ih_permutation to apply. - !! @param[inout] ih_memorypool memory pool to use. SUBROUTINE PermuteMatrix_wrp(ih_mat_in, ih_mat_out, ih_permutation, & & ih_memorypool) bind(c, name="PermuteMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_mat_in(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_mat_out(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_permutation(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_memorypool(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_mat_in(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_mat_out(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_permutation(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_memorypool(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_mat_in TYPE(DistributedSparseMatrix_wrp) :: h_mat_out TYPE(Permutation_wrp) :: h_permutation @@ -41,16 +37,12 @@ SUBROUTINE PermuteMatrix_wrp(ih_mat_in, ih_mat_out, ih_permutation, & END SUBROUTINE PermuteMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Undo a permutation applied to a matrix. - !! @param[in] ih_mat_in matrix to undo permutation of. - !! @param[out] ih_mat_out unpermuted matrix. - !! @param[in] ih_permutation to remove. - !! @param[inout] ih_memorypool memory pool to use. Optional. SUBROUTINE UndoPermuteMatrix_wrp(ih_mat_in, ih_mat_out, ih_permutation, & & ih_memorypool) bind(c, name="UndoPermuteMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_mat_in(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_mat_out(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_permutation(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_memorypool(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_mat_in(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_mat_out(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_permutation(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_memorypool(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_mat_in TYPE(DistributedSparseMatrix_wrp) :: h_mat_out TYPE(Permutation_wrp) :: h_permutation diff --git a/Source/Wrapper/MatrixMemoryPoolModule_wrp.f90 b/Source/Wrapper/MatrixMemoryPoolModule_wrp.f90 index 7eef91f9..8fd2f1fa 100644 --- a/Source/Wrapper/MatrixMemoryPoolModule_wrp.f90 +++ b/Source/Wrapper/MatrixMemoryPoolModule_wrp.f90 @@ -10,7 +10,6 @@ MODULE MatrixMemoryPoolModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the matrix memory pool data type. TYPE, PUBLIC :: MatrixMemoryPool_wrp - !> Actual data. TYPE(MatrixMemoryPool_t), POINTER :: data END TYPE MatrixMemoryPool_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -18,9 +17,6 @@ MODULE MatrixMemoryPoolModule_wrp PUBLIC :: DestructMatrixMemoryPool_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the Matrix Memory Pool constructor. - !> @param[out] ih_this handle to a constructed Matrix Memory Pool object. - !> @param[in] columns number of columns in the matrix. - !> @param[in] rows number of rows in the matrix. SUBROUTINE ConstructMatrixMemoryPool_wrp(ih_this, columns, rows) & & bind(c,name="ConstructMatrixMemoryPool_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -34,7 +30,6 @@ SUBROUTINE ConstructMatrixMemoryPool_wrp(ih_this, columns, rows) & END SUBROUTINE ConstructMatrixMemoryPool_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the destructor for a matrix memory pool - !> @param[inout] ih_this the matrix being destructed. PURE SUBROUTINE DestructMatrixMemoryPool_wrp(ih_this) & & bind(c,name="DestructMatrixMemoryPool_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) diff --git a/Source/Wrapper/MinimizerSolversModule_wrp.f90 b/Source/Wrapper/MinimizerSolversModule_wrp.f90 index fdf0e8bd..4ee6b618 100644 --- a/Source/Wrapper/MinimizerSolversModule_wrp.f90 +++ b/Source/Wrapper/MinimizerSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the minimizer solvers module for calling from other languages. MODULE MinimizerSolversModule_wrp USE DataTypesModule, ONLY : NTREAL USE DistributedSparseMatrixModule_wrp, ONLY : & @@ -14,22 +14,15 @@ MODULE MinimizerSolversModule_wrp PUBLIC :: ConjugateGradient_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the density matrix from a Hamiltonian using the CG method. - !! @param[in] ih_Hamiltonian the matrix to compute the corresponding density & - !! from. - !! @param[in] ih_InverseSquareRoot of the overlap matrix. - !! @param[in] nel the number of electrons. - !! @param[out] ih_Density the density matrix computed by this routine. - !! @param[out] chemical_potential_out the chemical potential calculated. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE ConjugateGradient_wrp(ih_Hamiltonian, ih_InverseSquareRoot, & & nel, ih_Density, chemical_potential_out, ih_solver_parameters) & & bind(c,name="ConjugateGradient_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Hamiltonian(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_InverseSquareRoot(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: nel - INTEGER(kind=c_int), INTENT(inout) :: ih_Density(SIZE_wrp) - REAL(NTREAL), INTENT(out) :: chemical_potential_out - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Hamiltonian(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InverseSquareRoot(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: nel + INTEGER(kind=c_int), INTENT(INOUT) :: ih_Density(SIZE_wrp) + REAL(NTREAL), INTENT(OUT) :: chemical_potential_out + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Hamiltonian TYPE(DistributedSparseMatrix_wrp) :: h_InverseSquareRoot TYPE(DistributedSparseMatrix_wrp) :: h_Density diff --git a/Source/Wrapper/PermutationModule_wrp.f90 b/Source/Wrapper/PermutationModule_wrp.f90 index f2d6c79e..8c9a3ac0 100644 --- a/Source/Wrapper/PermutationModule_wrp.f90 +++ b/Source/Wrapper/PermutationModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the load balancer module for calling from other languages. +!> Wraps the permutation module for calling from other languages. MODULE PermutationModule_wrp USE PermutationModule, ONLY : Permutation_t, ConstructDefaultPermutation, & ConstructReversePermutation, ConstructRandomPermutation, DestructPermutation @@ -10,7 +10,6 @@ MODULE PermutationModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the permutation data type. TYPE, PUBLIC :: Permutation_wrp - !> Actual data. TYPE(Permutation_t), POINTER :: data END TYPE Permutation_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -20,8 +19,6 @@ MODULE PermutationModule_wrp PUBLIC :: DestructPermutation_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Constructs a permutation that preserves the original order. - !! @param[inout] ih_this handle to the permutation to construct. - !! @param[in] matrix_dimension size of the matrix. SUBROUTINE ConstructDefaultPermutation_wrp(ih_this, matrix_dimension) & & bind(c,name="ConstructDefaultPermutation_wrp") INTEGER(kind=c_int), INTENT(out) :: ih_this(SIZE_wrp) @@ -34,8 +31,6 @@ SUBROUTINE ConstructDefaultPermutation_wrp(ih_this, matrix_dimension) & END SUBROUTINE ConstructDefaultPermutation_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Constructs a permutation that reverses the original order. - !! @param[inout] ih_this handle to the permutation to construct. - !! @param[in] matrix_dimension size of the matrix. SUBROUTINE ConstructReversePermutation_wrp(ih_this, matrix_dimension) & & bind(c,name="ConstructReversePermutation_wrp") INTEGER(kind=c_int), INTENT(out) :: ih_this(SIZE_wrp) @@ -48,8 +43,6 @@ SUBROUTINE ConstructReversePermutation_wrp(ih_this, matrix_dimension) & END SUBROUTINE ConstructReversePermutation_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Constructs a permutation that has a random order. - !! @param[inout] ih_this handle to the permutation to construct. - !! @param[in] matrix_dimension size of the matrix. SUBROUTINE ConstructRandomPermutation_wrp(ih_this, matrix_dimension) & & bind(c,name="ConstructRandomPermutation_wrp") INTEGER(kind=c_int), INTENT(out) :: ih_this(SIZE_wrp) @@ -62,7 +55,6 @@ SUBROUTINE ConstructRandomPermutation_wrp(ih_this, matrix_dimension) & END SUBROUTINE ConstructRandomPermutation_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Destruct a permutation object. - !! @param[inout] ih_this handle to the permutation to destruct. PURE SUBROUTINE DestructPermutation_wrp(ih_this) & & bind(c,name="DestructPermutation_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -71,4 +63,5 @@ PURE SUBROUTINE DestructPermutation_wrp(ih_this) & h_this = TRANSFER(ih_this,h_this) CALL DestructPermutation(h_this%data) END SUBROUTINE DestructPermutation_wrp +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! END MODULE PermutationModule_wrp diff --git a/Source/Wrapper/PolynomialSolversModule_wrp.f90 b/Source/Wrapper/PolynomialSolversModule_wrp.f90 index 44bb0717..01bb18e1 100644 --- a/Source/Wrapper/PolynomialSolversModule_wrp.f90 +++ b/Source/Wrapper/PolynomialSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the polynomial solvers module for calling from other languages. MODULE PolynomialSolversModule_wrp USE DataTypesModule, ONLY : NTREAL USE DistributedSparseMatrixModule_wrp, ONLY : & @@ -15,7 +15,6 @@ MODULE PolynomialSolversModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the polynomial data type. TYPE, PUBLIC :: Polynomial_wrp - !> Actual data. TYPE(Polynomial_t), POINTER :: DATA END TYPE Polynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -28,12 +27,10 @@ MODULE PolynomialSolversModule_wrp PUBLIC :: PatersonStockmeyerCompute_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the empty polynomial constructor. - !! @param[out] ih_this handle to the polynomial being created. - !! @param[in] degree the degree of the polynomial. PURE SUBROUTINE ConstructPolynomial_wrp(ih_this, degree) & & bind(c,name="ConstructPolynomial_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: degree + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: degree TYPE(Polynomial_wrp) :: h_this ALLOCATE(h_this%data) @@ -42,10 +39,9 @@ PURE SUBROUTINE ConstructPolynomial_wrp(ih_this, degree) & END SUBROUTINE ConstructPolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Destruct a polynomial object. - !! @param[inout] ih_this handle to the polynomial to free up. PURE SUBROUTINE DestructPolynomial_wrp(ih_this) & & bind(c,name="DestructPolynomial_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) TYPE(Polynomial_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -54,14 +50,11 @@ PURE SUBROUTINE DestructPolynomial_wrp(ih_this) & END SUBROUTINE DestructPolynomial_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set coefficient of a polynomial. - !! @param[inout] ih_this handle to the polynomial to set. - !! @param[in] degree for which to set the coefficient. - !! @param[in] coefficient value. SUBROUTINE SetCoefficient_wrp(ih_this, degree, coefficient) & & bind(c,name="SetCoefficient_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: degree - REAL(NTREAL), INTENT(in) :: coefficient + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: degree + REAL(NTREAL), INTENT(IN) :: coefficient TYPE(Polynomial_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -69,16 +62,12 @@ SUBROUTINE SetCoefficient_wrp(ih_this, degree, coefficient) & END SUBROUTINE SetCoefficient_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute A Matrix Polynomial Using Horner's Method. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = poly(InputMat) - !! @param[in] ih_polynomial polynomial to compute. - !! @param[in] ih_solver_parameters parameters for the solver (optional). SUBROUTINE HornerCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & & ih_solver_parameters) bind(c,name="HornerCompute_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_polynomial(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_polynomial(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(Polynomial_wrp) :: h_polynomial @@ -94,17 +83,13 @@ SUBROUTINE HornerCompute_wrp(ih_InputMat, ih_OutputMat, ih_polynomial, & END SUBROUTINE HornerCompute_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute A Matrix Polynomial Using Paterson and Stockmeyer's method. - !! @param[in] ih_InputMat the input matrix - !! @param[out] ih_OutputMat = poly(InputMat) - !! @param[in] ih_polynomial polynomial to compute. - !! @param[in] ih_solver_parameters parameters for the solver (optional). SUBROUTINE PatersonStockmeyerCompute_wrp(ih_InputMat, ih_OutputMat, & & ih_polynomial, ih_solver_parameters) & & bind(c,name="PatersonStockmeyerCompute_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_polynomial(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_polynomial(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(Polynomial_wrp) :: h_polynomial diff --git a/Source/Wrapper/ProcessGridModule_wrp.f90 b/Source/Wrapper/ProcessGridModule_wrp.f90 index 00f0c72e..bec13261 100644 --- a/Source/Wrapper/ProcessGridModule_wrp.f90 +++ b/Source/Wrapper/ProcessGridModule_wrp.f90 @@ -10,11 +10,6 @@ MODULE ProcessGridModule_wrp PUBLIC :: ConstructProcessGrid_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the process grid construction routine. - !> @param[in] world_comm_ a global communicator to split. - !> @param[in] process_rows_ number of rows. - !> @param[in] process_columns_ number of columns. - !> @param[in] process_slices_ number of slices. - !> @param[in] be_verbose verbosity. SUBROUTINE ConstructProcessGrid_wrp(world_comm_, process_rows_, & & process_columns_, process_slices_, be_verbose) & & bind(c,name="ConstructProcessGrid_wrp") @@ -28,7 +23,6 @@ SUBROUTINE ConstructProcessGrid_wrp(world_comm_, process_rows_, & END SUBROUTINE ConstructProcessGrid_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the slice of the current process. - !! @return slice number of the current process. FUNCTION GetMySlice_wrp() RESULT(return_val) bind(c,name="GetMySlice_wrp") !! Parameters INTEGER(kind=c_int) :: return_val @@ -36,7 +30,6 @@ FUNCTION GetMySlice_wrp() RESULT(return_val) bind(c,name="GetMySlice_wrp") END FUNCTION GetMySlice_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the column of the current process. - !! @return column number of the current process. FUNCTION GetMyColumn_wrp() RESULT(return_val) bind(c,name="GetMyColumn_wrp") !! Parameters INTEGER(kind=c_int) :: return_val @@ -44,7 +37,6 @@ FUNCTION GetMyColumn_wrp() RESULT(return_val) bind(c,name="GetMyColumn_wrp") END FUNCTION GetMyColumn_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the row of the current process. - !! @return row number of the current process. FUNCTION GetMyRow_wrp() RESULT(return_val) bind(c,name="GetMyRow_wrp") !! Parameters INTEGER(kind=c_int) :: return_val diff --git a/Source/Wrapper/RootSolversModule_wrp.f90 b/Source/Wrapper/RootSolversModule_wrp.f90 index 55553d01..b50ae2d1 100644 --- a/Source/Wrapper/RootSolversModule_wrp.f90 +++ b/Source/Wrapper/RootSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the root solvers module for calling from other languages. MODULE RootSolversModule_wrp USE DistributedSparseMatrixModule_wrp, ONLY : & & DistributedSparseMatrix_wrp @@ -14,16 +14,12 @@ MODULE RootSolversModule_wrp PUBLIC :: ComputeInverseRoot_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute a general matrix root. - !! @param[in] ih_InputMat the input matrix. - !! @param[out] ih_OutputMat = InputMat^-1/root. - !! @param[in] root which root to compute. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE ComputeRoot_wrp(ih_InputMat, ih_OutputMat, & & root, ih_solver_parameters) bind(c,name="ComputeRoot_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: root - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: root + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters @@ -37,16 +33,12 @@ SUBROUTINE ComputeRoot_wrp(ih_InputMat, ih_OutputMat, & END SUBROUTINE ComputeRoot_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute a general inverse matrix root. - !! @param[in] ih_InputMat the input matrix. - !! @param[out] ih_OutputMat = InputMat^-1/root. - !! @param[in] root which root to compute. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE ComputeInverseRoot_wrp(ih_InputMat, ih_OutputMat, & & root, ih_solver_parameters) bind(c,name="ComputeInverseRoot_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: root - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: root + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_InputMat TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters diff --git a/Source/Wrapper/SignSolversModule_wrp.f90 b/Source/Wrapper/SignSolversModule_wrp.f90 index 6181186f..f59d586a 100644 --- a/Source/Wrapper/SignSolversModule_wrp.f90 +++ b/Source/Wrapper/SignSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the sign solvers module for calling from other languages. MODULE SignSolversModule_wrp USE DistributedSparseMatrixModule_wrp, ONLY : & & DistributedSparseMatrix_wrp @@ -14,14 +14,11 @@ MODULE SignSolversModule_wrp PUBLIC :: PolarDecomposition_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Computes the matrix sign function. - !! @param[in] ih_Mat1 the input matrix. - !! @param[out] ih_SignMat the sign of Mat1. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE SignFunction_wrp(ih_Mat1, ih_SignMat, ih_solver_parameters) & & bind(c,name="SignFunction_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Mat1(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_SignMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Mat1(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_SignMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Mat1 TYPE(DistributedSparseMatrix_wrp) :: h_SignMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters @@ -34,16 +31,12 @@ SUBROUTINE SignFunction_wrp(ih_Mat1, ih_SignMat, ih_solver_parameters) & END SUBROUTINE SignFunction_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Computes the polar decomposition of a matrix Mat1 = U*H. - !! @param[in] ih_Mat1 the input matrix. - !! @param[out] ih_Umat the unitary polar factor. - !! @param[out] ih_Hmat the hermitian matrix factor. - !! @param[in] ih_solver_parameters parameters for the solver. SUBROUTINE PolarDecomposition_wrp(ih_Mat1, ih_Umat, ih_Hmat, & & ih_solver_parameters) bind(c,name="PolarDecomposition_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Mat1(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_Umat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_Hmat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Mat1(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_Umat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_Hmat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Mat1 TYPE(DistributedSparseMatrix_wrp) :: h_Umat TYPE(DistributedSparseMatrix_wrp) :: h_Hmat diff --git a/Source/Wrapper/SparseMatrixAlgebraModule_wrp.f90 b/Source/Wrapper/SparseMatrixAlgebraModule_wrp.f90 index 2adb102d..4f52a8d2 100644 --- a/Source/Wrapper/SparseMatrixAlgebraModule_wrp.f90 +++ b/Source/Wrapper/SparseMatrixAlgebraModule_wrp.f90 @@ -20,14 +20,11 @@ MODULE SparseMatrixAlgebraModule_wrp PUBLIC :: DotSparseMatrix_wrp PUBLIC :: Gemm_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the scale a sparse matrix by a constant routine. - !! @param[inout] ih_this handle to the matrix to scale. - !! @param[in] constant scale factor. PURE SUBROUTINE ScaleSparseMatrix_wrp(ih_this, constant) & & bind(c,name="ScaleSparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - REAL(NTREAL), INTENT(in) :: constant + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + REAL(NTREAL), INTENT(IN) :: constant TYPE(SparseMatrix_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -35,16 +32,12 @@ PURE SUBROUTINE ScaleSparseMatrix_wrp(ih_this, constant) & END SUBROUTINE ScaleSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap matrix incrementing function. - !! @param[in] ih_matA handle to Matrix A. - !! @param[in,out] ih_matB handle to Matrix B. - !! @param[in] alpha_in multiplier. - !! @param[in] threshold_in for flushing values to zero. PURE SUBROUTINE IncrementSparseMatrix_wrp(ih_matA, ih_matB, alpha_in, & & threshold_in) bind(c,name="IncrementSparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_matA(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_matB(SIZE_wrp) - REAL(NTREAL), INTENT(in) :: alpha_in - REAL(NTREAL), INTENT(in) :: threshold_in + INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_matB(SIZE_wrp) + REAL(NTREAL), INTENT(IN) :: alpha_in + REAL(NTREAL), INTENT(IN) :: threshold_in TYPE(SparseMatrix_wrp) :: h_matA TYPE(SparseMatrix_wrp) :: h_matB @@ -54,12 +47,10 @@ PURE SUBROUTINE IncrementSparseMatrix_wrp(ih_matA, ih_matB, alpha_in, & END SUBROUTINE IncrementSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap matrix dot product function. - !! @param[in] ih_matA handle to Matrix A. - !! @param[in,out] ih_matB handle to Matrix B. PURE FUNCTION DotSparseMatrix_wrp(ih_matA, ih_matB) RESULT(product) & & bind(c,name="DotSparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_matA(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_matB(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matB(SIZE_wrp) REAL(NTREAL) :: product TYPE(SparseMatrix_wrp) :: h_matA TYPE(SparseMatrix_wrp) :: h_matB @@ -70,14 +61,11 @@ PURE FUNCTION DotSparseMatrix_wrp(ih_matA, ih_matB) RESULT(product) & END FUNCTION DotSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap pairwise matrix multiplication function. - !! @param[in] ih_matA handle to Matrix A. - !! @param[in] ih_matB handle to Matrix B. - !! @param[out] ih_matC = A pairwise B SUBROUTINE PairwiseMultiplySparseMatrix_wrp(ih_matA, ih_matB, ih_matC) & & bind(c,name="PairwiseMultiplySparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_matA(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_matB(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_matC(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matB(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_matC(SIZE_wrp) TYPE(SparseMatrix_wrp) :: h_matA TYPE(SparseMatrix_wrp) :: h_matB TYPE(SparseMatrix_wrp) :: h_matC @@ -90,23 +78,14 @@ SUBROUTINE PairwiseMultiplySparseMatrix_wrp(ih_matA, ih_matB, ih_matC) & END SUBROUTINE PairwiseMultiplySparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap matrix multiplication function. - !! @param[in] ih_matA handle to Matrix A. - !! @param[in] ih_matB handle to Matrix B. - !! @param[out] ih_matC = alpha*matA*op( matB ) + beta*matC. - !! @param[in] IsATransposed true if A is already transposed. - !! @param[in] IsBTransposed true if B is already transposed. - !! @param[in] alpha scales the multiplication. - !! @param[in] beta scales matrix we sum on to. - !! @param[in] threshold for flushing values to zero. - !! @param[inout] ih_blocked_memory_pool handle to memory pool. SUBROUTINE Gemm_wrp(ih_matA, ih_matB, ih_matC, IsATransposed, & & IsBTransposed, alpha, beta, threshold, ih_blocked_memory_pool) & & bind(c,name="Gemm_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_matA(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_matB(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_matC(SIZE_wrp) - LOGICAL(kind=c_bool), INTENT(in) :: IsATransposed - LOGICAL(kind=c_bool), INTENT(in) :: IsBTransposed + INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matB(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_matC(SIZE_wrp) + LOGICAL(kind=c_bool), INTENT(IN) :: IsATransposed + LOGICAL(kind=c_bool), INTENT(IN) :: IsBTransposed REAL(NTREAL), INTENT(in) :: alpha REAL(NTREAL), INTENT(in) :: beta REAL(NTREAL), INTENT(in) :: threshold diff --git a/Source/Wrapper/SparseMatrixModule_wrp.f90 b/Source/Wrapper/SparseMatrixModule_wrp.f90 index 8c1ce053..77bb278a 100644 --- a/Source/Wrapper/SparseMatrixModule_wrp.f90 +++ b/Source/Wrapper/SparseMatrixModule_wrp.f90 @@ -16,7 +16,6 @@ MODULE SparseMatrixModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the sparse matrix data type. TYPE, PUBLIC :: SparseMatrix_wrp - !> Actual data. TYPE(SparseMatrix_t), POINTER :: DATA END TYPE SparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -33,31 +32,12 @@ MODULE SparseMatrixModule_wrp PUBLIC :: PrintSparseMatrixF_wrp PUBLIC :: MatrixToTripletList_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ! !> Wrap the empty sparse matrix constructor. - ! !! @param[out] ih_this handle to the matrix being created. - ! !! @param[in] columns number of matrix columns. - ! !! @param[in] rows number of matrix rows. - ! PURE SUBROUTINE ConstructEmptySparseMatrix_wrp(ih_this, columns, rows) & - ! & bind(c,name="ConstructEmptySparseMatrix_wrp") - ! INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - ! INTEGER(kind=c_int), INTENT(in) :: columns - ! INTEGER(kind=c_int), INTENT(in) :: rows - ! TYPE(SparseMatrix_wrp) :: h_this - ! - ! ALLOCATE(h_this%data) - ! CALL ConstructEmptySparseMatrix(h_this%data,columns,rows) - ! ih_this = TRANSFER(h_this,ih_this) - ! END SUBROUTINE ConstructEmptySparseMatrix_wrp -!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Create a sparse matrix by reading in a matrix market file. - !! @param[out] ih_this the matrix being constructed. - !! @param[in] file_name name of the file. - !! @param[in] name_size the number of characters in the file name. SUBROUTINE ConstructSparseMatrixFromFile_wrp(ih_this, file_name, name_size) & & bind(c,name="ConstructSparseMatrixFromFile_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - CHARACTER(kind=c_char), INTENT(in) :: file_name(name_size) - INTEGER(kind=c_int), INTENT(in) :: name_size + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + CHARACTER(kind=c_char), INTENT(IN) :: file_name(name_size) + INTEGER(kind=c_int), INTENT(IN) :: name_size TYPE(SparseMatrix_wrp) :: h_this !! Local Data CHARACTER(len=name_size) :: local_string @@ -73,16 +53,12 @@ SUBROUTINE ConstructSparseMatrixFromFile_wrp(ih_this, file_name, name_size) & END SUBROUTINE ConstructSparseMatrixFromFile_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct a sparse matrix from a \b SORTED triplet list. - !! @param[inout] ih_this handle to the matrix being constructed - !! @param[in] ih_triplet_list handle to a sorted list of triplet values - !! @param[in] rows number of matrix rows - !! @param[in] columns number of matrix columns PURE SUBROUTINE ConstructFromTripletList_wrp(ih_this, ih_triplet_list, & & rows, columns) bind(c,name="ConstructFromTripletList_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_triplet_list(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: columns - INTEGER(kind=c_int), INTENT(in) :: rows + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_triplet_list(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: columns + INTEGER(kind=c_int), INTENT(IN) :: rows !! Local Data TYPE(SparseMatrix_wrp) :: h_this TYPE(TripletList_wrp) :: h_triplet_list @@ -95,14 +71,11 @@ PURE SUBROUTINE ConstructFromTripletList_wrp(ih_this, ih_triplet_list, & END SUBROUTINE ConstructFromTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct a sparse matrix with zero values in it. - !! @param[inout] ih_this handle to the matrix being constructed - !! @param[in] rows number of matrix rows - !! @param[in] columns number of matrix columns PURE SUBROUTINE ConstructZeroSparseMatrix_wrp(ih_this, & & rows, columns) bind(c,name="ConstructZeroSparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: columns - INTEGER(kind=c_int), INTENT(in) :: rows + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: columns + INTEGER(kind=c_int), INTENT(IN) :: rows !! Local Data TYPE(SparseMatrix_wrp) :: h_this @@ -112,7 +85,6 @@ PURE SUBROUTINE ConstructZeroSparseMatrix_wrp(ih_this, & END SUBROUTINE ConstructZeroSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Explicitly destruct a sparse matrix - !! @param[inout] ih_this handle to the matrix to free up. PURE SUBROUTINE DestructSparseMatrix_wrp(ih_this) & & bind(c,name="DestructSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) @@ -125,12 +97,10 @@ PURE SUBROUTINE DestructSparseMatrix_wrp(ih_this) & END SUBROUTINE DestructSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the copy a sparse matrix routine. - !! @param[in] ih_matA handle to the matrix to copy - !! @param[inout] ih_matB matB = matA PURE SUBROUTINE CopySparseMatrix_wrp(ih_matA, ih_matB) & & bind(c,name="CopySparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_matA(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_matB(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_matB(SIZE_wrp) TYPE(SparseMatrix_wrp) :: h_matA TYPE(SparseMatrix_wrp) :: h_matB @@ -140,12 +110,9 @@ PURE SUBROUTINE CopySparseMatrix_wrp(ih_matA, ih_matB) & END SUBROUTINE CopySparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the row accessor. - !! @param[in] ih_this handle to the matrix. - !! @param[out] rows the number of rows. - PURE SUBROUTINE GetRows_wrp(ih_this, rows) & - & bind(c,name="GetRows_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(out) :: rows + PURE SUBROUTINE GetRows_wrp(ih_this, rows) bind(c,name="GetRows_wrp") + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(OUT) :: rows TYPE(SparseMatrix_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -153,12 +120,9 @@ PURE SUBROUTINE GetRows_wrp(ih_this, rows) & END SUBROUTINE GetRows_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the column accessor. - !! @param[in] ih_this handle to the matrix. - !! @param[out] columns the number of columns. - PURE SUBROUTINE GetColumns_wrp(ih_this, columns) & - & bind(c,name="GetColumns_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(out) :: columns + PURE SUBROUTINE GetColumns_wrp(ih_this, columns) bind(c,name="GetColumns_wrp") + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(OUT) :: columns TYPE(SparseMatrix_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -166,12 +130,10 @@ PURE SUBROUTINE GetColumns_wrp(ih_this, columns) & END SUBROUTINE GetColumns_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the matrix transpose function. - !! @param[in] ih_matA handle to the matrix to be transposed. - !! @param[inout] ih_matAT handle to the the input matrix transposed. PURE SUBROUTINE TransposeSparseMatrix_wrp(ih_matA, ih_matAT) & & bind(c,name="TransposeSparseMatrix_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_matA(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_matAT(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_matA(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_matAT(SIZE_wrp) TYPE(SparseMatrix_wrp) :: h_matA TYPE(SparseMatrix_wrp) :: h_matAT @@ -181,14 +143,11 @@ PURE SUBROUTINE TransposeSparseMatrix_wrp(ih_matA, ih_matAT) & END SUBROUTINE TransposeSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Warp the routine that prints out a sparse matrix to file. - !! @param[in] ih_this the matrix to be printed. - !! @param[in] file_name optionally, you can pass a file to print to. - !! @param[in] name_size the number of characters in the file name. SUBROUTINE PrintSparseMatrixF_wrp(ih_this, file_name, name_size) & & bind(c,name="PrintSparseMatrixF_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - CHARACTER(kind=c_char), INTENT(in) :: file_name(name_size) - INTEGER(kind=c_int), INTENT(in) :: name_size + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + CHARACTER(kind=c_char), INTENT(IN) :: file_name(name_size) + INTEGER(kind=c_int), INTENT(IN) :: name_size TYPE(SparseMatrix_wrp) :: h_this !! Local Data CHARACTER(len=name_size) :: local_string @@ -203,7 +162,6 @@ SUBROUTINE PrintSparseMatrixF_wrp(ih_this, file_name, name_size) & END SUBROUTINE PrintSparseMatrixF_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Warp the routine that prints the sparse matrix to the console. - !! @param[in] ih_this the matrix to be printed. SUBROUTINE PrintSparseMatrix_wrp(ih_this) & & bind(c,name="PrintSparseMatrix_wrp") INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) @@ -214,12 +172,10 @@ SUBROUTINE PrintSparseMatrix_wrp(ih_this) & END SUBROUTINE PrintSparseMatrix_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the routine that constructs a triplet list from a matrix. - !! @param[in] ih_this handle to the matrix to construct the triplet list from - !! @param[out] ih_triplet_list handle to the triplet list we created. SUBROUTINE MatrixToTripletList_wrp(ih_this, ih_triplet_list) & & bind(c,name="MatrixToTripletList_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(out) :: ih_triplet_list(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(OUT) :: ih_triplet_list(SIZE_wrp) TYPE(SparseMatrix_wrp) :: h_this TYPE(TripletList_wrp) :: h_triplet_list diff --git a/Source/Wrapper/SquareRootSolversModule_wrp.f90 b/Source/Wrapper/SquareRootSolversModule_wrp.f90 index d787a998..8c830327 100644 --- a/Source/Wrapper/SquareRootSolversModule_wrp.f90 +++ b/Source/Wrapper/SquareRootSolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the square root solvers module for calling from other languages. MODULE SquareRootSolversModule_wrp USE DistributedSparseMatrixModule_wrp, ONLY : & & DistributedSparseMatrix_wrp @@ -14,14 +14,11 @@ MODULE SquareRootSolversModule_wrp PUBLIC :: InverseSquareRoot_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the inverse square root of a matrix. - !! @param[in] ih_Mat1 Matrix 1. - !! @param[out] ih_InverseSquareRootMat = Mat1^-1/2. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE InverseSquareRoot_wrp(ih_Mat1, ih_InverseSquareRootMat, & & ih_solver_parameters) bind(c,name="InverseSquareRoot_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Mat1(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_InverseSquareRootMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Mat1(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_InverseSquareRootMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Mat1 TYPE(DistributedSparseMatrix_wrp) :: h_InverseSquareRootMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters @@ -36,14 +33,11 @@ SUBROUTINE InverseSquareRoot_wrp(ih_Mat1, ih_InverseSquareRootMat, & END SUBROUTINE InverseSquareRoot_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the square root of a matrix. - !! @param[in] ih_Mat1 Matrix 1. - !! @param[out] ih_SquareRootMat = Mat1^-1/2. - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE SquareRoot_wrp(ih_Mat1, ih_SquareRootMat, ih_solver_parameters) & & bind(c,name="SquareRoot_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_Mat1(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_SquareRootMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_Mat1(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_SquareRootMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) TYPE(DistributedSparseMatrix_wrp) :: h_Mat1 TYPE(DistributedSparseMatrix_wrp) :: h_SquareRootMat TYPE(IterativeSolverParameters_wrp) :: h_solver_parameters diff --git a/Source/Wrapper/TrigonometrySolversModule_wrp.f90 b/Source/Wrapper/TrigonometrySolversModule_wrp.f90 index 849c4f3d..9786d11b 100644 --- a/Source/Wrapper/TrigonometrySolversModule_wrp.f90 +++ b/Source/Wrapper/TrigonometrySolversModule_wrp.f90 @@ -1,5 +1,5 @@ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!> Wraps the overlap solvers module for calling from other languages. +!> Wraps the trigonometry solvers module for calling from other languages. MODULE TrigonometrySolversModule_wrp USE DistributedSparseMatrixModule_wrp, ONLY : & & DistributedSparseMatrix_wrp @@ -14,16 +14,13 @@ MODULE TrigonometrySolversModule_wrp PUBLIC :: Cosine_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the sine of a matrix. - !! @param[in] ih_InputMat Input. - !! @param[out] ih_OutputMat = sin(InputMat). - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE Sine_wrp(ih_InputMat, ih_OutputMat, ih_solver_parameters) & & bind(c,name="Sine_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) - TYPE(DistributedSparseMatrix_wrp) :: h_InputMat - TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) + TYPE(DistributedSparseMatrix_wrp) :: h_InputMat + TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(FixedSolverParameters_wrp) :: h_solver_parameters h_InputMat = TRANSFER(ih_InputMat,h_InputMat) @@ -35,16 +32,13 @@ SUBROUTINE Sine_wrp(ih_InputMat, ih_OutputMat, ih_solver_parameters) & END SUBROUTINE Sine_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Compute the cosine of a matrix. - !! @param[in] ih_InputMat Input. - !! @param[out] ih_OutputMat = cosin(InputMat). - !! @param[in] ih_solver_parameters parameters for the solver SUBROUTINE Cosine_wrp(ih_InputMat, ih_OutputMat, ih_solver_parameters) & & bind(c,name="Cosine_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_InputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(inout) :: ih_OutputMat(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: ih_solver_parameters(SIZE_wrp) - TYPE(DistributedSparseMatrix_wrp) :: h_InputMat - TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat + INTEGER(kind=c_int), INTENT(IN) :: ih_InputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_OutputMat(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_solver_parameters(SIZE_wrp) + TYPE(DistributedSparseMatrix_wrp) :: h_InputMat + TYPE(DistributedSparseMatrix_wrp) :: h_OutputMat TYPE(FixedSolverParameters_wrp) :: h_solver_parameters h_InputMat = TRANSFER(ih_InputMat,h_InputMat) diff --git a/Source/Wrapper/TripletListModule_wrp.f90 b/Source/Wrapper/TripletListModule_wrp.f90 index 7219171d..ffb84c2d 100644 --- a/Source/Wrapper/TripletListModule_wrp.f90 +++ b/Source/Wrapper/TripletListModule_wrp.f90 @@ -28,12 +28,10 @@ MODULE TripletListModule_wrp PUBLIC :: GetTripletListSize_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Wrap the triplet list constructor. - !> @param[out] ih_this handle to a constructed Matrix Memory Pool object. - !> @param[in] size of the triplet list. PURE SUBROUTINE ConstructTripletList_wrp(ih_this, size) & & bind(c,name="ConstructTripletList_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: size + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: size TYPE(TripletList_wrp) :: h_this ALLOCATE(h_this%data) @@ -45,7 +43,7 @@ END SUBROUTINE ConstructTripletList_wrp !! @param[inout] ih_this handle to the triplet list to destruct. PURE SUBROUTINE DestructTripletList_wrp(ih_this) & & bind(c,name="DestructTripletList_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) TYPE(TripletList_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -55,12 +53,10 @@ PURE SUBROUTINE DestructTripletList_wrp(ih_this) & END SUBROUTINE DestructTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Increase the size of a triplet list. - !! @param[inout] ih_this handle to the triplet list to resize. - !! @param[in] size to resize to. PURE SUBROUTINE ResizeTripletList_wrp(ih_this, size) & & bind(c,name="ResizeTripletList_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: size + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: size TYPE(TripletList_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) @@ -68,16 +64,12 @@ PURE SUBROUTINE ResizeTripletList_wrp(ih_this, size) & END SUBROUTINE ResizeTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Add a value to the end of the triplet list. - !! @param[inout] ih_this the triplet list to append to. - !! @param[in] index_column column of value. - !! @param[in] index_row row of value. - !! @param[in] point_value the value. PURE SUBROUTINE AppendToTripletList_wrp(ih_this, index_column, index_row, & & point_value) bind(c,name="AppendToTripletList_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: index_column - INTEGER(kind=c_int), INTENT(in) :: index_row - REAL(NTREAL), INTENT(in) :: point_value + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: index_column + INTEGER(kind=c_int), INTENT(IN) :: index_row + REAL(NTREAL), INTENT(IN) :: point_value TYPE(TripletList_wrp) :: h_this TYPE(Triplet_t) :: temp @@ -90,18 +82,13 @@ PURE SUBROUTINE AppendToTripletList_wrp(ih_this, index_column, index_row, & END SUBROUTINE AppendToTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the value of a triplet at a particular index. - !! @param[inout] ih_this handle to the triplet list to set. - !! @param[in] index the index at which to set the triplet. - !! @param[in] index_column the column value. - !! @param[in] index_row the row value. - !! @param[in] point_value the value at that point. PURE SUBROUTINE SetTripletAt_wrp(ih_this, index, index_column, index_row, & & point_value) bind(c,name="SetTripletAt_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: index - INTEGER(kind=c_int), INTENT(in) :: index_column - INTEGER(kind=c_int), INTENT(in) :: index_row - REAL(NTREAL), INTENT(in) :: point_value + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: index + INTEGER(kind=c_int), INTENT(IN) :: index_column + INTEGER(kind=c_int), INTENT(IN) :: index_row + REAL(NTREAL), INTENT(IN) :: point_value TYPE(TripletList_wrp) :: h_this TYPE(Triplet_t) :: temp @@ -114,18 +101,13 @@ PURE SUBROUTINE SetTripletAt_wrp(ih_this, index, index_column, index_row, & END SUBROUTINE SetTripletAt_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the value of a triplet at a particular index. - !! @param[inout] ih_this handle to the triplet list to get. - !! @param[in] index the index at which to get the triplet. - !! @param[out] index_column the column value. - !! @param[out] index_row the row value. - !! @param[out] point_value the value at that point. PURE SUBROUTINE GetTripletAt_wrp(ih_this, index, index_column, index_row, & & point_value) bind(c,name="GetTripletAt_wrp") - INTEGER(kind=c_int), INTENT(in) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(out) :: index - INTEGER(kind=c_int), INTENT(out) :: index_column - INTEGER(kind=c_int), INTENT(out) :: index_row - REAL(NTREAL), INTENT(out) :: point_value + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(OUT) :: index + INTEGER(kind=c_int), INTENT(OUT) :: index_column + INTEGER(kind=c_int), INTENT(OUT) :: index_row + REAL(NTREAL), INTENT(OUT) :: point_value TYPE(TripletList_wrp) :: h_this TYPE(Triplet_t) :: temp @@ -138,14 +120,11 @@ PURE SUBROUTINE GetTripletAt_wrp(ih_this, index, index_column, index_row, & END SUBROUTINE GetTripletAt_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Sorts a triplet list by index values. - !! @param[in] ih_this handle to the triplet list to sort. - !! @param[in] matrix_columns this is the highest column value in the list. - !! @param[inout] ih_sorted handle to the sorted list. PURE SUBROUTINE SortTripletList_wrp(ih_this, matrix_columns, ih_sorted) & & bind(c,name="SortTripletList_wrp") - INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(in) :: matrix_columns - INTEGER(kind=c_int), INTENT(INOUT) :: ih_sorted(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(IN) :: matrix_columns + INTEGER(kind=c_int), INTENT(INOUT) :: ih_sorted(SIZE_wrp) TYPE(TripletList_wrp) :: h_this TYPE(TripletList_wrp) :: h_sorted @@ -158,8 +137,6 @@ PURE SUBROUTINE SortTripletList_wrp(ih_this, matrix_columns, ih_sorted) & END SUBROUTINE SortTripletList_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the number of entries in a triplet list. - !! @param[in] ih_this list to get the size of. - !! @return list_size the number of entries in the triplet list. PURE FUNCTION GetTripletListSize_wrp(ih_this) RESULT(list_size) & & bind(c,name="GetTripletListSize_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) diff --git a/Source/Wrapper/TripletModule_wrp.f90 b/Source/Wrapper/TripletModule_wrp.f90 index dfa59441..4349e82a 100644 --- a/Source/Wrapper/TripletModule_wrp.f90 +++ b/Source/Wrapper/TripletModule_wrp.f90 @@ -10,7 +10,6 @@ MODULE TripletModule_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> A wrapper for the triplet data type. TYPE, PUBLIC :: Triplet_wrp - !> Actual data. TYPE(Triplet_t), POINTER :: DATA END TYPE Triplet_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -18,13 +17,9 @@ MODULE TripletModule_wrp PUBLIC :: GetTripletValues_wrp CONTAINS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Set the values of a triplet. - !! @param[inout] ih_this handle to the triplet to set the values of. - !! @param[in] index_column the column value. - !! @param[in] index_row the row value. - !! @param[in] point_value the value at that point. PURE SUBROUTINE SetTriplet_wrp(ih_this,index_column,index_row,point_value) & & bind(c,name="SetTriplet_wrp") - INTEGER(kind=c_int), INTENT(inout) :: ih_this(SIZE_wrp) + INTEGER(kind=c_int), INTENT(INOUT) :: ih_this(SIZE_wrp) INTEGER(kind=c_int), INTENT(IN) :: index_column INTEGER(kind=c_int), INTENT(IN) :: index_row REAL(NTREAL), INTENT(IN) :: point_value @@ -35,16 +30,12 @@ PURE SUBROUTINE SetTriplet_wrp(ih_this,index_column,index_row,point_value) & END SUBROUTINE SetTriplet_wrp !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Get the values of a triplet. - !! @param[in] ih_this the triplet to extract the values of. - !! @param[out] index_column column value. - !! @param[out] index_row row value. - !! @param[out] point_value actual stored value. PURE SUBROUTINE GetTripletValues_wrp(ih_this,index_column,index_row, & & point_value) bind(c,name="GetTripletValues_wrp") INTEGER(kind=c_int), INTENT(IN) :: ih_this(SIZE_wrp) - INTEGER(kind=c_int), INTENT(out) :: index_column - INTEGER(kind=c_int), INTENT(out) :: index_row - REAL(NTREAL), INTENT(out) :: point_value + INTEGER(kind=c_int), INTENT(OUT) :: index_column + INTEGER(kind=c_int), INTENT(OUT) :: index_row + REAL(NTREAL), INTENT(OUT) :: point_value TYPE(Triplet_wrp) :: h_this h_this = TRANSFER(ih_this,h_this) diff --git a/UnitTests/testChemistry.py b/UnitTests/testChemistry.py index 29a531a4..971042ef 100644 --- a/UnitTests/testChemistry.py +++ b/UnitTests/testChemistry.py @@ -10,7 +10,7 @@ from scipy.linalg import eigh import os from mpi4py import MPI -# MPI globa communicator +# MPI global communicator comm = MPI.COMM_WORLD from Helpers import THRESHOLD, EXTRAPTHRESHOLD