diff --git a/Source/Fortran/MatrixMemoryPoolModule.F90 b/Source/Fortran/MatrixMemoryPoolModule.F90 index c46f4ee2..4143560c 100644 --- a/Source/Fortran/MatrixMemoryPoolModule.F90 +++ b/Source/Fortran/MatrixMemoryPoolModule.F90 @@ -91,11 +91,8 @@ SUBROUTINE ConstructMatrixMemoryPoolSub_lr(this, columns, rows, sparsity_in) !> Estimated sparsity (optional). REAL(NTREAL), INTENT(IN), OPTIONAL :: sparsity_in - IF (PRESENT(sparsity_in)) THEN - this = MatrixMemoryPool_lr(columns, rows, sparsity_in) - ELSE - this = MatrixMemoryPool_lr(columns, rows) - END IF +#include "dense_includes/ConstructMatrixMemoryPool.f90" + END SUBROUTINE ConstructMatrixMemoryPoolSub_lr !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Subroutine wrapper for the constructor. @@ -109,11 +106,8 @@ SUBROUTINE ConstructMatrixMemoryPoolSub_lc(this, columns, rows, sparsity_in) !> Estimated sparsity (optional). REAL(NTREAL), INTENT(IN), OPTIONAL :: sparsity_in - IF (PRESENT(sparsity_in)) THEN - this = MatrixMemoryPool_lc(columns, rows, sparsity_in) - ELSE - this = MatrixMemoryPool_lc(columns, rows) - END IF +#include "dense_includes/ConstructMatrixMemoryPool.f90" + END SUBROUTINE ConstructMatrixMemoryPoolSub_lc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct Matrix Memory Pool object. diff --git a/Source/Fortran/SMatrixModule.F90 b/Source/Fortran/SMatrixModule.F90 index f7fe42e9..de6141cb 100644 --- a/Source/Fortran/SMatrixModule.F90 +++ b/Source/Fortran/SMatrixModule.F90 @@ -145,11 +145,8 @@ PURE SUBROUTINE ConstructEmptyMatrixSub_lsr(this, rows, columns, zero_in) !> Whether to set the matrix to zero. LOGICAL, INTENT(IN), OPTIONAL :: zero_in - IF (PRESENT(zero_in)) THEN - this = ConstructEmptyMatrix_lsr(rows, columns, zero_in) - ELSE - this = ConstructEmptyMatrix_lsr(rows, columns) - ENDIF + CALL DestructMatrix(this) +#include "sparse_includes/ConstructEmptyMatrix.f90" END SUBROUTINE ConstructEmptyMatrixSub_lsr !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -164,11 +161,8 @@ PURE SUBROUTINE ConstructEmptyMatrixSub_lsc(this, rows, columns, zero_in) !> Whether to set the matrix to zero. LOGICAL, INTENT(IN), OPTIONAL :: zero_in - IF (PRESENT(zero_in)) THEN - this = ConstructEmptyMatrix_lsc(rows, columns, zero_in) - ELSE - this = ConstructEmptyMatrix_lsc(rows, columns) - ENDIF + CALL DestructMatrix(this) +#include "sparse_includes/ConstructEmptyMatrix.f90" END SUBROUTINE ConstructEmptyMatrixSub_lsc !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Source/Fortran/TripletListModule.F90 b/Source/Fortran/TripletListModule.F90 index ca71c474..478edfc3 100644 --- a/Source/Fortran/TripletListModule.F90 +++ b/Source/Fortran/TripletListModule.F90 @@ -107,11 +107,8 @@ PURE SUBROUTINE ConstructTripletListSup_r(this, size_in) !> The length of the triplet list (default=0). INTEGER, INTENT(IN), OPTIONAL :: size_in - IF (PRESENT(size_in)) THEN - this = ConstructTripletList_r(size_in) - ELSE - this = ConstructTripletList_r() - END IF +#include "triplet_includes/ConstructTripletList.f90" + END SUBROUTINE ConstructTripletListSup_r !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Subroutine wrapper for constructing a triplet list. @@ -121,11 +118,8 @@ PURE SUBROUTINE ConstructTripletListSup_c(this, size_in) !> The length of the triplet list (default=0). INTEGER, INTENT(IN), OPTIONAL :: size_in - IF (PRESENT(size_in)) THEN - this = ConstructTripletList_c(size_in) - ELSE - this = ConstructTripletList_c() - END IF +#include "triplet_includes/ConstructTripletList.f90" + END SUBROUTINE ConstructTripletListSup_c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !> Construct a triplet list. diff --git a/Source/Fortran/dense_includes/ConstructMatrixMemoryPool.f90 b/Source/Fortran/dense_includes/ConstructMatrixMemoryPool.f90 index bdfd4936..f83a5e80 100644 --- a/Source/Fortran/dense_includes/ConstructMatrixMemoryPool.f90 +++ b/Source/Fortran/dense_includes/ConstructMatrixMemoryPool.f90 @@ -2,6 +2,8 @@ INTEGER :: alloc_stat INTEGER :: num_buckets + CALL DestructMatrixMemoryPool(this) + this%columns = columns this%rows = rows diff --git a/Source/Fortran/triplet_includes/ConstructTripletList.f90 b/Source/Fortran/triplet_includes/ConstructTripletList.f90 index 95882f98..75160cb7 100644 --- a/Source/Fortran/triplet_includes/ConstructTripletList.f90 +++ b/Source/Fortran/triplet_includes/ConstructTripletList.f90 @@ -7,7 +7,8 @@ size = 0 END IF - IF (ALLOCATED(this%DATA)) DEALLOCATE(this%DATA) + CALL DestructTripletList(this) + this%CurrentSize = size ALLOCATE(this%DATA(size))