Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Append Methods #285

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 37 additions & 93 deletions src/modules/Utility/src/AppendUtility.F90
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ MODULE PURE SUBROUTINE expand_real32(vec, n, chunk_size, val, finished)
!! set to true to return `vec`
!! as its correct size (`n`)
END SUBROUTINE expand_real32

MODULE PURE SUBROUTINE expand_real64(vec, n, chunk_size, val, finished)
REAL(REAL64), ALLOCATABLE, INTENT(INOUT) :: vec(:)
INTEGER(I4B), INTENT(INOUT) :: n
Expand Down Expand Up @@ -159,45 +160,33 @@ END SUBROUTINE expand_real64
!- Append a scalar real to an real vector
!- Append a real vector to a real vector

INTERFACE
!>
INTERFACE Append
! Append a scalar int to a vector of int
!
MODULE PURE SUBROUTINE Append_1a(A, ENTRY)
INTEGER(I4B), ALLOCATABLE, INTENT(INOUT) :: A(:)
INTEGER(I4B), INTENT(IN) :: ENTRY
END SUBROUTINE Append_1a

!>
! Append a scalar real to a vector of real
!
MODULE PURE SUBROUTINE Append_1b(A, ENTRY)
REAL(DFP), ALLOCATABLE, INTENT(INOUT) :: A(:)
REAL(DFP), INTENT(IN) :: ENTRY
END SUBROUTINE Append_1b

!>
! Append a scalar and vector int to a vector of int
!
MODULE PURE SUBROUTINE Append_1c(C, A, B)
INTEGER(I4B), ALLOCATABLE, INTENT(INOUT) :: C(:)
INTEGER(I4B), INTENT(IN) :: A(:)
INTEGER(I4B), INTENT(IN) :: B
END SUBROUTINE Append_1c

!>
! Append a scalar and vector real to a vector of real
!
MODULE PURE SUBROUTINE Append_1d(C, A, B)
REAL(DFP), ALLOCATABLE, INTENT(INOUT) :: C(:)
REAL(DFP), INTENT(IN) :: A(:)
REAL(DFP), INTENT(IN) :: B
END SUBROUTINE Append_1d
END INTERFACE

INTERFACE Append
MODULE PROCEDURE Append_1a, Append_1b, Append_1c, Append_1d
END INTERFACE
END INTERFACE Append

!----------------------------------------------------------------------------
! Append@Methods
Expand All @@ -214,7 +203,7 @@ END SUBROUTINE Append_1d
!- Append two vectors of int to another vector of int
!- Append two vector of real to another vector of real

INTERFACE
INTERFACE Append
MODULE PURE SUBROUTINE Append_2a(A, ENTRY)
INTEGER(I4B), ALLOCATABLE, INTENT(INOUT) :: A(:)
INTEGER(I4B), INTENT(IN) :: ENTRY(:)
Expand All @@ -236,11 +225,22 @@ MODULE PURE SUBROUTINE Append_2d(C, A, B)
REAL(DFP), INTENT(IN) :: A(:)
REAL(DFP), INTENT(IN) :: B(:)
END SUBROUTINE Append_2d
END INTERFACE

INTERFACE Append
MODULE PROCEDURE Append_2a, Append_2b, Append_2c, Append_2d
END INTERFACE
MODULE PURE SUBROUTINE Append_2e(D, C, A, B)
INTEGER(I4B), ALLOCATABLE, INTENT(INOUT) :: D(:)
INTEGER(I4B), INTENT(IN) :: A(:)
INTEGER(I4B), INTENT(IN) :: B(:)
INTEGER(I4B), INTENT(IN) :: C(:)
END SUBROUTINE Append_2e

MODULE PURE SUBROUTINE Append_2f(D, C, A, B)
REAL(DFP), ALLOCATABLE, INTENT(INOUT) :: D(:)
REAL(DFP), INTENT(IN) :: A(:)
REAL(DFP), INTENT(IN) :: B(:)
REAL(DFP), INTENT(IN) :: C(:)
END SUBROUTINE Append_2f

