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 `outputRealPrecision` 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_OutputRealPrecision_mod
49 :
50 : use Constants_mod, only: IK
51 : implicit none
52 :
53 : character(*), parameter :: MODULE_NAME = "@SpecBase_OutputRealPrecision_mod"
54 :
55 : integer(IK), parameter :: OUTPUT_REAL_PRECISION = 8
56 :
57 : integer(IK) :: outputRealPrecision ! namelist input
58 :
59 : type :: OutputRealPrecision_type
60 : integer(IK) :: val
61 : integer(IK) :: def
62 : integer(IK) :: null
63 : character(:), allocatable :: str
64 : character(:), allocatable :: desc
65 : contains
66 : procedure, pass :: set => setOutputRealPrecision, checkForSanity, nullifyNameListVar
67 : end type OutputRealPrecision_type
68 :
69 : interface OutputRealPrecision_type
70 : module procedure :: constructOutputRealPrecision
71 : end interface OutputRealPrecision_type
72 :
73 : private :: constructOutputRealPrecision, setOutputRealPrecision
74 :
75 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 :
77 : contains
78 :
79 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 :
81 1047 : function constructOutputRealPrecision(methodName) result(OutputRealPrecisionObj)
82 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
83 : !DEC$ ATTRIBUTES DLLEXPORT :: constructOutputRealPrecision
84 : #endif
85 : use Constants_mod, only: NULL_IK
86 : use String_mod, only: num2str
87 : implicit none
88 : character(*), intent(in) :: methodName
89 : type(OutputRealPrecision_type) :: OutputRealPrecisionObj
90 1047 : OutputRealPrecisionObj%def = OUTPUT_REAL_PRECISION
91 1047 : OutputRealPrecisionObj%null = NULL_IK
92 : OutputRealPrecisionObj%desc = &
93 : "The variable outputRealPrecision is a 32-bit integer number that determines the precision - that is, the number of &
94 : &significant digits - of the real numbers in the output files of " // methodName // ". Any positive integer is acceptable &
95 : &as the input value of outputRealPrecision. However, any digits of the output real numbers beyond the accuracy of 64-bit &
96 : &real numbers (approximately 16 digits of significance) will be meaningless and random. Set this variable to 16 (or larger) &
97 : &if full reproducibility of the simulation is needed in the future. But keep in mind that larger precisions will result in &
98 : &larger-size output files. This variable is ignored for binary output (if any occurs during the simulation). &
99 1047 : &The default value is " // num2str(OutputRealPrecisionObj%def) // "."
100 1047 : end function constructOutputRealPrecision
101 :
102 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 :
104 1047 : subroutine nullifyNameListVar(OutputRealPrecisionObj)
105 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
106 : !DEC$ ATTRIBUTES DLLEXPORT :: nullifyNameListVar
107 : #endif
108 : implicit none
109 : class(OutputRealPrecision_type), intent(in) :: OutputRealPrecisionObj
110 1047 : outputRealPrecision = OutputRealPrecisionObj%null
111 1047 : end subroutine nullifyNameListVar
112 :
113 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 :
115 1152 : subroutine setOutputRealPrecision(OutputRealPrecisionObj,outputRealPrecision)
116 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
117 : !DEC$ ATTRIBUTES DLLEXPORT :: setOutputRealPrecision
118 : #endif
119 1047 : use String_mod, only: num2str
120 : use Constants_mod, only: IK
121 : implicit none
122 : class(OutputRealPrecision_type), intent(inout) :: OutputRealPrecisionObj
123 : integer(IK), intent(in) :: outputRealPrecision
124 1152 : OutputRealPrecisionObj%val = outputRealPrecision
125 1152 : if (OutputRealPrecisionObj%val==OutputRealPrecisionObj%null) then
126 1029 : OutputRealPrecisionObj%val = OutputRealPrecisionObj%def
127 : end if
128 1152 : OutputRealPrecisionObj%str = num2str(OutputRealPrecisionObj%val)
129 1152 : end subroutine setOutputRealPrecision
130 :
131 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 :
133 1035 : subroutine checkForSanity(OutputRealPrecisionObj,Err,methodName)
134 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
135 : !DEC$ ATTRIBUTES DLLEXPORT :: checkForSanity
136 : #endif
137 1152 : use Err_mod, only: Err_type
138 : use String_mod, only: num2str
139 : implicit none
140 : class(OutputRealPrecision_type), intent(in) :: OutputRealPrecisionObj
141 : character(*), intent(in) :: methodName
142 : type(Err_type), intent(inout) :: Err
143 : character(*), parameter :: PROCEDURE_NAME = "@checkForSanity()"
144 1035 : if ( OutputRealPrecisionObj%val<1_IK ) then
145 12 : Err%occurred = .true.
146 : Err%msg = Err%msg // &
147 : MODULE_NAME // PROCEDURE_NAME // ": Error occurred. &
148 : &The input value for variable outputRealPrecision must be a positive integer < 16. If you are not sure &
149 : &about the appropriate value for this variable, simply drop it from the input. " // &
150 12 : methodName // " will automatically assign an appropriate value to it.\n\n"
151 : end if
152 2070 : end subroutine checkForSanity
153 :
154 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155 :
156 : end module SpecBase_OutputRealPrecision_mod ! LCOV_EXCL_LINE
|