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 `progressReportPeriod` 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_ProgressReportPeriod_mod
49 :
50 : use Constants_mod, only: IK
51 : implicit none
52 :
53 : character(*), parameter :: MODULE_NAME = "@SpecBase_ProgressReportPeriod_mod"
54 :
55 : integer(IK) :: progressReportPeriod ! namelist input
56 :
57 : type :: ProgressReportPeriod_type
58 : integer(IK) :: val
59 : integer(IK) :: def
60 : integer(IK) :: null
61 : character(:), allocatable :: desc
62 : contains
63 : procedure, pass :: set => setProgressReportPeriod, checkForSanity, nullifyNameListVar
64 : end type ProgressReportPeriod_type
65 :
66 : interface ProgressReportPeriod_type
67 : module procedure :: constructProgressReportPeriod
68 : end interface ProgressReportPeriod_type
69 :
70 : private :: constructProgressReportPeriod, setProgressReportPeriod
71 :
72 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 :
74 : contains
75 :
76 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 :
78 349 : function constructProgressReportPeriod() result(ProgressReportPeriodObj)
79 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
80 : !DEC$ ATTRIBUTES DLLEXPORT :: constructProgressReportPeriod
81 : #endif
82 : use Constants_mod, only: IK, NULL_IK
83 : use String_mod, only: num2str
84 : implicit none
85 : type(ProgressReportPeriod_type) :: ProgressReportPeriodObj
86 349 : ProgressReportPeriodObj%def = 1000_IK
87 349 : ProgressReportPeriodObj%null = NULL_IK
88 : ProgressReportPeriodObj%desc = &
89 : "Every progressReportPeriod calls to the objective function, the sampling progress will be reported to the log file. &
90 : &Note that progressReportPeriod must be a positive integer. &
91 349 : &The default value is " // num2str(ProgressReportPeriodObj%def) // "."
92 349 : end function constructProgressReportPeriod
93 :
94 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 :
96 349 : subroutine nullifyNameListVar(ProgressReportPeriodObj)
97 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
98 : !DEC$ ATTRIBUTES DLLEXPORT :: nullifyNameListVar
99 : #endif
100 : implicit none
101 : class(ProgressReportPeriod_type), intent(inout) :: ProgressReportPeriodObj
102 349 : progressReportPeriod = ProgressReportPeriodObj%null
103 349 : end subroutine nullifyNameListVar
104 :
105 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106 :
107 351 : subroutine setProgressReportPeriod(ProgressReportPeriodObj,progressReportPeriod)
108 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
109 : !DEC$ ATTRIBUTES DLLEXPORT :: setProgressReportPeriod
110 : #endif
111 349 : use Constants_mod, only: IK
112 : implicit none
113 : class(ProgressReportPeriod_type), intent(inout) :: ProgressReportPeriodObj
114 : integer(IK), intent(in) :: progressReportPeriod
115 351 : ProgressReportPeriodObj%val = progressReportPeriod
116 351 : if (ProgressReportPeriodObj%val==ProgressReportPeriodObj%null) then
117 343 : ProgressReportPeriodObj%val = ProgressReportPeriodObj%def
118 : end if
119 351 : end subroutine setProgressReportPeriod
120 :
121 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 :
123 345 : subroutine checkForSanity(ProgressReportPeriod,Err,methodName)
124 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
125 : !DEC$ ATTRIBUTES DLLEXPORT :: checkForSanity
126 : #endif
127 351 : use Err_mod, only: Err_type
128 : use String_mod, only: num2str
129 : implicit none
130 : class(ProgressReportPeriod_type), intent(in) :: ProgressReportPeriod
131 : character(*), intent(in) :: methodName
132 : type(Err_type), intent(inout) :: Err
133 : character(*), parameter :: PROCEDURE_NAME = "@checkForSanity()"
134 345 : if ( ProgressReportPeriod%val<1 ) then
135 4 : Err%occurred = .true.
136 : Err%msg = Err%msg // &
137 : MODULE_NAME // PROCEDURE_NAME // ": Error occurred. &
138 : &The input value for variable progressReportPeriod must be a positive integer value. If you are not sure &
139 : &about the appropriate value for this variable, simply drop it from the input. " // &
140 4 : methodName // " will automatically assign an appropriate value to it.\n\n"
141 : end if
142 690 : end subroutine checkForSanity
143 :
144 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 :
146 : end module SpecBase_ProgressReportPeriod_mod ! LCOV_EXCL_LINE
|