ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_arrayResize::setResized Interface Reference

Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1..3 to an arbitrary size while preserving the original contents or a subset of it.
More...

Detailed Description

Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1..3 to an arbitrary size while preserving the original contents or a subset of it.

The new array size is set to twice its current size or, to the requested input size(..).
The array contents or a requested subset of it are kept in the original indices in the output resized array or shifted to a new starting location lbc in the output array.

The following figure illustrates example resizing of a 1D array and transferal of its contents.


Parameters
[in,out]array: The input/output allocatable scalar of
  1. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU)
or array of rank 1..3 of either
  1. type css_pdt (parameterized container of string of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU)) or,
  2. type css_type (container of string of default kind SK) or,
  3. type character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU)
  4. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64)
  5. type logical of kind any supported by the processor (e.g., LK)
  6. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128)
  7. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128)
On output, the array will be (re)allocated to the requested new size with the same lower bound as before (or 1 if unallocated).
[in]size: The input non-negative scalar or array of type integer of default kind IK representing the new size of the output array.
  1. If array is a scalar or array of rank 1, then size must be a scalar.
  2. If array is an array of rank > 1, then size must be a vector of the same length as rank(array).
(optional, default = 2 * len/shape(array) where the condition 0 < len/shape(array) must hold, otherwise infinite loops within the program can occur.)
[in]lbc: The input scalar or array of type integer of default kind IK, representing the Lower Bound(s) of the Contents in the newly resized output array.
  1. If array is a scalar or array of rank 1, then lbc must be a scalar.
  2. If array is an array of rank > 1, then lbc must be a vector of the same length as rank(array).
(optional, default = lbcold. It can be present only if the size argument is also present.)
[in]lbcold: The input scalar or array of type integer of default kind IK, representing the Lower Bound(s) of the Contents in the original (old) input array that is to be copied to the newly allocated output array starting at the new lower bound(s) lbc.
(optional, default = ubound(array). If array is a scalar string, then default = 1. It can be present only if the size, lbc, and ubcold input arguments are also present.)
[in]ubcold: The input scalar or array of type integer of default kind IK, representing the Upper Bound(s) of the Contents in the original (old) input array that is to be copied to the newly allocated output array starting at the new lower bound(s) lbc.
(optional, default = ubound(array). If array is a scalar string, then default = len(array) It can be present only if the size and lbc and lbcold input arguments are also present.)
[out]failed: The output scalar logical of default kind LK that is .false. if and only if the requested array resizing is successful, otherwise it is set to .true. to signal the occurrence of an allocation error.
The value of failed is .true. only if the stat argument returned by the Fortran intrinsic allocate() statement is non-zero.
(optional, if missing and an allocation error occurs, the processor dictates the program behavior (normally execution stops).)
[out]errmsg: The output scalar character of default kind SK of arbitrary length type parameter.
If the optional output argument failed is present and an error occurs, errmsg will be set to a message describing the nature of the error.
This behavior conforms with the standard Fortran behavior for the intrinsic allocate() statement.
A length type parameter of 127 or more for errmsg should be sufficient for capturing most if not all error messages in entirety.
(optional. Its presence is relevant if and only if the optional output argument failed is also present.)


Possible calling interfaces

