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 `outputColumnWidth` 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_OutputColumnWidth_mod
49 :
50 : use Constants_mod, only: IK
51 : implicit none
52 :
53 : integer(IK), parameter :: OUTPUT_COL_WIDTH = 63
54 :
55 : integer(IK) :: outputColumnWidth ! namelist input
56 :
57 : character(*), parameter :: MODULE_NAME = "@SpecBase_OutputColumnWidth_mod"
58 :
59 : type :: OutputColumnWidth_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 => setOutputColumnWidth, checkForSanity, nullifyNameListVar
67 : end type OutputColumnWidth_type
68 :
69 : interface OutputColumnWidth_type
70 : module procedure :: constructOutputColumnWidth
71 : end interface OutputColumnWidth_type
72 :
73 : private :: constructOutputColumnWidth, setOutputColumnWidth
74 :
75 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 :
77 : contains
78 :
79 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 :
81 1047 : function constructOutputColumnWidth(methodName) result(OutputColumnWidthObj)
82 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
83 : !DEC$ ATTRIBUTES DLLEXPORT :: constructOutputColumnWidth
84 : #endif
85 : use Constants_mod, only: IK, NULL_IK
86 : use String_mod, only: num2str
87 : implicit none
88 : character(*), intent(in) :: methodName
89 : type(OutputColumnWidth_type) :: OutputColumnWidthObj
90 1047 : OutputColumnWidthObj%def = 0_IK
91 1047 : OutputColumnWidthObj%null = NULL_IK
92 : OutputColumnWidthObj%desc = &
93 : "The variable outputColumnWidth is a non-negative integer number that determines the width of &
94 : &the data columns in " // methodName // " formatted output files that have tabular structure. &
95 : &If it is set to zero, " // methodName // " will ensure to set the width of each output element &
96 : &to the minimum possible width without losing the requested output precision. In other words, &
97 : &setting outputColumnWidth = 0 will result in the smallest-size for the formatted output files that are in ASCII format. &
98 1047 : &The default value is " // num2str(OutputColumnWidthObj%def) // "."
99 1047 : end function constructOutputColumnWidth
100 :
101 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102 :
103 1047 : subroutine nullifyNameListVar(OutputColumnWidthObj)
104 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
105 : !DEC$ ATTRIBUTES DLLEXPORT :: nullifyNameListVar
106 : #endif
107 : implicit none
108 : class(OutputColumnWidth_type), intent(in) :: OutputColumnWidthObj
109 1047 : outputColumnWidth = OutputColumnWidthObj%null
110 2094 : end subroutine nullifyNameListVar
111 :
112 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113 :
114 1065 : subroutine setOutputColumnWidth(OutputColumnWidthObj,outputColumnWidth)
115 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
116 : !DEC$ ATTRIBUTES DLLEXPORT :: setOutputColumnWidth
117 : #endif
118 1047 : use String_mod, only: num2str
119 : use Constants_mod, only: IK
120 : implicit none
121 : class(OutputColumnWidth_type), intent(inout) :: OutputColumnWidthObj
122 : integer(IK), intent(in) :: outputColumnWidth
123 1065 : OutputColumnWidthObj%val = outputColumnWidth
124 1065 : if (OutputColumnWidthObj%val==OutputColumnWidthObj%null) then
125 1035 : OutputColumnWidthObj%val = OutputColumnWidthObj%def
126 : end if
127 1065 : OutputColumnWidthObj%str = num2str(OutputColumnWidthObj%val)
128 1065 : end subroutine setOutputColumnWidth
129 :
130 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131 :
132 1035 : subroutine checkForSanity(OutputColumnWidthObj,Err,methodName,outputRealPrecision)
133 : #if INTEL_COMPILER_ENABLED && defined DLL_ENABLED && (OS_IS_WINDOWS || defined OS_IS_DARWIN)
134 : !DEC$ ATTRIBUTES DLLEXPORT :: checkForSanity
135 : #endif
136 1065 : use Err_mod, only: Err_type
137 : use Constants_mod, only: IK
138 : use String_mod, only: num2str
139 : implicit none
140 : class(OutputColumnWidth_type), intent(in) :: OutputColumnWidthObj
141 : character(*), intent(in) :: methodName
142 : integer(IK) , intent(in) :: outputRealPrecision
143 : type(Err_type), intent(inout) :: Err
144 : character(*), parameter :: PROCEDURE_NAME = "@checkForSanity()"
145 1035 : if ( OutputColumnWidthObj%val<0_IK ) then
146 12 : Err%occurred = .true.
147 : Err%msg = Err%msg // &
148 : MODULE_NAME // PROCEDURE_NAME // ": Error occurred. &
149 : &The input value for variable outputColumnWidth must be a non-negative integer. &
150 : &If you are not sure about the appropriate value for this variable, simply drop it from the input. " // &
151 12 : methodName // " will automatically assign an appropriate value to it.\n\n"
152 1023 : elseif ( OutputColumnWidthObj%val>0_IK .and. OutputColumnWidthObj%val<outputRealPrecision+7_IK ) then
153 6 : Err%occurred = .true.
154 : Err%msg = Err%msg // &
155 : MODULE_NAME // PROCEDURE_NAME // ": Error occurred. The input value for variable outputColumnWidth &
156 : &must be equal to or greater than the input value for outputRealPrecision + 7. &
157 : &If you are not sure about the appropriate value for this variable, either set it to zero on input, &
158 : &or simply drop it from the input. " // methodName // &
159 6 : " will automatically assign an appropriate value to it.\n\n"
160 : end if
161 2070 : end subroutine checkForSanity
162 :
163 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
164 :
165 : end module SpecBase_OutputColumnWidth_mod ! LCOV_EXCL_LINE
|