Skip to content

Commit 1a4f058

Browse files
authored
[Enhancement] Add Procedures for Intrinsic character Type (#7)
* Update lib.f08 * Update lib.f08 * Create type_character.f08 * Update README.md * Update README.md * Update .justfile * Create feature:character.rst * Update doxygen.cfg * Update type_character.f08 * Create cnddel_character.f08 * Update type_character.f08 * Update feature:character.rst * Create cndall_character.f08 * Update cndall_character.f08 * Update cnddel_character.f08 * Update cndall_character.f08
1 parent 1d6090b commit 1a4f058

File tree

8 files changed

+214
-4
lines changed

8 files changed

+214
-4
lines changed

.justfile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
alias a := all
3535
alias b := library
3636
alias build := library
37+
alias clr := clear
3738
alias d := doxygen
3839
alias l := library
3940
alias ver := bump
@@ -58,13 +59,21 @@ f18-lib := f18 + ' ' + lib + ' ' + flags
5859
@default: all
5960

6061
# Execute all configured recipes.
61-
@all: doxygen library
62+
@all: clear doxygen library
6263

6364
# Increment the version numbers.
6465
@bump part:
6566
bump2version {{part}}
6667
scriv collect
6768

69+
# Compile the procedures for the `character` type.
70+
@character: interfaces
71+
just compile src/type_character.f08
72+
73+
# Remove build artifacts.
74+
@clear:
75+
git clean -dfx
76+
6877
# Compile the given source file and add it to the library.
6978
@compile source_file:
7079
gfortran {{f18-lib}} {{source_file}}
@@ -77,8 +86,11 @@ f18-lib := f18 + ' ' + lib + ' ' + flags
7786
cd latex/ && latexmk -f -r ../.latexmkrc --silent refman
7887
cp latex/refman.pdf doxygen.pdf
7988

80-
# Compile the target library.
81-
@library:
89+
# Create the library interfaces.
90+
@interfaces:
8291
just compile src/lib.f08
8392

93+
# Compile the target library.
94+
@library: character
95+
8496
################################################################################

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ version is as follows:
6565
| bump2version | Python CLI | automatic version increment |
6666
| Doxygen | application | source code documentation |
6767
| GFortran | application | Fortran 2018 compiler |
68+
| Git | application | build artifact removal |
6869
| Just | Rust binary | execution of the build instructions |
6970
| Latexmk | application | LaTeX compilation of Doxygen manual |
7071
| Scriv | Python CLI | changelog management |
@@ -92,4 +93,9 @@ In order to simplify the maintenance, **bump2version** as well as **Scriv** are
9293
used to automate the release generation. Scriv will compile the changelog on
9394
release after all version numbers were incremented by bump2version.
9495

96+
Build artifacts are prevented from begin committed by the `.gitignore` this
97+
repository contains. It furthermore controls which files are going to be
98+
removed by `git clean`. Thus, it is the simplest solution to employ **Git** for
99+
the removal of build artifacts.
100+
95101
<!----------------------------------------------------------------------------->

changelog.d/feature:character.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Added
2+
.....
3+
4+
- define library utility subroutine for conditional allocation and assignment
5+
of an allocatable object of type standard ``character``
6+
7+
- define library utility subroutine for conditional deallocation of an
8+
allocatable object of type standard ``character``
9+
10+
- define submodule for procedures associated with the standard ``character``
11+
intrinsic type

doxygen.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,8 @@ WARN_LOGFILE =
906906
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
907907
# Note: If this tag is empty the current directory is searched.
908908

909-
INPUT = src/
909+
INPUT = src/ \
910+
src/type_character/
910911

911912
# This tag can be used to specify the character encoding of the source files
912913
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

src/lib.f08

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,24 @@ module libcndmem
4848
private
4949
!> This library's version.
5050
character (*), parameter, public :: library_version = 'v0.0.0'
51+
52+
public :: cndall
53+
public :: cnddel
54+
55+
interface cndall
56+
pure module subroutine cndall_character (tgt, src)
57+
implicit none
58+
character (*), intent (in) :: src
59+
character (:), allocatable, intent (inout) :: tgt
60+
end subroutine cndall_character
61+
end interface cndall
62+
63+
interface cnddel
64+
pure module subroutine cnddel_character (tgt)
65+
implicit none
66+
character (:), allocatable, intent (inout) :: tgt
67+
end subroutine cnddel_character
68+
end interface cnddel
5169
end module libcndmem
5270

5371
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

src/type_character.f08

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
!!!!!!!!!!!!!!!!!!!!!!!! GNU General Public License 2.0 !!!!!!!!!!!!!!!!!!!!!!!!
2+
!! !!
3+
!! Copyright (C) 2022 Kevin Matthes !!
4+
!! !!
5+
!! This program is free software; you can redistribute it and/or modify !!
6+
!! it under the terms of the GNU General Public License as published by !!
7+
!! the Free Software Foundation; either version 2 of the License, or !!
8+
!! (at your option) any later version. !!
9+
!! !!
10+
!! This program is distributed in the hope that it will be useful, !!
11+
!! but WITHOUT ANY WARRANTY; without even the implied warranty of !!
12+
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !!
13+
!! GNU General Public License for more details. !!
14+
!! !!
15+
!! You should have received a copy of the GNU General Public License along !!
16+
!! with this program; if not, write to the Free Software Foundation, Inc., !!
17+
!! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. !!
18+
!! !!
19+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20+
21+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22+
!!
23+
!> \file type_character.f08
24+
!!
25+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26+
27+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28+
!!
29+
!> \author Kevin Matthes
30+
!> \copyright GPL-2.0
31+
!> \date 2022
32+
!> \note See `LICENSE' for full license.
33+
!> See `README.md' for project details.
34+
!>
35+
!> \brief The submodule defining procedures for the `character` type.
36+
!>
37+
!> This submodule contains the procedures associated with the `character`
38+
!> intrinsic type.
39+
!!
40+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41+
42+
submodule (libcndmem) type_character
43+
implicit none
44+
contains
45+
include 'type_character/cndall_character.f08'
46+
include 'type_character/cnddel_character.f08'
47+
end submodule type_character
48+
49+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
!!!!!!!!!!!!!!!!!!!!!!!! GNU General Public License 2.0 !!!!!!!!!!!!!!!!!!!!!!!!
2+
!! !!
3+
!! Copyright (C) 2022 Kevin Matthes !!
4+
!! !!
5+
!! This program is free software; you can redistribute it and/or modify !!
6+
!! it under the terms of the GNU General Public License as published by !!
7+
!! the Free Software Foundation; either version 2 of the License, or !!
8+
!! (at your option) any later version. !!
9+
!! !!
10+
!! This program is distributed in the hope that it will be useful, !!
11+
!! but WITHOUT ANY WARRANTY; without even the implied warranty of !!
12+
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !!
13+
!! GNU General Public License for more details. !!
14+
!! !!
15+
!! You should have received a copy of the GNU General Public License along !!
16+
!! with this program; if not, write to the Free Software Foundation, Inc., !!
17+
!! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. !!
18+
!! !!
19+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20+
21+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22+
!!
23+
!> \file cndall_character.f08
24+
!!
25+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26+
27+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28+
!!
29+
!> \author Kevin Matthes
30+
!> \copyright GPL-2.0
31+
!> \date 2022
32+
!> \note See `LICENSE' for full license.
33+
!> See `README.md' for project details.
34+
!>
35+
!> \brief Allocate the appropriate amount of memory for the assignment.
36+
!> \param tgt The allocatable object to receive the value.
37+
!> \param src The object to assign.
38+
!>
39+
!> This subroutine will **c**o**nd**itionally **all**ocate the given allocatable
40+
!> object and assign the other object to it. If the given allocatable object is
41+
!> not already allocated, the appropriate amount of memory will be allocated.
42+
!> If it should already be allocated, the memory will be reallocated.
43+
!!
44+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
45+
46+
pure subroutine cndall_character (tgt, src)
47+
implicit none
48+
character (*), intent (in) :: src
49+
character (:), allocatable, intent (inout) :: tgt
50+
intrinsic :: allocated
51+
intrinsic :: len
52+
53+
if (.not. allocated (tgt)) then
54+
allocate (character (len (src)) :: tgt)
55+
end if
56+
57+
tgt = src
58+
end subroutine cndall_character
59+
60+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
!!!!!!!!!!!!!!!!!!!!!!!! GNU General Public License 2.0 !!!!!!!!!!!!!!!!!!!!!!!!
2+
!! !!
3+
!! Copyright (C) 2022 Kevin Matthes !!
4+
!! !!
5+
!! This program is free software; you can redistribute it and/or modify !!
6+
!! it under the terms of the GNU General Public License as published by !!
7+
!! the Free Software Foundation; either version 2 of the License, or !!
8+
!! (at your option) any later version. !!
9+
!! !!
10+
!! This program is distributed in the hope that it will be useful, !!
11+
!! but WITHOUT ANY WARRANTY; without even the implied warranty of !!
12+
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the !!
13+
!! GNU General Public License for more details. !!
14+
!! !!
15+
!! You should have received a copy of the GNU General Public License along !!
16+
!! with this program; if not, write to the Free Software Foundation, Inc., !!
17+
!! 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. !!
18+
!! !!
19+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20+
21+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22+
!!
23+
!> \file cnddel_character.f08
24+
!!
25+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26+
27+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28+
!!
29+
!> \author Kevin Matthes
30+
!> \copyright GPL-2.0
31+
!> \date 2022
32+
!> \note See `LICENSE' for full license.
33+
!> See `README.md' for project details.
34+
!>
35+
!> \brief Deallocate the given allocatable object if it is allocated.
36+
!> \param tgt The object to deallocate.
37+
!>
38+
!> This subroutine will **c**o**nd**itionally **de**a**l**locate the given
39+
!> allocatable object. If it is allocated, it will be deallocated.
40+
!!
41+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42+
43+
pure subroutine cnddel_character (tgt)
44+
implicit none
45+
character (:), allocatable, intent (inout) :: tgt
46+
intrinsic :: allocated
47+
48+
if (allocated (tgt)) then
49+
deallocate (tgt)
50+
end if
51+
end subroutine cnddel_character
52+
53+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

0 commit comments

Comments
 (0)