END INTERFACE Append

!----------------------------------------------------------------------------
! Append@Methods
Expand All @@ -257,7 +257,7 @@ END SUBROUTINE Append_2d
!- Append a scalar and vector of int to another vector of int
!- Append a scalar and vector real to another vector of real

INTERFACE
INTERFACE Append
MODULE PURE SUBROUTINE Append_3a(A, ENTRY, mask)
INTEGER(I4B), ALLOCATABLE, INTENT(INOUT) :: A(:)
INTEGER(I4B), INTENT(IN) :: ENTRY
Expand All @@ -283,11 +283,7 @@ MODULE PURE SUBROUTINE Append_3d(C, A, B, mask)
REAL(DFP), INTENT(IN) :: B
LOGICAL(LGT), INTENT(IN) :: mask
END SUBROUTINE Append_3d
END INTERFACE

INTERFACE Append
MODULE PROCEDURE Append_3a, Append_3b, Append_3c, Append_3d
END INTERFACE
END INTERFACE Append

!----------------------------------------------------------------------------
! Append@Methods
Expand All @@ -302,7 +298,7 @@ END SUBROUTINE Append_3d
!- Append a vector of int to another vector of int
!- Append a vector of real to another vector of real

INTERFACE
INTERFACE Append
MODULE PURE SUBROUTINE Append_4a(A, ENTRY, mask)
INTEGER(I4B), ALLOCATABLE, INTENT(INOUT) :: A(:)
INTEGER(I4B), INTENT(IN) :: ENTRY(:)
Expand All @@ -328,11 +324,7 @@ MODULE PURE SUBROUTINE Append_4d(C, A, B, mask)
REAL(DFP), INTENT(IN) :: B(:)
LOGICAL(LGT), INTENT(IN) :: mask(:)
END SUBROUTINE Append_4d
END INTERFACE

INTERFACE Append
MODULE PROCEDURE Append_4a, Append_4b, Append_4c, Append_4d
END INTERFACE
END INTERFACE Append

!----------------------------------------------------------------------------
! Append@Methods
Expand All @@ -342,7 +334,7 @@ END SUBROUTINE Append_4d
! date: 22 March 2021
! summary: Append a scalar INTEGER to INTEGER vec tor

INTERFACE
INTERFACE OPERATOR(.Append.)
MODULE PURE FUNCTION func_Append_1a(A, ENTRY) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: A(:)
INTEGER(I4B), INTENT(IN) :: ENTRY
Expand All @@ -356,10 +348,6 @@ MODULE PURE FUNCTION func_Append_1b(A, ENTRY) RESULT(ans)
END FUNCTION func_Append_1b
END INTERFACE

INTERFACE OPERATOR(.APPEND.)
MODULE PROCEDURE func_Append_1a, func_Append_1b
END INTERFACE

!----------------------------------------------------------------------------
! Append@Methods
!----------------------------------------------------------------------------
Expand All @@ -368,7 +356,7 @@ END FUNCTION func_Append_1b
! date: 22 March 2021
! summary: Append two vectors of INTEGER

INTERFACE
INTERFACE OPERATOR(.APPEND.)
MODULE PURE FUNCTION func_Append_2a(A, ENTRY) RESULT(ans)
INTEGER(I4B), INTENT(IN) :: A(:)
INTEGER(I4B), INTENT(IN) :: ENTRY(:)
Expand All @@ -383,10 +371,6 @@ END FUNCTION func_Append_2b

END INTERFACE

INTERFACE OPERATOR(.APPEND.)
MODULE PROCEDURE func_Append_2a, func_Append_2b
END INTERFACE

!----------------------------------------------------------------------------
! ColConcat@Methods
!----------------------------------------------------------------------------
Expand All @@ -396,7 +380,7 @@ END FUNCTION func_Append_2b
! update: 2021-11-24
! summary: Concat columns of two vectors

