Generate and return the value of the optional
input argument if it is present, otherwise, return the input default
value.
- Parameters
-
[in] | default | : The input scalar, are array of arbitrary rank, of either
-
type
character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU), or
-
type
logical of kind any supported by the processor (e.g., LK), or
-
type
integer of kind any supported by the processor (e.g., IK, IK8, IK16, IK32, or IK64), 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),
or,
-
a scalar assumed-length
character of kind any supported by the processor (e.g., SK, SKA, SKD , or SKU),
whose value will be returned as the output if optional is missing among the input arguments.
|
[in] | optional | : The input value of the same type, kind, and rank as the input default argument, representing the optional input argument whose value will be returned if present.
(optional, default = default ) |
- Returns
value
: The output value of the same type, kind, and rank as the input default
.
-
If
optional
is present as an input argument, value
takes the value of optional
.
-
If
optional
is missing as an input argument, value
takes the value of default
.
If value
is of type character
, then its length type parameter is len(default)
.
Possible calling interfaces ⛓
Generate and return the value of the optional input argument if it is present, otherwise,...
This module contains procedures, generic interfaces, and types for generating default values for opti...
- Warning
- The condition
len(optional) <= len(default)
must hold when the input arguments are of type character
.
This is to ensure proper full assignment of the optional
value to the output whose length is that of default
.
This condition is 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
- The functions under this generic interface provide are solely intended to a provide convenient shortcut to evaluating whether an optional argument is present or not, and if missing, to return a default value.
Due to significant performance penalty associated with the use of these procedures, their usage should be limited to non-performance-critical sections of code.
Example usage ⛓
13 character(
3, SK),
allocatable :: Optional_SK(:,:), Default_SK(:,:), Output_SK(:,:)
14 logical(LK) ,
allocatable :: Optional_LK(:,:), Default_LK(:,:)
15 integer(IK) ,
allocatable :: Optional_IK(:,:), Default_IK(:,:)
16 complex(CK) ,
allocatable :: Optional_CK(:,:), Default_CK(:,:)
17 real(RK) ,
allocatable :: Optional_RK(:,:), Default_RK(:,:)
21 type(display_type) :: disp
25 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
26 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
27 call disp%show(
"! Return the optional value if present, otherwise the default value.")
28 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
29 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
32 Optional_SK
= reshape([
"AAA",
"BBB",
"CCC",
"DDD",
"EEE",
"FFF"], shape
= [
2,
3])
33 Optional_IK
= reshape([
1_IK,
2_IK,
3_IK,
4_IK,
5_IK,
6_IK], shape
= [
2,
3])
34 Optional_RK
= reshape([
1._RK,
2._RK,
3._RK,
4._RK,
5._RK,
6._RK], shape
= [
2,
3])
35 Optional_CK
= reshape([(
1._CK,
-1._CK), (
2._CK,
-2._CK), (
3._CK,
-3._CK), (
4._CK,
-4._CK), (
5._CK,
-5._CK), (
6._CK,
-6._CK)], shape
= [
2,
3])
36 Optional_LK
= reshape([
.false._LK,
.true._LK,
.false._LK,
.true._LK,
.false._LK,
.true._LK], shape
= [
2,
3])
38 Default_SK
= reshape([((Optional_SK(i,j), i
= size(Optional_SK,
1),
1,
-1), j
= size(Optional_SK,
2),
1,
-1)], shape
= shape(Optional_SK))
39 Default_IK
= reshape([((Optional_IK(i,j), i
= size(Optional_IK,
1),
1,
-1), j
= size(Optional_IK,
2),
1,
-1)], shape
= shape(Optional_IK))
40 Default_RK
= reshape([((Optional_RK(i,j), i
= size(Optional_RK,
1),
1,
-1), j
= size(Optional_RK,
2),
1,
-1)], shape
= shape(Optional_RK))
41 Default_CK
= reshape([((Optional_CK(i,j), i
= size(Optional_CK,
1),
1,
-1), j
= size(Optional_CK,
2),
1,
-1)], shape
= shape(Optional_CK))
42 Default_LK
= reshape([((Optional_LK(i,j), i
= size(Optional_LK,
1),
1,
-1), j
= size(Optional_LK,
2),
1,
-1)], shape
= shape(Optional_LK))
45 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
46 call disp%show(
"! Option character scalar/array.")
47 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
50 allocate(Output_SK,
mold = Optional_SK)
54 call disp%show( Default_SK, deliml
= SK_
"""" )
56 call disp%show( Optional_SK, deliml
= SK_
"""" )
57 call disp%show(
"Output_SK(:,:) = getOption(Default_SK)")
60 call disp%show( Output_SK(:,:), deliml
= SK_
"""" )
61 call disp%show(
"Output_SK(:,:) = getOption(Default_SK, Optional_SK)")
62 Output_SK(:,:)
= getOption(Default_SK, Optional_SK)
64 call disp%show( Output_SK(:,:), deliml
= SK_
"""" )
69 call disp%show( Default_SK(:,
1), deliml
= SK_
"""" )
71 call disp%show( Optional_SK(:,
1), deliml
= SK_
"""" )
72 call disp%show(
"Output_SK(:,1) = getOption(Default_SK(:,1))")
73 Output_SK(:,
1)
= getOption(Default_SK(:,
1))
75 call disp%show( Output_SK(:,
1), deliml
= SK_
"""" )
76 call disp%show(
"Output_SK(:,1) = getOption(Default_SK(:,1), Optional_SK(:,1))")
77 Output_SK(:,
1)
= getOption(Default_SK(:,
1), Optional_SK(:,
1))
79 call disp%show( Output_SK(:,
1), deliml
= SK_
"""" )
84 call disp%show( Default_SK(
1,
1), deliml
= SK_
"""" )
86 call disp%show( Optional_SK(
1,
1), deliml
= SK_
"""" )
87 call disp%show(
"Output_SK(1,1) = getOption(Default_SK(1,1))")
88 Output_SK(
1,
1)
= getOption(Default_SK(
1,
1))
90 call disp%show( Output_SK(
1,
1), deliml
= SK_
"""" )
91 call disp%show(
"Output_SK(1,1) = getOption(Default_SK(1,1), Optional_SK(1,1))")
92 Output_SK(
1,
1)
= getOption(Default_SK(
1,
1), Optional_SK(
1,
1))
94 call disp%show( Output_SK(
1,
1), deliml
= SK_
"""" )
98 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
99 call disp%show(
"! Option logical scalar/array.")
100 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
108 call disp%show(
"getOption(Default_LK)")
110 call disp%show(
"getOption(Default_LK, Optional_LK)")
119 call disp%show(
"getOption(Default_LK(:,1))")
121 call disp%show(
"getOption(Default_LK(:,1), Optional_LK(:,1))")
130 call disp%show(
"getOption(Default_LK(1,:))")
132 call disp%show(
"getOption(Default_LK(1,:), Optional_LK(1,:))")
141 call disp%show(
"getOption(Default_LK(1,1))")
143 call disp%show(
"getOption(Default_LK(1,1), Optional_LK(1,1))")
148 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
149 call disp%show(
"! Option integer scalar/array.")
150 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
158 call disp%show(
"getOption(Default_IK)")
160 call disp%show(
"getOption(Default_IK, Optional_IK)")
169 call disp%show(
"getOption(Default_IK(:,1))")
171 call disp%show(
"getOption(Default_IK(:,1), Optional_IK(:,1))")
180 call disp%show(
"getOption(Default_IK(1,:))")
182 call disp%show(
"getOption(Default_IK(1,:), Optional_IK(1,:))")
191 call disp%show(
"getOption(Default_IK(1,1))")
193 call disp%show(
"getOption(Default_IK(1,1), Optional_IK(1,1))")
198 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
199 call disp%show(
"! Option complex scalar/array.")
200 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
208 call disp%show(
"getOption(Default_CK)")
210 call disp%show(
"getOption(Default_CK, Optional_CK)")
219 call disp%show(
"getOption(Default_CK(:,1))")
221 call disp%show(
"getOption(Default_CK(:,1), Optional_CK(:,1))")
230 call disp%show(
"getOption(Default_CK(1,:))")
232 call disp%show(
"getOption(Default_CK(1,:), Optional_CK(1,:))")
241 call disp%show(
"getOption(Default_CK(1,1))")
243 call disp%show(
"getOption(Default_CK(1,1), Optional_CK(1,1))")
248 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%")
249 call disp%show(
"! Option real scalar/array.")
250 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%")
258 call disp%show(
"getOption(Default_RK)")
260 call disp%show(
"getOption(Default_RK, Optional_RK)")
269 call disp%show(
"getOption(Default_RK(:,1))")
271 call disp%show(
"getOption(Default_RK(:,1), Optional_RK(:,1))")
280 call disp%show(
"getOption(Default_RK(1,:))")
282 call disp%show(
"getOption(Default_RK(1,:), Optional_RK(1,:))")
291 call disp%show(
"getOption(Default_RK(1,1))")
293 call disp%show(
"getOption(Default_RK(1,1), Optional_RK(1,1))")
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 ⛓
24Output_SK(:,:)
= getOption(Default_SK, Optional_SK)
34Output_SK(:,
1)
= getOption(Default_SK(:,
1))
37Output_SK(:,
1)
= getOption(Default_SK(:,
1), Optional_SK(:,
1))
46Output_SK(
1,
1)
= getOption(Default_SK(
1,
1))
49Output_SK(
1,
1)
= getOption(Default_SK(
1,
1), Optional_SK(
1,
1))
79getOption(Default_LK(:,
1), Optional_LK(:,
1))
89getOption(Default_LK(
1,:), Optional_LK(
1,:))
99getOption(Default_LK(
1,
1), Optional_LK(
1,
1))
128getOption(Default_IK(:,
1), Optional_IK(:,
1))
138getOption(Default_IK(
1,:), Optional_IK(
1,:))
148getOption(Default_IK(
1,
1), Optional_IK(
1,
1))
158(
+6.0000000000000000,
-6.0000000000000000), (
+4.0000000000000000,
-4.0000000000000000), (
+2.0000000000000000,
-2.0000000000000000)
159(
+5.0000000000000000,
-5.0000000000000000), (
+3.0000000000000000,
-3.0000000000000000), (
+1.0000000000000000,
-1.0000000000000000)
161(
+1.0000000000000000,
-1.0000000000000000), (
+3.0000000000000000,
-3.0000000000000000), (
+5.0000000000000000,
-5.0000000000000000)
162(
+2.0000000000000000,
-2.0000000000000000), (
+4.0000000000000000,
-4.0000000000000000), (
+6.0000000000000000,
-6.0000000000000000)
164(
+6.0000000000000000,
-6.0000000000000000), (
+4.0000000000000000,
-4.0000000000000000), (
+2.0000000000000000,
-2.0000000000000000)
165(
+5.0000000000000000,
-5.0000000000000000), (
+3.0000000000000000,
-3.0000000000000000), (
+1.0000000000000000,
-1.0000000000000000)
167(
+1.0000000000000000,
-1.0000000000000000), (
+3.0000000000000000,
-3.0000000000000000), (
+5.0000000000000000,
-5.0000000000000000)
168(
+2.0000000000000000,
-2.0000000000000000), (
+4.0000000000000000,
-4.0000000000000000), (
+6.0000000000000000,
-6.0000000000000000)
172(
+6.0000000000000000,
-6.0000000000000000), (
+5.0000000000000000,
-5.0000000000000000)
174(
+1.0000000000000000,
-1.0000000000000000), (
+2.0000000000000000,
-2.0000000000000000)
176(
+6.0000000000000000,
-6.0000000000000000), (
+5.0000000000000000,
-5.0000000000000000)
177getOption(Default_CK(:,
1), Optional_CK(:,
1))
178(
+1.0000000000000000,
-1.0000000000000000), (
+2.0000000000000000,
-2.0000000000000000)
182(
+6.0000000000000000,
-6.0000000000000000), (
+4.0000000000000000,
-4.0000000000000000), (
+2.0000000000000000,
-2.0000000000000000)
184(
+1.0000000000000000,
-1.0000000000000000), (
+3.0000000000000000,
-3.0000000000000000), (
+5.0000000000000000,
-5.0000000000000000)
186(
+6.0000000000000000,
-6.0000000000000000), (
+4.0000000000000000,
-4.0000000000000000), (
+2.0000000000000000,
-2.0000000000000000)
187getOption(Default_CK(
1,:), Optional_CK(
1,:))
188(
+1.0000000000000000,
-1.0000000000000000), (
+3.0000000000000000,
-3.0000000000000000), (
+5.0000000000000000,
-5.0000000000000000)
192(
+6.0000000000000000,
-6.0000000000000000)
194(
+1.0000000000000000,
-1.0000000000000000)
196(
+6.0000000000000000,
-6.0000000000000000)
197getOption(Default_CK(
1,
1), Optional_CK(
1,
1))
198(
+1.0000000000000000,
-1.0000000000000000)
207+6.0000000000000000,
+4.0000000000000000,
+2.0000000000000000
208+5.0000000000000000,
+3.0000000000000000,
+1.0000000000000000
210+1.0000000000000000,
+3.0000000000000000,
+5.0000000000000000
211+2.0000000000000000,
+4.0000000000000000,
+6.0000000000000000
213+6.0000000000000000,
+4.0000000000000000,
+2.0000000000000000
214+5.0000000000000000,
+3.0000000000000000,
+1.0000000000000000
216+1.0000000000000000,
+3.0000000000000000,
+5.0000000000000000
217+2.0000000000000000,
+4.0000000000000000,
+6.0000000000000000
221+6.0000000000000000,
+5.0000000000000000
223+1.0000000000000000,
+2.0000000000000000
225+6.0000000000000000,
+5.0000000000000000
226getOption(Default_RK(:,
1), Optional_RK(:,
1))
227+1.0000000000000000,
+2.0000000000000000
231+6.0000000000000000,
+4.0000000000000000,
+2.0000000000000000
233+1.0000000000000000,
+3.0000000000000000,
+5.0000000000000000
235+6.0000000000000000,
+4.0000000000000000,
+2.0000000000000000
236getOption(Default_RK(
1,:), Optional_RK(
1,:))
237+1.0000000000000000,
+3.0000000000000000,
+5.0000000000000000
246getOption(Default_RK(
1,
1), Optional_RK(
1,
1))
- Benchmarks:
Benchmark :: The runtime performance of getOption vs. direct optional choice ⛓
3 use iso_fortran_env,
only:
error_unit
11 integer(IK) :: fileUnit
12 integer(IK) ,
parameter :: NSIZE
= 14_IK
13 integer(IK) ,
parameter :: NBENCH
= 2_IK
14 integer(IK) :: arraySize(
0:NSIZE)
15 real(RK) :: dummy
= 0._RK
17 real(RK) ,
allocatable :: Array(:)
18 real(RK) ,
allocatable :: Default(:)
19 type(bench_type) :: bench(NBENCH)
22 bench(
2)
= bench_type(name
= SK_
"direct", exec
= direct , overhead
= setOverhead)
24 arraySize
= [
0_IK, (
2_IK**isize, isize
= 0_IK, NSIZE
- 1_IK)]
26 write(
*,
"(*(g0,:,' '))")
27 write(
*,
"(*(g0,:,' '))")
"getOption() vs. direct()"
28 write(
*,
"(*(g0,:,' '))")
30 open(newunit
= fileUnit, file
= "main.out", status
= "replace")
32 write(fileUnit,
"(*(g0,:,','))")
"arraySize", (bench(i)
%name, i
= 1, NBENCH)
34 loopOverArraySize:
do isize
= 0_IK, NSIZE
36 write(
*,
"(*(g0,:,' '))")
"Benchmarking with size", arraySize(isize)
38 allocate(Array(arraySize(isize)), Default(arraySize(isize)))
39 call random_number(Default)
40 call random_number(Array)
42 bench(i)
%timing
= bench(i)
%getTiming(minsec
= 0.07_RK)
44 deallocate(Array, Default)
46 write(fileUnit,
"(*(g0,:,','))") arraySize(isize), (bench(i)
%timing
%mean, i
= 1, NBENCH)
48 end do loopOverArraySize
49 write(
*,
"(*(g0,:,' '))") dummy
50 write(
*,
"(*(g0,:,' '))")
60 subroutine setOverhead()
61 call random_number(unifrnd)
62 if (arraySize(isize)
> 0_IK)
then
68 dummy
= dummy
+ sum(Default)
70 dummy
= dummy
+ unifrnd
88 call random_number(unifrnd)
89 if (arraySize(isize)
> 0_IK)
then
90 if (unifrnd
< 0.5_RK)
then
91 call add_option_D1(Array)
96 if (unifrnd
< 0.5_RK)
then
97 call add_option_D0(unifrnd)
105 call random_number(unifrnd)
106 if (arraySize(isize)
> 0_IK)
then
107 if (unifrnd
< 0.5_RK)
then
108 call add_direct_D1(Array)
113 if (unifrnd
< 0.5_RK)
then
114 call add_direct_D0(unifrnd)
121 subroutine add_option_D0(value)
123 real(RK),
intent(in),
optional :: value
124 dummy
= dummy
+ getOption(unifrnd, value)
127 subroutine add_direct_D0(value)
128 real(RK),
intent(in),
optional :: value
129 if (
present(value))
then
130 dummy
= dummy
+ value
132 dummy
= dummy
+ unifrnd
136 subroutine add_option_D1(Value)
138 real(RK),
intent(in),
optional :: Value(:)
139 dummy
= dummy
+ sum(
getOption(Default, Value))
142 subroutine add_direct_D1(Value)
143 real(RK),
intent(in),
optional :: Value(:)
144 if (
present(Value))
then
145 dummy
= dummy
+ sum(Value)
147 dummy
= dummy
+ sum(Default)
Generate and return an object of type timing_type containing the benchmark timing information and sta...
This module contains abstract interfaces and types that facilitate benchmarking of different procedur...
This is the class for creating benchmark and performance-profiling objects.
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
Postprocessing of the benchmark output ⛓
3import matplotlib.pyplot
as plt
9methods = [
"direct",
"getOption"]
11df = pd.read_csv(
"main.out")
17ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
21 plt.plot( df[
"arraySize"].values + 1
26plt.xticks(fontsize = fontsize)
27plt.yticks(fontsize = fontsize)
28ax.set_xlabel(
"Array Size + 1", fontsize = fontsize)
29ax.set_ylabel(
"Runtime [ seconds ]", fontsize = fontsize)
30ax.set_title(
"getOption() vs. direct method.\nLower is better.", fontsize = fontsize)
34plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
35ax.tick_params(axis =
"y", which =
"minor")
36ax.tick_params(axis =
"x", which =
"minor")
44plt.savefig(
"benchmark.getOption_vs_direct.runtime.png")
50ax = plt.figure(figsize = 1.25 * np.array([6.4,4.6]), dpi = 200)
53plt.plot( df[
"arraySize"].values + 1
54 , np.ones(len(df[
"arraySize"].values))
58plt.plot( df[
"arraySize"].values + 1
59 , df[
"getOption"].values / df[
"direct"].values
63plt.xticks(fontsize = fontsize)
64plt.yticks(fontsize = fontsize)
65ax.set_xlabel(
"Array Size + 1", fontsize = fontsize)
66ax.set_ylabel(
"getOption() runtime compared to direct method", fontsize = fontsize)
67ax.set_title(
"getOption() to direct method Runtime Ratio.\nLower means faster. Lower than 1 means faster than direct method.", fontsize = fontsize)
71plt.grid(visible =
True, which =
"both", axis =
"both", color =
"0.85", linestyle =
"-")
72ax.tick_params(axis =
"y", which =
"minor")
73ax.tick_params(axis =
"x", which =
"minor")
74ax.legend ( [
"Direct Method (Equality)",
"getOption()"]
81plt.savefig(
"benchmark.getOption_vs_direct.runtime.ratio.png")
Visualization of the benchmark output ⛓
Benchmark moral ⛓
- The benchmark results indicate that explicit if-blocks for optional arguments tends to be 100-1000 times faster than calling the convenience functions under the generic interface getOption.
This performance difference tends to be about a factor of 10 times for scalar optional
arguments and grows substantially to larger factors with switching to increasing-size array-like optional
dummy arguments.
- Despite significant performance degradation with the use of getOption, note that the overall average overhead of calling getOption remains extremely small as of 2022 AD, on the order of nano to micro seconds depending on the size of the optional argument from scalar to large arrays.
- Additionally, the significance of performance degradation, if any, depends entirely on the ability of the compiler to inline the procedure.
The observed performance degradations report here occur without any compiler inlining attempts.
- Consequently, there is practically no harm in using getOption in non-performance-critical sections of a codebase, that is, parts of a codebase that are to be called less than billions of times at runtime.
- Test:
- test_pm_option
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 The functions under the generic interface getOption are inspired by and further extend the functionalities implemented in optval of the Fortran stdlib.
- Author:
- Amir Shahmoradi, September 1, 2020, 01:12 AM, Dallas, Texas
Definition at line 135 of file pm_option.F90.