Line data Source code
1 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 : !!!! !!!!
4 : !!!! ParaMonte: Parallel Monte Carlo and Machine Learning Library. !!!!
5 : !!!! !!!!
6 : !!!! Copyright (C) 2012-present, The Computational Data Science Lab !!!!
7 : !!!! !!!!
8 : !!!! This file is part of the ParaMonte library. !!!!
9 : !!!! !!!!
10 : !!!! LICENSE !!!!
11 : !!!! !!!!
12 : !!!! https://github.com/cdslaborg/paramonte/blob/main/LICENSE.md !!!!
13 : !!!! !!!!
14 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15 : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 :
17 : ! Define intel-specific shared property of files on Windows.
18 : #if INTEL_ENABLED && WINDOWS_ENABLED
19 : #define SHARED, shared
20 : #else
21 : #define SHARED
22 : #endif
23 : use pm_kind, only: SKC => SK, SK, IK, LK, RKD, modelr_type
24 : !use pm_io, only: FORMAT_GENERIC_BLANK_TABBED
25 : use pm_sysPath, only: MAX_LEN_FILE_PATH
26 : use pm_mathNumSys, only: getCountDigit
27 : use pm_paramonte, only: envis_type
28 : use pm_paramonte, only: envname, envis
29 : use pm_parallelism, only: image_type
30 : use pm_arrayRemove, only: getRemoved
31 : use pm_arrayResize, only: setResized
32 : use pm_matrixInit, only: getMatInit
33 : use pm_matrixInit, only: uppLowDia
34 : use pm_strASCII, only: getStrLower
35 : use pm_val2str, only: getStr
36 : use pm_except, only: setNAN
37 : use pm_except, only: isNAN
38 : use pm_except, only: isInf
39 : use pm_str, only: UNDEFINED
40 : use pm_io, only: field_type
41 : use pm_err, only: getFine
42 : use pm_io, only: filext
43 : use pm_io, only: TABEQV
44 : use pm_io, only: openArg_type
45 : use pm_distUnif, only: xoshiro256ssw_type
46 : use pm_io, only: display_type, mark_type, note_type, warn_type, stop_type, wrap_type
47 : use pm_strASCII, only: SUB ! Equivalent to the `Substitute` ASCII character used in the early days of communication.
48 : use pm_container, only: css_type
49 : use pm_timer, only: timer_type
50 :
51 : implicit none
52 : #if OMP_ENABLED
53 : character(63,SKC) :: co_outputFileNameDef
54 : #endif
55 : character(*,SKC) , parameter :: MODULE_NAME = SK_"@pm_sampling_base"
56 : !character(*,SKC) , parameter :: format = FORMAT_GENERIC_BLANK_TABBED ! format with which all simulation specs are reported to the output file.
57 : character(*,SKC) , parameter :: NL1 = new_line(SKC_"a")
58 : character(*,SKC) , parameter :: NL2 = NL1//NL1
59 : !character(*,SKC) , parameter :: RED = SKC_"ES" ! real edit descriptor.
60 :
61 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62 : ! simulation declarations.
63 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64 :
65 : type :: sfcbase_type
66 : integer(IK) :: nref = 0_IK !< \public The number of refinements, zero if sample size is prescribed by the user.
67 : integer(IK) , allocatable :: nsam(:) !< \public The array of shape `(1:nref)` containing the number of unique samples (compact sample size) at each refinement stage.
68 : integer(IK) , allocatable :: sumw(:) !< \public The array of shape `(1:nref)` containing the sum of the sample weights (verbose sample size) at each refinement stage.
69 : integer(IK) , allocatable :: sampleWeight(:) !< \public The array of shape `(1:nsam)` containing the final refined sample weights.
70 : real(RKC) , allocatable :: sampleLogFuncState(:,:) !< \public The array of shape `(1:ndim, nsam)` containing the final refined logFunc and sample weights.
71 : type(css_type) , allocatable :: colname(:)
72 : character(:,SKC) , allocatable :: header
73 : end type
74 :
75 : !> The Quantile derived type containing the distribution quantiles.
76 : type :: quantile_type
77 : real(RKC) , allocatable :: quan(:,:) ! 9 by ndim.
78 : real(RKC) :: prob(9) = [0._RKC, 0.05_RKC, 0.10_RKC, 0.25_RKC, 0.50_RKC, 0.75_RKC, 0.90_RKC, 0.95_RKC, 1.0_RKC]
79 : character(4,SKC) :: name(9) = [" Q0"," Q5"," Q10"," Q25"," Q50"," Q75"," Q90"," Q95","Q100"]
80 : end type
81 :
82 : type :: mode_type
83 : integer(IK) :: loc
84 : real(RKC) :: val
85 : real(RKC) , allocatable :: crd(:)
86 : end type
87 :
88 : type :: statistics_type
89 : integer(IK) :: size
90 : type(mode_type) :: mode
91 : type(quantile_type) :: quantile
92 : real(RKC) , allocatable :: cor(:,:)
93 : real(RKC) , allocatable :: cov(:,:)
94 : real(RKC) , allocatable :: avg(:)
95 : end type
96 :
97 : type :: progress_type
98 : integer(IK) :: counterPRP = 0_IK !< \public Counter for progress report file. The initialization is important.
99 : real(RKD) :: timeElapsedSinceStartInSeconds = 0._RKC !< \public Used in progress report. The initialization is important.
100 : real(RKD) :: clock = -1._RKC !< \public Used in progress report. The initialization is important.
101 : end type
102 :
103 : type, abstract :: astatbase_type
104 : integer(IK) :: ess !< \public The effective sample size.
105 : class(timer_type) , allocatable :: timer !< \public timer.
106 : type(statistics_type) :: chain !< \public chain statistics.
107 : type(statistics_type) :: sample !< \public sample statistics.
108 : type(progress_type) :: progress !< \public sampling progress info.
109 : real(RKD) :: avgTimePerFunCall = 0._RKD !< \public Average time per objective function call (in seconds).
110 : real(RKD) :: avgCommPerFunCall = 0._RKD !< \public Average inter-process communication time per function call (in seconds).
111 : integer(IK) :: numFunCallAccepted = 0_IK !< \public The number of accepted function calls during the sampling.
112 : integer(IK) :: numFunCallAcceptedRejected = 0_IK !< \public The number of accepted or rejected function calls during the sampling.
113 : integer(IK) :: numFunCallAcceptedLastReport = 0_IK !< \public Used in progress report.
114 : end type
115 :
116 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117 : ! auxiliary simulation information.
118 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 :
120 : type :: runis_type
121 : logical(LK) :: dry !< \public The scalar `logical` of default kind \LK, that is .true`. if and only if the simulation restarts from an existing incomplete simulation.
122 : logical(LK) :: new !< \public The scalar `logical` of default kind \LK, that is .true`. if and only if the simulation is fresh from the beginning.
123 : end type
124 :
125 : type :: run_type
126 : integer(IK) :: id !< \public The scalar `integer` of default kind \IK, containing the current simulation run number (always starting at `1`).
127 : type(runis_type) :: is
128 : end type
129 :
130 : type :: format_type
131 : character(:,SKC) , allocatable :: generic
132 : character(:,SKC) , allocatable :: integer
133 : character(:,SKC) , allocatable :: allreal
134 : character(:,SKC) , allocatable :: intreal
135 : character(:,SKC) , allocatable :: strreal
136 : character(:,SKC) , allocatable :: fixform
137 : end type
138 :
139 : type :: tabularFileFormat_type
140 : character(:,SKC) , allocatable :: header
141 : character(:,SKC) , allocatable :: rows
142 : end type
143 :
144 : type, extends(openArg_type) :: samplerFile_type
145 : logical(LK) :: extant = .false._LK
146 : character(:,SKC) , allocatable :: suffix
147 : character(:,SKC) , allocatable :: kind
148 : character(:,SKC) , allocatable :: ext
149 : type(css_type) , allocatable :: list(:)
150 : end type
151 :
152 : type, extends(samplerFile_type) :: chainFile_type
153 : type(tabularFileFormat_type) :: format
154 : end type
155 :
156 : type, extends(samplerFile_type) :: progressFile_type
157 : type(tabularFileFormat_type) :: format
158 : end type
159 :
160 : type, extends(samplerFile_type) :: reportFile_type
161 : character(len(TABEQV, IK),SKC) :: indent = TABEQV
162 : type(format_type) :: format
163 : end type
164 :
165 : type, extends(samplerFile_type) :: restartFile_type
166 : integer(IK) :: counter = 0_IK
167 : character(:,SKC) , allocatable :: format
168 : end type
169 :
170 : type, extends(samplerFile_type) :: sampleFile_type
171 : type(tabularFileFormat_type) :: format
172 : end type
173 :
174 : type :: ndim_type
175 : real(RKC) :: inv
176 : integer(IK) :: val
177 : character(:,SKC) , allocatable :: str
178 : character(:,SKC) , allocatable :: desc
179 : end type
180 :
181 : type :: method_type
182 : logical(LK) :: isParaDISE = .false._LK
183 : logical(LK) :: isParaDRAM = .false._LK
184 : logical(LK) :: isParaNest = .false._LK
185 : character(:,SKC) , allocatable :: val
186 : character(:,SKC) , allocatable :: desc
187 : end type
188 :
189 : type, extends(modelr_type) :: real_type
190 : real(RKC) :: large = -huge(0._RKC) !< \public The largest working real number without undue Euclidean distance overflow.
191 : character(:,SKC) , allocatable :: desc
192 : character(:,SKC) , allocatable :: ed !< \public real edit descriptor: ES
193 : character(:,SKC) , allocatable :: ex !< \public real exponent descriptor: E0
194 : end type
195 :
196 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
197 : ! specification declarations.
198 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 :
200 : !character(8192,SKC) :: description ! namelist input
201 : type :: description_type
202 : character(:,SKC) , allocatable :: val
203 : character(:,SKC) , allocatable :: def
204 : character(:,SKC) , allocatable :: null
205 : character(:,SKC) , allocatable :: desc
206 : end type
207 :
208 : !character(:,SKC) , allocatable :: domain ! namelist input
209 : type :: domain_type
210 : real(RKC) :: logVol = log(huge(0._RKC)) ! log-volume of the domain.
211 : logical(LK) :: isFinite ! paranest: always true. dram/dise: true only if domain is user-set.
212 : logical(LK) :: isCube
213 : logical(LK) :: isBall
214 : character(4,SKC) :: ball
215 : character(4,SKC) :: cube
216 : character(:,SKC) , allocatable :: val
217 : character(:,SKC) , allocatable :: def
218 : character(:,SKC) , allocatable :: null
219 : character(:,SKC) , allocatable :: desc
220 : end type
221 :
222 : !character(63,SKC) , allocatable :: domainAxisName(:) ! namelist input
223 : type :: domainAxisName_type
224 : character(63,SKC) :: null
225 : character(63,SKC) , allocatable :: val(:)
226 : character(63,SKC) , allocatable :: def(:)
227 : character(:,SKC) , allocatable :: desc
228 : character(:,SKC) , allocatable :: prefix
229 : end type
230 :
231 : !real(RKC) , allocatable :: domainBallCenter(:) ! namelist input
232 : type :: domainBallCenter_type
233 : real(RKC) , allocatable :: val(:)
234 : real(RKC) :: def
235 : character(:,SKC) , allocatable :: desc
236 : end type
237 :
238 : !real(RKC) , allocatable :: domainBallCorMat(:,:) ! namelist input
239 : type :: domainBallCorMat_type
240 : real(RKC) , allocatable :: val(:,:)
241 : real(RKC) , allocatable :: def(:,:)
242 : character(:,SKC) , allocatable :: desc
243 : end type
244 :
245 : !real(RKC) , allocatable :: domainBallCovMat(:,:) ! namelist input
246 : type :: domainBallCovMat_type
247 : logical(LK) :: isUserSet
248 : real(RKC) , allocatable :: def(:,:)
249 : real(RKC) , allocatable :: val(:,:)
250 : real(RKC) , allocatable :: inv(:,:)
251 : character(:,SKC) , allocatable :: desc
252 : end type
253 :
254 : !real(RKC) , allocatable :: domainBallStdVec(:) ! namelist input
255 : type :: domainBallStdVec_type
256 : real(RKC) , allocatable :: val(:)
257 : real(RKC) , allocatable :: def
258 : character(:,SKC) , allocatable :: desc
259 : end type
260 :
261 : !real(RKC) , allocatable :: domainCubeLimitLower(:) ! namelist input
262 : type :: domainCubeLimitLower_type
263 : real(RKC) :: def
264 : real(RKC) , allocatable :: val(:)
265 : character(:,SKC) , allocatable :: desc
266 : end type
267 :
268 : !real(RKC) , allocatable :: domainCubeLimitUpper(:) ! namelist input
269 : type :: domainCubeLimitUpper_type
270 : real(RKC) :: def
271 : real(RKC) , allocatable :: val(:)
272 : character(:,SKC) , allocatable :: desc
273 : end type
274 :
275 : !integer(IK) :: domainErrCount ! namelist input
276 : type :: domainErrCount_type
277 : integer(IK) :: def
278 : integer(IK) :: val
279 : integer(IK) :: null
280 : character(:,SKC) , allocatable :: str
281 : character(:,SKC) , allocatable :: desc
282 : end type
283 :
284 : !integer(IK) :: domainErrCountMax ! namelist input
285 : type :: domainErrCountMax_type
286 : integer(IK) :: val
287 : integer(IK) :: def
288 : integer(IK) :: null
289 : character(:,SKC) , allocatable :: str
290 : character(:,SKC) , allocatable :: desc
291 : end type
292 :
293 : !logical(LK) :: inputFileHasPriority
294 : type :: inputFileHasPriority_type
295 : logical(LK) :: val
296 : logical(LK) :: def
297 : character(:,SKC) , allocatable :: desc
298 : end type
299 :
300 : !character(:,SKC) , allocatable :: outputChainFileFormat
301 : type :: outputChainFileFormat_type
302 : logical(LK) :: isCompact
303 : logical(LK) :: isVerbose
304 : logical(LK) :: isBinary
305 : character(7,SKC) :: compact
306 : character(7,SKC) :: verbose
307 : character(6,SKC) :: binary
308 : character(:,SKC) , allocatable :: def
309 : character(:,SKC) , allocatable :: val
310 : character(:,SKC) , allocatable :: null
311 : character(:,SKC) , allocatable :: desc
312 : end type
313 :
314 : !integer(IK) :: outputColumnWidth ! namelist input
315 : type :: outputColumnWidth_type
316 : integer(IK) :: null
317 : integer(IK) :: def
318 : integer(IK) :: val
319 : character(:,SKC) , allocatable :: str
320 : character(:,SKC) , allocatable :: max
321 : character(:,SKC) , allocatable :: desc
322 : end type
323 :
324 : !character(:,SKC) , allocatable :: outputFileName ! namelist input
325 : type :: outputFileName_type
326 : character(:,SKC) , allocatable :: full
327 : character(:,SKC) , allocatable :: base
328 : character(:,SKC) , allocatable :: seps
329 : character(:,SKC) , allocatable :: sep
330 : character(:,SKC) , allocatable :: dir
331 : character(:,SKC) , allocatable :: val
332 : character(:,SKC) , allocatable :: def
333 : character(:,SKC) , allocatable :: null
334 : character(:,SKC) , allocatable :: desc
335 : end type
336 :
337 : !character(:,SKC) , allocatable :: outputStatus
338 : type :: outputStatusIs_type
339 : logical(LK) :: extend
340 : logical(LK) :: repeat
341 : logical(LK) :: retry
342 : end type
343 : type :: outputStatus_type
344 : type(outputStatusIs_type) :: is
345 : character(:,SKC) , allocatable :: def
346 : character(:,SKC) , allocatable :: val
347 : character(:,SKC) , allocatable :: null
348 : character(:,SKC) , allocatable :: desc
349 : end type
350 :
351 : !integer(IK) :: outputPrecision ! namelist input
352 : type :: outputPrecision_type
353 : character(:,SKC) , allocatable :: str
354 : integer(IK) :: val
355 : integer(IK) :: def
356 : integer(IK) :: null
357 : character(:,SKC) , allocatable :: desc
358 : end type
359 :
360 : !integer(IK) :: outputReportPeriod ! namelist input
361 : type :: outputReportPeriod_type
362 : real(RKC) :: inv
363 : integer(IK) :: val
364 : integer(IK) :: def
365 : integer(IK) :: null
366 : character(:,SKC) , allocatable :: desc
367 : end type
368 :
369 : !character(:,SKC) , allocatable :: outputRestartFileFormat ! namelist input
370 : type :: outputRestartFileFormat_type
371 : logical(LK) :: isBinary
372 : logical(LK) :: isAscii
373 : character(6,SKC) :: binary
374 : character(5,SKC) :: ascii
375 : character(:,SKC) , allocatable :: def
376 : character(:,SKC) , allocatable :: val
377 : character(:,SKC) , allocatable :: null
378 : character(:,SKC) , allocatable :: desc
379 : end type
380 :
381 : !integer(IK) :: outputSampleSize ! namelist input
382 : type :: outputSampleSize_type
383 : character(:,SKC) , allocatable :: str
384 : integer(IK) :: val
385 : integer(IK) :: def
386 : integer(IK) :: null
387 : character(:,SKC) , allocatable :: desc
388 : end type
389 :
390 : !character(:,SKC) , allocatable :: outputSeparator ! namelist input
391 : type :: outputSeparator_type
392 : character(:,SKC) , allocatable :: val
393 : character(:,SKC) , allocatable :: def
394 : character(:,SKC) , allocatable :: null
395 : character(:,SKC) , allocatable :: desc
396 : end type
397 :
398 : !character(:,SKC) , allocatable :: outputSplashMode ! namelist input
399 : type :: outputSplashModeIs_type
400 : logical(LK) :: normal = .false._LK
401 : logical(LK) :: silent = .false._LK
402 : logical(LK) :: quiet = .false._LK
403 : end type
404 : type :: outputSplashMode_type
405 : type(outputSplashModeIs_type) :: is
406 : character(6,SKC) :: normal = SKC_"normal"
407 : character(6,SKC) :: silent = SKC_"silent"
408 : character(5,SKC) :: quiet = SKC_"quiet"
409 : character(:,SKC) , allocatable :: null
410 : character(:,SKC) , allocatable :: def
411 : character(:,SKC) , allocatable :: val
412 : character(:,SKC) , allocatable :: desc
413 : end type
414 :
415 : !character(:,SKC) , allocatable :: parallelism
416 : type :: parallelismis_type
417 : logical(LK) :: forkJoin = .false._LK
418 : logical(LK) :: multiChain = .false._LK
419 : logical(LK) :: singleChain = .false._LK
420 : end type
421 : type :: parallelism_type
422 : type(parallelismis_type) :: is
423 : character(11,SKC) :: singleChain
424 : character(10,SKC) :: multiChain
425 : character(:,SKC) , allocatable :: def
426 : character(:,SKC) , allocatable :: val
427 : character(:,SKC) , allocatable :: null
428 : character(:,SKC) , allocatable :: desc
429 : end type
430 :
431 : !logical(LK) :: parallelismMpiFinalizeEnabled ! namelist input
432 : type :: parallelismMpiFinalizeEnabled_type
433 : logical(LK) :: val
434 : logical(LK) :: def
435 : character(:,SKC) , allocatable :: desc
436 : end type
437 :
438 : type :: parallelismNumThread_type
439 : integer(IK) :: val
440 : integer(IK) :: def
441 : integer(IK) :: null
442 : character(:,SKC) , allocatable :: desc
443 : end type
444 :
445 : !character(:,SKC) , allocatable :: plang ! namelist input
446 : !type :: plang_type
447 : ! !character(:,SKC) , allocatable :: val
448 : ! !character(:,SKC) , allocatable :: def
449 : ! !character(:,SKC) , allocatable :: null
450 : ! !character(:,SKC) , allocatable :: desc
451 : ! type(envis_type) :: is = envis
452 : !end type
453 :
454 : !integer(IK) :: randomSeed ! namelist input
455 : type :: randomSeed_type
456 : integer(IK) :: val
457 : integer(IK) :: null
458 : !integer(IK) :: imageID
459 : !integer(IK) :: sizeSeed
460 : !integer(IK) :: imageCount
461 : !integer(IK) :: processID
462 : !integer(IK) , allocatable :: Seed(:,:)
463 : character(:,SKC) , allocatable :: desc
464 : end type
465 :
466 : !character(:,SKC) , allocatable :: sysInfoFilePath ! namelist input
467 : type :: sysInfoFilePath_type
468 : character(:,SKC) , allocatable :: def
469 : character(:,SKC) , allocatable :: val
470 : character(:,SKC) , allocatable :: null
471 : end type
472 :
473 : !real(RKC) :: targetAcceptanceRate(2) ! namelist input
474 : type :: targetAcceptanceRate_type
475 : logical(LK) :: enabled
476 : real(RKC) :: val(2)
477 : real(RKC) :: def(2)
478 : real(RKC) :: aim ! The target efficiency (depends on the sampler).
479 : character(:,SKC) , allocatable :: desc
480 : end type
481 :
482 : !> \brief
483 : !> This is the derived type containing the base properties of a ParaMonte sampler.
484 : !>
485 : !> \details
486 : !> This derived type contains (and shall contain) only the base sampler specifications
487 : !> that are meant to be set and frozen before the start of the simulation kernel.<br>
488 : !> Any component that changes over the course of simulation should become
489 : !> part of [statbase_type](@ref pm_sampling_base::statbase_type).<br>
490 : !>
491 : type :: specbase_type
492 : type(xoshiro256ssw_type) :: rng !< \public Random number generator.
493 : type(run_type) :: run !< \public The simulation run ID and information.
494 : logical(LK) :: overridable !< \public The scalar `logical` of default kind \LK that is `.true.` if and only if the namelist argument `inputFileHasPriority` is `.false.`.
495 : character(:,SKC), allocatable :: msg !< \public The scalar `character` containing the messages common between stdout and the report file.
496 : type(ndim_type) :: ndim
497 : type(image_type) :: image
498 : type(method_type) :: method
499 : type(real_type) :: real
500 : type(display_type) :: disp
501 : type(chainFile_type) :: chainFile
502 : type(progressFile_type) :: progressFile
503 : type(reportFile_type) :: reportFile
504 : type(restartFile_type) :: restartFile
505 : type(sampleFile_type) :: sampleFile
506 : type(description_type ) :: description
507 : type(domain_type ) :: domain
508 : type(domainAxisName_type ) :: domainAxisName
509 : type(domainBallCenter_type ) :: domainBallCenter
510 : type(domainBallCorMat_type ) :: domainBallCorMat
511 : type(domainBallCovMat_type ) :: domainBallCovMat
512 : type(domainBallStdVec_type ) :: domainBallStdVec
513 : type(domainCubeLimitLower_type ) :: domainCubeLimitLower
514 : type(domainCubeLimitUpper_type ) :: domainCubeLimitUpper
515 : type(domainErrCount_type ) :: domainErrCount
516 : type(domainErrCountMax_type ) :: domainErrCountMax
517 : type(inputFileHasPriority_type ) :: inputFileHasPriority
518 : type(outputChainFileFormat_type ) :: outputChainFileFormat
519 : type(outputColumnWidth_type ) :: outputColumnWidth
520 : type(outputFileName_type ) :: outputFileName
521 : type(outputPrecision_type ) :: outputPrecision
522 : type(outputReportPeriod_type ) :: outputReportPeriod
523 : type(outputRestartFileFormat_type ) :: outputRestartFileFormat
524 : type(outputSampleSize_type ) :: outputSampleSize
525 : type(outputSeparator_type ) :: outputSeparator
526 : type(outputSplashMode_type ) :: outputSplashMode
527 : type(outputStatus_type ) :: outputStatus
528 : type(parallelism_type ) :: parallelism
529 : type(parallelismMpiFinalizeEnabled_type ) :: parallelismMpiFinalizeEnabled
530 : type(parallelismNumThread_type ) :: parallelismNumThread
531 : !type(plang_type ) :: plang
532 : type(randomSeed_type ) :: randomSeed
533 : type(sysInfoFilePath_type ) :: sysInfoFilePath
534 : type(targetAcceptanceRate_type ) :: targetAcceptanceRate
535 : contains
536 : procedure, pass, public :: set
537 : procedure, pass, private :: isFailedResizeList
538 : procedure, pass, private :: openFiles
539 : procedure, pass, private :: openFile
540 : procedure, pass, private :: sanitize
541 : procedure, pass, private :: report
542 : end type
543 :
544 : interface specbase_type
545 : module procedure :: construct
546 : end interface
547 :
548 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549 :
550 : contains
551 :
552 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
553 :
554 0 : subroutine killMeAlreadyCMake1_RK5(); use pm_sampling_scio_RK5, only: RKC; end subroutine
555 0 : subroutine killMeAlreadyCMake1_RK4(); use pm_sampling_scio_RK4, only: RKC; end subroutine
556 0 : subroutine killMeAlreadyCMake1_RK3(); use pm_sampling_scio_RK3, only: RKC; end subroutine
557 0 : subroutine killMeAlreadyCMake1_RK2(); use pm_sampling_scio_RK2, only: RKC; end subroutine
558 0 : subroutine killMeAlreadyCMake1_RK1(); use pm_sampling_scio_RK1, only: RKC; end subroutine
559 :
560 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
561 :
562 14 : function construct(modelr, method, ndim) result(spec)
563 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
564 : !DEC$ ATTRIBUTES DLLEXPORT :: construct
565 : #endif
566 : type(modelr_type), intent(in) :: modelr
567 : character(*,SKC), intent(in) :: method
568 : integer(IK), intent(in) :: ndim
569 : type(specbase_type) :: spec
570 :
571 14 : block
572 : integer(IK) :: width
573 : character(:,SKC), allocatable :: prefix
574 14 : prefix = spec%reportFile%indent//method
575 14 : width = 115_IK - len(prefix, IK)
576 : spec%disp = display_type( tmsize = 0_IK, bmsize = 1_IK & ! LCOV_EXCL_LINE
577 : , mark = mark_type(prefix = spec%reportFile%indent, tmsize = 0_IK, bmsize = 1_IK, width = 99999_IK) & ! LCOV_EXCL_LINE
578 : , note = note_type(prefix = prefix, tmsize = 0_IK, bmsize = 1_IK, width = width) & ! LCOV_EXCL_LINE
579 : , warn = warn_type(prefix = prefix, tmsize = 0_IK, bmsize = 1_IK, width = width) & ! LCOV_EXCL_LINE
580 : , stop = stop_type(prefix = prefix, tmsize = 1_IK, bmsize = 2_IK, width = width) & ! LCOV_EXCL_LINE
581 28 : )
582 : end block
583 14 : spec%disp%width = max(80_IK, min(132_IK, abs(spec%disp%width))) - 4_IK ! laptops have tiny screens - 2 * margin width (= 2).
584 14 : spec%disp%text%width = spec%disp%width
585 14 : spec%real%large = real(aint(sqrt(modelr%huge) / ndim), RKC)
586 14 : spec%image = image_type()
587 :
588 : ndim_block: block
589 14 : spec%ndim%val = ndim
590 14 : spec%ndim%inv = 1._RKC / real(ndim, RKC)
591 : !spec%ndim%sqpndim = ndim**2 + ndim
592 14 : spec%ndim%str = getStr(ndim)
593 : spec%ndim%desc = &
594 : SKC_"The simulation specification `ndim` is a positive scalar of type `integer` of kind 32-bit, &
595 : &representing the number of dimensions of the domain of the objective function. &
596 : &Unlike most other simulation specifications, `ndim` cannot be set from within an external input function &
597 : &and the user must always specify it along with the objective function at the time of calling the exploration routine &
598 : &separately from the rest of the (optional) simulation specifications. &
599 14 : &As such, `ndim` has no default value and is always user-supplied."
600 : end block ndim_block
601 :
602 14 : method_block: block
603 : character(:,SKC), allocatable :: lowval
604 14 : spec%method%val = method
605 14 : lowval = getStrLower(spec%method%val)
606 14 : spec%method%isParaDISE = logical(lowval == SKC_"paradise", LK)
607 14 : spec%method%isParaDRAM = logical(lowval == SKC_"paradram", LK)
608 14 : spec%method%isParaNest = logical(lowval == SKC_"paranest", LK)
609 : spec%method%desc = &
610 : SKC_"The simulation specification `method` is a scalar string, &
611 : &representing the method of exploring the objective function. &
612 : &Unlike most other simulation specifications, `method` cannot be set from within an external input function &
613 : &and the user always specifies it by calling the corresponding objective function exploration routine. &
614 : &As such, `method` has no default value and is always user-supplied. &
615 : &The following density function exploration methods are currently or will be supported by the ParaMonte library:"//NL2//&
616 : SKC_" ParaDRAM"//NL2//&
617 : SKC_" The ParaDRAM acronym stands for Parallel Delayed-Rejection Adaptive Metropolis Markov Chain Monte Carlo. &
618 : &The ParaDRAM sampler can optimize and explore the landscape of objective functions stochastically. &
619 : &For more details of the ParaDRAM sampling scheme, refer to the references section in the documentation of the ParaMonte library:"//NL2//&
620 28 : SKC_" https://www.cdslab.org/paramonte"
621 : end block method_block
622 :
623 : modelr_block: block
624 14 : spec%real%modelr_type = modelr
625 14 : spec%real%ed = SKC_"ES"
626 14 : spec%real%ex = SKC_"E0"
627 : spec%real%desc = &
628 : SKC_"The simulation specification `modelr` is an object whose components contain the &
629 : &characteristics of `real` (float) data type model (hence the name `modelr`) used for (most) computations during the simulation. &
630 : &The real/float type used within the simulation is the same as that of the input and output values to and from the objective function. &
631 : &It is set by the user when the sampler is called. As such, unlike most other simulation specifications, `modelr` cannot be set from &
632 : &within an external input function, the user always specifies it when calling the corresponding sampler. &
633 : &Therefore, `modelr` has no default value and is always user-supplied when calling the sampler. &
634 : &The components of `modelr` are important for future determination of the type and kind of the real/float used in the simulation. &
635 : &The `modelr` object contains the following real/float characteristics:"//NL2//&
636 : SKC_"+ `digits`"//NL2//&
637 : SKC_" The number of significant bit digits in the real/float model used in the simulations."//NL2//&
638 : SKC_"+ `kind`"//NL2//&
639 : SKC_" The processor-dependent kind type-parameter of the real/float model used in the current simulation."//NL2//&
640 : SKC_"+ `maxexponent`"//NL2//&
641 : SKC_" The maximum exponent for the real/float model used in the current simulation."//NL2//&
642 : SKC_"+ `minexponent`"//NL2//&
643 : SKC_" The minimum exponent for the real/float model used in the current simulation."//NL2//&
644 : SKC_"+ `precision`"//NL2//&
645 : SKC_" The equivalent decimal precision (number of digits after the decimal point) of the real/float model used in the current simulation."//NL2//&
646 : SKC_"+ `radix`"//NL2//&
647 : SKC_" The base in the real/float model used in the current simulation."//NL2//&
648 : SKC_"+ `range`"//NL2//&
649 : SKC_" The decimal exponent range in the real/float model used in the current simulation. &
650 : &It is the value corresponding to `int(min(log10(huge), -log10(tiny)))` where `huge` &
651 : &and `tiny` are the largest and smallest positive numbers in the real/float model"//NL2//&
652 : SKC_"+ `storage_size`"//NL2//&
653 : SKC_" The size, in bits, that would be taken in memory by a scalar of the real/float model used in the current simulation."//NL2//&
654 : SKC_"+ `epsilon`"//NL2//&
655 : SKC_" The smallest normal value representable by the real/float model used in the current simulation such that `1 < 1 + epsilon`."//NL2//&
656 : SKC_"+ `huge`"//NL2//&
657 : SKC_" The largest normal value representable by the real/float model used in the current simulation (without causing overflow)."//NL2//&
658 : SKC_"+ `tiny`"//NL2//&
659 14 : SKC_" The smallest positive normal value representable by the real/float model used in the current simulation (without causing underflow)."
660 : end block modelr_block
661 :
662 : description_block: block
663 : use pm_sampling_scio, only: description
664 14 : spec%description%null = repeat(SUB, len(description, IK))
665 14 : spec%description%def = UNDEFINED
666 : spec%description%desc = &
667 : SKC_"The simulation specification `description` is a scalar string of maximum length `"//getStr(len(description, IK))//&
668 : SKC_"` characters containing general information about the simulation to be performed. It has no effects &
669 : &on the simulation and serves only as a general description for future reference. &
670 : &The sampler parser automatically recognizes the C-style `'\n'` escape sequence as the new-line character &
671 : &and `'\\'` as the backslash character `'\'` if used in the contents of `description`. For example, `'\\n'` &
672 : &will be converted to `'\n'` on the output, while `'\n'` translates to the new-line character. &
673 14 : &The default value for `description` is `'"//spec%description%def//SKC_"'`."
674 : !$omp master
675 14 : description = spec%description%null
676 : !$omp end master
677 : end block description_block
678 :
679 : domain_block: block
680 : use pm_sampling_scio, only: domain
681 14 : spec%domain%isFinite = spec%method%isParaNest
682 14 : spec%domain%isCube = .false._LK
683 14 : spec%domain%isBall = .false._LK
684 14 : spec%domain%cube = SKC_"cube"
685 14 : spec%domain%ball = SKC_"ball"
686 14 : spec%domain%null = repeat(SUB, len(domain, IK))
687 14 : spec%domain%def = spec%domain%cube
688 : spec%domain%desc = &
689 : SKC_"The simulation specification `domain` is a scalar string of maximum length `"//getStr(len(domain, IK))//SKC_"`, &
690 : &containing the model's name that defines the objective function's domain. &
691 : &The string value must be enclosed by either single or double quotation marks when provided as input. &
692 : &The following domain models are currently supported:"//NL2//&
693 : SKC_"+ `domain = '"//spec%domain%cube//SKC_"'`"//NL2//&
694 : SKC_" This is equivalent to an `ndim`-dimensional hyper-cube (n-cube) whose upper and lower bounds are specified &
695 : &by the input simulation specifications `domainCubeLimitUpper` and `domainCubeLimitLower` respectively."//NL2//&
696 : SKC_"+ `domain = '"//spec%domain%ball//SKC_"'`"//NL2//&
697 : SKC_" This is equivalent to an `ndim`-dimensional hyper-ellipsoid (n-ball) whose center and covariance matrix can be &
698 : &specified by the input simulation specification `domainBallCenter` and `domainBallCovMat` respectively. Alternatively, &
699 : &the user can let the ParaMonte samplers construct the covariance matrix of the ellipsoidal domain from the input &
700 : &values for the `domainBallCorMat` and `domainBallStdVec` simulation specifications. Note that a spherical &
701 : &domain can be defined by dropping the `domainBallCovMat` and `domainBallCorMat` specifications from the input &
702 : &and setting all elements of `domainBallStdVec` to the desired radius of the domain."//NL2//&
703 14 : SKC_"The default value for `domain` is an infinite cube in the case of the ParaDRAM and ParaDISE samplers, and a unit-sized cube for the ParaNest sampler."
704 : !$omp master
705 14 : domain = spec%domain%null
706 : !$omp end master
707 : end block domain_block
708 :
709 : domainAxisName_block: block
710 : use pm_sampling_scio, only: domainAxisName
711 : integer(IK) :: idim
712 14 : spec%domainAxisName%prefix = SKC_"sampleState"
713 14 : spec%domainAxisName%null = repeat(SUB, len(domainAxisName, IK))
714 14 : call setResized(spec%domainAxisName%def, ndim)
715 42 : do idim = 1, ndim
716 42 : spec%domainAxisName%def(idim) = spec%domainAxisName%prefix//getStr(idim)
717 : end do
718 : spec%domainAxisName%desc = &
719 : SKC_"The simulation specification `domainAxisName` is a vector of scalar string values, each element of which contains &
720 : &the names of the corresponding axis of the density function domain (to be explored/sampled). &
721 : &It is used to construct the headers of the simulation output files. &
722 : &Any element of `domainAxisName` not set by the user will automatically be assigned a default name. &
723 : &If all elements of `domainAxisName` are set to the same value, then a number will be suffixed to each element &
724 : &representing the ID of the corresponding dimension of the domain of the density function. &
725 : &The default value for `domainAxisName` is '"//spec%domainAxisName%prefix//SKC_"i' where integer `'i'` at the &
726 14 : &end of the name is replaced by the index of the corresponding domain axis."
727 : !$omp master
728 14 : call setResized(domainAxisName, ndim)
729 42 : domainAxisName = spec%domainAxisName%null
730 : !$omp end master
731 : end block domainAxisName_block
732 :
733 : domainBallCenter_block: block
734 : use pm_sampling_scio, only: domainBallCenter
735 14 : spec%domainBallCenter%def = 0._RKC
736 : spec%domainBallCenter%desc = &
737 : SKC_"The simulation specification `domainBallCenter` is a vector of type `real` of highest precision supported by the ParaMonte library, &
738 : &of size `ndim` containing the coordinates of the center of the hyper-ellipsoidal (or spherical) `ndim`-dimensional domain of the objective function. &
739 : &When passed to the sampler from within an external input file, every missing element of `domainBallCenter` will be set to the origin (zero). &
740 : &Together with `domainBallCovMat`, or with `domainBallCorMat` and `domainBallStdVec`, it forms a hyper-ellipsoidal &
741 : &or hyper-spherical domain for the ParaMonte samplers. Note that an ellipsoidal/spherical domain is used if only if the &
742 : &input simulation specification `domain` is set to 'ellipsoid' or 'sphere' or `ball`. Otherwise, a cubical domain will be used. &
743 14 : &The default value for `domainBallCenter` is the origin (i.e., a zero-valued vector of size `ndim`)."
744 : !$omp master
745 14 : call setResized(domainBallCenter, ndim)
746 42 : call setNAN(domainBallCenter(1 : ndim))
747 : !$omp end master
748 : end block domainBallCenter_block
749 :
750 : domainBallCorMat_block: block
751 : use pm_sampling_scio, only: domainBallCorMat
752 272 : spec%domainBallCorMat%def = getMatInit([ndim, ndim], uppLowDia, vupp = 0._RKC, vlow = 0._RKC, vdia = 1._RKC)
753 : spec%domainBallCorMat%desc = &
754 : SKC_"The simulation specification `domainBallCorMat` is a positive-definite matrix of type `real` of highest precision available in the ParaMonte Library &
755 : &of size `(ndim, ndim)` representing the correlation matrix of the domain of the objective function, where `ndim` is the dimension of the domain. &
756 : &Combined with the input simulation specification `domainBallStdVec` it defines the objective function's hyper-ellipsoidal (or spherical) domain. &
757 : &If the input simulation specification `domainBallCovMat` is provided by the user, then any values set &
758 : &for `domainBallCorMat` and `domainBallStdVec` will be automatically ignored. The input specification `domainBallCorMat` &
759 : &along with `proposalStdVec` are especially useful when covariance matrix computation is non-trivial. &
760 : &When passed to the sampler from within an external input sampler specification file, any missing element of `domainBallCovMat` &
761 14 : &will be set to the appropriate default value. The default value for `domainBallCorMat` is an `ndim`-by-`ndim` Identity matrix."
762 : !$omp master
763 42 : call setResized(domainBallCorMat, [ndim, ndim])
764 122 : call setNAN(domainBallCorMat)
765 : !$omp end master
766 : end block domainBallCorMat_block
767 :
768 : domainBallCovMat_block: block
769 : use pm_sampling_scio, only: domainBallCovMat
770 14 : spec%domainBallCovMat%isUserSet = .false._LK ! This must be set here. It is important for the proper setting from inputFile and inputArg.
771 14 : if (spec%method%isParaDRAM .or. spec%method%isParaDISE) then
772 272 : spec%domainBallCovMat%def = getMatInit([ndim, ndim], uppLowDia, 0._RKC, 0._RKC, spec%real%large**2)
773 0 : elseif (spec%method%isParaNest) then
774 0 : spec%domainBallCovMat%def = getMatInit([ndim, ndim], uppLowDia, 0._RKC, 0._RKC, 1._RKC)
775 : end if
776 42 : call setResized(spec%domainBallCovMat%def, [ndim, ndim])
777 42 : call setResized(spec%domainBallCovMat%val, [ndim, ndim])
778 : spec%domainBallCovMat%desc = &
779 : SKC_"The simulation specification `domainBallCovMat` is a positive-definite matrix of type `real` of the highest precision available in the ParaMonte Library &
780 : &of size `(ndim, ndim)` representing the Gramian matrix of the domain of the objective function, where `ndim` is the dimension of the domain. &
781 : &If the user provides this input simulation specification, then any values set for the input simulation &
782 : &specifications `domainBallCorMat` and `domainBallStdVec` will be automatically ignored. When set from inside an external &
783 : &input ParaMonte specification file, any missing element of `domainBallCovMat` will be set to the appropriate default value. &
784 : &To specify an ndim-dimensional spherical domain, set `domainBallCovMat` to the identity matrix whose diagonal elements are &
785 : &radius-squared of the desired hyper-sphere (n-ball). The default value for `domainBallCovMat` is an `ndim`-by-`ndim` Identity matrix &
786 : &for simulations (such as the ParaNest integrator) that require a finite domain and an `ndim`-by-`ndim` diagonal matrix whose diagonals &
787 : &are practically set to infinity for simulations that do not require a finite domain (such as the ParaDRAM and ParaDISE MCMC samplers)."//NL2//&
788 : SKC_"> **Note**: The use of `CovMat` in the name of this simulation specification is theoretically incorrect as the domain &
789 : &of the objective function is not a distribution. Even if it is considered a hyper-ellipsoidal uniform distribution &
790 : &this specification would still not represent its covariance matrix because it represents the Gramian matrix. &
791 : &However, the decision was made to name this specification as `CovMat` because of its nice fit to the rest of &
792 14 : &the relevant simulation specifications and user familiarity with keywords."
793 : !$omp master
794 42 : call setResized(domainBallCovMat, [ndim, ndim])
795 122 : call setNAN(domainBallCovMat)
796 : !$omp end master
797 : end block domainBallCovMat_block
798 :
799 : domainBallStdVec_block: block
800 : use pm_sampling_scio, only: domainBallStdVec
801 14 : if (spec%method%isParaDRAM .or. spec%method%isParaDISE) then
802 14 : spec%domainBallStdVec%def = spec%real%large
803 0 : elseif (spec%method%isParaNest) then
804 0 : spec%domainBallStdVec%def = 1._RKC
805 : end if
806 : spec%domainBallStdVec%desc = &
807 : SKC_"The simulation specification `domainBallStdVec` is a positive-valued vector of type `real` of the highest precision available &
808 : &within the ParaMonte library, of size `ndim`, where `ndim` is the dimension of the domain of the objective function. &
809 : &It represents the square roots of the diagonal elements of the covariance matrix of the domain of the objective function. &
810 : &If the covariance matrix of the ellipsoidal/spherical domain (`domainBallCovMat`) is missing from the input specifications &
811 : &to the sampler, then `domainBallStdVec` (along with the input specification `domainBallCorMat`) will be used to &
812 : &construct the covariance matrix of the domain of the objective function. However, if `domainBallCovMat` is present &
813 : &among the input specifications to the sampler, then the input values for `domainBallStdVec` and `domainBallCorMat` &
814 : &will be ignored and `domainBallCovMat` will be used to construct the domain of the user-specified objective function. &
815 : &To specify an `ndim`-dimensional spherical domain, drop `domainBallCovMat` and `domainBallCorMat` from the input and &
816 : &set all elements of `domainBallStdVec` to the desired radius of the hyper-spherical domain. The default value for &
817 : &any missing elements of `domainBallStdVec` is `1` for simulations requiring a finite domain (such as the ParaNest &
818 14 : &integrator) and `+Infinity` for simulations not requiring a finite domain (such as the ParaDRAM and ParaDISE samplers)."
819 : !$omp master
820 14 : call setResized(domainBallStdVec, ndim)
821 42 : call setNAN(domainBallStdVec)
822 : !$omp end master
823 : end block domainBallStdVec_block
824 :
825 : domainCubeLimitLower_block: block
826 : use pm_sampling_scio, only: domainCubeLimitLower
827 14 : if (spec%method%isParaDRAM .or. spec%method%isParaDISE) then
828 14 : spec%domainCubeLimitLower%def = -spec%real%large
829 0 : elseif (spec%method%isParaNest) then
830 0 : spec%domainCubeLimitLower%def = -1._RKC
831 : end if
832 : spec%domainCubeLimitLower%desc = &
833 : SKC_"The simulation specification `domainCubeLimitLower` is a vector of type `real` of the highest precision available within &
834 : &by the ParaMonte library, of size `ndim` where `ndim` is the number of dimensions of the domain of the target density function. &
835 : &It contains the lower boundaries of the cubical domain of the objective function to be sampled. &
836 : &When `domainCubeLimitLower` is specified inside an external input file supplied to the sampler, &
837 : &it is also possible to assign only select values of `domainCubeLimitLower` &
838 : &and leave the rest of the components to be assigned the default value. &
839 : &For example, having the following inside the input file, "//NL2//&
840 : SKC_"+ `domainCubeLimitLower(3:5) = -100`"//NL2//&
841 : SKC_" will only set the lower limits of the third, fourth, and the fifth dimensions to `-100`, or,"//NL2//&
842 : SKC_"+ `domainCubeLimitLower(1) = -100, domainCubeLimitLower(2) = -1.e6`"//NL2//&
843 : SKC_" will set the lower limit on the first dimension to `-100`, and `1.e6` on the second dimension, or,"//NL2//&
844 : SKC_"+ `domainCubeLimitLower = 3*-2.5e100`"//NL2//&
845 : SKC_" will only set the lower limits on the first, second, and third dimensions to `-2.5*10^100`, while the &
846 : &rest of the lower limits for the missing dimensions will be automatically set to the default value."//NL2//&
847 : SKC_"The default value for all elements of `domainCubeLimitLower` is `"//getStr(spec%domainCubeLimitLower%def)//SKC_"`."//NL1//&
848 14 : SKC_"Beware that some ParaMonte samplers such as ParaNest require the user to explicitly specify the domain boundaries."
849 : !$omp master
850 14 : call setResized(domainCubeLimitLower, ndim)
851 42 : call setNAN(domainCubeLimitLower)
852 : !$omp end master
853 : end block domainCubeLimitLower_block
854 :
855 : domainCubeLimitUpper_block: block
856 : use pm_sampling_scio, only: domainCubeLimitUpper
857 14 : if (spec%method%isParaDRAM .or. spec%method%isParaDISE) then
858 14 : spec%domainCubeLimitUpper%def = +spec%real%large
859 0 : elseif (spec%method%isParaNest) then
860 0 : spec%domainCubeLimitUpper%def = +1._RKC
861 : end if
862 : spec%domainCubeLimitUpper%desc = &
863 : SKC_"The simulation specification `domainCubeLimitUpper` is a vector of type `real` of the highest precision available within &
864 : &by the ParaMonte library, of size `ndim` where `ndim` is the number of dimensions of the domain of the target density function. &
865 : &It contains the upper boundaries of the cubical domain of the objective function to be sampled. &
866 : &When `domainCubeLimitUpper` is specified inside an external input file supplied to the sampler, &
867 : &it is also possible to assign only select values of `domainCubeLimitUpper` &
868 : &and leave the rest of the components to be assigned the default value. &
869 : &For example,"//NL2//&
870 : SKC_"+ `domainCubeLimitUpper(3:5) = 100`"//NL2//&
871 : SKC_" will only set the upper limits of the third, fourth, and the fifth dimensions to 100, or,"//NL2//&
872 : SKC_"+ `domainCubeLimitUpper(1) = 100, domainCubeLimitUpper(2) = 1.e6`"//NL2//&
873 : SKC_" will set the upper limit on the first dimension to `100`, and 1.e6 on the second dimension, or,"//NL2//&
874 : SKC_"+ `domainCubeLimitUpper = 3 * 2.5e100`"//NL2//&
875 : SKC_" will only set the upper limits on the first, second, and third dimensions to `2.5*10^100`, while the &
876 : &rest of the upper limits for the missing dimensions will be automatically set to the default value."//NL2//&
877 : SKC_"The default value for all elements of `domainCubeLimitUpper` is `"//getStr(spec%domainCubeLimitUpper%def)//SKC_"`."//NL1//&
878 14 : SKC_"Beware that some ParaMonte samplers such as ParaNest require the user to specify the domain boundaries explicitly."
879 : !$omp master
880 14 : call setResized(domainCubeLimitUpper, ndim)
881 42 : call setNAN(domainCubeLimitUpper)
882 : !$omp end master
883 : end block domainCubeLimitUpper_block
884 :
885 : domainErrCount_block: block
886 : use pm_sampling_scio, only: domainErrCount
887 14 : spec%domainErrCount%null = -huge(0_IK)
888 14 : spec%domainErrCount%def = 10000_IK
889 : spec%domainErrCount%desc = &
890 : SKC_"The simulation specification `domainErrCount` is a scalar of type `integer` beyond which the user will be warned &
891 : &about the newly proposed points excessively falling outside the domain of the objective function. For every `domainErrCount` &
892 : &consecutively-proposed new points that fall outside the domain of the objective function the user will be warned until &
893 : &`domainErrCount = domainErrCountMax`, in which case the sampler returns a fatal error and the program stops globally. &
894 : &The counter for this warning is reset after a proposal sample from within the domain of the objective function is obtained. &
895 : &When out-of-domain sampling happens frequently, it strongly indicates something fundamentally wrong in the simulation. &
896 : &It is, therefore, important to closely inspect and monitor for frequent out-of-domain samplings. &
897 : &This can be done by setting `domainErrCount` to an appropriate value determined by the user. &
898 14 : &The default value for `domainErrCount` is `"//getStr(spec%domainErrCount%def)//SKC_"`."
899 : !$omp master
900 14 : domainErrCount = spec%domainErrCount%null
901 : !$omp end master
902 : end block domainErrCount_block
903 :
904 : domainErrCountMax_block: block
905 : use pm_sampling_scio, only: domainErrCountMax
906 14 : spec%domainErrCountMax%null = -huge(0_IK)
907 14 : spec%domainErrCountMax%def = 100000_IK
908 : spec%domainErrCountMax%desc = &
909 : SKC_"The simulation specification `domainErrCountMax` is a scalar of type `integer` beyond which the program will stop globally &
910 : &with a fatal error message declaring that the maximum number of proposal-out-of-domain-bounds has reached. &
911 : &The counter for this global-stop request is reset after a proposal is accepted as a sample from within the domain of the objective function. &
912 : &When out-of-domain sampling happens frequently, it strongly indicates something fundamentally wrong in the simulation. &
913 : &It is, therefore, important to closely inspect and monitor for frequent out-of-domain samplings. &
914 : &This can be done by setting `domainErrCountMax` to an appropriate value determined by the user. &
915 14 : &The default value for `domainErrCountMax` is `"//getStr(spec%domainErrCountMax%def)//SKC_"`."
916 : !$omp master
917 14 : domainErrCountMax = spec%domainErrCountMax%null
918 : !$omp end master
919 : end block domainErrCountMax_block
920 :
921 : inputFileHasPriority_block: block
922 : use pm_sampling_scio, only: inputFileHasPriority
923 14 : spec%inputFileHasPriority%def = .false._LK
924 : spec%inputFileHasPriority%desc = &
925 : SKC_"The simulation specification `inputFileHasPriority` is a scalar of type `logical` (Boolean) of default kind. &
926 : &If it is set to the logical true value (e.g., `.true.`, `true` or `.t.` from within an external input file), &
927 : &then, the input specifications of the simulation will be read from the user-specified input specification file &
928 : &and the simulation specification assignments from within the programming language environment (if any are made) &
929 : &will be completely ignored. If `inputFileHasPriority` is set to the logical false value, then all simulation &
930 : &specifications that are taken from the user-specified input file will be overwritten by their corresponding &
931 : &user-set input values from within the user programming environment (if such specifications are set). &
932 : &This feature is useful when, for example, some simulation specifications have to be computed and specified &
933 : &at runtime and, therefore, cannot be specified before the program execution. Currently, this functionality &
934 : &(i.e., prioritizing the input file values to input-procedure-argument values) is available only in the Fortran &
935 : &interface to the ParaMonte library routines. It can be set exclusively within an external input file, and its &
936 : &value is ignored in non-Fortran programming language simulation environments. &
937 14 : &The default value for `inputFileHasPriority` is `"//getStr(spec%inputFileHasPriority%def)//SKC_"`."
938 : !$omp master
939 14 : inputFileHasPriority = spec%inputFileHasPriority%def
940 : !$omp end master
941 : end block inputFileHasPriority_block
942 :
943 : outputChainFileFormat_block: block
944 : use pm_sampling_scio, only: outputChainFileFormat
945 14 : spec%outputChainFileFormat%compact = SKC_"compact"
946 14 : spec%outputChainFileFormat%verbose = SKC_"verbose"
947 14 : spec%outputChainFileFormat%binary = SKC_"binary"
948 14 : spec%outputChainFileFormat%isCompact = .false._LK
949 14 : spec%outputChainFileFormat%isVerbose = .false._LK
950 14 : spec%outputChainFileFormat%isBinary = .false._LK
951 14 : spec%outputChainFileFormat%def = spec%outputChainFileFormat%compact
952 14 : spec%outputChainFileFormat%null = repeat(SUB, len(outputChainFileFormat, IK))
953 : spec%outputChainFileFormat%desc = &
954 : SKC_"The simulation specification `outputChainFileFormat` is a scalar string of maximum length `"//getStr(len(outputChainFileFormat, IK))//SKC_"` characters &
955 : &representing the sampler output chain file(s) format. If specified within an external input file, it must be singly or doubly quoted. &
956 : &Three values are possible:"//NL2//&
957 : SKC_"+ `outputChainFileFormat = 'compact'` or `outputChainFileFormat = 'ascii'`"//NL2//&
958 : SKC_" This is the ASCII (text) file format, which is human-readable but does not preserve the full accuracy of the output values. &
959 : &It is also a significantly slower chain file generation mode than the binary file format (see below). &
960 : &If the compact format is specified, each of the repeating visited states in the simulation will be condensed into a single entry (row) &
961 : &in the output simulation chain file. Each entry will be then assigned a sample weight that is equal to the number of repetitions of &
962 : &that state in the chain. Thus, each row in the output chain file will represent a unique sample from the objective function. &
963 : &This will lead to a significantly smaller ASCII chain file and faster output size than the verbose chain file format (see below)."//NL2//&
964 : SKC_"+ `outputChainFileFormat = 'verbose'`"//NL2//&
965 : SKC_" This is the ASCII (text) file format, which is human-readable but does not preserve the full accuracy of the output values. &
966 : &It is also a significantly slower chain file generation mode compared to compact and binary chain file formats (see above and below). &
967 : &If the verbose format is specified, all visited states will have equal sampling weights of `1` in the output simulation chain file. &
968 : &The verbose format can lead to much larger chain file sizes than the compact and binary file formats. &
969 : &This is especially true if the target objective function has a high-dimensional domain."//NL2//&
970 : SKC_"+ `outputChainFileFormat = '"//spec%outputChainFileFormat%binary//SKC_"'`"//NL2//&
971 : SKC_" This is the binary file format, which is not human-readable but preserves the exact values in the output chain file. &
972 : &It is also often the fastest mode of chain file generation. If the binary file format is chosen, the chain will be &
973 : &automatically output in the compact format (but as binary) to ensure the production of the smallest possible output chain file. &
974 : &Binary chain files will have the "//filext%binary//SKC_" file extensions. Use the binary format if you need full accuracy &
975 : &representation of the output values while having the smallest-size output chain file in the shortest time possible."//NL2//&
976 : SKC_"The default value for `outputChainFileFormat` is `'"//spec%outputChainFileFormat%def//SKC_"'` as it provides a reasonable trade-off &
977 14 : &between speed and output file size for the specified simulation task. The input values are case-INsensitive."
978 : !$omp master
979 14 : outputChainFileFormat = spec%outputChainFileFormat%null
980 : !$omp end master
981 : end block outputChainFileFormat_block
982 :
983 : outputColumnWidth_block: block
984 : use pm_sampling_scio, only: outputColumnWidth
985 14 : spec%outputColumnWidth%null = -huge(0)
986 14 : spec%outputColumnWidth%def = 0_IK
987 : spec%outputColumnWidth%desc = &
988 : SKC_"The simulation specification `outputColumnWidth` is a non-negative scalar of type `integer` that &
989 : &determines the width of the data columns in the formatted tabular files by output the sampler. &
990 : &If it is set to zero, the sampler will ensure to set the width of each output element &
991 : &to the minimum possible width without losing the requested output precision. In other words, &
992 : &setting `outputColumnWidth = 0` will result in the smallest-size for the formatted output files that are in ASCII format. &
993 14 : &The default value for `outputColumnWidth` is `"//getStr(spec%outputColumnWidth%def)//SKC_"`."
994 : !$omp master
995 14 : outputColumnWidth = spec%outputColumnWidth%null
996 : !$omp end master
997 : end block outputColumnWidth_block
998 :
999 : outputFileName_block: block
1000 : use pm_sampling_scio, only: outputFileName
1001 : character(8,SKC):: date
1002 : character(10,SKC):: time
1003 14 : call date_and_time(date,time)
1004 14 : spec%outputFileName%def = method//SKC_"_"//date//SKC_"_"//time(1:6)//SKC_"_"//time(8:10)
1005 : ! Set the default outputFileName to the same on all parallel images.
1006 : #if CAF_ENABLED
1007 : block
1008 : character(63,SKC), save :: co_outputFileNameDef[*]
1009 : if (this_image() == 1) then
1010 : co_outputFileNameDef = spec%outputFileName%def
1011 : sync images(*)
1012 : else
1013 : sync images(1)
1014 : spec%outputFileName%def = trim(adjustl(co_outputFileNameDef[1]))
1015 : end if
1016 : end block
1017 : #elif MPI_ENABLED
1018 : block
1019 : use mpi !mpi_f08, only: mpi_character, mpi_comm_world, mpi_bcast
1020 : integer :: ierrMPI
1021 : character(63) :: co_outputFileNameDef ! This must be the default kind.
1022 : co_outputFileNameDef = spec%outputFileName%def
1023 : ! bcast co_outputFileNameDef from image one to all others.
1024 : call mpi_bcast ( co_outputFileNameDef & ! buffer
1025 : , 63 & ! count
1026 : , mpi_character & ! datatype
1027 : , 0 & ! root
1028 : , mpi_comm_world & ! comm
1029 : , ierrMPI & ! ierr
1030 : )
1031 : spec%outputFileName%def = trim(adjustl(co_outputFileNameDef))
1032 : end block
1033 : !#elif OMP_ENABLED
1034 : ! !$omp master
1035 : ! co_outputFileNameDef = spec%outputFileName%def
1036 : ! !$omp end master
1037 : ! !$omp barrier
1038 : ! spec%outputFileName%def = trim(adjustl(co_outputFileNameDef))
1039 : #endif
1040 14 : spec%outputFileName%null = repeat(SUB, len(outputFileName, IK))
1041 : spec%outputFileName%desc = &
1042 : SKC_"The simulation specification `outputFileName` is a scalar string of maximum length `"//getStr(len(outputFileName, IK))//SKC_"` &
1043 : &containing the path and the base of the filename for the sampler output files. If not provided by the user, &
1044 : &the default `outputFileName` is constructed from the current date and time:"//NL2//&
1045 : SKC_" sampler_yyyymmdd_hhmmss_mmm"//NL2//&
1046 : SKC_"where `sampler` is replaced with the name of the ParaMonte sampler invoked, and `yyyy`, `mm`, `dd`, `hh`, `mm`, `ss`, &
1047 : &and `mmm` are replaced with the current year, month, day, hour, minute, second, and millisecond. &
1048 : &In such a case, the output files' default directory will be the sampler's current working directory. &
1049 : &If `outputFileName` is provided but ends with a separator character '/' or '\' (as in Unix or Windows OS), &
1050 : &then its value will be used as the directory to which the sampler output files will be written. &
1051 : &In this case, the default output file naming convention described above will be used. &
1052 : &The specified directory will be automatically created if it does not exist already. &
1053 : &Note that the specified path is left-adjusted and right-padded, erasing all trailing whitespace characters. &
1054 : &The value of `outputFileName` is always automatically suffixed with `_run<i>_pid<j>_<type>.<ext>` where "//NL2//&
1055 : SKC_"+ `<ext>` is replaced with an appropriate file extension, typically `.txt` or `.bin` depending on the type of the file contents,"//NL2//&
1056 : SKC_"+ `<type>` is replaced with the simulation file type (e.g., `chain`, `report`, `sample`, `restart`, etc),"//NL2//&
1057 : SKC_"+ `<j>` is replaced with the process (image/thread) ID (PID) that generates the current simulation file,"//NL2//&
1058 : SKC_"+ `<i>` is replaced with the simulation run number which depends on the existence of previous simulation files &
1059 14 : &with the same file name prefix and the specified value for the simulation specification `outputStatus`."
1060 : !$omp master
1061 14 : outputFileName = spec%outputFileName%null
1062 : !$omp end master
1063 : end block outputFileName_block
1064 :
1065 : outputPrecision_block: block
1066 : use pm_sampling_scio, only: outputPrecision
1067 14 : spec%outputPrecision%def = nint(modelr%precision * 1.2, IK)
1068 14 : spec%outputPrecision%null = -huge(0_IK)
1069 : spec%outputPrecision%desc = &
1070 : SKC_"The simulation specification `outputPrecision` is a scalar of type `integer` representing the precision &
1071 : &(i.e., the number of significant digits) of the real and complex numbers in the output simulation files. &
1072 : &Any positive integer is acceptable as the input value of `outputPrecision`. However, any digits of the &
1073 : &output real numbers beyond the actual accuracy of floating-point numbers (e.g., ~16 digits of significance for 64-bit `real`) &
1074 : &will be meaningless and random. Set this variable to the precision of the requested floating point precision in the simulation &
1075 : &(or to larger values) if full reproducibility of the simulation is needed in the future. However, keep in mind that higher &
1076 : &precisions result in larger-size output files. This variable is ignored for binary output (if any occurs during the simulation). &
1077 : &The binary output files preserve the full precision of numbers. &
1078 14 : &The default value for `outputPrecision` depends on the `real` precision, e.g., `"//getStr(spec%outputPrecision%def)//SKC_"`."
1079 : !$omp master
1080 14 : outputPrecision = spec%outputPrecision%null
1081 : !$omp end master
1082 : end block outputPrecision_block
1083 :
1084 : outputReportPeriod_block: block
1085 : use pm_sampling_scio, only: outputReportPeriod
1086 14 : spec%outputReportPeriod%null = -huge(0_IK)
1087 14 : spec%outputReportPeriod%def = 1000_IK
1088 : spec%outputReportPeriod%desc = &
1089 : SKC_"The simulation specification `outputReportPeriod` is a positive-valued scalar of type `integer`. &
1090 : &Every `outputReportPeriod` calls to the objective function, the sampling progress will be reported to the progress file. &
1091 14 : &The default value for `outputReportPeriod` is `"//getStr(spec%outputReportPeriod%def)//SKC_"`."
1092 : !$omp master
1093 14 : outputReportPeriod = spec%outputReportPeriod%null
1094 : !$omp end master
1095 : end block outputReportPeriod_block
1096 :
1097 : outputRestartFileFormat_block: block
1098 : use pm_sampling_scio, only: outputRestartFileFormat
1099 14 : spec%outputRestartFileFormat%binary = SKC_"binary"
1100 14 : spec%outputRestartFileFormat%ascii = SKC_"ascii"
1101 14 : spec%outputRestartFileFormat%isBinary = .false._LK
1102 14 : spec%outputRestartFileFormat%isAscii = .false._LK
1103 14 : spec%outputRestartFileFormat%def = spec%outputRestartFileFormat%binary
1104 14 : spec%outputRestartFileFormat%null = repeat(SUB, len(outputRestartFileFormat, IK))
1105 : spec%outputRestartFileFormat%desc = &
1106 : SKC_"The simulation specification `outputRestartFileFormat` is a scalar string of maximum length `"//getStr(len(outputRestartFileFormat, IK))//SKC_"` &
1107 : &representing the output restart file(s) format used to restart an interrupted simulation. &
1108 : &Two values are possible:"//NL2//&
1109 : SKC_"+ `outputRestartFileFormat = '"//spec%outputRestartFileFormat%binary//SKC_"'`"//NL2//&
1110 : SKC_" This is the binary file format which is not human-readable but preserves the exact values of the &
1111 : &specification variables required for the simulation restart. This full accuracy representation is required &
1112 : &to exactly reproduce an interrupted simulation. The binary format is also normally the fastest mode of restart file &
1113 : &generation. Binary restart files will have the `"//filext%binary//SKC_"` file extensions."//NL2//&
1114 : SKC_"+ `outputRestartFileFormat = '"//spec%outputRestartFileFormat%ascii//SKC_"'`"//NL2//&
1115 : SKC_" This is the ASCII (text) file format, which is human-readable but does not preserve the full accuracy of &
1116 : &the specification variables required for the simulation restart. It is also a significantly slower mode of &
1117 : &restart file generation, compared to the binary format. Therefore, its usage should be limited to situations where &
1118 : &the user wants to track the dynamics of simulation specifications throughout the simulation time. &
1119 : &ASCII restart file(s) will have the `"//filext%ascii//SKC_"` file extensions."//NL2//&
1120 : SKC_"The default value for `outputRestartFileFormat` is `'"//spec%outputRestartFileFormat%def//SKC_"'`. &
1121 14 : &Note that the input values are case-INsensitive."
1122 : !$omp master
1123 14 : outputRestartFileFormat = spec%outputRestartFileFormat%null
1124 : !$omp end master
1125 : end block outputRestartFileFormat_block
1126 :
1127 : outputSampleSize_block: block
1128 : use pm_sampling_scio, only: outputSampleSize
1129 14 : spec%outputSampleSize%null = -huge(0_IK)
1130 14 : spec%outputSampleSize%def = -1_IK
1131 : spec%outputSampleSize%desc = &
1132 : SKC_"The simulation specification `outputSampleSize` is a non-zero scalar of type `integer` whose value dictates the number of &
1133 : &(hopefully, independent and identically distributed [i.i.d.]) samples to be drawn from the user-provided objective function.&
1134 : &Three ranges of values are possible. If"//NL2//&
1135 : SKC_"+ `outputSampleSize < 0`,"//NL2//&
1136 : SKC_" then, the absolute value of `outputSampleSize` dictates the sample size in units of the effective sample size. &
1137 : &The effective sample is, by definition, i.i.d., free from duplicates and residual autocorrelation. The &
1138 : &effective sample size is automatically determined by the sampler toward the end of the simulation. &
1139 : &For example:"//NL2//&
1140 : SKC_" + `outputSampleSize = -1` yields the effective i.i.d. sample drawn from the objective function."//NL2//&
1141 : SKC_" + `outputSampleSize = -2` yields a (potentially non-i.i.d.) sample twice as big as the effective sample."//NL2//&
1142 : SKC_"+ `outputSampleSize > 0`,"//NL2//&
1143 : SKC_" then, the sample size is assumed to be in units of the number of points to be sampled. &
1144 : &If outputSampleSize turns out to be less than effectiveSampleSize, the resulting sample will be i.i.d.. &
1145 : &If outputSampleSize turns out to be larger than effectiveSampleSize, the resulting sample will be &
1146 : &potentially non-i.i.d.. The larger this difference, the more non-i.i.d. the resulting &
1147 : &final refined sample will be. For example:"//NL2//&
1148 : SKC_" + `outputSampleSize = 1000` yields a `1000`-points sample from the objective function."//NL2//&
1149 : !SKC_" outputSampleSize = 0,"//NL2//&
1150 : !SKC_" then, no sample file will be generated."//NL2//&
1151 14 : SKC_"The default value for `outputSampleSize` is `"//getStr(spec%outputSampleSize%def)//SKC_"`."
1152 : !$omp master
1153 14 : outputSampleSize = spec%outputSampleSize%null
1154 : !$omp end master
1155 : end block outputSampleSize_block
1156 :
1157 : outputSeparator_block: block
1158 : use pm_sampling_scio, only: outputSeparator
1159 14 : spec%outputSeparator%null = repeat(SUB, len(outputSeparator, IK))
1160 14 : spec%outputSeparator%def = SKC_","
1161 : spec%outputSeparator%desc = &
1162 : SKC_"The simulation specification `outputSeparator` is a scalar string of maximum length `"//getStr(len(outputSeparator, IK))//SKC_"` &
1163 : &containing a sequence of one or more allowed characters used to separate fields within records of tabular contents &
1164 : &in the simulation output files. Digits, the period symbol `'.'`, and the addition and subtraction operators: `'+'` and `'-'`) are not allowed. &
1165 : &To output in Comma-Separated-Values (CSV) format, set `outputSeparator = ','`. If the input value is not provided, &
1166 : &the default separator `'"//spec%outputSeparator%def//SKC_"'` will be used when input `outputColumnWidth = 0`, and a single &
1167 : &space character, '"//spec%outputSeparator%def//SKC_"' will be used when input `outputColumnWidth > 0`. &
1168 : &A value of `'\t'` is interpreted as the TAB character. To avoid this interpretation, &
1169 : &use '\\\t' to yield '\t' without being interpreted as the TAB character. &
1170 14 : &The default value for `outputSeparator` is `'"//spec%outputSeparator%def//SKC_"'`."
1171 : !$omp master
1172 14 : outputSeparator = spec%outputSeparator%null
1173 : !$omp end master
1174 : end block outputSeparator_block
1175 :
1176 : outputSplashMode_block: block
1177 : use pm_sampling_scio, only: outputSplashMode
1178 14 : spec%outputSplashMode%null = repeat(SUB, len(outputSplashMode, IK))
1179 : if (envis%c .or. envis%cpp .or. envis%fortran) then
1180 14 : spec%outputSplashMode%def = spec%outputSplashMode%normal
1181 : else
1182 : spec%outputSplashMode%def = spec%outputSplashMode%quiet
1183 : end if
1184 : spec%outputSplashMode%desc = &
1185 : SKC_"The simulation specification `outputSplashMode` is a scalar string of maximum length `"//getStr(len(spec%outputSplashMode%null, IK))//SKC_"` &
1186 : &representing the level of information output on screen while running or postprocessing the simulation. &
1187 : &Three values are possible:"//NL2//&
1188 : SKC_"+ `outputSplashMode = '"//spec%outputSplashMode%normal//SKC_"'`"//NL2//&
1189 : SKC_" Under this option, the simulation splash and progress bar will be shown on screen as well as all post-processing details. &
1190 : &This is the default behavior in compiled language environments (e.g., C, C++, Fortran, ...)."//NL2//&
1191 : SKC_"+ `outputSplashMode = '"//spec%outputSplashMode%quiet//SKC_"'`"//NL2//&
1192 : SKC_" Under this option, the splash screen will be hidden from the standard output but other information will be displayed as usual. &
1193 : &This is the default behavior in dynamic language environments (e.g., MATLAB, Python, R, ...)."//NL2//&
1194 : SKC_"+ `outputSplashMode = '"//spec%outputSplashMode%silent//SKC_"'`"//NL2//&
1195 : SKC_" Under this option, no information about the simulation will be shown on screen. &
1196 : &Use this option if the simulations are expected to be short and straightforward &
1197 : &or there is a limit on the amount of text allowed for display in standard output. &
1198 : &This situation happens, for example, in online code coverage and CI platforms."//NL2//&
1199 : SKC_"The default value for `outputSplashMode` is `'normal'` in compiled programming language environments &
1200 14 : &and `'quiet'` in dynamic programming language environments. Note that the input values are case-INsensitive."
1201 : !$omp master
1202 14 : outputSplashMode = spec%outputSplashMode%null
1203 : !$omp end master
1204 : end block outputSplashMode_block
1205 :
1206 : outputStatus_block: block
1207 : use pm_sampling_scio, only: outputStatus
1208 14 : spec%outputStatus%is%extend = .false._LK
1209 14 : spec%outputStatus%is%repeat = .false._LK
1210 14 : spec%outputStatus%is%retry = .false._LK
1211 14 : spec%outputStatus%def = SKC_"extend"
1212 14 : spec%outputStatus%null = repeat(SUB, len(outputStatus, IK))
1213 : spec%outputStatus%desc = &
1214 : SKC_"The simulation specification `outputStatus` is a scalar string of maximum `"//getStr(len(outputStatus, IK))//SKC_"` characters, &
1215 : &whose value describes the protocol for dealing with and handling the simulation output files concerning potentially existing past simulations. &
1216 : &The string value must be enclosed by single or double quotation marks when provided as input in an external input file. &
1217 : &Three values are possible:"//NL2//&
1218 : SKC_"+ `outputStatus = 'extend'`"//NL2//&
1219 : SKC_" This is the default behavior where the sampler will search for any prior simulation output files &
1220 : &with the same user-specified file name prefix in the working directory to restart the simulation. &
1221 : &If an old interrupted set of simulation output files exists in the working directory, &
1222 : &the sampler will attempt to restart the simulation from the last recorded simulation state. &
1223 : &The restart operation may fail if the user has modified or tampered with the old simulation output files. &
1224 : &If prior simulation files exist and represent a complete simulation, &
1225 : &a new simulation run will be performed with a new set of output files starting from the last successful run. &
1226 : &The parameters of the new simulation are initialized based on the output of the most recent successful simulation. &
1227 : &For MCMC type of simulations, this means starting from the last sampled point in the output sample file of the previous &
1228 : &simulation and using an initial proposal covariance matrix constructed from the output sample of the previous simulation. &
1229 : &A new simulation will start if the sampler does not find any prior simulations with the same output file names. &
1230 : &This default behavior allows seamless restart functionality while ensuring old potentially valuable computationally &
1231 : &expensive simulations are not inadvertently erased and replaced by the new simulation output files."//NL2//&
1232 : SKC_"+ `outputStatus = 'repeat'`"//NL2//&
1233 : SKC_" This option is nearly identical to 'extend' except for the fact that the new simulation specifications &
1234 : &are not initialized from the specifications of the last successful simulation run (if any exists). &
1235 : &Instead, a new set of simulation files will be generated as if the last simulation run is replicated. &
1236 : &If the simulation configuration has not changed since the last successful simulation run, then the new simulation &
1237 : &output sample, chain, and restart files will be identical to those of the last successful simulation. &
1238 : &This outputting is primarily useful for cross-platform or cross-compiler testing and development."//NL2//&
1239 : SKC_"+ `outputStatus = 'retry'`"//NL2//&
1240 : SKC_" This option is nearly identical to 'repeat' except for the fact that the new simulation starts afresh and overwrites &
1241 : &any potentially existing output files from the most recent simulation with the same names without ever using them. &
1242 : &There is no restart functionality with this option. The most recent simulation files are deleted regardless of &
1243 : &completion status. This option is effectively equivalent to deleting the set of output files from the last simulation &
1244 : &run and rerunning the simulation with the default value 'extend' for the specification `outputStatus`. &
1245 : &Use this option for quick tests or small exploratory problems where lots of quick runs must be performed."//NL2//&
1246 14 : SKC_"The default value for `outputStatus` is `'"//spec%outputStatus%def//SKC_"'`. The input values are case-INsensitive."
1247 : !$omp master
1248 14 : outputStatus = spec%outputStatus%null
1249 : !$omp end master
1250 : end block outputStatus_block
1251 : !SKC_" outputStatus = 'copy-extend'"//NL2//&
1252 : !SKC_" This option is nearly identical to the default behavior 'extend' except for the fact that the most &
1253 : ! &recent existing simulation output are copied into the new simulation file before starting the new simulation. &
1254 : ! &If no simulation exists, the sampler will start a new simulation as in the default behavior 'extend'. &
1255 : ! &If the most recent existing simulation is incomplete, the sampler will &
1256 : ! &complete the interrupted simulation as in the default behavior 'extend'. &
1257 : ! &Unlike 'extend', however, if the sampler detects any old completed simulation files, it will duplicate &
1258 : ! &the most recent existing simulation under new unique output file names for the new simulation run. &
1259 : ! &Then the sampler will use the last simulation state from the duplicated simulation &
1260 : ! &to extend the most recently completed simulation with a brand new simulation. &
1261 : ! &By convention, the sampler suffixes the user-specified `outputFileName` value for extensible &
1262 : ! &simulations with `_run<i>` where `<i>` is replaced by the simulation extension attempt number. &
1263 : ! &The 'extend' behavior is particularly useful for situations where the lack of convergence requires &
1264 : ! &the new simulation to be extended from the last state and with the updated parameters of an older simulation. &
1265 : ! &Successful extension of a series of simulations requires specifying `outputStatus = 'extend'` &
1266 : ! &from the first (unextended) simulation to the last (extended) simulation. &
1267 : ! &Beware that the repeated copy-extension of a simulation will lead to increasingly larger simulation output files, &
1268 : ! &because each new simulation copies the entire past efforts into the new simulation files. &
1269 : ! &This option has been added upon request by the GitHub user: https://github.com/Peku995"//NL2//&
1270 : !SKC_" outputStatus = 'copy-retry'"//NL2//&
1271 : !SKC_" This option is nearly identical to 'copy-extend' except for the fact that the most recent files are first &
1272 : ! &deleted and the new simulation starts as if 'copy-extend' has been specified as the value of `outputStatus`."//NL2//&
1273 :
1274 : parallelism_block: block
1275 : use pm_sampling_scio, only: parallelism
1276 14 : spec%parallelism%is%multiChain = .false._LK
1277 14 : spec%parallelism%is%singleChain = .false._LK
1278 14 : spec%parallelism%singleChain = "singleChain"
1279 14 : spec%parallelism%multiChain = "multiChain"
1280 14 : spec%parallelism%def = spec%parallelism%singleChain
1281 14 : spec%parallelism%null = repeat(SUB, len(parallelism, IK))
1282 : spec%parallelism%desc = &
1283 : SKC_"The simulation specification `parallelism` is a scalar string of maximum length `"//getStr(len(spec%parallelism%null, IK))//SKC_"` &
1284 : &that represents the parallelization method to be used in the simulation. &
1285 : &The string value must be enclosed by single or double quotation marks when provided in an external input file. &
1286 : &Two options are currently supported:"//NL2//&
1287 : SKC_"+ `parallelism = '"//spec%parallelism%multiChain//SKC_"'`"//NL2//&
1288 : SKC_" This method uses the Prefect Parallelism scheme in which multiple MCMC chains are generated &
1289 : &independently of each other. In this case, multiple output MCMC chain files will also be generated. &
1290 : &The Perfect parallelism is available only in Coarray/MPI-enabled parallel simulations (not in OpenMP or other shared-memory). &
1291 : &However, it can be readily emulated by running multiple independent simulations concurrently in any programming environment."//NL2//&
1292 : SKC_"+ `parallelism = '"//spec%parallelism%singleChain//SKC_"'`"//NL2//&
1293 : SKC_" This method uses the fork-style parallelization scheme. In this case, a single MCMC chain file will be generated. &
1294 : &At each MCMC step, multiple proposal steps will be checked in parallel until one proposal is accepted. &
1295 : &This is the default for all parallelism paradigms supported by the ParaMonte library and the only option for shared memory parallelism."//NL2//&
1296 : SKC_"Note that in serial mode, there is no parallelism. Therefore, this option does not affect non-parallel simulations and ignores its value. &
1297 : &The serial mode is equivalent to either of the parallelism methods with only one simulation image (processor, core, or thread). &
1298 : &The default value for `parallelism` is `'"//spec%parallelism%def//SKC_"'`. &
1299 14 : &Note that the input values are case-INsensitive and whitespace characters are ignored."
1300 : !$omp master
1301 14 : parallelism = spec%parallelism%null
1302 : !$omp end master
1303 : end block parallelism_block
1304 :
1305 : parallelismMpiFinalizeEnabled_block: block
1306 : use pm_sampling_scio, only: parallelismMpiFinalizeEnabled
1307 14 : spec%parallelismMpiFinalizeEnabled%def = .true._LK
1308 : spec%parallelismMpiFinalizeEnabled%desc = &
1309 : SKC_"The simulation specification `parallelismMpiFinalizeEnabled` is a scalar of type `logical` (Boolean). &
1310 : &In MPI parallel simulations, if `parallelismMpiFinalizeEnabled` is set to the logical/Boolean true value, &
1311 : &then a call will be made to the `MPI_Finalize()` routine from inside the ParaMonte routine at the end of the &
1312 : &simulation to finalize the MPI communications. Set this variable to the logical/Boolean if you do not want the &
1313 : &ParaMonte library to finalize the MPI communications for you. When this specification is set within an external input file, &
1314 : &the values `F`, `False`, `false`, `FALSE`, and `.false.` all represent the logical true value and &
1315 : &the values `T`, `True`, `true`, `TRUE`, and `.true.` all represent the logical true value. &
1316 : &This is a low-level simulation specification variable relevant to MPI parallelism simulations. &
1317 : &If you do not use MPI-routine calls in your main program, you can safely ignore this variable with its default value. &
1318 : &If you intend the ParaMonte samplers or other MPI-enabled ParaMonte routines repeatedly in one run &
1319 : &then you will have to `parallelismMpiFinalizeEnabled` to the logical `false` value to prevent early finalization of the MPI-library. &
1320 : &Note that in non-MPI-enabled simulations, such as serial and Coarray-enabled simulations, &
1321 14 : &the value of this variable is completely ignored. The default value for `parallelismMpiFinalizeEnabled` is `"//getStr(spec%parallelismMpiFinalizeEnabled%def)//SKC_"`."
1322 : !$omp master
1323 14 : parallelismMpiFinalizeEnabled = spec%parallelismMpiFinalizeEnabled%def
1324 : !$omp end master
1325 : end block parallelismMpiFinalizeEnabled_block
1326 :
1327 : parallelismNumThread_block: block
1328 : use pm_sampling_scio, only: parallelismNumThread
1329 14 : spec%parallelismNumThread%null = -huge(spec%parallelismNumThread%null)
1330 14 : spec%parallelismNumThread%def = 0_IK
1331 : spec%parallelismNumThread%desc = &
1332 : SKC_"The simulation specification `parallelismNumThread` is a non-negative scalar of type `integer` of kind 32-bit, &
1333 : &representing the number of parallel user-specified objective function evaluations in a Fork-Join shared-memory parallelism. &
1334 : &Such parallelism paradigms include OpenMP-enabled shared-memory parallel simulations in C, C++, and Fortran or shared-memory &
1335 : &simulations in higher-level programming language environments such as MATLAB, Python, and R. &
1336 : &This specification is currently relevant to only OpenMP-enabled parallel ParaMonte library builds or in the context of dynamic &
1337 : &interpreted programming languages such as those mentioned above. As such, its value or presence is ignored in serial simulations &
1338 : &or Coarray/MPI -enabled parallel simulations. Specifying `0` leads to using all available CPU threads for the requested simulation. &
1339 : &The default value for `parallelismNumThread` is `0`, which implies using the maximum number of available threads in concurrent or &
1340 14 : &OpenMP-enabled builds of the ParaMonte library."
1341 : !$omp master
1342 14 : parallelismNumThread = spec%parallelismNumThread%null
1343 : !$omp end master
1344 : end block parallelismNumThread_block
1345 :
1346 : !plang_block: block
1347 : ! use pm_sampling_scio, only: plang
1348 : ! spec%plang%null = repeat(SUB, len(plang, IK))
1349 : ! spec%plang%def = envname
1350 : ! spec%plang%desc = &
1351 : ! SKC_"The simulation specification `plang` is a scalar string of maximum length `"//getStr(spec%plang%null)//&
1352 : ! SKC_"`. It is an internal ParaMonte variable used to provide information about other languages interface with the ParaMonte routines."
1353 : ! !$omp master
1354 : ! plang = spec%plang%null
1355 : ! !$omp end master
1356 : !end block plang_block
1357 :
1358 : randomSeed_block: block
1359 : use pm_sampling_scio, only: randomSeed
1360 14 : spec%randomSeed%null = -huge(0_IK)
1361 : spec%randomSeed%desc = &
1362 : SKC_"The simulation specification `randomSeed` is a positive scalar of type `integer` of kind 32-bit &
1363 : &whose value serves as the seed of the random number generator. When specified by the user, &
1364 : &the seed of the simulation random number generator will be set in a specific deterministic manner to enable future &
1365 : &replications of the simulation with the same configuration and input specifications. The default for `randomSeed` &
1366 : &is a processor-dependent random value to ensure complete simulation randomness at every run. &
1367 : &In parallel simulations, the seed, whether default or user-specified, is uniquely set on &
1368 14 : &all processors, threads, cores, or images in all circumstances to ensure simulation randomness."
1369 : !$omp master
1370 14 : randomSeed = spec%randomSeed%null
1371 : !$omp end master
1372 : end block randomSeed_block
1373 :
1374 : sysInfoFilePath_block: block
1375 : use pm_dateTime, only: getDateTime
1376 : use pm_sampling_scio, only: sysInfoFilePath
1377 : character(8,SKC) :: date
1378 14 : call date_and_time(date)
1379 14 : spec%sysInfoFilePath%def = SKC_".sysinfo."//getDateTime(format = SKC_"%Y%m")//SKC_".cache"
1380 14 : spec%sysInfoFilePath%null = repeat(SUB, len(sysInfoFilePath, IK))
1381 : !$omp master
1382 14 : sysInfoFilePath = spec%sysInfoFilePath%null
1383 : !$omp end master
1384 : end block sysInfoFilePath_block
1385 :
1386 : targetAcceptanceRate_block: block
1387 : use pm_sampling_scio, only: targetAcceptanceRate
1388 14 : spec%targetAcceptanceRate%enabled = .false._LK
1389 42 : spec%targetAcceptanceRate%def = [0._RKC, 1._RKC]
1390 : spec%targetAcceptanceRate%desc = &
1391 : SKC_"The simulation specification `targetAcceptanceRate` is a vector of type `real` of size `2` of the highest precision &
1392 : &available within the ParaMonte library whose values (in the range `[0, 1]`) determine the optimal target range for the &
1393 : &simulation efficiency, defined as the ratio of the number of accepted objective function calls to the total number of &
1394 : &function calls made through the simulation. The first and the second elements of `targetAcceptanceRate` determine the &
1395 : &lower and upper bounds of the desired acceptance rate, respectively. When the acceptance rate of the sampler is outside the &
1396 : &specified limits, the simulation settings will be automatically adjusted to bring the overall acceptance rate to within the &
1397 : &user-specified limits given by `targetAcceptanceRate`. When assigned from within a dynamic-language programming environment &
1398 : &(such as MATLAB, Python, or R) or from within an input file, `targetAcceptanceRate` can also be a scalar real number in the &
1399 : &range `[0, 1]`. In such a case, the sampler will constantly attempt (albeit with no guarantee of success) to bring the average &
1400 : &acceptance ratio of the sampler as close to the user-provided target ratio as possible. Specifically, the success of the adaptive &
1401 : &MCMC samplers (e.g., ParaDRAM) in keeping the average acceptance ratio close to the requested target value depends heavily on:"//NL2//&
1402 : SKC_"+ the specified value of `proposalAdaptationPeriod`; the larger, the easier."//NL1//&
1403 : SKC_"+ the specified value of `proposalAdaptationCount`; the larger, the easier."//NL2//&
1404 : SKC_"Note that the acceptance ratio adjustments will only occur every `proposalAdaptationPeriod` &
1405 : &sampling steps for a total number of `proposalAdaptationCount` in adaptive MCMC samplings. &
1406 14 : &The default value for `targetAcceptanceRate` is the range `[0, 1]`."
1407 : !$omp master
1408 42 : call setNAN(targetAcceptanceRate)
1409 : !$omp end master
1410 : end block targetAcceptanceRate_block
1411 :
1412 : !$omp barrier
1413 :
1414 70 : end function construct
1415 :
1416 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1417 :
1418 13 : function set(spec, sampler) result(err)
1419 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
1420 : !DEC$ ATTRIBUTES DLLEXPORT :: set
1421 : #endif
1422 : use pm_err, only: err_type
1423 : use pm_sampling, only: sampler_type
1424 : use pm_paramonte, only: getParaMonteSplash
1425 : class(specbase_type), intent(inout) :: spec
1426 : class(sampler_type), intent(in), optional :: sampler
1427 : type(err_type) :: err
1428 :
1429 : integer(IK), parameter :: PROGRESS_BAR_WIDTH = 85_IK
1430 :
1431 : err%occurred = .false._LK
1432 13 : err%msg = SKC_""
1433 :
1434 : ! Setup the splash screen.
1435 :
1436 13 : if (spec%image%is%first) then
1437 : ! These messages are to be displayed only if outputSplashMode is set to normal.
1438 13 : spec%msg = SKC_"Setting up the "//envname//SKC_" environment for a "//spec%method%val//SKC_" simulation..."
1439 13 : if (allocated(sampler%inputFile)) then
1440 : block
1441 : logical :: exist; integer :: iostat; exist = .false.
1442 : ! The following test is necessary since Intel compiler `inquire()`
1443 : ! implementation fails with larger than maximum file path length.
1444 3 : exist = len(sampler%inputFile, IK) <= MAX_LEN_FILE_PATH
1445 3 : if (exist) then
1446 3 : inquire(file = sampler%inputFile, exist = exist, iostat = iostat)
1447 4 : exist = exist .and. iostat == 0
1448 : end if
1449 3 : if (exist) then
1450 : spec%msg = spec%msg//NL2//SKC_"The user-specified input file for "//spec%method%val//SKC_" specifications detected."//NL1& ! LCOV_EXCL_LINE
1451 2 : //SKC_"All "//spec%method%val//SKC_" simulation specifications will be read from:"//NL1//SKC_""""//sampler%inputFile//SKC_""""
1452 : else
1453 : spec%msg = spec%msg//NL2//SKC_"The user-specified internal input file for "//spec%method%val//SKC_" specifications detected."//NL1& ! LCOV_EXCL_LINE
1454 1 : //SKC_"All "//spec%method%val//SKC_" simulation specifications will be read from the specified internal namelist file..."
1455 : end if
1456 : end block
1457 : else
1458 : spec%msg = spec%msg//NL2//SKC_"No user-specified input file for the "//spec%method%val//SKC_" simulation specifications detected."//NL1& ! LCOV_EXCL_LINE
1459 10 : //SKC_"The sampler will use the default simulation settings where needed."
1460 : end if
1461 : end if
1462 :
1463 : ! Read the namelist from the `inputFile`.
1464 :
1465 13 : if (allocated(sampler%inputFile)) then
1466 : block
1467 : use pm_parallelism, only: isFailedImage
1468 : use pm_sampling_scio, only: setSpecFromInput
1469 : !$omp master
1470 3 : call setSpecFromInput(spec%method%val, sampler%inputFile, err)
1471 : !$omp end master
1472 3 : if (isFailedImage(err%occurred)) then
1473 0 : if (spec%image%is%first) then
1474 0 : call spec%disp%show(getParaMonteSplash(width = max(PROGRESS_BAR_WIDTH, spec%disp%width)))
1475 0 : call spec%disp%note%show(spec%msg)
1476 : end if
1477 0 : return
1478 : end if
1479 : !$omp barrier
1480 : end block
1481 : end if
1482 :
1483 : block
1484 : use pm_sampling_scio, only: inputFileHasPriority
1485 13 : spec%overridable = .not. inputFileHasPriority
1486 : end block
1487 :
1488 : description_block: block
1489 : use pm_sampling_scio, only: description
1490 : use pm_strASCII, only: getAsciiFromEscaped
1491 13 : if (spec%overridable .and. allocated(sampler%description)) then
1492 0 : spec%description%val = getAsciiFromEscaped(trim(adjustl(sampler%description)))
1493 : else
1494 13 : spec%description%val = getAsciiFromEscaped(trim(adjustl(description)))
1495 : end if
1496 13 : if (spec%description%val == trim(adjustl(spec%description%null))) spec%description%val = trim(adjustl(spec%description%def))
1497 : end block description_block
1498 :
1499 : domain_block: block
1500 : use pm_sampling_scio, only: domain
1501 13 : if (spec%overridable .and. allocated(sampler%domain)) then
1502 0 : spec%domain%val = getStrLower(trim(adjustl(sampler%domain)))
1503 : else
1504 13 : spec%domain%val = getStrLower(trim(adjustl(domain)))
1505 : end if
1506 13 : if (spec%domain%val == spec%domain%null) spec%domain%val = spec%domain%def
1507 13 : spec%domain%isBall = spec%domain%val == spec%domain%ball .or. spec%domain%val == SKC_"ball"
1508 13 : spec%domain%isCube = spec%domain%val == spec%domain%cube
1509 : end block domain_block
1510 :
1511 : domainAxisName_block: block
1512 : use pm_sampling_scio, only: domainAxisName
1513 : integer(IK) :: idim
1514 13 : if (spec%overridable .and. allocated(sampler%domainAxisName)) then
1515 35 : spec%domainAxisName%val = sampler%domainAxisName
1516 : else
1517 38 : spec%domainAxisName%val = spec%domainAxisName%def
1518 : end if
1519 13 : do concurrent(idim = 1 : size(spec%domainAxisName%val, 1, IK))
1520 40 : if (trim(adjustl(domainAxisName(idim))) /= trim(adjustl(spec%domainAxisName%null))) spec%domainAxisName%val(idim) = domainAxisName(idim)
1521 : end do
1522 : end block domainAxisName_block
1523 :
1524 : domainBallCenter_block: block
1525 : use pm_sampling_scio, only: domainBallCenter
1526 13 : if (spec%overridable .and. allocated(sampler%domainBallCenter)) then
1527 0 : spec%domainBallCenter%val = real(sampler%domainBallCenter, RKC)
1528 : else
1529 66 : spec%domainBallCenter%val = domainBallCenter
1530 : end if
1531 40 : where (isNAN(spec%domainBallCenter%val))
1532 : spec%domainBallCenter%val = spec%domainBallCenter%def
1533 : end where
1534 : end block domainBallCenter_block
1535 :
1536 : domainBallCorMat_block: block
1537 : use pm_sampling_scio, only: domainBallCorMat
1538 : integer(IK) :: idim, jdim
1539 13 : if (spec%overridable .and. allocated(sampler%domainBallCorMat)) then
1540 0 : spec%domainBallCorMat%val = real(sampler%domainBallCorMat, RKC)
1541 : else
1542 158 : spec%domainBallCorMat%val = domainBallCorMat
1543 : end if
1544 40 : do jdim = 1, spec%ndim%val
1545 119 : do idim = 1, spec%ndim%val
1546 106 : if (isNAN(spec%domainBallCorMat%val(idim, jdim))) then
1547 59 : spec%domainBallCorMat%val(idim, jdim) = spec%domainBallCorMat%def(idim, jdim)
1548 : else
1549 20 : spec%domain%isFinite = .true._LK
1550 : end if
1551 : end do
1552 : end do
1553 : end block domainBallCorMat_block
1554 :
1555 : domainBallCovMat_block: block
1556 : use pm_sampling_scio, only: domainBallCovMat
1557 : integer(IK) :: idim, jdim
1558 13 : if (spec%overridable .and. allocated(sampler%domainBallCovMat)) then
1559 0 : spec%domainBallCovMat%val = real(sampler%domainBallCovMat, RKC)
1560 : else
1561 132 : spec%domainBallCovMat%val = domainBallCovMat
1562 : end if
1563 40 : do jdim = 1, spec%ndim%val
1564 119 : do idim = 1, spec%ndim%val
1565 106 : if (isNAN(spec%domainBallCovMat%val(idim, jdim))) then
1566 59 : spec%domainBallCovMat%val(idim, jdim) = spec%domainBallCovMat%def(idim, jdim)
1567 : else
1568 20 : spec%domainBallCovMat%isUserSet = .true._LK
1569 : end if
1570 : end do
1571 : end do
1572 13 : spec%domain%isFinite = spec%domain%isFinite .or. spec%domainBallCovMat%isUserSet
1573 : end block domainBallCovMat_block
1574 :
1575 : domainBallStdVec_block: block
1576 : use pm_sampling_scio, only: domainBallStdVec
1577 : integer(IK) :: idim
1578 13 : if (spec%overridable .and. allocated(sampler%domainBallStdVec)) then
1579 0 : spec%domainBallStdVec%val = real(sampler%domainBallStdVec, RKC)
1580 : else
1581 66 : spec%domainBallStdVec%val = domainBallStdVec
1582 : end if
1583 40 : do idim = 1, spec%ndim%val
1584 40 : if (isNAN(spec%domainBallStdVec%val(idim)) .or. isInf(spec%domainBallStdVec%val(idim))) then
1585 21 : spec%domainBallStdVec%val(idim) = spec%domainBallStdVec%def
1586 : else
1587 6 : spec%domain%isFinite = .true._LK
1588 : end if
1589 : end do
1590 : end block domainBallStdVec_block
1591 :
1592 : domainCubeLimitLower_block: block
1593 : use pm_sampling_scio, only: domainCubeLimitLower
1594 : integer(IK) :: idim
1595 13 : if (spec%overridable .and. allocated(sampler%domainCubeLimitLower)) then
1596 21 : spec%domainCubeLimitLower%val = real(sampler%domainCubeLimitLower, RKC)
1597 : else
1598 38 : spec%domainCubeLimitLower%val = domainCubeLimitLower
1599 : end if
1600 40 : do idim = 1, spec%ndim%val
1601 40 : if (isNAN(spec%domainCubeLimitLower%val(idim)) .or. isInf(spec%domainCubeLimitLower%val(idim))) then
1602 14 : spec%domainCubeLimitLower%val(idim) = spec%domainCubeLimitLower%def
1603 : else
1604 13 : spec%domain%isFinite = .true._LK
1605 : end if
1606 : end do
1607 : end block domainCubeLimitLower_block
1608 :
1609 : domainCubeLimitUpper_block: block
1610 : use pm_sampling_scio, only: domainCubeLimitUpper
1611 : integer(IK) :: idim
1612 13 : if (spec%overridable .and. allocated(sampler%domainCubeLimitUpper)) then
1613 0 : spec%domainCubeLimitUpper%val = real(sampler%domainCubeLimitUpper, RKC)
1614 : else
1615 66 : spec%domainCubeLimitUpper%val = domainCubeLimitUpper
1616 : end if
1617 40 : do idim = 1, spec%ndim%val
1618 40 : if (isNAN(spec%domainCubeLimitUpper%val(idim)) .or. isInf(spec%domainCubeLimitUpper%val(idim))) then
1619 21 : spec%domainCubeLimitUpper%val(idim) = spec%domainCubeLimitUpper%def
1620 : else
1621 6 : spec%domain%isFinite = .true._LK
1622 : end if
1623 : end do
1624 : end block domainCubeLimitUpper_block
1625 :
1626 : domainErrCount_block: block
1627 : use pm_sampling_scio, only: domainErrCount
1628 13 : if (spec%overridable .and. allocated(sampler%domainErrCount)) then
1629 0 : spec%domainErrCount%val = sampler%domainErrCount
1630 : else
1631 13 : spec%domainErrCount%val = domainErrCount
1632 : end if
1633 13 : if (spec%domainErrCount%val == spec%domainErrCount%null) spec%domainErrCount%val = spec%domainErrCount%def
1634 13 : spec%domainErrCount%str = getStr(spec%domainErrCount%val)
1635 : end block domainErrCount_block
1636 :
1637 : domainErrCountMax_block: block
1638 : use pm_sampling_scio, only: domainErrCountMax
1639 13 : if (spec%overridable .and. allocated(sampler%domainErrCountMax)) then
1640 0 : spec%domainErrCountMax%val = sampler%domainErrCountMax
1641 : else
1642 13 : spec%domainErrCountMax%val = domainErrCountMax
1643 : end if
1644 13 : if (spec%domainErrCountMax%val == spec%domainErrCountMax%null) spec%domainErrCountMax%val = spec%domainErrCountMax%def
1645 13 : spec%domainErrCountMax%str = getStr(spec%domainErrCountMax%val)
1646 : end block domainErrCountMax_block
1647 :
1648 : inputFileHasPriority_block: block
1649 : use pm_sampling_scio, only: inputFileHasPriority
1650 : !if (spec%overridable .and. allocated(sampler%inputFileHasPriority)) then
1651 : ! spec%inputFileHasPriority%val = sampler%inputFileHasPriority
1652 : !else
1653 13 : spec%inputFileHasPriority%val = inputFileHasPriority
1654 : !end if
1655 : end block inputFileHasPriority_block
1656 :
1657 13 : outputChainFileFormat_block: block
1658 : use pm_sampling_scio, only: outputChainFileFormat
1659 : character(:,SKC), allocatable :: lowerCaseVal
1660 13 : if (spec%overridable .and. allocated(sampler%outputChainFileFormat)) then
1661 0 : spec%outputChainFileFormat%val = trim(adjustl(sampler%outputChainFileFormat))
1662 : else
1663 13 : spec%outputChainFileFormat%val = trim(adjustl(outputChainFileFormat))
1664 : end if
1665 13 : if (spec%outputChainFileFormat%val == trim(adjustl(spec%outputChainFileFormat%null))) spec%outputChainFileFormat%val = trim(adjustl(spec%outputChainFileFormat%def))
1666 13 : lowerCaseVal = getStrLower(spec%outputChainFileFormat%val)
1667 13 : spec%outputChainFileFormat%iscompact = lowerCaseVal == getStrLower(spec%outputChainFileFormat%compact) .or. lowerCaseVal == getStrLower(SKC_"ascii")
1668 13 : spec%outputChainFileFormat%isverbose = lowerCaseVal == getStrLower(spec%outputChainFileFormat%verbose)
1669 26 : spec%outputChainFileFormat%isBinary = lowerCaseVal == getStrLower(spec%outputChainFileFormat%binary)
1670 : end block outputChainFileFormat_block
1671 :
1672 : outputColumnWidth_block: block
1673 : use pm_sampling_scio, only: outputColumnWidth
1674 13 : if (spec%overridable .and. allocated(sampler%outputColumnWidth)) then
1675 0 : spec%outputColumnWidth%val = sampler%outputColumnWidth
1676 : else
1677 13 : spec%outputColumnWidth%val = outputColumnWidth
1678 : end if
1679 13 : if (spec%outputColumnWidth%val == spec%outputColumnWidth%null) spec%outputColumnWidth%val = spec%outputColumnWidth%def
1680 13 : spec%outputColumnWidth%str = getStr(spec%outputColumnWidth%val)
1681 : end block outputColumnWidth_block
1682 :
1683 : outputFileName_block: block
1684 : use pm_sampling_scio, only: outputFileName
1685 13 : if (spec%overridable .and. allocated(sampler%outputFileName)) then
1686 10 : spec%outputFileName%val = trim(adjustl(sampler%outputFileName))
1687 : else
1688 3 : spec%outputFileName%val = trim(adjustl(outputFileName))
1689 : end if
1690 13 : if (spec%outputFileName%val == trim(adjustl(spec%outputFileName%null))) spec%outputFileName%val = spec%outputFileName%def
1691 : end block outputFileName_block
1692 :
1693 13 : outputStatus_block: block
1694 : use pm_sampling_scio, only: outputStatus
1695 : character(:,SKC), allocatable :: lowerCaseVal
1696 13 : if (spec%overridable .and. allocated(sampler%outputStatus)) then
1697 8 : spec%outputStatus%val = trim(adjustl(sampler%outputStatus))
1698 : else
1699 5 : spec%outputStatus%val = trim(adjustl(outputStatus))
1700 : end if
1701 13 : if (spec%outputStatus%val == trim(adjustl(spec%outputStatus%null))) spec%outputStatus%val = trim(adjustl(spec%outputStatus%def))
1702 13 : lowerCaseVal = getRemoved(getRemoved(getStrLower(spec%outputStatus%val), SKC_" "), SKC_"-")
1703 13 : spec%outputStatus%is%extend = index(lowerCaseVal, SKC_"extend") /= 0
1704 13 : spec%outputStatus%is%repeat = index(lowerCaseVal, SKC_"repeat") /= 0
1705 26 : spec%outputStatus%is%retry = index(lowerCaseVal, SKC_"retry") /= 0
1706 : end block outputStatus_block
1707 :
1708 : outputPrecision_block: block
1709 : use pm_sampling_scio, only: outputPrecision
1710 13 : if (spec%overridable .and. allocated(sampler%outputPrecision)) then
1711 0 : spec%outputPrecision%val = sampler%outputPrecision
1712 : else
1713 13 : spec%outputPrecision%val = outputPrecision
1714 : end if
1715 13 : if (spec%outputPrecision%val == spec%outputPrecision%null) spec%outputPrecision%val = spec%outputPrecision%def
1716 13 : spec%outputPrecision%str = getStr(spec%outputPrecision%val)
1717 : end block outputPrecision_block
1718 :
1719 : outputReportPeriod_block: block
1720 : use pm_sampling_scio, only: outputReportPeriod
1721 13 : if (spec%overridable .and. allocated(sampler%outputReportPeriod)) then
1722 0 : spec%outputReportPeriod%val = sampler%outputReportPeriod
1723 : else
1724 13 : spec%outputReportPeriod%val = outputReportPeriod
1725 : end if
1726 13 : if (spec%outputReportPeriod%val == spec%outputReportPeriod%null) spec%outputReportPeriod%val = spec%outputReportPeriod%def
1727 : end block outputReportPeriod_block
1728 :
1729 13 : outputRestartFileFormat_block: block
1730 : use pm_sampling_scio, only: outputRestartFileFormat
1731 : character(:,SKC), allocatable :: lowerCaseVal
1732 13 : if (spec%overridable .and. allocated(sampler%outputRestartFileFormat)) then
1733 0 : spec%outputRestartFileFormat%val = trim(adjustl(sampler%outputRestartFileFormat))
1734 : else
1735 13 : spec%outputRestartFileFormat%val = trim(adjustl(outputRestartFileFormat))
1736 : end if
1737 13 : if (spec%outputRestartFileFormat%val == trim(adjustl(spec%outputRestartFileFormat%null))) spec%outputRestartFileFormat%val = trim(adjustl(spec%outputRestartFileFormat%def))
1738 13 : lowerCaseVal = getStrLower(spec%outputRestartFileFormat%val)
1739 13 : spec%outputRestartFileFormat%isAscii = logical(lowerCaseVal == getStrLower(spec%outputRestartFileFormat%ascii), LK)
1740 26 : spec%outputRestartFileFormat%isBinary = logical(lowerCaseVal == getStrLower(spec%outputRestartFileFormat%binary), LK)
1741 : end block outputRestartFileFormat_block
1742 :
1743 : outputSampleSize_block: block
1744 : use pm_sampling_scio, only: outputSampleSize
1745 13 : if (spec%overridable .and. allocated(sampler%outputSampleSize)) then
1746 7 : spec%outputSampleSize%val = sampler%outputSampleSize
1747 : else
1748 6 : spec%outputSampleSize%val = outputSampleSize
1749 : end if
1750 13 : if (spec%outputSampleSize%val == spec%outputSampleSize%null) spec%outputSampleSize%val = spec%outputSampleSize%def
1751 13 : spec%outputSampleSize%str = getStr(spec%outputSampleSize%val)
1752 : end block outputSampleSize_block
1753 :
1754 : outputSeparator_block: block
1755 : use pm_strASCII, only: HT
1756 : use pm_sampling_scio, only: outputSeparator
1757 13 : if (spec%overridable .and. allocated(sampler%outputSeparator)) then
1758 0 : spec%outputSeparator%val = trim(adjustl(sampler%outputSeparator))
1759 : else
1760 13 : spec%outputSeparator%val = trim(adjustl(outputSeparator))
1761 : end if
1762 13 : if (spec%outputSeparator%val == spec%outputSeparator%null) then
1763 11 : if (allocated(spec%outputSeparator%val)) deallocate(spec%outputSeparator%val)
1764 11 : spec%outputSeparator%val = spec%outputSeparator%def
1765 : !if (outputColumnWidth == 0_IK) then
1766 : ! spec%outputSeparator%val = spec%outputSeparator%def
1767 : !else
1768 : ! spec%outputSeparator%val = SKC_" "
1769 : !end if
1770 2 : elseif (spec%outputSeparator%val == SKC_"") then
1771 0 : spec%outputSeparator%val = SKC_" "
1772 2 : elseif (spec%outputSeparator%val == SKC_"\t") then
1773 0 : spec%outputSeparator%val = HT
1774 2 : elseif (spec%outputSeparator%val == SKC_"\\t") then
1775 0 : spec%outputSeparator%val = SKC_"\t"
1776 : end if
1777 : end block outputSeparator_block
1778 :
1779 13 : outputSplashMode_block: block
1780 : use pm_sampling_scio, only: outputSplashMode
1781 : character(:,SKC), allocatable :: lowerCaseVal
1782 13 : if (spec%overridable .and. allocated(sampler%outputSplashMode)) then
1783 0 : spec%outputSplashMode%val = trim(adjustl(sampler%outputSplashMode))
1784 : else
1785 13 : spec%outputSplashMode%val = trim(adjustl(outputSplashMode))
1786 : end if
1787 13 : if (spec%outputSplashMode%val == trim(adjustl(spec%outputSplashMode%null))) spec%outputSplashMode%val = trim(adjustl(spec%outputSplashMode%def))
1788 13 : lowerCaseVal = getStrLower(spec%outputSplashMode%val)
1789 13 : spec%outputSplashMode%is%normal = logical(lowerCaseVal == getStrLower(spec%outputSplashMode%normal), LK)
1790 13 : spec%outputSplashMode%is%silent = logical(lowerCaseVal == getStrLower(spec%outputSplashMode%silent), LK)
1791 13 : spec%outputSplashMode%is%quiet = logical(lowerCaseVal == getStrLower(spec%outputSplashMode%quiet), LK)
1792 39 : if (spec%image%is%first) then
1793 13 : if (spec%outputSplashMode%is%normal) call spec%disp%show(getParaMonteSplash(width = max(PROGRESS_BAR_WIDTH, spec%disp%width)))
1794 13 : if (.not. spec%outputSplashMode%is%silent) call spec%disp%note%show(spec%msg)
1795 : end if
1796 : end block outputSplashMode_block
1797 :
1798 13 : parallelism_block: block
1799 : use pm_sampling_scio, only: parallelism
1800 : character(:,SKC), allocatable :: lowerCaseVal
1801 13 : if (spec%overridable .and. allocated(sampler%parallelism)) then
1802 0 : spec%parallelism%val = sampler%parallelism
1803 : else
1804 13 : spec%parallelism%val = parallelism
1805 : end if
1806 13 : spec%parallelism%val = trim(adjustl(getRemoved(spec%parallelism%val, SKC_" ")))
1807 13 : if (spec%parallelism%val == trim(adjustl(spec%parallelism%null))) spec%parallelism%val = trim(adjustl(spec%parallelism%def))
1808 13 : lowerCaseVal = getStrLower(spec%parallelism%val)
1809 : #if CAF_ENABLED || MPI_ENABLED
1810 : spec%parallelism%is%singleChain = lowerCaseVal == getStrLower(spec%parallelism%singleChain)
1811 : spec%parallelism%is%multiChain = lowerCaseVal == getStrLower(spec%parallelism%multiChain)
1812 : #else
1813 : ! This is critical for serial, concurrent and openmp applications.
1814 13 : spec%parallelism%val = spec%parallelism%singleChain
1815 13 : spec%parallelism%is%singleChain = .true._LK
1816 26 : spec%parallelism%is%multiChain = .false._LK
1817 : #endif
1818 : end block parallelism_block
1819 :
1820 : parallelismMpiFinalizeEnabled_block: block
1821 : use pm_sampling_scio, only: parallelismMpiFinalizeEnabled
1822 13 : if (spec%overridable .and. allocated(sampler%parallelismMpiFinalizeEnabled)) then
1823 1 : spec%parallelismMpiFinalizeEnabled%val = sampler%parallelismMpiFinalizeEnabled
1824 : else
1825 12 : spec%parallelismMpiFinalizeEnabled%val = parallelismMpiFinalizeEnabled
1826 : end if
1827 : end block parallelismMpiFinalizeEnabled_block
1828 :
1829 : parallelismNumThread_block: block
1830 : use pm_sampling_scio, only: parallelismNumThread
1831 13 : if (spec%overridable .and. allocated(sampler%parallelismNumThread)) then
1832 : !print *, sampler%parallelismNumThread
1833 1 : spec%parallelismNumThread%val = sampler%parallelismNumThread
1834 : else
1835 12 : spec%parallelismNumThread%val = parallelismNumThread
1836 : end if
1837 13 : if (spec%parallelismNumThread%val == spec%parallelismNumThread%null) spec%parallelismNumThread%val = spec%parallelismNumThread%def
1838 : #if OMP_ENABLED
1839 : if (0 < spec%parallelismNumThread%val) spec%image%count = spec%parallelismNumThread%val
1840 : #endif
1841 : end block parallelismNumThread_block
1842 :
1843 : !plang_block: block
1844 : ! use pm_sampling_scio, only: plang
1845 : ! if (spec%overridable .and. allocated(sampler%plang)) then
1846 : ! spec%plang%val = trim(adjustl(sampler%plang))
1847 : ! else
1848 : ! spec%plang%val = trim(adjustl(plang))
1849 : ! end if
1850 : ! if (spec%plang%val == trim(adjustl(spec%plang%null))) spec%plang%val = spec%plang%def
1851 : !end block plang_block
1852 :
1853 : randomSeed_block: block
1854 : use pm_kind, only: IKD, RKD
1855 : use pm_distUnif, only: setUnifRand
1856 : use pm_sampling_scio, only: randomSeed
1857 : use pm_distUnif, only: getUnifRand, splitmix64_type
1858 : integer(IK), parameter :: HALF_HUGE = int(real(huge(0_IK)) * .5, IK)
1859 : type(splitmix64_type) :: rng
1860 13 : if (spec%overridable .and. allocated(sampler%randomSeed)) then
1861 1 : spec%randomSeed%val = sampler%randomSeed
1862 : else
1863 12 : spec%randomSeed%val = randomSeed
1864 : end if
1865 13 : if (randomSeed == spec%randomSeed%null) then
1866 13 : rng = splitmix64_type()
1867 13 : spec%randomSeed%val = getUnifRand(rng, int(sqrt(real(HALF_HUGE, RKD)), IK), HALF_HUGE)
1868 : end if
1869 26 : spec%rng = xoshiro256ssw_type(seed = int(spec%randomSeed%val, IKD), imageID = spec%image%id)
1870 : !#if __GFORTRAN__ && CAF_ENABLED
1871 : ! ! opencoarrays crashes without this, by somehow setting comv_randomSeed(1)%err%occurred = TRUE
1872 : ! ! likely a result of memory corruption
1873 : ! !if (comv_randomSeed(1)%err%occurred) write(*,*) ""
1874 : !#endif
1875 : ! if (comv_randomSeed(1)%err%occurred) then
1876 : ! ! LCOV_EXCL_START
1877 : ! err%occurred = .true._LK
1878 : ! err%msg = err%msg//PROCEDURE_NAME//comv_randomSeed(1)%err%msg
1879 : ! return
1880 : ! ! LCOV_EXCL_STOP
1881 : ! end if
1882 : ! call comv_randomSeed(1)%get()
1883 : ! spec%randomSeed%Seed(:,spec%randomSeed%imageID) = comv_randomSeed(1)%val(:)
1884 : !#if CAF_ENABLED
1885 : ! sync all ! allow all images to set the seed first, then fetch the values
1886 : ! do imageID = 1, spec%randomSeed%imageCount
1887 : ! if (imageID/=spec%randomSeed%imageID) spec%randomSeed%Seed(:,imageID) = comv_randomSeed(1)[imageID]%val(:)
1888 : ! end do
1889 : !#elif MPI_ENABLED
1890 : ! allocate(Seed(spec%randomSeed%sizeSeed,spec%randomSeed%imageCount))
1891 : ! call mpi_barrier(mpi_comm_world,ierrMPI) ! allow all images to set the seed first, then fetch the values
1892 : ! call mpi_allgather ( spec%randomSeed%Seed(:,spec%randomSeed%imageID) & ! LCOV_EXCL_LINE : send buffer
1893 : ! , spec%randomSeed%sizeSeed & ! LCOV_EXCL_LINE : send count
1894 : ! , mpi_integer & ! LCOV_EXCL_LINE : send datatype
1895 : ! , Seed(:,:) & ! LCOV_EXCL_LINE : receive buffer
1896 : ! , spec%randomSeed%sizeSeed & ! LCOV_EXCL_LINE : receive count
1897 : ! , mpi_integer & ! LCOV_EXCL_LINE : receive datatype
1898 : ! , mpi_comm_world & ! LCOV_EXCL_LINE : comm
1899 : ! , ierrMPI & ! LCOV_EXCL_LINE : ierr
1900 : ! )
1901 : ! spec%randomSeed%Seed(:,:) = Seed
1902 : ! deallocate(Seed)
1903 : !#endif
1904 : ! deallocate(comv_randomSeed)
1905 : end block randomSeed_block
1906 :
1907 : sysInfoFilePath_block: block
1908 : use pm_sampling_scio, only: sysInfoFilePath
1909 13 : if (spec%overridable .and. allocated(sampler%sysInfoFilePath)) then
1910 0 : spec%sysInfoFilePath%val = trim(adjustl(sampler%sysInfoFilePath))
1911 : else
1912 13 : spec%sysInfoFilePath%val = trim(adjustl(sysInfoFilePath))
1913 : end if
1914 13 : if (spec%sysInfoFilePath%val == spec%sysInfoFilePath%null) spec%sysInfoFilePath%val = spec%sysInfoFilePath%def
1915 13 : if (allocated(spec%sysInfoFilePath%null)) deallocate(spec%sysInfoFilePath%null)
1916 : end block sysInfoFilePath_block
1917 :
1918 : targetAcceptanceRate_block: block
1919 : use pm_sampling_scio, only: targetAcceptanceRate
1920 : logical(LK) :: lowerUpperSet(2)
1921 13 : if (spec%overridable .and. allocated(sampler%targetAcceptanceRate)) then
1922 0 : spec%targetAcceptanceRate%val = real(sampler%targetAcceptanceRate, RKC)
1923 : else
1924 39 : spec%targetAcceptanceRate%val = targetAcceptanceRate
1925 : end if
1926 65 : lowerUpperSet = .not. isNAN(spec%targetAcceptanceRate%val)
1927 13 : if (lowerUpperSet(1) .and. .not. lowerUpperSet(2)) spec%targetAcceptanceRate%val(2) = spec%targetAcceptanceRate%val(1)
1928 13 : if (lowerUpperSet(2) .and. .not. lowerUpperSet(1)) spec%targetAcceptanceRate%val(1) = spec%targetAcceptanceRate%val(2)
1929 39 : if (.not.(lowerUpperSet(1) .or. lowerUpperSet(2))) spec%targetAcceptanceRate%val(:) = spec%targetAcceptanceRate%def
1930 39 : spec%targetAcceptanceRate%enabled = logical(any(spec%targetAcceptanceRate%val /= spec%targetAcceptanceRate%def), LK)
1931 13 : if (spec%targetAcceptanceRate%enabled) then
1932 0 : spec%targetAcceptanceRate%aim = sum(spec%targetAcceptanceRate%val) / 2._RKC
1933 13 : elseif (spec%method%isParaDISE .or. spec%method%isParaDRAM) then
1934 13 : spec%targetAcceptanceRate%aim = .234_RKC
1935 0 : elseif (spec%method%isParaNest) then
1936 0 : spec%targetAcceptanceRate%aim = .2_RKC
1937 : else
1938 : error stop "This cannot happen." ! LCOV_EXCL_LINE
1939 : end if
1940 : end block targetAcceptanceRate_block
1941 :
1942 : ! Resolve the conflicting cases.
1943 :
1944 : block
1945 : use pm_sampleCov, only: getCov, uppDia
1946 184 : if (.not. spec%domainBallCovMat%isUserSet) spec%domainBallCovMat%val = getCov(spec%domainBallCorMat%val, uppDia, spec%domainBallStdVec%val)
1947 : end block
1948 :
1949 13 : if (spec%outputColumnWidth%val /= 0_IK) spec%outputSeparator%val = SKC_" "
1950 :
1951 : ! Setup the parallel images info.
1952 :
1953 13 : spec%image%is%leader = spec%image%is%first .or. spec%parallelism%is%multiChain
1954 13 : spec%image%is%rooter = .not. spec%image%is%leader
1955 :
1956 : ! Set the auxiliary dependent variables.
1957 :
1958 40 : spec%outputColumnWidth%max = getStr(max(spec%outputPrecision%val, spec%outputColumnWidth%val, maxval(len_trim(spec%domainAxisName%val, IK))) + getCountDigit(spec%real%minexponent) + 6)
1959 13 : spec%reportFile%format%allreal = SKC_"('"//spec%reportFile%indent//SKC_"',*("//spec%real%ed//spec%outputColumnWidth%max//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,' '))"
1960 13 : spec%reportFile%format%intreal = SKC_"('"//spec%reportFile%indent//SKC_"',1I"//spec%outputColumnWidth%max//SKC_",' ',*("//spec%real%ed//spec%outputColumnWidth%max//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,' '))"
1961 13 : spec%reportFile%format%strreal = SKC_"('"//spec%reportFile%indent//SKC_"',1A"//spec%outputColumnWidth%max//SKC_",' ',*("//spec%real%ed//spec%outputColumnWidth%max//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,' '))"
1962 13 : spec%reportFile%format%fixform = SKC_"('"//spec%reportFile%indent//SKC_"',*(g"//spec%outputColumnWidth%max//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,' '))"
1963 13 : spec%reportFile%format%integer = SKC_"('"//spec%reportFile%indent//SKC_"',*(I"//spec%outputColumnWidth%max//SKC_",:,' '))"
1964 13 : spec%reportFile%format%generic = SKC_"('"//spec%reportFile%indent//SKC_"',*(g0,:,' '))"
1965 :
1966 13 : spec%restartFile%format = SKC_"(*(g0,:,'"//NL1//SKC_"'))"
1967 13 : spec%progressFile%format%header = SKC_"(*(g"//spec%outputColumnWidth%str//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,'"//spec%outputSeparator%val//SKC_"'))"
1968 13 : spec%progressFile%format%rows = spec%progressFile%format%header!SKC_"(2I"//spec%outputColumnWidth%str//SKC_"*("//spec%real%ed//spec%outputColumnWidth%str//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,'"//spec%outputSeparator%val//SKC_"'))"
1969 13 : spec%sampleFile%format%header = SKC_"(*(g"//spec%outputColumnWidth%str//SKC_"."//spec%outputPrecision%str//spec%real%ex//SKC_",:,'"//spec%outputSeparator%val//SKC_"'))"
1970 13 : spec%chainFile%format%header = spec%sampleFile%format%header
1971 :
1972 : ! open output files, report and sanitize.
1973 :
1974 13 : call spec%openFiles(err)
1975 13 : if (err%occurred) return
1976 13 : if (spec%image%is%leader) call spec%report()
1977 13 : call spec%sanitize(err)
1978 :
1979 : ! The format setup of setupOutputFiles() uses the generic g0 edit descriptor.
1980 : ! Here the format is revised to be more specific.
1981 : ! g0 edit descriptor format is slightly more arbitrary and compiler-dependent.
1982 : ! These must be set here (and not in `spec%openFile()`) because the required info needs
1983 : ! to be validated first in `spec%sanitize()` after being reported to the output files.
1984 :
1985 13 : if (0_IK < spec%outputColumnWidth%val) then
1986 : associate(colWidth => spec%outputColumnWidth%str, precision => spec%outputPrecision%str, sep => spec%outputSeparator%val)
1987 0 : spec%sampleFile%format%rows = SKC_"("//getStr(1 + spec%ndim%val)//SKC_"("//spec%real%ed//colWidth//SKC_"."//precision//spec%real%ex//SKC_",:,'"//sep//SKC_"'))"
1988 0 : if (spec%method%isParaDISE .or. spec%method%isParaDRAM) then
1989 : spec%chainFile%format%rows = SKC_"("// &
1990 : SKC_"2(I"//colWidth//SKC_",'"//sep//SKC_"')"// &
1991 : SKC_","// &
1992 : SKC_"2("//spec%real%ed//colWidth//SKC_"."//precision//spec%real%ex//SKC_",'"//sep//SKC_"')"// &
1993 : SKC_","// &
1994 : SKC_"2(I"//colWidth//SKC_",'"//sep//SKC_"')"// &
1995 : SKC_","// &
1996 : spec%sampleFile%format%rows// &
1997 0 : SKC_")"
1998 0 : elseif (spec%method%isParaNest) then
1999 : spec%chainFile%format%rows = SKC_"("// &
2000 : SKC_"1(I"//colWidth//SKC_",'"//sep//SKC_"')"// &
2001 : SKC_","// &
2002 : getStr(spec%ndim%val + 5_IK)//spec%sampleFile%format%rows// &
2003 : !SKC_","// &
2004 : !SKC_"1(A1"//colWidth//SKC_",'"//sep//SKC_"')"// & ! what is this? apparently, a commented-out linefeed.
2005 0 : SKC_")"
2006 : else
2007 : error stop getStr(__FILE__)//SK_"@"//getFine(__FILE__, __LINE__)//SK_": Internal library error occurred. This serious error must be reported to the developers." ! LCOV_EXCL_LINE
2008 : end if
2009 : end associate
2010 : else
2011 13 : spec%chainFile%format%rows = spec%chainFile%format%header
2012 13 : spec%sampleFile%format%rows = spec%sampleFile%format%header
2013 : end if
2014 :
2015 26 : end function set
2016 :
2017 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2018 :
2019 13 : subroutine openFiles(spec, err)
2020 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
2021 : !DEC$ ATTRIBUTES DLLEXPORT :: openFiles
2022 : #endif
2023 : use pm_err, only: err_type
2024 : use pm_sysPath, only: isDir
2025 : use pm_sysPath, only: isFile
2026 : use pm_sysPath, only: getDirSep
2027 : use pm_sysInfo, only: getSysInfo
2028 : use pm_sysPath, only: getDirSeps
2029 : use pm_sysPath, only: getDirName
2030 : use pm_sysPath, only: getPathAbs
2031 : use pm_sysPath, only: getBaseName
2032 : use pm_sysPath, only: getDirCurrent
2033 : use pm_sysPath, only: isFailedRemove
2034 : use pm_sysPath, only: isFailedMakeDir
2035 : use pm_paramonte, only: PARAMONTE_COMPILER_OPTIONS
2036 : use pm_paramonte, only: PARAMONTE_COMPILER_VERSION
2037 : use pm_parallelism, only: PARALLELIZATION_MODE
2038 : use pm_arrayStrip, only: getStripped, right
2039 : use pm_io, only: setContentsFrom, LEN_IOMSG
2040 : use pm_paramonte, only: getParaMonteSplash
2041 : use pm_sysShell, only: isShellWindows
2042 : use pm_str, only: getStrWrapped
2043 : use pm_sysPath, only: verbatim
2044 : use pm_str, only: isEndedWith
2045 :
2046 : type(err_type), intent(inout) :: err
2047 : class(specbase_type), intent(inout) :: spec
2048 : character(*,SKC), parameter :: PROCEDURE_NAME = MODULE_NAME//SKC_"@openFiles()"
2049 : character(*,SKC), parameter :: PARALLELIZATION_MODE_SKC = PARALLELIZATION_MODE
2050 13 : character(:,SKC), allocatable :: strtemp
2051 : character(LEN_IOMSG,SKC) :: errmsg
2052 : integer(IK) :: iostat, iell
2053 : logical(LK) :: endsWithDirSep
2054 : logical(LK) :: failed
2055 :
2056 : ! get the directory separators.
2057 :
2058 13 : errmsg = repeat(" ", len(errmsg))
2059 13 : spec%outputFileName%sep = getDirSep(failed, errmsg)
2060 13 : if (failed) then
2061 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Failed to infer directory separator: "//trim(adjustl(errmsg))//NL2 ! LCOV_EXCL_LINE
2062 : return ! LCOV_EXCL_LINE
2063 : end if
2064 :
2065 13 : spec%outputFileName%seps = getDirSeps(failed, errmsg)
2066 13 : if (failed) then
2067 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Failed to infer directory separator: "//trim(adjustl(errmsg))//NL2 ! LCOV_EXCL_LINE
2068 : return ! LCOV_EXCL_LINE
2069 : end if
2070 :
2071 13 : if (spec%outputFileName%val == spec%outputFileName%def) then
2072 : spec%msg = SKC_"No user-specified `outputFileName` for "//spec%method%val//SKC_" output files detected."//NL1//&
2073 1 : SKC_"Generating appropriate filenames for "//spec%method%val//SKC_" output files from the current date and time..."//NL2
2074 1 : spec%outputFileName%base = getBaseName(spec%outputFileName%val, spec%outputFileName%seps, verbatim)
2075 : else
2076 12 : spec%msg = SKC_"Variable `outputFileName` detected among the user-supplied specifications of the "//spec%method%val//SKC_" sampler:"//NL1//SKC_""""//spec%outputFileName%val//SKC_""""//NL2
2077 : end if
2078 :
2079 : ! get the current working directory, just FYI.
2080 :
2081 13 : strtemp = getDirCurrent(failed)
2082 13 : spec%msg = spec%msg//SKC_"Path to the current working directory:"//NL1//SKC_""""//strtemp//SKC_""""//NL2
2083 :
2084 : ! For some reason, getPathAbs() (which relies on Intel specialized routine, returns a path with newline character at the end in OpenMP-parallel mode.
2085 13 : spec%outputFileName%dir = getPathAbs(getDirName(spec%outputFileName%val, spec%outputFileName%seps, verbatim), failed, errmsg)
2086 13 : if (failed) then
2087 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred while inferring the directory name from the specified `outputFileName`. "//trim(adjustl(errmsg))//NL2 ! LCOV_EXCL_LINE
2088 : return ! LCOV_EXCL_LINE
2089 : end if
2090 13 : if (len_trim(adjustl(spec%outputFileName%dir)) == 0_IK) then
2091 0 : spec%outputFileName%dir = trim(adjustl(strtemp))!//spec%outputFileName%sep
2092 0 : spec%msg = spec%msg//SKC_"All output files will be written to the current working directory:"//NL1//SKC_""""//spec%outputFileName%dir//SKC_""""//NL2
2093 : else
2094 13 : spec%msg = spec%msg//SKC_"Generating the requested directory for the "//spec%method%val//SKC_" simulation output files:"//NL1//SKC_""""//spec%outputFileName%dir//SKC_""""//NL2
2095 : end if
2096 :
2097 38 : endsWithDirSep = any(isEndedWith(css_type(spec%outputFileName%val), css_type([(spec%outputFileName%seps(iell : iell), iell = 1, len(spec%outputFileName%seps))])))
2098 13 : if (endsWithDirSep) spec%msg = spec%msg//SKC_"The specified `outputFileName` does not contain a filename prefix for "//spec%method%val//SKC_" output files."//NL1//&
2099 1 : SKC_"Generating appropriate filenames for "//spec%method%val//SKC_" output files from the current date and time..."//NL2
2100 13 : if (endsWithDirSep .or. spec%outputFileName%val == spec%outputFileName%def) then
2101 2 : spec%outputFileName%base = spec%outputFileName%def
2102 : else
2103 11 : spec%outputFileName%base = getBaseName(spec%outputFileName%val, spec%outputFileName%seps, verbatim)
2104 : end if
2105 :
2106 : ! construct the semi full name.
2107 :
2108 13 : spec%outputFileName%full = spec%outputFileName%dir
2109 28 : endsWithDirSep = any(isEndedWith(css_type(spec%outputFileName%full), css_type([(spec%outputFileName%seps(iell : iell), iell = 1, len(spec%outputFileName%seps))])))
2110 13 : if (.not. endsWithDirSep) spec%outputFileName%full = spec%outputFileName%full//spec%outputFileName%sep
2111 13 : spec%outputFileName%full = spec%outputFileName%full//spec%outputFileName%base//SKC_"_run"
2112 :
2113 : ! Generate the output files directory.
2114 :
2115 13 : if (spec%image%is%first) then
2116 13 : failed = isFailedMakeDir(spec%outputFileName%dir)
2117 13 : call spec%image%sync()
2118 : else
2119 0 : call spec%image%sync()
2120 0 : failed = .not. isDir(spec%outputFileName%dir)
2121 : end if
2122 :
2123 : ! in parallel mode, ensure the directory exists before moving on.
2124 :
2125 13 : if (failed) then
2126 0 : if (spec%image%is%first .and. .not. spec%outputSplashMode%is%silent) call spec%disp%note%show(spec%msg)
2127 0 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred while making directory '"//spec%outputFileName%dir//SKC_"'."//NL1//trim(errmsg)//NL2
2128 : err%occurred = .true._LK ! LCOV_EXCL_LINE
2129 : return ! LCOV_EXCL_LINE
2130 : end if
2131 :
2132 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2133 : ! Only leader images: Generate the output filenames, search for pre-existing runs, and open the report file.
2134 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2135 :
2136 13 : spec%chainFile %openArg_type = openArg_type(status = SKC_"replace")
2137 13 : spec%sampleFile %openArg_type = openArg_type(status = SKC_"replace")
2138 13 : spec%reportFile %openArg_type = openArg_type(status = SKC_"replace")
2139 13 : spec%restartFile %openArg_type = openArg_type(status = SKC_"replace")
2140 13 : spec%progressFile %openArg_type = openArg_type(status = SKC_"replace")
2141 :
2142 13 : spec%chainFile %kind = SKC_"chain"
2143 13 : spec%sampleFile %kind = SKC_"sample"
2144 13 : spec%reportFile %kind = SKC_"report"
2145 13 : spec%restartFile %kind = SKC_"restart"
2146 13 : spec%progressFile %kind = SKC_"progress"
2147 :
2148 13 : spec%chainFile %ext = filext%ascii
2149 13 : spec%sampleFile %ext = filext%ascii
2150 13 : spec%reportFile %ext = filext%ascii
2151 13 : spec%restartFile %ext = filext%ascii
2152 13 : spec%progressFile %ext = filext%ascii
2153 :
2154 : ! Reset the file extensions as necessary.
2155 :
2156 13 : if (spec%outputChainFileFormat%isBinary) then
2157 0 : spec%chainFile%form = SKC_"unformatted"
2158 0 : spec%chainFile%access = SKC_"stream"
2159 0 : spec%chainFile%ext = filext%binary
2160 : end if
2161 :
2162 13 : if (spec%outputRestartFileFormat%isBinary) then
2163 11 : spec%restartFile%form = SKC_"unformatted"
2164 11 : spec%restartFile%access = SKC_"stream"
2165 11 : spec%restartFile%ext = filext%binary
2166 : end if
2167 :
2168 : ! Define the file full suffix.
2169 :
2170 13 : strtemp = SKC_"_pid"//getStr(merge(spec%image%id, 1_IK, spec%parallelism%is%multiChain))//SKC_"_"
2171 13 : spec%chainFile %suffix = strtemp//spec%chainFile %kind//spec%chainFile %ext
2172 13 : spec%sampleFile %suffix = strtemp//spec%sampleFile %kind//spec%sampleFile %ext
2173 13 : spec%reportFile %suffix = strtemp//spec%reportFile %kind//spec%reportFile %ext
2174 13 : spec%restartFile %suffix = strtemp//spec%restartFile %kind//spec%restartFile %ext
2175 13 : spec%progressFile %suffix = strtemp//spec%progressFile %kind//spec%progressFile %ext
2176 :
2177 :
2178 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2179 : ! Search for older simulations with the same naming prefix and determine simulation start mode (restart vs. new).
2180 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2181 :
2182 13 : if (spec%isFailedResizeList(1_IK, errmsg)) then
2183 0 : err%occurred = .true._LK
2184 0 : err%msg = PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg)
2185 0 : return
2186 : end if
2187 :
2188 13 : spec%run%id = 0_IK
2189 : loopListFiles: do
2190 :
2191 25 : spec%run%id = spec%run%id + 1_IK
2192 25 : if (size(spec%chainFile%list, 1, IK) < spec%run%id) then
2193 11 : if (spec%isFailedResizeList(spec%run%id * 2_IK, errmsg)) then
2194 0 : err%occurred = .true._LK
2195 0 : err%msg = PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg)
2196 0 : return
2197 : end if
2198 : end if
2199 :
2200 25 : strtemp = getStr(spec%run%id)
2201 25 : spec%chainFile %list(spec%run%id)%val = spec%outputFileName%full//strtemp//spec%chainFile %suffix
2202 25 : spec%sampleFile %list(spec%run%id)%val = spec%outputFileName%full//strtemp//spec%sampleFile %suffix
2203 25 : spec%reportFile %list(spec%run%id)%val = spec%outputFileName%full//strtemp//spec%reportFile %suffix
2204 25 : spec%restartFile %list(spec%run%id)%val = spec%outputFileName%full//strtemp//spec%restartFile %suffix
2205 25 : spec%progressFile %list(spec%run%id)%val = spec%outputFileName%full//strtemp//spec%progressFile %suffix
2206 25 : spec%chainFile %extant = isFile(spec%chainFile %list(spec%run%id)%val)
2207 25 : spec%sampleFile %extant = isFile(spec%sampleFile %list(spec%run%id)%val)
2208 25 : spec%reportFile %extant = isFile(spec%reportFile %list(spec%run%id)%val)
2209 25 : spec%restartFile %extant = isFile(spec%restartFile %list(spec%run%id)%val)
2210 25 : spec%progressFile %extant = isFile(spec%progressFile %list(spec%run%id)%val)
2211 :
2212 : ! exceptional case: chainFile
2213 :
2214 25 : if (.not. spec%chainFile%extant) then
2215 13 : if (spec%outputChainFileFormat%isBinary) then
2216 0 : strtemp = getStripped(spec%chainFile%list(spec%run%id)%val, filext%binary, right)//filext%ascii
2217 : else
2218 13 : strtemp = getStripped(spec%chainFile%list(spec%run%id)%val, filext%ascii, right)//filext%binary
2219 : end if
2220 13 : spec%chainFile%extant = isFile(strtemp)
2221 13 : if (spec%chainFile%extant) spec%chainFile%list(spec%run%id)%val = strtemp
2222 : end if
2223 :
2224 : ! exceptional case: restartFile
2225 :
2226 25 : if (.not. spec%restartFile%extant) then
2227 13 : if (spec%outputChainFileFormat%isBinary) then
2228 0 : strtemp = getStripped(spec%restartFile%list(spec%run%id)%val, filext%binary, right)//filext%ascii
2229 : else
2230 13 : strtemp = getStripped(spec%restartFile%list(spec%run%id)%val, filext%ascii, right)//filext%binary
2231 : end if
2232 13 : spec%restartFile%extant = isFile(strtemp)
2233 13 : if (spec%restartFile%extant) spec%restartFile%list(spec%run%id)%val = strtemp
2234 : end if
2235 :
2236 : ! If all files exist, search for the next batch.
2237 :
2238 : if (spec%chainFile %extant .and. & ! LCOV_EXCL_LINE
2239 : spec%sampleFile %extant .and. & ! LCOV_EXCL_LINE
2240 : spec%reportFile %extant .and. & ! LCOV_EXCL_LINE
2241 : spec%restartFile %extant .and. & ! LCOV_EXCL_LINE
2242 : spec%progressFile %extant) cycle
2243 12 : exit ! only if no files or only some files exist.
2244 :
2245 : end do loopListFiles
2246 :
2247 13 : spec%run%is%new = .not. (spec%reportFile%extant .or. spec%progressFile%extant .or. spec%restartFile%extant .or. spec%chainFile%extant .or. spec%sampleFile%extant) ! fresh (no restart) simulation if no file exists.
2248 14 : spec%msg = spec%msg//getStr(spec%run%id - 1)//trim(merge(SKC_" count ", SKC_" counts", spec%run%id <= 2))//SKC_" of preexisting complete simulation runs with the same name prefix were detected."//NL2
2249 :
2250 13 : if (spec%outputStatus%is%retry) then
2251 :
2252 : ! The following is possible only if the `outpuStatus` is in `retry` mode and the most recent simulation is complete, in which case, the file names must be regenerated.
2253 : ! This ensures `run%id` is set to the latest existing simulation run (complete or incomplete) which will be overwritten by new fresh simulation.
2254 : ! The latest incomplete or complete simulation files will be deleted (replaced) in retry mode.
2255 10 : spec%outputStatus%is%extend = spec%outputStatus%is%retry
2256 10 : spec%outputStatus%is%retry = .false._LK
2257 10 : if (spec%run%is%new) then
2258 10 : if (1_IK < spec%run%id) spec%run%id = spec%run%id - 1_IK
2259 10 : spec%msg = spec%msg//SKC_"The last complete simulation run #"//getStr(spec%run%id)//" will be overwritten as requested."//NL1
2260 : else
2261 0 : spec%msg = spec%msg//SKC_"The last incomplete simulation run #"//getStr(spec%run%id)//" will be overwritten as requested."//NL1
2262 0 : spec%run%is%new = .true._LK
2263 : end if
2264 :
2265 : ! Delete all the last batch of existing files in retry mode.
2266 :
2267 10 : if (spec%image%is%first .or. spec%parallelism%is%multiChain) then
2268 10 : if (isFailedRemove(spec%chainFile %list(spec%run%id)%val, forced = .true._LK, ntry = 10_IK, errmsg = errmsg)) then; failed = .true._LK; err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg); end if
2269 10 : if (isFailedRemove(spec%sampleFile %list(spec%run%id)%val, forced = .true._LK, ntry = 10_IK, errmsg = errmsg)) then; failed = .true._LK; err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg); end if
2270 10 : if (isFailedRemove(spec%reportFile %list(spec%run%id)%val, forced = .true._LK, ntry = 10_IK, errmsg = errmsg)) then; failed = .true._LK; err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg); end if
2271 10 : if (isFailedRemove(spec%restartFile %list(spec%run%id)%val, forced = .true._LK, ntry = 10_IK, errmsg = errmsg)) then; failed = .true._LK; err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg); end if
2272 10 : if (isFailedRemove(spec%progressFile%list(spec%run%id)%val, forced = .true._LK, ntry = 10_IK, errmsg = errmsg)) then; failed = .true._LK; err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//trim(errmsg); end if
2273 10 : if (failed) then
2274 0 : call spec%disp%note%show(spec%msg//err%msg)
2275 0 : err%occurred = .true._LK
2276 0 : return
2277 : end if
2278 : end if
2279 :
2280 : else
2281 :
2282 3 : spec%msg = spec%msg//SKC_"Checking for simulation restart possibility..."//NL2
2283 :
2284 : end if
2285 :
2286 13 : spec%chainFile %file = spec%chainFile %list(spec%run%id)%val
2287 13 : spec%sampleFile %file = spec%sampleFile %list(spec%run%id)%val
2288 13 : spec%reportFile %file = spec%reportFile %list(spec%run%id)%val
2289 13 : spec%restartFile %file = spec%restartFile %list(spec%run%id)%val
2290 13 : spec%progressFile %file = spec%progressFile %list(spec%run%id)%val
2291 : !print *, spec%chainFile %file
2292 : !print *, spec%sampleFile %file
2293 : !print *, spec%reportFile %file
2294 : !print *, spec%restartFile %file
2295 : !print *, spec%progressFile %file
2296 :
2297 13 : if (spec%sampleFile%extant) then
2298 : ! compromised simulation because a file other than the output sample is missing.
2299 0 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. All output files are essential for a successful simulation restart."//NL1//SKC_"List of missing simulation output files:"
2300 0 : if (.not. spec%chainFile %extant) err%msg = err%msg//NL1//SKC_""""//spec%chainFile %file//SKC_""""
2301 0 : if (.not. spec%reportFile %extant) err%msg = err%msg//NL1//SKC_""""//spec%reportFile %file//SKC_""""
2302 0 : if (.not. spec%restartFile %extant) err%msg = err%msg//NL1//SKC_""""//spec%restartFile %file//SKC_""""
2303 0 : if (.not. spec%progressFile %extant) err%msg = err%msg//NL1//SKC_""""//spec%progressFile %file//SKC_""""
2304 0 : if (spec%image%is%first .and. .not. spec%outputSplashMode%is%silent) call spec%disp%note%show(spec%msg)
2305 0 : err%occurred = .true._LK
2306 0 : return
2307 13 : elseif (spec%run%is%new) then
2308 13 : if (1_IK < spec%run%id) then
2309 1 : strtemp = SKC_" from the most recent completed simulation"
2310 : else
2311 12 : strtemp = SKC_""
2312 : end if
2313 13 : spec%msg = spec%msg//SKC_"Starting a fresh simulation run #"//getStr(spec%run%id)//strtemp//SKC_"..."//NL2
2314 13 : spec%chainFile %status = SKC_"new"
2315 13 : spec%sampleFile %status = SKC_"new"
2316 13 : spec%reportFile %status = SKC_"new"
2317 13 : spec%restartFile %status = SKC_"new"
2318 13 : spec%progressFile %status = SKC_"new"
2319 : !block
2320 : ! use pm_paramonte, only: PARAMONTE_WEB_ISSUES
2321 : ! if (spec%outputStatus%isCopy) error stop SK_"copy-extension facility is not yet implemented. Please report this to the ParaMonte developers at: "//PARAMONTE_WEB_ISSUES
2322 : !end block
2323 : else ! legible restart (dry) mode.
2324 0 : spec%msg = spec%msg//SKC_"Restarting the existing incomplete simulation run #"//getStr(spec%run%id)//NL2
2325 0 : spec%chainFile %status = SKC_"old"
2326 0 : spec%sampleFile %status = SKC_"new"
2327 0 : spec%reportFile %status = SKC_"old"
2328 0 : spec%restartFile %status = SKC_"old"
2329 0 : spec%progressFile %status = SKC_"old"
2330 0 : spec%reportFile %position = SKC_"append"
2331 : end if
2332 13 : spec%run%is%dry = .not. spec%run%is%new
2333 :
2334 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 : ! print the stdout message for generating / appending the output report file(s):
2336 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2337 :
2338 13 : spec%msg = spec%msg//SKC_"Running the simulation in "//PARALLELIZATION_MODE_SKC//SKC_" on "//getStr(spec%image%count)//trim(merge(SKC_" process... ", SKC_" processes...", spec%image%count == 1_IK))//NL2
2339 :
2340 : ! ensure all images sync here to avoid wrong inquire() result for the existence of the files.
2341 :
2342 13 : call spec%image%sync()
2343 :
2344 : ! open the output files
2345 :
2346 13 : blockLeaderFileSetup: if (spec%image%is%leader) then
2347 :
2348 13 : call spec%openFile(spec%reportFile, err, spec%msg)
2349 13 : if (err%occurred) return
2350 :
2351 13 : spec%msg = spec%msg//spec%reportFile%file//NL2
2352 13 : spec%disp%unit = spec%reportFile%unit
2353 13 : spec%disp%mark%unit = spec%disp%unit
2354 13 : spec%disp%note%unit = spec%disp%unit
2355 13 : spec%disp%warn%unit = spec%disp%unit
2356 13 : spec%disp%stop%unit = spec%disp%unit
2357 13 : spec%disp%text%unit = spec%disp%unit
2358 13 : spec%disp%text%width = 128_IK
2359 13 : spec%disp%width = 128_IK
2360 :
2361 : ! rewrite the accumulated info to the stdout and all report files.
2362 :
2363 : !if (spec%run%is%new) then
2364 13 : if (isFile(spec%sysInfoFilePath%val)) then
2365 0 : call setContentsFrom(spec%sysInfoFilePath%val, strtemp, iostat, errmsg)
2366 : if (iostat /= 0_IK) strtemp = UNDEFINED ! LCOV_EXCL_LINE
2367 : else
2368 : ! This can take a long time, for example, about 0.75 seconds to execute on Stampede Login nodes.
2369 : ! Get system info via only the first image.
2370 : ! On many parallel processors via singleChain this leads to
2371 : ! the creation of thousands of files on the system, simultaneously.
2372 : ! This is not needed by any process other than the leader images.
2373 13 : strtemp = getStripped(getSysInfo(failed), NL1)
2374 : end if
2375 13 : call spec%disp%show(getParaMonteSplash())
2376 13 : call spec%disp%text%wrap(NL1//SKC_"ParaMonte.library.interface.specifications"//NL1)
2377 13 : call spec%disp%show(getStrWrapped(SKC_"The "//envname//SKC_"."))
2378 13 : call spec%disp%text%wrap(NL1//SKC_"ParaMonte.library.compiler.version"//NL1)
2379 13 : call spec%disp%show(getStrWrapped(PARAMONTE_COMPILER_VERSION))
2380 13 : call spec%disp%text%wrap(NL1//SKC_"ParaMonte.library.compiler.options"//NL1)
2381 13 : call spec%disp%show(getStrWrapped(PARAMONTE_COMPILER_OPTIONS))
2382 13 : call spec%disp%text%wrap(NL1//SKC_"ParaMonte.runtime.platform.specifications"//NL1)
2383 13 : call spec%disp%show(getStrWrapped(strtemp))
2384 13 : call spec%disp%text%wrap(NL1//spec%method%val//".simulation.environment.setup"//NL1)
2385 : !end if
2386 :
2387 :
2388 : ! The sample file will be opened by the samplers at the time of writing to the file. Its non-existence is indicative of restart mode.
2389 : !call spec%openFile(spec%sampleFile, err, spec%msg); if (err%occurred) return ! open/append the output sampleFile.
2390 13 : call spec%openFile(spec%progressFile, err, spec%msg); if (err%occurred) return ! open/append the output progressFile.
2391 13 : call spec%openFile(spec%restartFile, err, spec%msg); if (err%occurred) return ! open/append the output restartFile.
2392 13 : call spec%openFile(spec%chainFile, err, spec%msg); if (err%occurred) return ! open/append the output chainFile.
2393 :
2394 13 : call spec%disp%note%show(spec%msg//SKC_"Done.")
2395 :
2396 : ! read the header line of the time file, only by leader images
2397 :
2398 13 : iostat = 0
2399 13 : if (spec%run%is%dry) read(spec%progressFile%unit, *, iostat = iostat)
2400 13 : if (spec%run%is%new .or. is_iostat_end(iostat)) then
2401 13 : write(spec%progressFile%unit,spec%progressFile%format%header) "numFuncCallTotal" &
2402 13 : , "numFuncCallAccepted" &
2403 13 : , "meanAcceptanceRateSinceStart" &
2404 13 : , "meanAcceptanceRateSinceLastReport" &
2405 13 : , "timeElapsedSinceLastReportInSeconds" &
2406 13 : , "timeElapsedSinceStartInSeconds" &
2407 26 : , "timeRemainedToFinishInSeconds"
2408 13 : flush(spec%progressFile%unit)
2409 : end if
2410 :
2411 : end if blockLeaderFileSetup
2412 :
2413 13 : end subroutine openFiles
2414 :
2415 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2416 :
2417 52 : subroutine openFile(spec, samplerFile, err, msg)
2418 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
2419 : !DEC$ ATTRIBUTES DLLEXPORT :: openFile
2420 : #endif
2421 : use pm_arrayStrip, only: getStripped, right
2422 : !use pm_str, only: isEndedWith
2423 : use pm_err, only: err_type
2424 : use pm_io, only: getFileUnit
2425 : type(err_type), intent(inout) :: err
2426 : class(specbase_type), intent(inout) :: spec
2427 : character(:,SKC), intent(inout), allocatable, optional :: msg
2428 : class(samplerFile_type), intent(inout) :: samplerFile
2429 : character(*,SKC), parameter :: PROCEDURE_NAME = MODULE_NAME//SKC_"@openFiles()"
2430 : ! open/append the output files:
2431 52 : if (present(msg)) msg = msg//merge(SKC_"Generating the new output ", SKC_"Appending to the existing ", spec%run%is%new)//samplerFile%kind//SKC_" file:"//NL1
2432 : ! for some unknown reason, if newunit is used, GFortran opens the file as an internal file. Therefore, do not use `newunit`.
2433 : !samplerFile%unit = getFileUnit()
2434 : ! The Intel ifort SHARED attribute is essential for file unlocking on Windows OS.
2435 52 : if (samplerFile%access /= SKC_"direct") then
2436 52 : open(newunit = samplerFile%unit, file = samplerFile%file, form = samplerFile%form, access = samplerFile%access, status = samplerFile%status, iostat = samplerFile%iostat, iomsg = samplerFile%iomsg SHARED, position = samplerFile%position)
2437 : else
2438 0 : open(newunit = samplerFile%unit, file = samplerFile%file, form = samplerFile%form, access = samplerFile%access, status = samplerFile%status, iostat = samplerFile%iostat, iomsg = samplerFile%iomsg SHARED)
2439 : end if
2440 : !block
2441 : !use pm_io, only: isOpen
2442 : !integer(IK) :: lenrec
2443 : !character(:), allocatable :: record
2444 : !select type (samplerFile)
2445 : !type is (chainFile_type)
2446 : ! associate(thisFile => samplerFile)
2447 : ! print *, "isOpen(thisFile%unit)", isOpen(thisFile%unit)
2448 : ! if (isOpen(thisFile%unit)) close(thisFile%unit)
2449 : ! open(newunit = thisFile%unit, file = thisFile%file, form = "unformatted", access = "stream", status = "old")
2450 : ! call setResized(record, 162_IK)
2451 : ! !read(thisFile%unit) record
2452 : ! !print *, record(1:1) == achar(0)
2453 : ! !print *, """"//record//""""
2454 : ! lenrec = 0_IK
2455 : ! do
2456 : ! lenrec = lenrec + 1_IK
2457 : ! print *, lenrec
2458 : ! if (len(record, IK) < lenrec) call setResized(record)
2459 : ! read(thisFile%unit) record(lenrec : lenrec)
2460 : ! if (record(lenrec : lenrec) /= achar(0)) cycle
2461 : ! lenrec = lenrec - 1_IK
2462 : ! exit
2463 : ! end do
2464 : !end associate
2465 : !end select
2466 : !end block
2467 52 : if (samplerFile%iostat /= 0_IK) then
2468 : ! LCOV_EXCL_START
2469 : if (spec%image%is%first .and. same_type_as(samplerFile, spec%reportFile) .and. present(msg) .and. .not. spec%outputSplashMode%is%silent) call spec%disp%note%show(getStripped(msg, NL1, right))
2470 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred while opening the "//spec%method%val//SKC_" *"//samplerFile%suffix//SKC_" file="""//samplerFile%file//SKC_""". "
2471 : if (scan(SKC_" ", samplerFile%file) /= 0_IK) then
2472 : err%msg = err%msg//& ! LCOV_EXCL_LINE
2473 : SKC_"It appears that absolute path used for the output files contains whitespace characters. This could be one potential cause of the simulation failure. &
2474 : &The whitespace characters are often problematic in paths. Ensure the path used for the output files does not contain whitespace characters."
2475 : end if
2476 : err%msg = err%msg//trim(samplerFile%iomsg)
2477 : err%occurred = .true._LK
2478 : ! LCOV_EXCL_STOP
2479 52 : elseif (spec%image%is%first .and. same_type_as(samplerFile, spec%reportFile)) Then
2480 13 : if (present(msg) .and. .not. spec%outputSplashMode%is%silent) call spec%disp%note%show(msg, bmsize = 0_IK)
2481 26 : block
2482 : use pm_arrayReplace, only: getReplaced
2483 : character(:,SKC), allocatable :: filelist
2484 : integer(IK) :: imageID
2485 13 : filelist = SKC_""
2486 26 : do imageID = 1, merge(spec%image%count, 1_IK, spec%parallelism%is%multiChain)
2487 26 : filelist = filelist//SKC_""""//getReplaced(spec%reportFile%file, spec%reportFile%suffix, replacement = getReplaced(spec%reportFile%suffix, SKC_"pid1", SKC_"pid"//getStr(imageID)))//SKC_""""//NL1
2488 : end do
2489 26 : if (.not. spec%outputSplashMode%is%silent) call spec%disp%note%show(filelist//NL1//SKC_"Please see the output *"//spec%reportFile%suffix//SKC_" and *"//spec%progressFile%suffix//SKC_" files for further realtime simulation details...", tmsize = 0_IK, bmsize = 1_IK)
2490 : end block
2491 : else
2492 39 : if (present(msg)) msg = msg//SKC_""""//samplerFile%file//SKC_""""//NL2
2493 : end if
2494 52 : end subroutine openFile
2495 :
2496 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2497 :
2498 120 : function isFailedResizeList(spec, newsize, errmsg) result(failed)
2499 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
2500 : !DEC$ ATTRIBUTES DLLEXPORT :: isFailedResizeList
2501 : #endif
2502 : class(specbase_type), intent(inout) :: spec
2503 : character(*,SKC), intent(out) :: errmsg
2504 : integer(IK), intent(in) :: newsize
2505 : logical(LK) :: failed
2506 24 : call setResized(spec%chainFile %list, newsize, failed = failed, errmsg = errmsg); if (failed) then; errmsg = MODULE_NAME//SK_"@isFailedResizeList(): "//getFine(__FILE__, __LINE__)//trim(errmsg); return; end if
2507 24 : call setResized(spec%sampleFile %list, newsize, failed = failed, errmsg = errmsg); if (failed) then; errmsg = MODULE_NAME//SK_"@isFailedResizeList(): "//getFine(__FILE__, __LINE__)//trim(errmsg); return; end if
2508 24 : call setResized(spec%reportFile %list, newsize, failed = failed, errmsg = errmsg); if (failed) then; errmsg = MODULE_NAME//SK_"@isFailedResizeList(): "//getFine(__FILE__, __LINE__)//trim(errmsg); return; end if
2509 24 : call setResized(spec%restartFile %list, newsize, failed = failed, errmsg = errmsg); if (failed) then; errmsg = MODULE_NAME//SK_"@isFailedResizeList(): "//getFine(__FILE__, __LINE__)//trim(errmsg); return; end if
2510 24 : call setResized(spec%progressFile %list, newsize, failed = failed, errmsg = errmsg); if (failed) then; errmsg = MODULE_NAME//SK_"@isFailedResizeList(): "//getFine(__FILE__, __LINE__)//trim(errmsg); return; end if
2511 24 : end function isFailedResizeList
2512 :
2513 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2514 :
2515 : ! The report method must exclusively contain reposting and no other tasks.
2516 13 : subroutine report(spec)
2517 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
2518 : !DEC$ ATTRIBUTES DLLEXPORT :: report
2519 : #endif
2520 : use pm_kind, only: SK
2521 : class(specbase_type), intent(inout) :: spec
2522 :
2523 13 : call spec%disp%text%wrap(NL1//spec%method%val//SKC_".simulation.specifications.base"//NL1)
2524 :
2525 : associate(ndim => spec%ndim%val, format => spec%reportFile%format%generic)
2526 :
2527 13 : call spec%disp%show("ndim")
2528 13 : call spec%disp%show(spec%ndim%val, format = format)
2529 13 : call spec%disp%note%show(spec%ndim%desc)
2530 :
2531 13 : call spec%disp%show("method")
2532 13 : call spec%disp%show(spec%method%val, format = format)
2533 13 : call spec%disp%note%show(spec%method%desc)
2534 :
2535 13 : call spec%disp%show("modelr")
2536 13 : call spec%disp%show(SK_" digits: "//getStr(spec%real% digits, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2537 13 : call spec%disp%show(SK_" kind: "//getStr(spec%real% kind, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2538 13 : call spec%disp%show(SK_" maxexponent: "//getStr(spec%real% maxexponent, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2539 13 : call spec%disp%show(SK_" minexponent: "//getStr(spec%real% minexponent, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2540 13 : call spec%disp%show(SK_" precision: "//getStr(spec%real% precision, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2541 13 : call spec%disp%show(SK_" radix: "//getStr(spec%real% radix, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2542 13 : call spec%disp%show(SK_" range: "//getStr(spec%real% range, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2543 13 : call spec%disp%show(SK_"storage_size: "//getStr(spec%real%storage_size, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2544 13 : call spec%disp%show(SK_" epsilon: "//getStr(spec%real% epsilon, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2545 13 : call spec%disp%show(SK_" huge: "//getStr(spec%real% huge, signed = .true._LK), format = format, tmsize = 0_IK, bmsize = 0_IK)
2546 13 : call spec%disp%show(SK_" tiny: "//getStr(spec%real% tiny, signed = .true._LK), format = format, tmsize = 0_IK)
2547 : !associate(modelr => spec%real)
2548 : !call spec%disp%show("modelr%digits", format = format, tmsize = 0_IK, bmsize = 0_IK)
2549 : !call spec%disp%show( modelr%digits , format = format, tmsize = 0_IK, bmsize = 0_IK)
2550 : !call spec%disp%show("modelr%kind", format = format, tmsize = 0_IK, bmsize = 0_IK)
2551 : !call spec%disp%show( modelr%kind , format = format, tmsize = 0_IK, bmsize = 0_IK)
2552 : !call spec%disp%show("modelr%maxexponent", format = format, tmsize = 0_IK, bmsize = 0_IK)
2553 : !call spec%disp%show( modelr%maxexponent , format = format, tmsize = 0_IK, bmsize = 0_IK)
2554 : !call spec%disp%show("modelr%minexponent", format = format, tmsize = 0_IK, bmsize = 0_IK)
2555 : !call spec%disp%show( modelr%minexponent , format = format, tmsize = 0_IK, bmsize = 0_IK)
2556 : !call spec%disp%show("modelr%precision", format = format, tmsize = 0_IK, bmsize = 0_IK)
2557 : !call spec%disp%show( modelr%precision , format = format, tmsize = 0_IK, bmsize = 0_IK)
2558 : !call spec%disp%show("modelr%radix", format = format, tmsize = 0_IK, bmsize = 0_IK)
2559 : !call spec%disp%show( modelr%radix , format = format, tmsize = 0_IK, bmsize = 0_IK)
2560 : !call spec%disp%show("modelr%range", format = format, tmsize = 0_IK, bmsize = 0_IK)
2561 : !call spec%disp%show( modelr%range , format = format, tmsize = 0_IK, bmsize = 0_IK)
2562 : !call spec%disp%show("modelr%storage_size", format = format, tmsize = 0_IK, bmsize = 0_IK)
2563 : !call spec%disp%show( modelr%storage_size , format = format, tmsize = 0_IK, bmsize = 0_IK)
2564 : !call spec%disp%show("modelr%epsilon", format = format, tmsize = 0_IK, bmsize = 0_IK)
2565 : !call spec%disp%show( modelr%epsilon , format = format, tmsize = 0_IK, bmsize = 0_IK)
2566 : !call spec%disp%show("modelr%huge", format = format, tmsize = 0_IK, bmsize = 0_IK)
2567 : !call spec%disp%show( modelr%huge , format = format, tmsize = 0_IK, bmsize = 0_IK)
2568 : !call spec%disp%show("modelr%tiny", format = format, tmsize = 0_IK, bmsize = 0_IK)
2569 : !call spec%disp%show( modelr%tiny , format = format, tmsize = 0_IK, bmsize = 0_IK)
2570 : !end associate
2571 13 : call spec%disp%note%show(spec%real%desc)
2572 :
2573 13 : call spec%disp%show("description")
2574 : !call spec%disp%show(spec%description%val, format = format)
2575 13 : call spec%disp%mark%show(spec%description%val)
2576 13 : call spec%disp%note%show(spec%description%desc)
2577 :
2578 13 : call spec%disp%show("domain")
2579 13 : call spec%disp%show(spec%domain%val, format = format)
2580 13 : call spec%disp%note%show(spec%domain%desc)
2581 :
2582 13 : call spec%disp%show("domainAxisName")
2583 39 : call spec%disp%show(reshape(spec%domainAxisName%val, [ndim, 1_IK]), format = format)
2584 13 : call spec%disp%note%show(spec%domainAxisName%desc)
2585 :
2586 13 : call spec%disp%show("domainBallCenter")
2587 39 : call spec%disp%show(reshape(spec%domainBallCenter%val, [ndim, 1_IK]), format = format)
2588 13 : call spec%disp%note%show(spec%domainBallCenter%desc)
2589 :
2590 13 : call spec%disp%show("domainBallCorMat")
2591 13 : call spec%disp%show(spec%domainBallCorMat%val, format = format)
2592 13 : call spec%disp%note%show(spec%domainBallCorMat%desc)
2593 :
2594 13 : call spec%disp%show("domainBallCovMat")
2595 13 : call spec%disp%show(spec%domainBallCovMat%val, format = format)
2596 13 : call spec%disp%note%show(spec%domainBallCovMat%desc)
2597 :
2598 13 : call spec%disp%show("domainBallStdVec")
2599 39 : call spec%disp%show(reshape(spec%domainBallStdVec%val, [ndim, 1_IK]), format = format)
2600 13 : call spec%disp%note%show(spec%domainBallStdVec%desc)
2601 :
2602 13 : call spec%disp%show("domainCubeLimitLower")
2603 39 : call spec%disp%show(reshape(spec%domainCubeLimitLower%val, [ndim, 1_IK]), format = format)
2604 13 : call spec%disp%note%show(spec%domainCubeLimitLower%desc)
2605 :
2606 13 : call spec%disp%show("domainCubeLimitUpper")
2607 39 : call spec%disp%show(reshape(spec%domainCubeLimitUpper%val, [ndim, 1_IK]), format = format)
2608 13 : call spec%disp%note%show(spec%domainCubeLimitUpper%desc)
2609 :
2610 13 : call spec%disp%show("domainErrCount")
2611 13 : call spec%disp%show(spec%domainErrCount%val, format = format)
2612 13 : call spec%disp%note%show(spec%domainErrCount%desc)
2613 :
2614 13 : call spec%disp%show("domainErrCountMax")
2615 13 : call spec%disp%show(spec%domainErrCountMax%val, format = format)
2616 13 : call spec%disp%note%show(spec%domainErrCountMax%desc)
2617 :
2618 13 : call spec%disp%show("inputFileHasPriority")
2619 13 : call spec%disp%show(spec%inputFileHasPriority%val, format = format)
2620 13 : call spec%disp%note%show(spec%inputFileHasPriority%desc)
2621 :
2622 13 : call spec%disp%show("outputChainFileFormat")
2623 13 : call spec%disp%show(spec%outputChainFileFormat%val, format = format)
2624 13 : call spec%disp%note%show(spec%outputChainFileFormat%desc)
2625 :
2626 13 : call spec%disp%show("outputColumnWidth")
2627 13 : call spec%disp%show(spec%outputColumnWidth%val, format = format)
2628 13 : call spec%disp%note%show(spec%outputColumnWidth%desc)
2629 :
2630 13 : call spec%disp%show("outputFileName")
2631 13 : call spec%disp%show(spec%outputFileName%val, format = format)
2632 13 : call spec%disp%note%show(spec%outputFileName%desc)
2633 :
2634 13 : call spec%disp%show("outputPrecision")
2635 13 : call spec%disp%show(spec%outputPrecision%val, format = format)
2636 13 : call spec%disp%note%show(spec%outputPrecision%desc)
2637 :
2638 13 : call spec%disp%show("outputReportPeriod")
2639 13 : call spec%disp%show(spec%outputReportPeriod%val, format = format)
2640 13 : call spec%disp%note%show(spec%outputReportPeriod%desc)
2641 :
2642 13 : call spec%disp%show("outputRestartFileFormat")
2643 13 : call spec%disp%show(spec%outputRestartFileFormat%val, format = format)
2644 13 : call spec%disp%note%show(spec%outputRestartFileFormat%desc)
2645 :
2646 13 : call spec%disp%show("outputSampleSize")
2647 13 : call spec%disp%show(spec%outputSampleSize%val, format = format)
2648 13 : call spec%disp%note%show(spec%outputSampleSize%desc)
2649 :
2650 13 : call spec%disp%show("outputSeparator")
2651 13 : call spec%disp%show(spec%outputSeparator%val, format = format)
2652 13 : call spec%disp%note%show(spec%outputSeparator%desc)
2653 :
2654 13 : call spec%disp%show("outputSplashMode")
2655 13 : call spec%disp%show(spec%outputSplashMode%val, format = format)
2656 13 : call spec%disp%note%show(spec%outputSplashMode%desc)
2657 :
2658 13 : call spec%disp%show("outputStatus")
2659 13 : call spec%disp%show(spec%outputStatus%val, format = format)
2660 13 : call spec%disp%note%show(spec%outputStatus%desc)
2661 :
2662 13 : call spec%disp%show("parallelism")
2663 13 : call spec%disp%show(spec%parallelism%val, format = format)
2664 13 : call spec%disp%note%show(spec%parallelism%desc)
2665 :
2666 13 : call spec%disp%show("parallelismMpiFinalizeEnabled")
2667 13 : call spec%disp%show(spec%parallelismMpiFinalizeEnabled%val, format = format)
2668 13 : call spec%disp%note%show(spec%parallelismMpiFinalizeEnabled%desc)
2669 :
2670 13 : call spec%disp%show("parallelismNumThread")
2671 13 : call spec%disp%show(spec%parallelismNumThread%val, format = format)
2672 13 : call spec%disp%note%show(spec%parallelismNumThread%desc)
2673 :
2674 : !call spec%disp%show("plang")
2675 : !call spec%disp%show(spec%plang%val, format = format)
2676 : !call spec%disp%note%show(spec%plang%desc)
2677 :
2678 13 : call spec%disp%show("randomSeed")
2679 13 : call spec%disp%show(spec%randomSeed%val, format = format)
2680 13 : call spec%disp%note%show(spec%randomSeed%desc)
2681 :
2682 : !call spec%disp%show("sysInfoFilePath")
2683 : !call spec%disp%show(spec%sysInfoFilePath%val, format = format)
2684 : !call spec%disp%note%show(spec%sysInfoFilePath%desc)
2685 :
2686 13 : call spec%disp%show("targetAcceptanceRate")
2687 13 : call spec%disp%show(reshape(spec%targetAcceptanceRate%val, [2, 1]), format = format)
2688 26 : call spec%disp%note%show(spec%targetAcceptanceRate%desc)
2689 :
2690 : end associate
2691 :
2692 13 : end subroutine report
2693 :
2694 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2695 :
2696 13 : subroutine sanitize(spec, err)
2697 : #if __INTEL_COMPILER && DLL_ENABLED && (_WIN32 || _WIN64)
2698 : !DEC$ ATTRIBUTES DLLEXPORT :: sanitize
2699 : #endif
2700 : use pm_err, only: err_type
2701 : type(err_type), intent(inout) :: err
2702 : class(specbase_type), intent(inout) :: spec
2703 : character(*,SKC), parameter :: PROCEDURE_NAME = MODULE_NAME//SKC_"@sanitize()"
2704 :
2705 : ndim_block: block
2706 13 : if (spec%ndim%val < 1_IK) then
2707 0 : err%occurred = .true._LK
2708 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2709 : &The input value for the specification `ndim` ("//spec%ndim%str//SKC_") must be a positive integer. &
2710 : &The specification `ndim` represents the number of dimensions of the domain of the objective function &
2711 0 : &to be explored via the user-specified exploration routine."
2712 : end if
2713 : end block ndim_block
2714 :
2715 : method_block: block
2716 13 : if (.not. (spec%method%isParaDRAM .or. spec%method%isParaDISE .or. spec%method%isParaNest)) then
2717 0 : err%occurred = .true._LK
2718 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Internal Error occurred. &
2719 0 : &The specified method name '"//spec%method%val//SKC_"' for the exploration routine does not match the internal list of method names."
2720 : end if
2721 : end block method_block
2722 :
2723 : description_block: block
2724 13 : if (spec%description%val == spec%description%null) then
2725 0 : err%occurred = .true._LK
2726 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. Internal library error detected. &
2727 0 : &The contents of `description` cannot be null-valued."
2728 : end if
2729 : end block description_block
2730 :
2731 : domain_block: block
2732 13 : if (.not. (spec%domain%isBall .or. spec%domain%isCube)) then
2733 0 : err%occurred = .true._LK
2734 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2735 : &Invalid requested value for the sampler domain. &
2736 : &The input requested domain model ("//spec%domain%val//SKC_") is not supported. &
2737 0 : &The input specification domain cannot be set to anything other than '"//spec%domain%cube//SKC_"', or '"//spec%domain%ball//SKC_"'"
2738 : end if
2739 : end block domain_block
2740 :
2741 : domainAxisName_block: block
2742 26 : character(len(spec%domainAxisName%val, IK),SKC) :: newval(size(spec%domainAxisName%val, 1, IK))
2743 : logical(LK) :: redefined
2744 : integer(IK) :: idim
2745 : redefined = .false._LK
2746 40 : do idim = 1, size(spec%domainAxisName%val, 1, IK)
2747 92 : if (any(spec%domainAxisName%val(idim) == spec%domainAxisName%val(1 : idim - 1)) .or. any(spec%domainAxisName%val(idim) == spec%domainAxisName%val(idim + 1:))) then
2748 0 : newval(idim) = trim(adjustl(spec%domainAxisName%val(idim)))//getStr(idim)
2749 : redefined = .true._LK
2750 : else
2751 27 : newval(idim) = spec%domainAxisName%val(idim)
2752 : end if
2753 : end do
2754 13 : if (redefined) spec%domainAxisName%val(:) = newval
2755 : end block domainAxisName_block
2756 :
2757 : domainBallCenter_block: block
2758 40 : if (.not. all(-huge(0._RKC) < spec%domainBallCenter%val .and. spec%domainBallCenter%val < huge(0._RKC))) then
2759 0 : err%occurred = .true._LK
2760 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2761 0 : &The specified values for `domainBallCenter` must be all finite: "//getStr(spec%domainBallCenter%val)//SKC_"'"
2762 : end if
2763 : end block domainBallCenter_block
2764 :
2765 : domainBallCorMat_block: block
2766 : use pm_matrixClass, only: posdefmat
2767 : use pm_matrixClass, only: isMatClass
2768 : ! There is no need to check for eyeness of the input correlation matrix. Only positive definiteness is enough.
2769 : ! If the input correlation matrix is problematic, it will eventually lead to a non-positive-definite covariance matrix.
2770 13 : if (.not. isMatClass(spec%domainBallCorMat%val, posdefmat)) then
2771 0 : err%occurred = .true._LK ! This must be set only when .true.
2772 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The input requested `domainBallCorMat` for defining the &
2773 0 : &domain of the objective function passed to the sampler is not a positive-definite matrix: "//getStr(spec%domainBallCorMat%val)
2774 : end if
2775 : end block domainBallCorMat_block
2776 :
2777 : domainBallCovMat_block: block
2778 : use pm_matrixInv, only: setMatInv, choUpp
2779 : use pm_matrixTrace, only: getMatMulTraceLog
2780 : use pm_matrixChol, only: setMatChol, transHerm, lowDia
2781 : real(RKC), allocatable :: chol(:,:)
2782 : integer(IK) :: info
2783 13 : if (spec%domain%isFinite) then
2784 27 : call setResized(chol, [spec%ndim%val, spec%ndim%val])
2785 27 : call setResized(spec%domainBallCovMat%inv, [spec%ndim%val, spec%ndim%val])
2786 9 : call setMatChol(spec%domainBallCovMat%val, lowDia, info, chol, transHerm)
2787 9 : if (info /= 0_IK) then
2788 0 : err%occurred = .true._LK ! This must be set only when .true.
2789 : err%msg = err%msg//&
2790 : PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The input requested `domainBallCovMat` for defining the domain &
2791 0 : &of the objective function passed to the sampler is not a positive-definite matrix :"//getStr(spec%domainBallCovMat%val)
2792 : end if
2793 9 : spec%domain%logVol = getMatMulTraceLog(chol)
2794 9 : call setMatInv(spec%domainBallCovMat%inv, chol, choUpp)
2795 : end if
2796 : end block domainBallCovMat_block
2797 :
2798 : domainBallStdVec_block: block
2799 : integer(IK) :: idim
2800 40 : do idim = 1, size(spec%domainBallStdVec%val, 1, IK)
2801 40 : if (spec%domainBallStdVec%val(idim) <= 0._RKC) then
2802 0 : err%occurred = .true._LK
2803 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2804 : &The input requested value ("//getStr(spec%domainBallStdVec%val(idim))//SKC_") for the component `"//getStr(idim)//&
2805 0 : SKC_"` of the input specification `domainBallStdVec` of the simulation must be a positive real number."
2806 : end if
2807 : end do
2808 : end block domainBallStdVec_block
2809 :
2810 : domainCubeLimitLower_block: block
2811 : integer(IK) :: idim
2812 40 : if (.not. all(-huge(0._RKC) < spec%domainCubeLimitLower%val .and. spec%domainCubeLimitLower%val < huge(0._RKC))) then
2813 0 : err%occurred = .true._LK
2814 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2815 0 : &The specified values for `domainCubeLimitLower` must be all finite: "//getStr(spec%domainCubeLimitLower%val)//SKC_"'"
2816 : end if
2817 : ! domainCubeLimitLower must be all less than domainCubeLimitUpper.
2818 40 : do idim = 1, size(spec%domainCubeLimitUpper%val(:), 1, IK)
2819 40 : if (spec%domainCubeLimitUpper%val(idim) <= spec%domainCubeLimitLower%val(idim)) then
2820 0 : err%occurred = .true._LK
2821 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2822 : &The input value for the upper limit of the component "//getStr(idim)//SKC_" of the &
2823 : &variable domainCubeLimitUpper cannot be smaller than or equal to the input value &
2824 : &for the lower limit of the corresponding dimension as given by domainCubeLimitLower:"//NL1//&
2825 : SKC_" domainCubeLimitLower("//getStr(idim)//SKC_") = "//getStr(spec%domainCubeLimitLower%val(idim))//NL1//&
2826 0 : SKC_" domainCubeLimitUpper("//getStr(idim)//SKC_") = "//getStr(spec%domainCubeLimitUpper%val(idim))
2827 : end if
2828 : end do
2829 : end block domainCubeLimitLower_block
2830 :
2831 : domainCubeLimitUpper_block: block
2832 40 : if (.not. all(-huge(0._RKC) < spec%domainCubeLimitUpper%val .and. spec%domainCubeLimitUpper%val < huge(0._RKC))) then
2833 0 : err%occurred = .true._LK
2834 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2835 0 : &The specified values for `domainCubeLimitUpper` must be all finite: "//getStr(spec%domainCubeLimitUpper%val)//SKC_"'"
2836 : end if
2837 : end block domainCubeLimitUpper_block
2838 :
2839 : domainErrCount_block: block
2840 13 : if (spec%domainErrCount%val < 1_IK) then
2841 0 : err%occurred = .true._LK
2842 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2843 : &The input value for variable `domainErrCount` must be a positive integer. If you are unsure &
2844 : &about the appropriate value for this variable, simply drop it from the input. &
2845 0 : &The sampler will automatically assign an appropriate value to it."
2846 : end if
2847 : end block domainErrCount_block
2848 :
2849 : domainErrCountMax_block: block
2850 13 : if (spec%domainErrCountMax%val < 1_IK) then
2851 0 : err%occurred = .true._LK
2852 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2853 : &The input value for variable `domainErrCountMax` must be a positive integer. &
2854 : &If you are unsure about the appropriate value for this variable, simply drop it from the input. &
2855 0 : &The sampler will automatically assign an appropriate value to it."
2856 : end if
2857 : end block domainErrCountMax_block
2858 :
2859 : !inputFileHasPriority_block: block
2860 : !end block inputFileHasPriority_block
2861 :
2862 : outputChainFileFormat_block: block
2863 13 : if (.not.(spec%outputChainFileFormat%isCompact .or. spec%outputChainFileFormat%isVerbose .or. spec%outputChainFileFormat%isBinary)) then
2864 0 : err%occurred = .true._LK
2865 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The input requested chain file format ('"//spec%outputChainFileFormat%val//&
2866 : SKC_"') contained within the simulation specification `outputChainFileFormat` cannot be anything other than '"//&
2867 : spec%outputChainFileFormat%compact//SKC_"' or '"//spec%outputChainFileFormat%verbose//SKC_"' or '"//spec%outputChainFileFormat%binary//SKC_"'. If you do not &
2868 : &know an appropriate value for outputChainFileFormat, drop it from the input list. &
2869 0 : &The sampler will automatically assign an appropriate value to it."
2870 : end if
2871 : end block outputChainFileFormat_block
2872 :
2873 : outputColumnWidth_block: block
2874 13 : if (spec%outputColumnWidth%val < 0_IK) then
2875 0 : err%occurred = .true._LK
2876 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2877 : &The input value for variable `outputColumnWidth` must be a non-negative integer. &
2878 : &If you are unsure about the appropriate value for this variable, simply drop it from the input. &
2879 0 : &The sampler will automatically assign an appropriate value to it."
2880 13 : elseif (0_IK < spec%outputColumnWidth%val .and. spec%outputColumnWidth%val < spec%outputPrecision%val + 7_IK) then
2881 0 : err%occurred = .true._LK
2882 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The input value for variable &
2883 : &`outputColumnWidth` must be equal to or greater than the input value for `outputPrecision + 7`. &
2884 : &If you are unsure about the appropriate value for this variable, either set it to zero on input, &
2885 0 : &or simply drop it from the input. The sampler will automatically assign an appropriate value to it."
2886 : end if
2887 : end block outputColumnWidth_block
2888 :
2889 : outputFileName_block: block
2890 : ! Ideally there should be a test here to ensure the prefix contains only valid characters.
2891 13 : if (spec%outputFileName%val == SKC_"") then
2892 0 : err%occurred = .true._LK
2893 : err%msg = err%msg//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2894 0 : &The input value for variable outputFileName cannot be empty."
2895 : end if
2896 : end block outputFileName_block
2897 :
2898 : outputStatus_block: block
2899 13 : if (.not. (spec%outputStatus%is%extend .or. spec%outputStatus%is%retry)) then
2900 0 : err%occurred = .true._LK
2901 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The specified chain file format ('"//spec%outputStatus%val//&
2902 : SKC_"') via `outputStatus` cannot be anything other than 'retry', 'extend', 'copy-retry', or 'copy-extend'. &
2903 : &If you do not know an appropriate value for `outputStatus`, drop it from the input list. &
2904 0 : &The sampler will automatically assign an appropriate value to it."
2905 : end if
2906 : end block outputStatus_block
2907 :
2908 : outputPrecision_block: block
2909 13 : if (spec%outputPrecision%val < 1_IK) then
2910 0 : err%occurred = .true._LK
2911 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2912 : &The input value for variable `outputPrecision` must be a positive integer. &
2913 : &If you are unsure about the appropriate value for this variable, simply drop it from the input. &
2914 0 : &The sampler will automatically assign an appropriate value to it."
2915 : end if
2916 : end block outputPrecision_block
2917 :
2918 : outputReportPeriod_block: block
2919 13 : if (spec%outputReportPeriod%val < 1_IK) then
2920 0 : err%occurred = .true._LK
2921 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2922 : &The input value for variable outputReportPeriod must be a positive integer value. &
2923 : &If you are unsure about the appropriate value for this variable, simply drop it from the input. &
2924 0 : &The sampler will automatically assign an appropriate value to it."
2925 : else
2926 13 : spec%outputReportPeriod%inv = 1._RKC / spec%outputReportPeriod%val
2927 : end if
2928 : end block outputReportPeriod_block
2929 :
2930 : outputRestartFileFormat_block: block
2931 13 : if (.not. (spec%outputRestartFileFormat%isBinary .or. spec%outputRestartFileFormat%isAscii)) then
2932 0 : err%occurred = .true._LK
2933 : err%msg = err%msg//PROCEDURE_NAME//SKC_"@sanitize(): Error occurred. &
2934 : &The input requested restart file format ('"//spec%outputRestartFileFormat%val//&
2935 : SKC_"') represented by the variable `outputRestartFileFormat` cannot be anything other than '"//&
2936 : spec%outputRestartFileFormat%binary//SKC_"' or '"//spec%outputRestartFileFormat%ascii//SKC_"'. &
2937 : &If you are unsure about an appropriate value for `outputRestartFileFormat`, drop it from the input list. &
2938 0 : &The sampler will automatically assign an appropriate value to it."
2939 : end if
2940 : end block outputRestartFileFormat_block
2941 :
2942 : outputSampleSize_block: block
2943 13 : if (.not. abs(spec%outputSampleSize%val) < huge(0_IK)) then
2944 0 : err%occurred = .true._LK
2945 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2946 : &The input value for `outputSampleSize` cannot be larger than the largest representable integer. &
2947 : &If you are unsure of an appropriate value for this variable, simply drop it from the input. &
2948 0 : &The sampler will automatically assign an appropriate value to it."
2949 : end if
2950 : end block outputSampleSize_block
2951 :
2952 13 : outputSeparator_block: block
2953 : use pm_strASCII, only: isCharDigit
2954 : character(:,SKC), allocatable :: separator
2955 : integer(IK) :: separatorLen, i
2956 13 : separator = trim(adjustl(spec%outputSeparator%val))
2957 13 : separatorLen = len(separator, IK)
2958 52 : do i = 1_IK, separatorLen
2959 26 : if (isCharDigit(separator(i:i)) .or. separator(i:i) == SKC_"." .or. separator(i:i) == SKC_"-" .or. separator(i:i) == SKC_"+") then
2960 0 : err%occurred = .true._LK
2961 : err%msg = err%msg//NL2//PROCEDURE_NAME//SKC_"@sanitize(): Error occurred. &
2962 : &The input value for variable outputSeparator cannot contain any digits or the period symbol '.' or '-' &
2963 : &or '+'. If you are unsure about the appropriate value for this variable, simply drop it from the input. &
2964 0 : &The sampler will automatically assign an appropriate value to it."
2965 : exit
2966 : end if
2967 : end do
2968 : end block outputSeparator_block
2969 :
2970 : outputSplashMode_block: block
2971 13 : if (.not. (spec%outputSplashMode%is%normal .or. spec%outputSplashMode%is%silent .or. spec%outputSplashMode%is%quiet)) then
2972 0 : err%occurred = .true._LK
2973 : err%msg = err%msg//NL2//PROCEDURE_NAME//SKC_"@sanitize(): Error occurred. &
2974 : &The input requested splash mode ('"//spec%outputSplashMode%val//&
2975 : SKC_"') represented by the variable `outputSplashMode` cannot be anything other than '"//&
2976 : spec%outputSplashMode%normal//SKC_"' or '"//spec%outputSplashMode%quiet//SKC_"' or '"//spec%outputSplashMode%silent//SKC_"'. &
2977 : &If you are unsure about an appropriate value for `outputSplashMode`, drop it from the input list. &
2978 0 : &The sampler will automatically assign an appropriate value to it."
2979 : end if
2980 : end block outputSplashMode_block
2981 :
2982 : parallelism_block: block
2983 13 : if (.not.(spec%parallelism%is%singleChain .or. spec%parallelism%is%multiChain)) then
2984 0 : err%occurred = .true._LK
2985 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
2986 : &The input requested parallelization method ("//spec%parallelism%val//&
2987 : SKC_") represented by variable `parallelism` cannot be anything other than &
2988 : &'"//spec%parallelism%singleChain//SKC_"' or '"//spec%parallelism%multiChain//SKC_"'. If you are unsure about &
2989 : &the appropriate value for `parallelism`, drop it from the input list. &
2990 0 : &The sampler will automatically assign an appropriate value to it."
2991 : end if
2992 13 : spec%parallelism%is%forkJoin = spec%parallelism%is%singleChain .and. 1_IK < spec%image%count
2993 : end block parallelism_block
2994 :
2995 : parallelismMpiFinalizeEnabled_block: block
2996 : end block parallelismMpiFinalizeEnabled_block
2997 :
2998 : parallelismNumThread_block: block
2999 : #if OMP_ENABLED
3000 : if (spec%parallelismNumThread%val < 0_IK) then
3001 : err%occurred = .true._LK
3002 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
3003 : &The input value for the specification `parallelismNumThread` ("//getStr(spec%parallelismNumThread%val)//SKC_") must be a non-negative integer. &
3004 : &The specification `parallelismNumThread` represents the number of shared-memory CPU threads over which multiple parallel evaluations of the &
3005 : &objective function must be done. This specification is relevant only to OpenMP-enabled parallel simulations in C, C++, and Fortran, &
3006 : &and shared-memory non-MPI parallel simulations in higher-level programming languages such as MATLAB, Python, or R. &
3007 : &Specifying `0` leads to using all available CPU threads for the requested simulation task."
3008 : end if
3009 : #endif
3010 : end block parallelismNumThread_block
3011 :
3012 : !plang_block: block
3013 : !end block plang_block
3014 :
3015 : randomSeed_block: block
3016 13 : if (spec%randomSeed%val < 1_IK) then
3017 0 : err%occurred = .true._LK
3018 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. &
3019 : &The input value for `randomSeed` ("//getStr(spec%randomSeed%val)//SKC_") must be a positive integer. &
3020 : &If you are unsure about the appropriate value for this variable, simply drop it from the input. &
3021 0 : &The sampler will automatically assign an appropriate value to it."
3022 : end if
3023 : end block randomSeed_block
3024 :
3025 : sysInfoFilePath_block: block
3026 : end block sysInfoFilePath_block
3027 :
3028 : targetAcceptanceRate_block: block
3029 78 : if (any(spec%targetAcceptanceRate%val < 0._RKC) .or. any(1._RKC < spec%targetAcceptanceRate%val)) then
3030 0 : err%occurred = .true._LK
3031 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The target acceptance ratio limits `targetAcceptanceRate` ["//&
3032 0 : getStr(spec%targetAcceptanceRate%val(1))//SKC_", "//getStr(spec%targetAcceptanceRate%val(2))//SKC_"] cannot be less than 0 or larger than 1."
3033 : end if
3034 39 : if (all(spec%targetAcceptanceRate%val == 0._RKC) .or. all(spec%targetAcceptanceRate%val == 1._RKC)) then
3035 0 : err%occurred = .true._LK
3036 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The target acceptance ratio limits targetAcceptanceRate ["//&
3037 0 : getStr(spec%targetAcceptanceRate%val(1))//SKC_", "//getStr(spec%targetAcceptanceRate%val(2))//SKC_"] cannot be both 0 or both 1."
3038 : end if
3039 13 : if (spec%targetAcceptanceRate%val(2) < spec%targetAcceptanceRate%val(1)) then
3040 0 : err%occurred = .true._LK
3041 : err%msg = err%msg//NL2//PROCEDURE_NAME//getFine(__FILE__, __LINE__)//SKC_": Error occurred. The the lower limit of the input specification targetAcceptanceRate ["//&
3042 0 : getStr(spec%targetAcceptanceRate%val(1))//SKC_","//getStr(spec%targetAcceptanceRate%val(2))//SKC_"] cannot be larger than the specified upper limit."
3043 : end if
3044 : end block targetAcceptanceRate_block
3045 :
3046 26 : if (spec%domain%isCube .and. spec%domain%isFinite) spec%domain%logVol = sum(log(spec%domainCubeLimitUpper%val - spec%domainCubeLimitLower%val))
3047 :
3048 13 : end subroutine sanitize
3049 :
3050 : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3051 :
3052 : #undef SHARED
|