INTERFACE
INTERFACE ColConcat
MODULE PURE FUNCTION colConcat_1a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:)
REAL(REAL32), INTENT(IN) :: b(:)
Expand Down Expand Up @@ -432,11 +416,6 @@ MODULE PURE FUNCTION colConcat_1f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION colConcat_1f
END INTERFACE

INTERFACE ColConcat
MODULE PROCEDURE colConcat_1a, colConcat_1b, colConcat_1c, &
& colConcat_1d, colConcat_1e, colConcat_1f
END INTERFACE ColConcat

INTERFACE OPERATOR(.ColConcat.)
Expand All @@ -453,7 +432,7 @@ END FUNCTION colConcat_1f
! update: 2021-11-24
! summary: Concat columns of a matrix and a vector

INTERFACE
INTERFACE ColConcat
MODULE PURE FUNCTION colConcat_2a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:, :)
REAL(REAL32), INTENT(IN) :: b(:)
Expand Down Expand Up @@ -489,11 +468,6 @@ MODULE PURE FUNCTION colConcat_2f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION colConcat_2f
END INTERFACE

INTERFACE ColConcat
MODULE PROCEDURE colConcat_2a, colConcat_2b, colConcat_2c, &
& colConcat_2d, colConcat_2e, colConcat_2f
END INTERFACE ColConcat

INTERFACE OPERATOR(.ColConcat.)
Expand All @@ -510,7 +484,7 @@ END FUNCTION colConcat_2f
! update: 2021-11-24
! summary: Concat columns of rank1 and rank2 array

INTERFACE
INTERFACE ColConcat
MODULE PURE FUNCTION colConcat_3a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:)
REAL(REAL32), INTENT(IN) :: b(:, :)
Expand Down Expand Up @@ -546,11 +520,6 @@ MODULE PURE FUNCTION colConcat_3f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:, :)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION colConcat_3f
END INTERFACE

INTERFACE ColConcat
MODULE PROCEDURE colConcat_3a, colConcat_3b, colConcat_3c, &
& colConcat_3d, colConcat_3e, colConcat_3f
END INTERFACE ColConcat

INTERFACE OPERATOR(.ColConcat.)
Expand All @@ -567,7 +536,7 @@ END FUNCTION colConcat_3f
! update: 2021-11-24
! summary: Concat columns of rank2 and rank2 array

INTERFACE
INTERFACE ColConcat
MODULE PURE FUNCTION colConcat_4a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:, :)
REAL(REAL32), INTENT(IN) :: b(:, :)
Expand Down Expand Up @@ -603,11 +572,6 @@ MODULE PURE FUNCTION colConcat_4f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:, :)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION colConcat_4f
END INTERFACE

INTERFACE ColConcat
MODULE PROCEDURE colConcat_4a, colConcat_4b, colConcat_4c, &
& colConcat_4d, colConcat_4e, colConcat_4f
END INTERFACE ColConcat

INTERFACE OPERATOR(.ColConcat.)
Expand All @@ -624,7 +588,7 @@ END FUNCTION colConcat_4f
! update: 2021-11-24
! summary: Concat rows of two vectors

INTERFACE
INTERFACE RowConcat
MODULE PURE FUNCTION rowConcat_1a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:)
REAL(REAL32), INTENT(IN) :: b(:)
Expand Down Expand Up @@ -660,12 +624,7 @@ MODULE PURE FUNCTION rowConcat_1f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION rowConcat_1f
END INTERFACE

INTERFACE rowConcat
MODULE PROCEDURE rowConcat_1a, rowConcat_1b, rowConcat_1c, &
& rowConcat_1d, rowConcat_1e, rowConcat_1f
END INTERFACE rowConcat
END INTERFACE RowConcat

