Generate and return an array of specified rank and shape of arbitrary intrinsic type and kind with its rectangular core and halo set to the corresponding user-specified values.
More...
Generate and return an array of specified rank and shape of arbitrary intrinsic type and kind with its rectangular core and halo set to the corresponding user-specified values.
The halo of an array of arbitrary rank is defined as the complement of rectangular core region of arbitrary size within a super-rectangle array.
The following figure illustrates example cores and halos of two 1D and 2D arrays.
- Parameters
-
[in] | Size | : The input non-negative scalar or vector of size rank(array) of type integer of default kind IK, representing the shape of the output array, array(@Size) .
-
If the desired rank of the output
array is <= 1 , then Size must be a scalar.
-
If the desired rank of the output
array is >= 2 , then Size must be a vector of size rank(array) .
|
[in] | core | : The input contiguous array of the same rank as the output array , of the same type and kind as the output array , containing the array value to paste into the rectangular core of array .
The extents of core (i.e., shape(core) ) delineate the rectangular core of array into which core will be pasted.
-
If
array is of type character , then the condition len(core) <= len(array) must hold.
|
[in] | halo | : The input scalar of the same type and kind as the output array , containing the value to write to the halo surrounding the specified rectangular core of the array .
-
If
array is a scalar string, then halo must be a single character (with length type parameter 1 ).
-
If
array is an array of type character , then halo can have arbitrary length type parameter satisfying the condition len(halo) <= len(array) .
|
[in] | coffset | : The input non-negative scalar or vector of size rank(array) of type integer of default kind IK representing the index offset from the first (top-left corner) element of array , such that array(@coffset + 1) represents the indices of first element of the rectangular core of array .
-
If the output
array is of rank <= 1 , then coffset must be a scalar.
-
If the output
array is of rank >= 2 , then coffset must be a vector of size rank(array) .
|
- Returns
array
: The output scalar of,
-
type
character
of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU) of the specified length type parameter size
or,
the output array of rank 1
, 2
, or 3
, of the user-specified shape size
, of either,
-
type
character
of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU), or
-
type
integer
of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64), or
-
type
logical
of kind any supported by the processor (e.g., LK), or
-
type
complex
of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128), or
-
type
real
of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128).
On output, the rectangular core and halo of the array will be initialized to the specified input arguments core
and halo
respectively.
Possible calling interfaces ⛓
call getCoreHalo(array(:), core(@
shape(array)), halo, coffset)
call getCoreHalo(array(..), core(@
shape(array)), halo, coffset(
1:
rank(array)))
!
Generate and return an array of specified rank and shape of arbitrary intrinsic type and kind with it...
This module contains procedures and generic interfaces for efficient initialization of arbitrary rect...
- Warning
- All warnings and conditions associated with setCoreHalo also apply to this generic interface.
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.
- See also
- setCoreHalo
setResized
setRebound
setRebilled
getCoreHalo
setCoreHalo
setRefilled
getCentered
setCentered
getPadded
setPadded
Example usage ⛓
14 type(display_type) :: disp
21 call disp%show( size, deliml
= SK_
"""" ); \
23 call disp%show( core, deliml
= SK_
"""" ); \
25 call disp%show( halo, deliml
= SK_
"""" ); \
27 call disp%show( coffset, deliml
= SK_
"""" ); \
28 call disp%show(
"array = getCoreHalo(size, core, halo, coffset)"); \
31 call disp%show( array, deliml
= SK_
"""" ); \
36 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
37 call disp%show(
"! Initialize scalar with core and halo values.")
38 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
42 integer(IK) :: coffset
= 3, size
= 21; \
43 character(:),
allocatable :: array, core, halo; \
44 core
= "In God We Trust"; halo
= "*";
48 integer(IK) :: coffset
= 2, size
= 41; \
49 character(:),
allocatable :: array, core, halo; \
50 core
= "In Science We Invest"; halo
= "~";
54 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
55 call disp%show(
"! Initialize vector with core and halo values.")
56 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
60 integer(IK) :: coffset
= 3, size
= 10; \
61 character(
5),
allocatable :: array(:), core(:), halo; \
62 core
= [
character(
5) ::
"In",
"God",
"We",
"Trust"]; \
67 integer(IK) :: coffset
= 3, size
= 10; \
68 character(
5),
allocatable :: array(:), core(:), halo; \
69 character(
7) :: array(
10)
= "", core(
4)
= [
character(
7) ::
"In",
"Science",
"We",
"Invest"]; \
74 integer(IK) :: coffset
= 2, size
= 10; \
75 integer,
allocatable :: array(:), core(:), halo; \
76 core
= [
1,
2,
3,
4]; \
81 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
82 call disp%show(
"! Initialize matrix with core and halo values.")
83 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
87 integer(IK) :: coffset(
2)
= [
5,
3],
size(
2)
= [
10,
10]; \
88 integer,
allocatable :: array(:,:), core(:,:), halo; \
89 core
= reshape([
1,
2,
3,
4,
5,
6], [
2,
3]); \
94 integer(IK) :: coffset(
2)
= [
3,
5],
size(
2)
= [
10,
10]; \
95 logical,
allocatable :: array(:,:), core(:,:), halo; \
96 core
= reshape([(
.false., i
= 1,
9)], [
3,
3]); \
101 integer(IK) :: coffset(
2)
= [
3,
5],
size(
2)
= [
10,
10]; \
102 complex,
allocatable :: array(:,:), core(:,:), halo; \
103 core
= reshape([(i, i
= 1,
9)], [
3,
3]); \
108 integer(IK) :: coffset(
2)
= [
3,
5],
size(
2)
= [
10,
10]; \
109 real,
allocatable :: array(:,:), Core(:,:), halo; \
110 core
= reshape([(i, i
= 1,
9)], [
3,
3]); \
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter CK
The default complex kind in the ParaMonte library: real64 in Fortran, c_double_complex in C-Fortran I...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
16"***In God We Trust***"
28"~~In Science We Invest~~~~~~~~~~~~~~~~~~~"
38"In ",
"God ",
"We ",
"Trust"
45"*****",
"*****",
"*****",
"In ",
"God ",
"We ",
"Trust",
"*****",
"*****",
"*****"
57"-1",
"-1",
"+1",
"+2",
"+3",
"+4",
"-1",
"-1",
"-1",
"-1"
75"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
76"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
77"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
78"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
79"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
80"-1",
"-1",
"-1",
"+1",
"+3",
"+5",
"-1",
"-1",
"-1",
"-1"
81"-1",
"-1",
"-1",
"+2",
"+4",
"+6",
"-1",
"-1",
"-1",
"-1"
82"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
83"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
84"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1",
"-1"
98"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
99"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
100"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
101"T",
"T",
"T",
"T",
"T",
"F",
"F",
"F",
"T",
"T"
102"T",
"T",
"T",
"T",
"T",
"F",
"F",
"F",
"T",
"T"
103"T",
"T",
"T",
"T",
"T",
"F",
"F",
"F",
"T",
"T"
104"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
105"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
106"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
107"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T",
"T"
112"+1.00000000, +0.00000000",
"+4.00000000, +0.00000000",
"+7.00000000, +0.00000000"
113"+2.00000000, +0.00000000",
"+5.00000000, +0.00000000",
"+8.00000000, +0.00000000"
114"+3.00000000, +0.00000000",
"+6.00000000, +0.00000000",
"+9.00000000, +0.00000000"
116"-1.00000000, +0.00000000"
121"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
122"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
123"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
124"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"+1.00000000, +0.00000000",
"+4.00000000, +0.00000000",
"+7.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
125"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"+2.00000000, +0.00000000",
"+5.00000000, +0.00000000",
"+8.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
126"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"+3.00000000, +0.00000000",
"+6.00000000, +0.00000000",
"+9.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
127"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
128"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
129"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
130"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000",
"-1.00000000, +0.00000000"
135"+1.00000000",
"+4.00000000",
"+7.00000000"
136"+2.00000000",
"+5.00000000",
"+8.00000000"
137"+3.00000000",
"+6.00000000",
"+9.00000000"
144"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
145"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
146"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
147"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"+1.00000000",
"+4.00000000",
"+7.00000000",
"-1.00000000",
"-1.00000000"
148"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"+2.00000000",
"+5.00000000",
"+8.00000000",
"-1.00000000",
"-1.00000000"
149"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"+3.00000000",
"+6.00000000",
"+9.00000000",
"-1.00000000",
"-1.00000000"
150"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
151"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
152"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
153"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000",
"-1.00000000"
- Test:
- test_pm_arrayInit
- Todo:
- Low Priority: This generic interface can be extended to
array
arguments of higher ranks.
- Todo:
- Normal Priority: Unlike setCoreHalo, this functional generic interface lacks the option for scalar input
core
.
This is because of ambiguity created by scalar core
for output array
of ranks two and higher.
This can be resolved once the Fortran standard allows deferred rank function output.
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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- 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 181 of file pm_arrayInit.F90.