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 This module contains tests of the module [ParaMonteChainFileContents_mod](@ref paramontechainfilecontents_mod).
44 : !> \author Amir Shahmoradi
45 :
46 : module Test_ParaMonteChainFileContents_mod
47 :
48 : use Test_mod, only: Test_type, getLogFuncMVN
49 : use ParaMonteChainFileContents_mod
50 : implicit none
51 :
52 : private
53 : public :: test_ParaMonteChainFileContents
54 :
55 : type(Test_type) :: Test
56 :
57 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 :
59 : contains
60 :
61 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 :
63 3 : subroutine test_ParaMonteChainFileContents()
64 : implicit none
65 3 : Test = Test_type(moduleName=MODULE_NAME)
66 3 : call Test%run(test_constructChainFileContents_1, "test_constructChainFileContents_1")
67 3 : call Test%finalize()
68 3 : end subroutine test_ParaMonteChainFileContents
69 :
70 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 :
72 3 : function test_constructChainFileContents_1() result(assertion)
73 3 : use Constants_mod, only: IK, RK
74 : use ParaDRAM_mod, only: ParaDRAM_type
75 : implicit none
76 : logical :: assertion
77 3 : type(ParaDRAM_type) :: PD
78 3 : type(ChainFileContents_type):: CFC
79 : real(RK) , parameter :: tolerance = 1.e-10_RK
80 : character(*), parameter :: DELIM = "delim"
81 : !character(9), parameter :: variableNameList(*) = ["var1", "var2"]
82 : integer(IK) , parameter :: NDIM = 2_IK
83 3 : assertion = .true.
84 : #if defined CODECOV_ENABLED || defined SAMPLER_TEST_ENABLED
85 :
86 : call PD%runSampler ( ndim = NDIM &
87 : , getLogFunc = getLogFuncMVN &
88 : , outputFileName = Test%outDir//"/"//MODULE_NAME//"/test_constructChainFileContents_1" &
89 : , mpiFinalizeRequested = .false. &
90 : , outputRealPrecision = 15_IK &
91 : , outputDelimiter = DELIM &
92 : , sampleSize = 10_IK &
93 3 : )
94 3 : assertion = assertion .and. .not. PD%Err%occurred
95 3 : if (Test%isDebugMode .and. .not. assertion) then
96 : ! LCOV_EXCL_START
97 : write(*,"(10(g0,:,', '))")
98 : write(*,"(10(g0,:,', '))") "PD%Err%occurred", PD%Err%occurred
99 : write(*,"(10(g0,:,', '))") "PD%Err%msg ", PD%Err%msg
100 : write(*,"(10(g0,:,', '))")
101 : return
102 : end if
103 : ! LCOV_EXCL_STOP
104 :
105 : ! read the chain file, first call without the optional input file, in which case no error should happen.
106 :
107 3 : CFC = ChainFileContents_type( ndim = NDIM )
108 3 : assertion = assertion .and. .not. CFC%Err%occurred
109 3 : if (Test%isDebugMode .and. .not. assertion) then
110 : ! LCOV_EXCL_START
111 : write(*,"(10(g0,:,', '))")
112 : write(*,"(10(g0,:,', '))") "CFC%Err%occurred", CFC%Err%occurred
113 : write(*,"(10(g0,:,', '))") "CFC%Err%msg ", CFC%Err%msg
114 : write(*,"(10(g0,:,', '))")
115 : return
116 : end if
117 : ! LCOV_EXCL_STOP
118 :
119 : CFC = ChainFileContents_type( ndim = NDIM &
120 : !, variableNameList = variableNameList &
121 : , chainFilePath = PD%ChainFile%Path%original &
122 : , targetChainSize = 2 * PD%Chain%Count%compact &
123 : , chainSize = PD%Chain%Count%compact &
124 : , chainFileForm = "compact" &
125 33 : )
126 3 : assertion = assertion .and. .not. CFC%Err%occurred
127 3 : if (Test%isDebugMode .and. .not. assertion) then
128 : ! LCOV_EXCL_START
129 : write(*,"(10(g0,:,', '))")
130 : write(*,"(10(g0,:,', '))") "CFC%Err%occurred", CFC%Err%occurred
131 : write(*,"(10(g0,:,', '))") "CFC%Err%msg ", CFC%Err%msg
132 : write(*,"(10(g0,:,', '))")
133 : return
134 : end if
135 : ! LCOV_EXCL_STOP
136 :
137 : #endif
138 64 : end function test_constructChainFileContents_1
139 :
140 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141 :
142 : end module Test_ParaMonteChainFileContents_mod
|