call setResized(array, failed = failed, errmsg = errmsg) ! Resize to twice as large with the same lower bound as before and optionally gracefully return if reallocation fails.
call setResized(array, size, failed = failed, errmsg = errmsg) ! Resize to the requested `size` with the same lower bound as before and optionally gracefully return if reallocation fails.
call setResized(array, size, lbc, failed = failed, errmsg = errmsg) ! Resize to the requested `size`, write `array` to the output `array(\@lbc:)`, optionally gracefully return upon failure.
call setResized(array, size, lbc, lbcold, ubcold, failed = failed, errmsg = errmsg) ! Resize to the requested `size` with the same lower bound, write `array(\@lbcold:ubcold)` to `array(\@lbc:\@lbc-lbcold+ubcold)`, optionally gracefully return upon failure.
!
Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1....
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
Warning
Note that the new elements of the newly allocated array are not initialized to any particular value on output.
if array is a container of an allocatable component, the new elements remain unallocated upon return.
In such a case, the contents of the new elements of the output array is processor dependent, frequently meaningless, and should not be relied upon, even if they seem to have been initialized.
If the initialization of the new elements with a specific fill is necessary, use setRefilled to resize arrays and filling the new elements.
The condition all(0 < len/shape(array)) must hold for the corresponding input arguments when the input size argument is missing.
The condition allocated(array) must hold (the input array must be preallocated) when any or all of the optional input arguments lbc, lbcold, ubcold are present or when the size argument is missing.
The condition all(0 <= size) must hold for the corresponding input argument.
The condition all(lbound(array) <= lbcold .and. lbcold <= ubound(array)) must hold for the corresponding input arguments.
The condition all(lbound(array) <= ubcold .and. ubcold <= ubound(array)) must hold for the corresponding input arguments.
The condition all(lbound(array) <= lbc) must hold for the corresponding input arguments.
The condition all(lbc + ubcold - lbcold <= lbound(array) + size - 1) must hold for the corresponding input arguments (i.e., the upper bound(s) of contents cannot overflow the upper bound(s) of the new array).
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Note
If the input array is unallocated, it will be allocated to the requested shape, equivalent to allocate(array(@size)).
The sole purpose of this generic interface is to provide a convenient but fast method of resizing allocatable arrays without losing the contents of the array.
See pm_arrayResize for the relevant benchmarks.
Developer Remark:
An optional dummy argument stat (instead of failed) for the procedures of this generic interface are impossible as it creates ambiguous interfaces.
See also
setResized
setRebound
setRefilled
setRebilled
getCoreHalo
setCoreHalo
getCentered
setCentered
getPadded
setPadded


Example usage