INTERFACE OPERATOR(.rowConcat.)
MODULE PROCEDURE rowConcat_1a, rowConcat_1b, rowConcat_1c, &
Expand All @@ -681,7 +640,7 @@ END FUNCTION rowConcat_1f
! update: 2021-11-24
! summary: Concat rows of a matrix and a vector

INTERFACE
INTERFACE RowConcat
MODULE PURE FUNCTION rowConcat_2a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:, :)
REAL(REAL32), INTENT(IN) :: b(:)
Expand Down Expand Up @@ -717,12 +676,7 @@ MODULE PURE FUNCTION rowConcat_2f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION rowConcat_2f
END INTERFACE

INTERFACE rowConcat
MODULE PROCEDURE rowConcat_2a, rowConcat_2b, rowConcat_2c, &
& rowConcat_2d, rowConcat_2e, rowConcat_2f
END INTERFACE rowConcat
END INTERFACE RowConcat

INTERFACE OPERATOR(.rowConcat.)
MODULE PROCEDURE rowConcat_2a, rowConcat_2b, rowConcat_2c, &
Expand All @@ -738,7 +692,7 @@ END FUNCTION rowConcat_2f
! update: 2021-11-24
! summary: Concat rows of rank1 and rank2 array

INTERFACE
INTERFACE RowConcat
MODULE PURE FUNCTION rowConcat_3a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:)
REAL(REAL32), INTENT(IN) :: b(:, :)
Expand Down Expand Up @@ -774,12 +728,7 @@ MODULE PURE FUNCTION rowConcat_3f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:, :)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION rowConcat_3f
END INTERFACE

INTERFACE rowConcat
MODULE PROCEDURE rowConcat_3a, rowConcat_3b, rowConcat_3c, &
& rowConcat_3d, rowConcat_3e, rowConcat_3f
END INTERFACE rowConcat
END INTERFACE RowConcat

INTERFACE OPERATOR(.rowConcat.)
MODULE PROCEDURE rowConcat_3a, rowConcat_3b, rowConcat_3c, &
Expand All @@ -795,7 +744,7 @@ END FUNCTION rowConcat_3f
! update: 2021-11-24
! summary: Concat rows of rank2 and rank2 array

INTERFACE
INTERFACE RowConcat
MODULE PURE FUNCTION rowConcat_4a(a, b) RESULT(ans)
REAL(REAL32), INTENT(IN) :: a(:, :)
REAL(REAL32), INTENT(IN) :: b(:, :)
Expand Down Expand Up @@ -831,12 +780,7 @@ MODULE PURE FUNCTION rowConcat_4f(a, b) RESULT(ans)
INTEGER(INT8), INTENT(IN) :: b(:, :)
INTEGER(INT8), ALLOCATABLE :: ans(:, :)
END FUNCTION rowConcat_4f
END INTERFACE

INTERFACE rowConcat
MODULE PROCEDURE rowConcat_4a, rowConcat_4b, rowConcat_4c, &
& rowConcat_4d, rowConcat_4e, rowConcat_4f
END INTERFACE rowConcat
END INTERFACE RowConcat

INTERFACE OPERATOR(.rowConcat.)
MODULE PROCEDURE rowConcat_4a, rowConcat_4b, rowConcat_4c, &
Expand Down
29 changes: 29 additions & 0 deletions src/submodules/Utility/src/Append/Append_2abcd.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
! This program is a part of EASIFEM library
! Copyright (C) 2020-2021 Vikas Sharma, Ph.D
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <https: //www.gnu.org/licenses/>
!

INTEGER(I4B) :: na, nb, nc

na = SIZE( A )
nb = SIZE( B )
nc = SIZE( C )

CALL Reallocate( D, na+nb+nc )
IF(na .gt. 0) D(1:na) = A
IF(nb .gt. 0) D(na + 1: na+nb) = B
IF(nc .gt. 0) D(na + nb + 1:) = C


Loading
Loading