|
| 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 | +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
0 commit comments