Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!!
4 : !!!! MIT License
5 : !!!!
6 : !!!! ParaMonte: plain powerful parallel Monte Carlo library.
7 : !!!!
8 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab
9 : !!!!
10 : !!!! This file is part of the ParaMonte library.
11 : !!!!
12 : !!!! Permission is hereby granted, free of charge, to any person obtaining a
13 : !!!! copy of this software and associated documentation files (the "Software"),
14 : !!!! to deal in the Software without restriction, including without limitation
15 : !!!! the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 : !!!! and/or sell copies of the Software, and to permit persons to whom the
17 : !!!! Software is furnished to do so, subject to the following conditions:
18 : !!!!
19 : !!!! The above copyright notice and this permission notice shall be
20 : !!!! included in all copies or substantial portions of the Software.
21 : !!!!
22 : !!!! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 : !!!! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 : !!!! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 : !!!! IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
26 : !!!! DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
27 : !!!! OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
28 : !!!! OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 : !!!!
30 : !!!! ACKNOWLEDGMENT
31 : !!!!
32 : !!!! ParaMonte is an honor-ware and its currency is acknowledgment and citations.
33 : !!!! As per the ParaMonte library license agreement terms, if you use any parts of
34 : !!!! this library for any purposes, kindly acknowledge the use of ParaMonte in your
35 : !!!! work (education/research/industry/development/...) by citing the ParaMonte
36 : !!!! library as described on this page:
37 : !!!!
38 : !!!! https://github.com/cdslaborg/paramonte/blob/main/ACKNOWLEDGMENT.md
39 : !!!!
40 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
42 :
43 : !> \brief
44 : !> This module contains the classes and procedures for setting up the `domainLowerLimitVec` attribute of ParaMonte samplers.
45 : !> For more information, see the description of this attribute in the body of the module.
46 : !> \author Amir Shahmoradi
47 :
48 : module SpecBase_DomainLowerLimitVec_mod
49 :
50 : use Constants_mod, only: RK
51 : implicit none
52 :
53 : character(*), parameter :: MODULE_NAME = "@SpecBase_DomainLowerLimitVec_mod"
54 :
55 : real(RK), allocatable :: domainLowerLimitVec(:) ! namelist input
56 :
57 : type :: domainLowerLimitVec_type
58 : real(RK), allocatable :: Val(:)
59 : real(RK) :: def
60 : real(RK) :: null
61 : character(:), allocatable :: desc
62 : contains
63 : procedure, pass :: set => setDomainLowerLimitVec, checkForSanity, nullifyNameListVar
64 : end type DomainLowerLimitVec_type
65 :
66 : interface DomainLowerLimitVec_type
67 : module procedure :: constructDomainLowerLimitVec
68 : end interface DomainLowerLimitVec_type
69 :
70 : private :: constructDomainLowerLimitVec, setDomainLowerLimitVec, checkForSanity, nullifyNameListVar
71 :
72 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 :
74 : contains
75 :
76 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 :
78 1047 : function constructDomainLowerLimitVec(methodName) result(DomainLowerLimitVecObj)
79 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
80 : !DEC$ ATTRIBUTES DLLEXPORT :: constructDomainLowerLimitVec
81 : #endif
82 : use Decoration_mod, only: TAB
83 : use Constants_mod, only: NULL_RK, NEGINF_RK
84 : use String_mod, only: num2str
85 : implicit none
86 : type(DomainLowerLimitVec_type) :: DomainLowerLimitVecObj
87 : character(*), intent(in) :: methodName
88 1047 : DomainLowerLimitVecObj%def = NEGINF_RK
89 1047 : DomainLowerLimitVecObj%null = NULL_RK
90 : DomainLowerLimitVecObj%desc = &
91 : "domainLowerLimitVec represents the lower boundaries of the cubical domain of the objective function to be sampled. &
92 : &It is an ndim-dimensional vector of 64-bit real numbers, where ndim is the number of variables of the objective function. &
93 : &It is also possible to assign only select values of domainLowerLimitVec and leave the rest of the components to be assigned &
94 : &the default value. This is POSSIBLE ONLY when domainLowerLimitVec is defined inside the input file to "//methodName//". &
95 : &For example, having the following inside the input file, \n\n&
96 : & domainLowerLimitVec(3:5) = -100\n\n&
97 : & will only set the lower limits of the third, fourth, and the fifth dimensions to -100, or,\n\n&
98 : & domainLowerLimitVec(1) = -100, domainLowerLimitVec(2) = -1.e6 \n\n&
99 : & will set the lower limit on the first dimension to -100, and 1.e6 on the second dimension, or,\n\n&
100 : & domainLowerLimitVec = 3*-2.5e100\n\n&
101 : & will only set the lower limits on the first, second, and the third dimensions to -2.5*10^100, while the rest of &
102 : &the lower limits for the missing dimensions will be automatically set to the default value.\n\n&
103 1047 : &The default value for all elements of domainLowerLimitVec is: " // num2str(DomainLowerLimitVecObj%def) // "."
104 1047 : end function constructDomainLowerLimitVec
105 :
106 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 :
108 1047 : subroutine nullifyNameListVar(DomainLowerLimitVecObj,nd)
109 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
110 : !DEC$ ATTRIBUTES DLLEXPORT :: nullifyNameListVar
111 : #endif
112 1047 : use Constants_mod, only: IK
113 : implicit none
114 : class(DomainLowerLimitVec_type), intent(in) :: DomainLowerLimitVecObj
115 : integer(IK), intent(in) :: nd
116 1044 : if (allocated(domainLowerLimitVec)) deallocate(domainLowerLimitVec)
117 1047 : allocate(domainLowerLimitVec(nd))
118 2553 : domainLowerLimitVec(1:nd) = DomainLowerLimitVecObj%null
119 1047 : end subroutine nullifyNameListVar
120 :
121 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 :
123 2250 : subroutine setDomainLowerLimitVec(DomainLowerLimitVecObj,domainLowerLimitVec)
124 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
125 : !DEC$ ATTRIBUTES DLLEXPORT :: setDomainLowerLimitVec
126 : #endif
127 1047 : use Constants_mod, only: IK, RK
128 : implicit none
129 : class(DomainLowerLimitVec_type), intent(inout) :: DomainLowerLimitVecObj
130 : real(RK), intent(in) :: domainLowerLimitVec(:)
131 2811 : DomainLowerLimitVecObj%Val = domainLowerLimitVec
132 2733 : where ( DomainLowerLimitVecObj%Val == DomainLowerLimitVecObj%null )
133 1125 : DomainLowerLimitVecObj%Val = DomainLowerLimitVecObj%def
134 : end where
135 1125 : end subroutine setDomainLowerLimitVec
136 :
137 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 :
139 1035 : subroutine checkForSanity(DomainLowerLimitVecObj,Err)
140 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
141 : !DEC$ ATTRIBUTES DLLEXPORT :: checkForSanity
142 : #endif
143 1125 : use Err_mod, only: Err_type
144 : use Constants_mod, only: IK, NEGINF_RK
145 : use String_mod, only: num2str
146 : implicit none
147 : class(DomainLowerLimitVec_type), intent(in) :: DomainLowerLimitVecObj
148 : type(Err_type), intent(inout) :: Err
149 : character(*), parameter :: PROCEDURE_NAME = MODULE_NAME//"@checkForSanity()"
150 : integer(IK) :: i
151 2529 : do i = 1,size(DomainLowerLimitVecObj%Val(:))
152 2529 : if ( DomainLowerLimitVecObj%Val(i) < NEGINF_RK ) then
153 12 : Err%occurred = .true.
154 : Err%msg = Err%msg // &
155 : PROCEDURE_NAME // ": Error occurred. The component " // num2str(i) // &
156 24 : " of the variable domainLowerLimitVec (" // num2str(DomainLowerLimitVecObj%Val(i)) // ") &
157 : &cannot be smaller than the smallest positive real number representable in the simulation (" // &
158 12 : num2str(NEGINF_RK) // ").\n\n"
159 : end if
160 : end do
161 1035 : end subroutine checkForSanity
162 :
163 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 :
165 : end module SpecBase_DomainLowerLimitVec_mod ! LCOV_EXCL_LINE
|