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

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

Detailed Description

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

The array contents or a requested subset of it are kept in the original indices in the output rebound array or shifted to a new starting location lbc in the output array.
The rest of the elements (including the newly-added elements) are filled with the user-specified fill.

The following figure illustrates example resizing and refilling 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 character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU)
  2. type integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64)
  3. type logical of kind any supported by the processor (e.g., LK)
  4. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128)
  5. 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 lower and upper bounds (lb, ub).
[in]fill: The input scalar of the same type and kind as the input array containing the value to fill the new elements (if any) of array. If array is of type character, then
  1. The equality len(fill) == 1 must also hold if array is of zero rank (i.e., a scalar string).
  2. The equality len(fill) <= len(array) must also hold if array is of non-zero rank.
[in]lb: The input scalar or array of type integer of default kind IK representing the new Lower Bound of the output array.
  1. If array is a scalar or array of rank 1, then lb must be a scalar.
  2. If array is an array of rank > 1, then lb must be a vector of the same length as rank(array).
[in]ub: The input scalar or array of type integer of default kind IK representing the new Upper Bound of the output array.
  1. If array is a scalar or array of rank 1, then ub must be a scalar.
  2. If array is an array of rank > 1, then ub must be a vector of the same length as rank(array).
[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 rebound 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.)
[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 = lbound(array). If array is a scalar string, then default = 1. It can be present only if the input arguments lbc and ubcold 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 input arguments lbc and lbcold 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 setRebilled(array(..), fill, lb(..), ub(..), failed = failed, errmsg = errmsg) ! Rebind and refill to the requested `size` with the same lower bound as before and optionally gracefully return if reallocation fails.
call setRebilled(array(..), fill, lb(..), ub(..), lbc(..), failed = failed, errmsg = errmsg) ! Rebind and refill to the requested `size`, write `array` to the output `array(\@lbc:)`, optionally gracefully return upon failure.
call setRebilled(array(..), fill, lb(..), ub(..), lbc(..), lbcold(..), ubcold(..), failed = failed, errmsg = errmsg) ! Rebind and refill 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) and refill an input allocatable scalar string or array of rank ...
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
Warning
The condition all(0 <= ub - lb + 1) must hold for the corresponding input argument (i.e., the size of the output array must be non-negative).
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(lb <= lbc) must hold for the corresponding input arguments.
The condition all(lbc - lbcold + ubcold <= ub) 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).
The equality len(fill) == 1 must also hold if array is of zero rank (i.e., a scalar string).
The equality len(fill) <= len(array) must also hold if array is of non-zero rank.
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 and filled entirely with fill, equivalent to allocate(array(\@lb:ub), source = fill).
If the initialization of the new elements with fill is not necessary, use setResized to resize arrays without initialization.
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 and refilling the new elements with requested fill.
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 REBILL_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('fill'); \
13 call disp%show( FILL , deliml = SK_"""" ); \
14 call disp%show('lb'); \
15 call disp%show( LB ); \
16 call disp%show('ub'); \
17 call disp%show( UB ); \
18 call disp%show('call setRebilled(array, fill, lb, ub)'); \
19 call setRebilled(array, FILL, LB, UB) ; \
20 call disp%show('array'); \
21 call disp%show( array , deliml = SK_"""" ); \
22 call disp%show('lbound(array)'); \
23 call disp%show( lbound(array) ); \
24 call disp%show('ubound(array)'); \
25 call disp%show( ubound(array) ); \
26end block;
27
28! Define an expansion with contents shifting procedure call macro to avoid duplications in the example source file. Check the output file for usage.
29#define REBILL_SHIFT_ARRAY \
30block; \
31 DECLARE; \
32 CONSTRUCT; \
33 call disp%show('array'); \
34 call disp%show( array , deliml = SK_"""" ); \
35 call disp%show('lbound(array)'); \
36 call disp%show( lbound(array) ); \
37 call disp%show('ubound(array)'); \
38 call disp%show( ubound(array) ); \
39 call disp%show('fill'); \
40 call disp%show( FILL , deliml = SK_"""" ); \
41 call disp%show('lb'); \
42 call disp%show( LB ); \
43 call disp%show('ub'); \
44 call disp%show( UB ); \
45 call disp%show('lbc'); \
46 call disp%show( LBC ); \
47 call disp%show('call setRebilled(array, fill, lb, ub, lbc)'); \
48 call setRebilled(array, FILL, LB, UB, LBC) ; \
49 call disp%show('array'); \
50 call disp%show( array , deliml = SK_"""" ); \
51 call disp%show('lbound(array)'); \
52 call disp%show( lbound(array) ); \
53 call disp%show('ubound(array)'); \
54 call disp%show( ubound(array) ); \
55end block;
56
57! 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.
58#define REBILL_SHIFT_SUBSET_ARRAY \
59block; \
60 DECLARE; \
61 CONSTRUCT; \
62 call disp%show('array'); \
63 call disp%show( array , deliml = SK_"""" ); \
64 call disp%show('lbound(array)'); \
65 call disp%show( lbound(array) ); \
66 call disp%show('ubound(array)'); \
67 call disp%show( ubound(array) ); \
68 call disp%show('fill'); \
69 call disp%show( FILL , deliml = SK_"""" ); \
70 call disp%show('lb'); \
71 call disp%show( LB ); \
72 call disp%show('ub'); \
73 call disp%show( UB ); \
74 call disp%show('lbc'); \
75 call disp%show( LBC ); \
76 call disp%show('lbcold'); \
77 call disp%show( LBCOLD ); \
78 call disp%show('ubcold'); \
79 call disp%show( UBCOLD ); \
80 call disp%show('call setRebilled(array, fill, lb, ub, lbc, lbcold, ubcold)'); \
81 call setRebilled(array, FILL, LB, UB, LBC, LBCOLD, UBCOLD) ; \
82 call disp%show('array'); \
83 call disp%show( array , deliml = SK_"""" ); \
84 call disp%show('lbound(array)'); \
85 call disp%show( lbound(array) ); \
86 call disp%show('ubound(array)'); \
87 call disp%show( ubound(array) ); \
88end block;
89
90program example
91
92 use pm_kind, only: SK, IK
93 use pm_kind, only: SKG => SK ! All kinds are supported.
94 use pm_kind, only: LKG => LK ! All kinds are supported.
95 use pm_kind, only: IKG => IK ! All kinds are supported.
96 use pm_kind, only: CKG => CK ! All kinds are supported.
97 use pm_kind, only: RKG => RK ! All kinds are supported.
98 use pm_io, only: display_type
100
101 implicit none
102
103 type(display_type) :: disp
104 disp = display_type(file = "main.out.F90")
105
106 call disp%skip()
107 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
108 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
109 call disp%show("! Expand an array with specific lower and upper bounds.")
110 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
111 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
112 call disp%skip()
113
114 call disp%skip()
115 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
116 call disp%show("! Expand `character` vector.")
117 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
118 call disp%skip()
119
120#define LB 2_IK
121#define UB 10_IK
122#define FILL SKG_"--"
123#define DECLARE character(2,SKG), allocatable :: array(:)
124#define CONSTRUCT allocate(array(3:8)); array(:) = ["AA", "BB", "CC", "DD", "EE", "FF"]
125REBILL_ARRAY
126
127 call disp%skip()
128 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
129 call disp%show("! Expand `integer` vector.")
130 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
131 call disp%skip()
132
133#define LB 2_IK
134#define UB 10_IK
135#define FILL -3_IKG
136#define DECLARE integer(IKG), allocatable :: array(:)
137#define CONSTRUCT allocate(array(3:8)); array(:) = [1, 2, 3, 4, 5, 6]
138REBILL_ARRAY
139
140 call disp%skip()
141 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
142 call disp%show("! Expand `logical` vector.")
143 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
144 call disp%skip()
145
146#define LB 2_IK
147#define UB 10_IK
148#define FILL .false._LKG
149#define DECLARE logical(LKG), allocatable :: array(:)
150#define CONSTRUCT allocate(array(3:8)); array(:) = [.true., .true., .true., .true., .true., .true.]
151REBILL_ARRAY
152
153 call disp%skip()
154 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
155 call disp%show("! Expand `complex` vector.")
156 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
157 call disp%skip()
158
159#define LB 2_IK
160#define UB 10_IK
161#define FILL cmplx(-9.,-9.,CKG)
162#define DECLARE complex(CKG), allocatable :: array(:)
163#define CONSTRUCT allocate(array(3:8)); array(:) = [(1., -1.), (2., -2.), (3., -3.), (4., -4.), (5., -5.), (6., -6.)]
164REBILL_ARRAY
165
166 call disp%skip()
167 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
168 call disp%show("! Expand `real` vector.")
169 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%")
170 call disp%skip()
171
172#define LB 2_IK
173#define UB 10_IK
174#define FILL -1._RKG
175#define DECLARE real(RKG), allocatable :: array(:)
176#define CONSTRUCT allocate(array(3:8)); array(:) = [1., 2., 3., 4., 5., 6.]
177REBILL_ARRAY
178
179 call disp%skip()
180 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
181 call disp%show("! Expand `character` matrix.")
182 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%")
183 call disp%skip()
184
185#define LB [-1_IK, -1_IK]
186#define UB [+7_IK, +7_IK]
187#define FILL SKG_"--"
188#define DECLARE character(2,SKG), allocatable :: array(:,:)
189#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
190REBILL_ARRAY
191
192 call disp%skip()
193 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
194 call disp%show("! Expand `character` cube.")
195 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%")
196 call disp%skip()
197
198#define LB [-1_IK, -1_IK, 1_IK]
199#define UB [+7_IK, +7_IK, 3_IK]
200#define FILL SKG_"--"
201#define DECLARE character(2,SKG), allocatable :: array(:,:,:)
202#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])
203REBILL_ARRAY
204
205 call disp%skip()
206 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
207 call disp%show("! Expand `character` with partially-overlapping bounds.")
208 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
209 call disp%skip()
210
211#define LB [-1_IK, -1_IK]
212#define UB [+2_IK, +4_IK]
213#define FILL SKG_"--"
214#define DECLARE character(2,SKG), allocatable :: array(:,:)
215#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
216REBILL_ARRAY
217
218 call disp%skip()
219 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
220 call disp%show("! Expand `character` with entirely new non-overlapping bounds.")
221 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
222 call disp%skip()
223
224#define LB [-1_IK, -1_IK]
225#define UB [+1_IK, +2_IK]
226#define FILL SKG_"--"
227#define DECLARE character(2,SKG), allocatable :: array(:,:)
228#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
229REBILL_ARRAY
230
231 call disp%skip()
232 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
233 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
234 call disp%show("! Expand an array and shift its contents.")
235 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
236 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
237 call disp%skip()
238
239 call disp%skip()
240 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
241 call disp%show("! Expand and shift `character` vector.")
242 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
243 call disp%skip()
244
245#define LB -2_IK
246#define UB 10_IK
247#define LBC -2_IK
248#define FILL SKG_"--"
249#define DECLARE character(2,SKG), allocatable :: array(:)
250#define CONSTRUCT allocate(array(3:8)); array(:) = ["AA", "BB", "CC", "DD", "EE", "FF"]
251REBILL_SHIFT_ARRAY
252
253 call disp%skip()
254 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
255 call disp%show("! Expand and shift `character` matrix.")
256 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
257 call disp%skip()
258
259#define LB [+5_IK, +5_IK]
260#define UB [10_IK, 10_IK]
261#define LBC [7_IK, 7_IK]
262#define FILL SKG_"--"
263#define DECLARE character(2,SKG), allocatable :: array(:,:)
264#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
265REBILL_SHIFT_ARRAY
266
267 call disp%skip()
268 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
269 call disp%show("! Expand and shift `character` cube.")
270 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
271 call disp%skip()
272
273#define LB [+5_IK, +5_IK, 1_IK]
274#define UB [10_IK, 10_IK, 2_IK]
275#define LBC [7_IK, 7_IK, 2_IK]
276#define FILL SKG_"--"
277#define DECLARE character(2,SKG), allocatable :: array(:,:,:)
278#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])
279REBILL_SHIFT_ARRAY
280
281 call disp%skip()
282 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
283 call disp%show("! Expand and shift `character` with partially-overlapping bounds.")
284 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
285 call disp%skip()
286
287#define LB [-1_IK, -1_IK]
288#define UB [+2_IK, +4_IK]
289#define LBC [0_IK, 0_IK]
290#define FILL SKG_"--"
291#define DECLARE character(2,SKG), allocatable :: array(:,:)
292#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
293REBILL_SHIFT_ARRAY
294
295 call disp%skip()
296 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
297 call disp%show("! Expand and shift `character` with entirely new non-overlapping bounds.")
298 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
299 call disp%skip()
300
301#define LB [-1_IK, -1_IK]
302#define UB [+1_IK, +2_IK]
303#define LBC [-1_IK, 1_IK]
304#define FILL SKG_"--"
305#define DECLARE character(2,SKG), allocatable :: array(:,:)
306#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
307REBILL_SHIFT_ARRAY
308
309 call disp%skip()
310 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
311 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
312 call disp%show("! Expand an array and shift a subset of its contents.")
313 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
314 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
315 call disp%skip()
316
317 call disp%skip()
318 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
319 call disp%show("! Expand and shift `character` vector.")
320 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
321 call disp%skip()
322
323#define LB -2_IK
324#define UB 10_IK
325#define LBC -2_IK
326#define LBCOLD 5_IK
327#define UBCOLD 7_IK
328#define FILL SKG_"--"
329#define DECLARE character(2,SKG), allocatable :: array(:)
330#define CONSTRUCT allocate(array(3:8)); array(:) = ["AA", "BB", "CC", "DD", "EE", "FF"]
331REBILL_SHIFT_SUBSET_ARRAY
332
333 call disp%skip()
334 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
335 call disp%show("! Expand and shift `character` matrix.")
336 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
337 call disp%skip()
338
339#define LB [1_IK, 3_IK]
340#define UB [2_IK, 4_IK]
341#define LBC [1_IK, 3_IK]
342#define LBCOLD [2_IK, 4_IK]
343#define UBCOLD [3_IK, 5_IK]
344#define FILL SKG_"--"
345#define DECLARE character(2,SKG), allocatable :: array(:,:)
346#define CONSTRUCT allocate(array(2:3,3:5)); array(:,:) = reshape(["AA", "BB", "CC", "DD", "EE", "FF"], shape = shape(array), order = [2, 1])
347REBILL_SHIFT_SUBSET_ARRAY
348
349 call disp%skip()
350 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
351 call disp%show("! Expand and shift `character` cube.")
352 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
353 call disp%skip()
354
355#define LB [1_IK, 2_IK, 3_IK]
356#define UB [2_IK, 3_IK, 5_IK]
357#define LBC [1_IK, 2_IK, 4_IK]
358#define LBCOLD [1_IK, 2_IK, 2_IK]
359#define UBCOLD [2_IK, 3_IK, 2_IK]
360#define FILL SKG_"--"
361#define DECLARE character(2,SKG), allocatable :: array(:,:,:)
362#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])
363REBILL_SHIFT_SUBSET_ARRAY
364
365end 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 lower and upper bounds.
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
19fill
20"--"
21lb
22+2
23ub
24+10
25call setRebilled(array, fill, lb, ub)
26array
27"--", "AA", "BB", "CC", "DD", "EE", "FF", "--", "--"
28lbound(array)
29+2
30ubound(array)
31+10
32
33!%%%%%%%%%%%%%%%%%%%%%%%%%
34! Expand `integer` vector.
35!%%%%%%%%%%%%%%%%%%%%%%%%%
36
37array
38"+1", "+2", "+3", "+4", "+5", "+6"
39lbound(array)
40+3
41ubound(array)
42+8
43fill
44"-3"
45lb
46+2
47ub
48+10
49call setRebilled(array, fill, lb, ub)
50array
51"-3", "+1", "+2", "+3", "+4", "+5", "+6", "-3", "-3"
52lbound(array)
53+2
54ubound(array)
55+10
56
57!%%%%%%%%%%%%%%%%%%%%%%%%%
58! Expand `logical` vector.
59!%%%%%%%%%%%%%%%%%%%%%%%%%
60
61array
62"T", "T", "T", "T", "T", "T"
63lbound(array)
64+3
65ubound(array)
66+8
67fill
68"F"
69lb
70+2
71ub
72+10
73call setRebilled(array, fill, lb, ub)
74array
75"F", "T", "T", "T", "T", "T", "T", "F", "F"
76lbound(array)
77+2
78ubound(array)
79+10
80
81!%%%%%%%%%%%%%%%%%%%%%%%%%
82! Expand `complex` vector.
83!%%%%%%%%%%%%%%%%%%%%%%%%%
84
85array
86"+1.0000000000000000, -1.0000000000000000", "+2.0000000000000000, -2.0000000000000000", "+3.0000000000000000, -3.0000000000000000", "+4.0000000000000000, -4.0000000000000000", "+5.0000000000000000, -5.0000000000000000", "+6.0000000000000000, -6.0000000000000000"
87lbound(array)
88+3
89ubound(array)
90+8
91fill
92"-9.0000000000000000, -9.0000000000000000"
93lb
94+2
95ub
96+10
97call setRebilled(array, fill, lb, ub)
98array
99"-9.0000000000000000, -9.0000000000000000", "+1.0000000000000000, -1.0000000000000000", "+2.0000000000000000, -2.0000000000000000", "+3.0000000000000000, -3.0000000000000000", "+4.0000000000000000, -4.0000000000000000", "+5.0000000000000000, -5.0000000000000000", "+6.0000000000000000, -6.0000000000000000", "-9.0000000000000000, -9.0000000000000000", "-9.0000000000000000, -9.0000000000000000"
100lbound(array)
101+2
102ubound(array)
103+10
104
105!%%%%%%%%%%%%%%%%%%%%%%
106! Expand `real` vector.
107!%%%%%%%%%%%%%%%%%%%%%%
108
109array
110"+1.0000000000000000", "+2.0000000000000000", "+3.0000000000000000", "+4.0000000000000000", "+5.0000000000000000", "+6.0000000000000000"
111lbound(array)
112+3
113ubound(array)
114+8
115fill
116"-1.0000000000000000"
117lb
118+2
119ub
120+10
121call setRebilled(array, fill, lb, ub)
122array
123"-1.0000000000000000", "+1.0000000000000000", "+2.0000000000000000", "+3.0000000000000000", "+4.0000000000000000", "+5.0000000000000000", "+6.0000000000000000", "-1.0000000000000000", "-1.0000000000000000"
124lbound(array)
125+2
126ubound(array)
127+10
128
129!%%%%%%%%%%%%%%%%%%%%%%%%%%%
130! Expand `character` matrix.
131!%%%%%%%%%%%%%%%%%%%%%%%%%%%
132
133array
134"AA", "BB", "CC"
135"DD", "EE", "FF"
136lbound(array)
137+2, +3
138ubound(array)
139+3, +5
140fill
141"--"
142lb
143-1, -1
144ub
145+7, +7
146call setRebilled(array, fill, lb, ub)
147array
148"--", "--", "--", "--", "--", "--", "--", "--", "--"
149"--", "--", "--", "--", "--", "--", "--", "--", "--"
150"--", "--", "--", "--", "--", "--", "--", "--", "--"
151"--", "--", "--", "--", "AA", "BB", "CC", "--", "--"
152"--", "--", "--", "--", "DD", "EE", "FF", "--", "--"
153"--", "--", "--", "--", "--", "--", "--", "--", "--"
154"--", "--", "--", "--", "--", "--", "--", "--", "--"
155"--", "--", "--", "--", "--", "--", "--", "--", "--"
156"--", "--", "--", "--", "--", "--", "--", "--", "--"
157lbound(array)
158-1, -1
159ubound(array)
160+7, +7
161
162!%%%%%%%%%%%%%%%%%%%%%%%%%
163! Expand `character` cube.
164!%%%%%%%%%%%%%%%%%%%%%%%%%
165
166array
167slice(:,:,1) =
168"AA", "BB", "CC"
169"DD", "EE", "FF"
170lbound(array)
171+2, +3, +2
172ubound(array)
173+3, +5, +2
174fill
175"--"
176lb
177-1, -1, +1
178ub
179+7, +7, +3
180call setRebilled(array, fill, lb, ub)
181array
182slice(:,:,1) =
183"--", "--", "--", "--", "--", "--", "--", "--", "--"
184"--", "--", "--", "--", "--", "--", "--", "--", "--"
185"--", "--", "--", "--", "--", "--", "--", "--", "--"
186"--", "--", "--", "--", "--", "--", "--", "--", "--"
187"--", "--", "--", "--", "--", "--", "--", "--", "--"
188"--", "--", "--", "--", "--", "--", "--", "--", "--"
189"--", "--", "--", "--", "--", "--", "--", "--", "--"
190"--", "--", "--", "--", "--", "--", "--", "--", "--"
191"--", "--", "--", "--", "--", "--", "--", "--", "--"
192slice(:,:,2) =
193"--", "--", "--", "--", "--", "--", "--", "--", "--"
194"--", "--", "--", "--", "--", "--", "--", "--", "--"
195"--", "--", "--", "--", "--", "--", "--", "--", "--"
196"--", "--", "--", "--", "AA", "BB", "CC", "--", "--"
197"--", "--", "--", "--", "DD", "EE", "FF", "--", "--"
198"--", "--", "--", "--", "--", "--", "--", "--", "--"
199"--", "--", "--", "--", "--", "--", "--", "--", "--"
200"--", "--", "--", "--", "--", "--", "--", "--", "--"
201"--", "--", "--", "--", "--", "--", "--", "--", "--"
202slice(:,:,3) =
203"--", "--", "--", "--", "--", "--", "--", "--", "--"
204"--", "--", "--", "--", "--", "--", "--", "--", "--"
205"--", "--", "--", "--", "--", "--", "--", "--", "--"
206"--", "--", "--", "--", "--", "--", "--", "--", "--"
207"--", "--", "--", "--", "--", "--", "--", "--", "--"
208"--", "--", "--", "--", "--", "--", "--", "--", "--"
209"--", "--", "--", "--", "--", "--", "--", "--", "--"
210"--", "--", "--", "--", "--", "--", "--", "--", "--"
211"--", "--", "--", "--", "--", "--", "--", "--", "--"
212lbound(array)
213-1, -1, +1
214ubound(array)
215+7, +7, +3
216
217!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218! Expand `character` with partially-overlapping bounds.
219!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220
221array
222"AA", "BB", "CC"
223"DD", "EE", "FF"
224lbound(array)
225+2, +3
226ubound(array)
227+3, +5
228fill
229"--"
230lb
231-1, -1
232ub
233+2, +4
234call setRebilled(array, fill, lb, ub)
235array
236"--", "--", "--", "--", "--", "--"
237"--", "--", "--", "--", "--", "--"
238"--", "--", "--", "--", "--", "--"
239"--", "--", "--", "--", "AA", "BB"
240lbound(array)
241-1, -1
242ubound(array)
243+2, +4
244
245!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246! Expand `character` with entirely new non-overlapping bounds.
247!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
248
249array
250"AA", "BB", "CC"
251"DD", "EE", "FF"
252lbound(array)
253+2, +3
254ubound(array)
255+3, +5
256fill
257"--"
258lb
259-1, -1
260ub
261+1, +2
262call setRebilled(array, fill, lb, ub)
263array
264"--", "--", "--", "--"
265"--", "--", "--", "--"
266"--", "--", "--", "--"
267lbound(array)
268-1, -1
269ubound(array)
270+1, +2
271
272!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274! Expand an array and shift its contents.
275!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
277
278
279!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
280! Expand and shift `character` vector.
281!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282
283array
284"AA", "BB", "CC", "DD", "EE", "FF"
285lbound(array)
286+3
287ubound(array)
288+8
289fill
290"--"
291lb
292-2
293ub
294+10
295lbc
296-2
297call setRebilled(array, fill, lb, ub, lbc)
298array
299"AA", "BB", "CC", "DD", "EE", "FF", "--", "--", "--", "--", "--", "--", "--"
300lbound(array)
301-2
302ubound(array)
303+10
304
305!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306! Expand and shift `character` matrix.
307!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308
309array
310"AA", "BB", "CC"
311"DD", "EE", "FF"
312lbound(array)
313+2, +3
314ubound(array)
315+3, +5
316fill
317"--"
318lb
319+5, +5
320ub
321+10, +10
322lbc
323+7, +7
324call setRebilled(array, fill, lb, ub, lbc)
325array
326"--", "--", "--", "--", "--", "--"
327"--", "--", "--", "--", "--", "--"
328"--", "--", "--", "--", "--", "--"
329"--", "--", "--", "--", "--", "--"
330"--", "--", "--", "--", "--", "--"
331"--", "--", "--", "--", "--", "--"
332lbound(array)
333+5, +5
334ubound(array)
335+10, +10
336
337!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
338! Expand and shift `character` cube.
339!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
340
341array
342slice(:,:,1) =
343"AA", "BB", "CC"
344"DD", "EE", "FF"
345lbound(array)
346+1, +1, +1
347ubound(array)
348+2, +3, +1
349fill
350"--"
351lb
352+5, +5, +1
353ub
354+10, +10, +2
355lbc
356+7, +7, +2
357call setRebilled(array, fill, lb, ub, lbc)
358array
359slice(:,:,1) =
360"--", "--", "--", "--", "--", "--"
361"--", "--", "--", "--", "--", "--"
362"--", "--", "--", "--", "--", "--"
363"--", "--", "--", "--", "--", "--"
364"--", "--", "--", "--", "--", "--"
365"--", "--", "--", "--", "--", "--"
366slice(:,:,2) =
367"--", "--", "--", "--", "--", "--"
368"--", "--", "--", "--", "--", "--"
369"--", "--", "--", "--", "--", "--"
370"--", "--", "--", "--", "--", "--"
371"--", "--", "--", "--", "--", "--"
372"--", "--", "--", "--", "--", "--"
373lbound(array)
374+5, +5, +1
375ubound(array)
376+10, +10, +2
377
378!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379! Expand and shift `character` with partially-overlapping bounds.
380!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381
382array
383"AA", "BB", "CC"
384"DD", "EE", "FF"
385lbound(array)
386+2, +3
387ubound(array)
388+3, +5
389fill
390"--"
391lb
392-1, -1
393ub
394+2, +4
395lbc
396+0, +0
397call setRebilled(array, fill, lb, ub, lbc)
398array
399"--", "--", "--", "--", "--", "--"
400"--", "AA", "BB", "CC", "--", "--"
401"--", "DD", "EE", "FF", "--", "--"
402"--", "--", "--", "--", "--", "--"
403lbound(array)
404-1, -1
405ubound(array)
406+2, +4
407
408!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409! Expand and shift `character` with entirely new non-overlapping bounds.
410!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411
412array
413"AA", "BB", "CC"
414"DD", "EE", "FF"
415lbound(array)
416+2, +3
417ubound(array)
418+3, +5
419fill
420"--"
421lb
422-1, -1
423ub
424+1, +2
425lbc
426-1, +1
427call setRebilled(array, fill, lb, ub, lbc)
428array
429"--", "--", "AA", "BB"
430"--", "--", "DD", "EE"
431"--", "--", "--", "--"
432lbound(array)
433-1, -1
434ubound(array)
435+1, +2
436
437!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
438!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
439! Expand an array and shift a subset of its contents.
440!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
441!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
442
443
444!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
445! Expand and shift `character` vector.
446!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
447
448array
449"AA", "BB", "CC", "DD", "EE", "FF"
450lbound(array)
451+3
452ubound(array)
453+8
454fill
455"--"
456lb
457-2
458ub
459+10
460lbc
461-2
462lbcold
463+5
464ubcold
465+7
466call setRebilled(array, fill, lb, ub, lbc, lbcold, ubcold)
467array
468"CC", "DD", "EE", "--", "--", "--", "--", "--", "--", "--", "--", "--", "--"
469lbound(array)
470-2
471ubound(array)
472+10
473
474!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
475! Expand and shift `character` matrix.
476!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477
478array
479"AA", "BB", "CC"
480"DD", "EE", "FF"
481lbound(array)
482+2, +3
483ubound(array)
484+3, +5
485fill
486"--"
487lb
488+1, +3
489ub
490+2, +4
491lbc
492+1, +3
493lbcold
494+2, +4
495ubcold
496+3, +5
497call setRebilled(array, fill, lb, ub, lbc, lbcold, ubcold)
498array
499"BB", "CC"
500"EE", "FF"
501lbound(array)
502+1, +3
503ubound(array)
504+2, +4
505
506!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507! Expand and shift `character` cube.
508!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
509
510array
511slice(:,:,1) =
512"AA", "CC", "EE"
513"GG", "II", "KK"
514slice(:,:,2) =
515"BB", "DD", "FF"
516"HH", "JJ", "LL"
517lbound(array)
518+1, +1, +1
519ubound(array)
520+2, +3, +2
521fill
522"--"
523lb
524+1, +2, +3
525ub
526+2, +3, +5
527lbc
528+1, +2, +4
529lbcold
530+1, +2, +2
531ubcold
532+2, +3, +2
533call setRebilled(array, fill, lb, ub, lbc, lbcold, ubcold)
534array
535slice(:,:,1) =
536"--", "--"
537"--", "--"
538slice(:,:,2) =
539"DD", "FF"
540"JJ", "LL"
541slice(:,:,3) =
542"--", "--"
543"--", "--"
544lbound(array)
545+1, +2, +3
546ubound(array)
547+2, +3, +5
548
Test:
test_pm_arrayRebill
Todo:
Very Low Priority: This generic interface can be extended to arrays of higher ranks.
Todo:
Normal Priority: This generic interface should be extended to arrays of container type as done in pm_arrayResize.


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 at Austin

Definition at line 214 of file pm_arrayRebill.F90.


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