1! Define an expansion procedure call macro to avoid duplications in the example source file. Check the output file for usage.
2#define RESIZE_ARRAY \
3block; \
4 DECLARE; \
5 CONSTRUCT; \
6 call disp%show('array'); \
7 call disp%show( array , deliml = SK_"""" ); \
8 call disp%show('lbound(array)'); \
9 call disp%show( lbound(array) ); \
10 call disp%show('ubound(array)'); \
11 call disp%show( ubound(array) ); \
12 call disp%show('size'); \
13 call disp%show( SIZE ); \
14 call disp%show('array'); \
15 call disp%show( array , deliml = SK_"""" ); \
16 call disp%show('lbound(array)'); \
17 call disp%show( lbound(array) ); \
18 call disp%show('ubound(array)'); \
19 call disp%show( ubound(array) ); \
20end block;
21
22! Define an expansion with contents shifting procedure call macro to avoid duplications in the example source file. Check the output file for usage.
23#define RESIZE_SHIFT_ARRAY \
24block; \
25 DECLARE; \
26 CONSTRUCT; \
27 call disp%show('array'); \
28 call disp%show( array , deliml = SK_"""" ); \
29 call disp%show('lbound(array)'); \
30 call disp%show( lbound(array) ); \
31 call disp%show('ubound(array)'); \
32 call disp%show( ubound(array) ); \
33 call disp%show('size'); \
34 call disp%show( SIZE ); \
35 call disp%show('lbc'); \
36 call disp%show( LBC ); \
37 call disp%show('array'); \
38 call disp%show( array , deliml = SK_"""" ); \
39 call disp%show('lbound(array)'); \
40 call disp%show( lbound(array) ); \
41 call disp%show('ubound(array)'); \
42 call disp%show( ubound(array) ); \
43end block;
44
45! Define an expansion/shrinkage with contents shifting and subsetting procedure call macro to avoid duplications in the example source file. Check the output file for usage.
46#define RESIZE_SHIFT_SUBSET_ARRAY \
47block; \
48 DECLARE; \
49 CONSTRUCT; \
50 call disp%show('array'); \
51 call disp%show( array , deliml = SK_"""" ); \
52 call disp%show('lbound(array)'); \
53 call disp%show( lbound(array) ); \
54 call disp%show('ubound(array)'); \
55 call disp%show( ubound(array) ); \
56 call disp%show('size'); \
57 call disp%show( SIZE ); \
58 call disp%show('lbc'); \
59 call disp%show( LBC ); \
60 call disp%show('lbcold'); \
61 call disp%show( LBCOLD ); \
62 call disp%show('ubcold'); \
63 call disp%show( UBCOLD ); \
64 call disp%show('array'); \
65 call disp%show( array , deliml = SK_"""" ); \
66 call disp%show('lbound(array)'); \
67 call disp%show( lbound(array) ); \
68 call disp%show('ubound(array)'); \
69 call disp%show( ubound(array) ); \
70end block;
71
72program example
73
74 use pm_kind, only: SK, IK
75 use pm_kind, only: SKG => SK ! All kinds are supported.
76 use pm_kind, only: LKG => LK ! All kinds are supported.
77 use pm_kind, only: IKG => IK ! All kinds are supported.
78 use pm_kind, only: CKG => CK ! All kinds are supported.
79 use pm_kind, only: RKG => RK ! All kinds are supported.
80 use pm_io, only: display_type
81 use pm_arrayResize, only: setResized
82
83 implicit none
84
85 type(display_type) :: disp
86 disp = display_type(file = "main.out.F90")
87
88 call disp%skip()
89 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
90 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
91 call disp%show("! Expand an array with specific size.")
92 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
93 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
94 call disp%skip()
95
96 call disp%skip()
97 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
98 call disp%show("! Expand `character` vector.")
99 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
100 call disp%skip()
101
102#define SIZE 9_IK
103#define DECLARE character(2,SKG), allocatable :: array(:)
104#define CONSTRUCT allocate(array(3:8)); array(:) = ["AA", "BB", "CC", "DD", "EE", "FF"]
105RESIZE_ARRAY
106
107 call disp%skip()
108 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
109 call disp%show("! Expand `integer` vector.")
110 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
111 call disp%skip()
112
113#define SIZE 9_IK
114#define DECLARE integer(IKG), allocatable :: array(:)
115#define CONSTRUCT allocate(array(3:8)); array(:) = [1, 2, 3, 4, 5, 6]
116RESIZE_ARRAY
117
118 call disp%skip()
119 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
120 call disp%show("! Expand `logical` vector.")
121 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
122 call disp%skip()
123
124#define SIZE 9_IK
125#define DECLARE logical(LKG), allocatable :: array(:)
126#define CONSTRUCT allocate(array(3:8)); array(:) = [.true., .true., .true., .true., .true., .true.]
127RESIZE_ARRAY
128
129 call disp%skip()
130 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
131 call disp%show("! Expand `complex` vector.")
132 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
133 call disp%skip()
134
135#define SIZE 9_IK
136#define DECLARE complex(CKG), allocatable :: array(:)
137#define CONSTRUCT allocate(array(3:8)); array(:) = [(1., -1.), (2., -2.), (3., -3.), (4., -4.), (5., -5.), (6., -6.)]
138RESIZE_ARRAY
139
140 call disp%skip()
141 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
142 call disp%show("! Expand `real` vector.")
143 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
144 call disp%skip()
145
146#define SIZE 9_IK
147#define DECLARE real(RKG), allocatable :: array(:)
148#define CONSTRUCT allocate(array(3:8)); array(:) = [1., 2., 3., 4., 5., 6.]
149RESIZE_ARRAY
150
151 call disp%skip()
152 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
153 call disp%show("! Expand `character` matrix.")
154 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
155 call disp%skip()
156
157#define SIZE [9_IK, 9_IK]
158#define DECLARE character(2,SKG), allocatable :: array(:,:)
159#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
160RESIZE_ARRAY
161
162 call disp%skip()
163 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
164 call disp%show("! Expand `character` cube.")
165 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
166 call disp%skip()
167
168#define SIZE [9_IK, 9_IK, 3_IK]
169#define DECLARE character(2,SKG), allocatable :: array(:,:,:)
170#define CONSTRUCT allocate(array(2:3,3:5,2:2)); array(:,:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [3, 2, 1])
171RESIZE_ARRAY
172
173 call disp%skip()
174 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
175 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
176 call disp%show("! Expand an array and shift its contents.")
177 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
178 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
179 call disp%skip()
180
181 call disp%skip()
182 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
183 call disp%show("! Expand and shift `character` vector.")
184 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
185 call disp%skip()
186
187#define SIZE 13_IK
188#define LBC 5_IK
189#define DECLARE character(2,SKG), allocatable :: array(:)
190#define CONSTRUCT allocate(array(3:8)); array(:) = ["AA", "BB", "CC", "DD", "EE", "FF"]
191RESIZE_SHIFT_ARRAY
192
193 call disp%skip()
194 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
195 call disp%show("! Expand and shift `character` matrix.")
196 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
197 call disp%skip()
198
199#define SIZE [6_IK, 6_IK]
200#define LBC [4_IK, 4_IK]
201#define DECLARE character(2,SKG), allocatable :: array(:,:)
202#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
203RESIZE_SHIFT_ARRAY
204
205 call disp%skip()
206 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
207 call disp%show("! Expand and shift `character` cube.")
208 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
209 call disp%skip()
210
211#define SIZE [6_IK, 6_IK, 3_IK]
212#define LBC [3_IK, 4_IK, 2_IK]
213#define DECLARE character(2,SKG), allocatable :: array(:,:,:)
214#define CONSTRUCT allocate(array(1:2,1:3,1:1)); array(:,:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [3, 2, 1])
215RESIZE_SHIFT_ARRAY
216
217 call disp%skip()
218 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
219 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
220 call disp%show("! Expand an array and shift a subset of its contents.")
221 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
222 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
223 call disp%skip()
224
225 call disp%skip()
226 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
227 call disp%show("! Expand and shift `character` vector.")
228 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
229 call disp%skip()
230
231#define SIZE 13_IK
232#define LBC 5_IK
233#define LBCOLD 5_IK
234#define UBCOLD 7_IK
235#define DECLARE character(2,SKG), allocatable :: array(:)
236#define CONSTRUCT allocate(array(3:8)); array(:) = ["AA", "BB", "CC", "DD", "EE", "FF"]
237RESIZE_SHIFT_SUBSET_ARRAY
238
239 call disp%skip()
240 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
241 call disp%show("! Expand and shift `character` matrix.")
242 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
243 call disp%skip()
244
245#define SIZE [2_IK, 3_IK]
246#define LBC [2_IK, 4_IK]
247#define LBCOLD [2_IK, 4_IK]
248#define UBCOLD [3_IK, 5_IK]
249#define DECLARE character(2,SKG), allocatable :: array(:,:)
250#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
251RESIZE_SHIFT_SUBSET_ARRAY
252
253 call disp%skip()
254 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
255 call disp%show("! Expand and shift `character` cube.")
256 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
257 call disp%skip()
258
259#define SIZE [2_IK, 2_IK, 4_IK]
260#define LBC [1_IK, 1_IK, 3_IK]
261#define LBCOLD [1_IK, 2_IK, 2_IK]
262#define UBCOLD [2_IK, 3_IK, 2_IK]
263#define DECLARE character(2,SKG), allocatable :: array(:,:,:)
264#define CONSTRUCT allocate(array(1:2,1:3,1:2)); array(:,:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF", "GG", "HH", "II", "JJ", "KK", "LL"], shape = shape(array), order = [3, 2, 1])
265RESIZE_SHIFT_SUBSET_ARRAY
266
267end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
Definition: pm_kind.F90:543
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter CK
The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I...
Definition: pm_kind.F90:542
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4! Expand an array with specific size.
5!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8
9!%%%%%%%%%%%%%%%%%%%%%%%%%%%
10! Expand `character` vector.
11!%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
13array
14"AA", "BB", "CC", "DD", "EE", "FF"
15lbound(array)
16+3
17ubound(array)
18+8
19size
20+9
21array
22"AA", "BB", "CC", "DD", "EE", "FF"
23lbound(array)
24+3
25ubound(array)
26+8
27
28!%%%%%%%%%%%%%%%%%%%%%%%%%
29! Expand `integer` vector.
30!%%%%%%%%%%%%%%%%%%%%%%%%%
31
32array
33"+1", "+2", "+3", "+4", "+5", "+6"
34lbound(array)
35+3
36ubound(array)
37+8
38size
39+9
40array
41"+1", "+2", "+3", "+4", "+5", "+6"
42lbound(array)
43+3
44ubound(array)
45+8
46
47!%%%%%%%%%%%%%%%%%%%%%%%%%
48! Expand `logical` vector.
49!%%%%%%%%%%%%%%%%%%%%%%%%%
50
51array
52"T", "T", "T", "T", "T", "T"
53lbound(array)
54+3
55ubound(array)
56+8
57size
58+9
59array
60"T", "T", "T", "T", "T", "T"
61lbound(array)
62+3
63ubound(array)
64+8
65
66!%%%%%%%%%%%%%%%%%%%%%%%%%
67! Expand `complex` vector.
68!%%%%%%%%%%%%%%%%%%%%%%%%%
69
70array
71"+1.0000000000000000, -1.0000000000000000", "+2.0000000000000000, -2.0000000000000000", "+3.0000000000000000, -3.0000000000000000", "+4.0000000000000000, -4.0000000000000000", "+5.0000000000000000, -5.0000000000000000", "+6.0000000000000000, -6.0000000000000000"
72lbound(array)
73+3
74ubound(array)
75+8
76size
77+9
78array
79"+1.0000000000000000, -1.0000000000000000", "+2.0000000000000000, -2.0000000000000000", "+3.0000000000000000, -3.0000000000000000", "+4.0000000000000000, -4.0000000000000000", "+5.0000000000000000, -5.0000000000000000", "+6.0000000000000000, -6.0000000000000000"
80lbound(array)
81+3
82ubound(array)
83+8
84
85!%%%%%%%%%%%%%%%%%%%%%%
86! Expand `real` vector.
87!%%%%%%%%%%%%%%%%%%%%%%
88
89array
90"+1.0000000000000000", "+2.0000000000000000", "+3.0000000000000000", "+4.0000000000000000", "+5.0000000000000000", "+6.0000000000000000"
91lbound(array)
92+3
93ubound(array)
94+8
95size
96+9
97array
98"+1.0000000000000000", "+2.0000000000000000", "+3.0000000000000000", "+4.0000000000000000", "+5.0000000000000000", "+6.0000000000000000"
99lbound(array)
100+3
101ubound(array)
102+8
103
104!%%%%%%%%%%%%%%%%%%%%%%%%%%%
105! Expand `character` matrix.
106!%%%%%%%%%%%%%%%%%%%%%%%%%%%
107
108array
109"AA", "BB", "CC"
110"DD", "EE", "FF"
111lbound(array)
112+2, +3
113ubound(array)
114+3, +5
115size
116+9, +9
117array
118"AA", "BB", "CC"
119"DD", "EE", "FF"
120lbound(array)
121+2, +3
122ubound(array)
123+3, +5
124
125!%%%%%%%%%%%%%%%%%%%%%%%%%
126! Expand `character` cube.
127!%%%%%%%%%%%%%%%%%%%%%%%%%
128
129array
130slice(:,:,1) =
131"AA", "BB", "CC"
132"DD", "EE", "FF"
133lbound(array)
134+2, +3, +2
135ubound(array)
136+3, +5, +2
137size
138+9, +9, +3
139array
140slice(:,:,1) =
141"AA", "BB", "CC"
142"DD", "EE", "FF"
143lbound(array)
144+2, +3, +2
145ubound(array)
146+3, +5, +2
147
148!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
150! Expand an array and shift its contents.
151!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
152!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
153
154
155!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
156! Expand and shift `character` vector.
157!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158
159array
160"AA", "BB", "CC", "DD", "EE", "FF"
161lbound(array)
162+3
163ubound(array)
164+8
165size
166+13
167lbc
168+5
169array
170"AA", "BB", "CC", "DD", "EE", "FF"
171lbound(array)
172+3
173ubound(array)
174+8
175
176!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177! Expand and shift `character` matrix.
178!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179
180array
181"AA", "BB", "CC"
182"DD", "EE", "FF"
183lbound(array)
184+2, +3
185ubound(array)
186+3, +5
187size
188+6, +6
189lbc
190+4, +4
191array
192"AA", "BB", "CC"
193"DD", "EE", "FF"
194lbound(array)
195+2, +3
196ubound(array)
197+3, +5
198
199!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200! Expand and shift `character` cube.
201!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202
203array
204slice(:,:,1) =
205"AA", "BB", "CC"
206"DD", "EE", "FF"
207lbound(array)
208+1, +1, +1
209ubound(array)
210+2, +3, +1
211size
212+6, +6, +3
213lbc
214+3, +4, +2
215array
216slice(:,:,1) =
217"AA", "BB", "CC"
218"DD", "EE", "FF"
219lbound(array)
220+1, +1, +1
221ubound(array)
222+2, +3, +1
223
224!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226! Expand an array and shift a subset of its contents.
227!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229
230
231!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232! Expand and shift `character` vector.
233!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234
235array
236"AA", "BB", "CC", "DD", "EE", "FF"
237lbound(array)
238+3
239ubound(array)
240+8
241size
242+13
243lbc
244+5
245lbcold
246+5
247ubcold
248+7
249array
250"AA", "BB", "CC", "DD", "EE", "FF"
251lbound(array)
252+3
253ubound(array)
254+8
255
256!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257! Expand and shift `character` matrix.
258!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259
260array
261"AA", "BB", "CC"
262"DD", "EE", "FF"
263lbound(array)
264+2, +3
265ubound(array)
266+3, +5
267size
268+2, +3
269lbc
270+2, +4
271lbcold
272+2, +4
273ubcold
274+3, +5
275array
276"AA", "BB", "CC"
277"DD", "EE", "FF"
278lbound(array)
279+2, +3
280ubound(array)
281+3, +5
282
283!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
284! Expand and shift `character` cube.
285!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
286
287array
288slice(:,:,1) =
289"AA", "CC", "EE"
290"GG", "II", "KK"
291slice(:,:,2) =
292"BB", "DD", "FF"
293"HH", "JJ", "LL"
294lbound(array)
295+1, +1, +1
296ubound(array)
297+2, +3, +2
298size
299+2, +2, +4
300lbc
301+1, +1, +3
302lbcold
303+1, +2, +2
304ubcold
305+2, +3, +2
306array
307slice(:,:,1) =
308"AA", "CC", "EE"
309"GG", "II", "KK"
310slice(:,:,2) =
311"BB", "DD", "FF"
312"HH", "JJ", "LL"
313lbound(array)
314+1, +1, +1
315ubound(array)
316+2, +3, +2
317
Test:
test_pm_arrayResize
Todo:
Very Low Priority: This generic interface can be extended to arrays of higher ranks than currently supported.
Bug:

Status: Unresolved
Source: GNU Fortran Compiler gfortran version 10-12
Description: There is an annoying gfortran bug concerning allocation of allocatable arrays of strings with assumed length type parameter.
The typical compiler error message is around line 230: Error allocating 283223642230368 bytes: Cannot allocate memory.
This requires the allocation statement be explicit for character arrays of non-zero rank.
This makes the already complex code superbly more complex and messy.

Remedy (as of ParaMonte Library version 2.0.0): For now, the allocatable arrays of type character are allocated with explicit shape in the allocation statement.
This explicit allocation for character types must be removed and replaced with the generic allocation once the bug is resolved.
Bug:

Status: Unresolved
Source: Intel Classic Fortran Compiler ifort version 2021-2022
Description: There is an Intel compiler 2020-2022 bug in processing multiple CHECK_ASSERTION macros in individual routines of this module in debug compile mode.
The problem does not appear to exist in other compilation modes.
However, this bug does seem to be related to other similar instances where Intel Classic Fortran Compiler ifort cannot tolerate frequent appearance of use statements within a single submodule.

Remedy (as of ParaMonte Library version 2.0.0): For now, the resolution was to remove and replace the checking macros with explicit merged block statements.
A similar problem also was present in the implementation of pm_quadPack.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, September 1, 2017, 12:00 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 249 of file pm_arrayResize.F90.


The documentation for this interface was generated from the following file: