ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
test_pm_val2str.F90
Go to the documentation of this file.
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
19
21
22 use pm_val2str
23 use pm_test, only: test_type, LK
24 implicit none
25
26 private
27 public :: setTest
28 type(test_type) :: test
29
30!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31
32 interface
33
34 module function test_getStr_SK_1 () result(assertion); logical(LK) :: assertion; end function
35 module function test_getStr_LK_1 () result(assertion); logical(LK) :: assertion; end function
36#if RK3_ENABLED
37 module function test_getStr_RK3_1 () result(assertion); logical(LK) :: assertion; end function
38#endif
39#if RK2_ENABLED
40 module function test_getStr_RK2_1 () result(assertion); logical(LK) :: assertion; end function
41#endif
42#if RK1_ENABLED
43 module function test_getStr_RK1_1 () result(assertion); logical(LK) :: assertion; end function
44#endif
45#if CK3_ENABLED
46 module function test_getStr_CK3_1 () result(assertion); logical(LK) :: assertion; end function
47#endif
48#if CK2_ENABLED
49 module function test_getStr_CK2_1 () result(assertion); logical(LK) :: assertion; end function
50#endif
51#if CK1_ENABLED
52 module function test_getStr_CK1_1 () result(assertion); logical(LK) :: assertion; end function
53#endif
54#if IK4_ENABLED
55 module function test_getStr_IK4_1 () result(assertion); logical(LK) :: assertion; end function
56#endif
57#if IK3_ENABLED
58 module function test_getStr_IK3_1 () result(assertion); logical(LK) :: assertion; end function
59#endif
60#if IK2_ENABLED
61 module function test_getStr_IK2_1 () result(assertion); logical(LK) :: assertion; end function
62#endif
63#if IK1_ENABLED
64 module function test_getStr_IK1_1 () result(assertion); logical(LK) :: assertion; end function
65#endif
66
67 end interface
68
69!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
70
71contains
72
73!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74
75 subroutine setTest()
76
77 implicit none
78
80
81 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82
83 call test%run(test_getStr_SK_1 , SK_"test_getStr_SK_1")
84 call test%run(test_getStr_LK_1 , SK_"test_getStr_LK_1")
85
86 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
87
88#if RK3_ENABLED
89 call test%run(test_getStr_RK3_1, SK_"test_getStr_RK3_1")
90#endif
91#if RK2_ENABLED
92 call test%run(test_getStr_RK2_1, SK_"test_getStr_RK2_1")
93#endif
94#if RK1_ENABLED
95 call test%run(test_getStr_RK1_1, SK_"test_getStr_RK1_1")
96#endif
97
98 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99
100#if CK3_ENABLED
101 call test%run(test_getStr_CK3_1, SK_"test_getStr_CK3_1")
102#endif
103#if CK2_ENABLED
104 call test%run(test_getStr_CK2_1, SK_"test_getStr_CK2_1")
105#endif
106#if CK1_ENABLED
107 call test%run(test_getStr_CK1_1, SK_"test_getStr_CK1_1")
108#endif
109
110 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111
112#if IK4_ENABLED
113 call test%run(test_getStr_IK4_1, SK_"test_getStr_IK4_1")
114#endif
115#if IK3_ENABLED
116 call test%run(test_getStr_IK3_1, SK_"test_getStr_IK3_1")
117#endif
118#if IK2_ENABLED
119 call test%run(test_getStr_IK2_1, SK_"test_getStr_IK2_1")
120#endif
121#if IK1_ENABLED
122 call test%run(test_getStr_IK1_1 , SK_"test_getStr_IK1_1")
123#endif
124
125 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
126
127 call test%summarize()
128
129 end subroutine setTest
130
131!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132
133! function test_getStr_IK3_1() result(assertion)
134! use pm_kind, only: IK => IK3
135! implicit none
136! logical :: assertion
137! character(*), parameter :: this_ref = "12345"
138! integer(IK) , parameter :: this_int = 12345_IK
139! character(:), allocatable :: this
140! this = getStr(this_int)
141! assertion = this == this_ref .and. len(this) == len(this_ref)
142! if (test%traceable .and. .not. assertion) then
143! ! LCOV_EXCL_START
144! write(test%disp%unit,"(*(g0))")
145! write(test%disp%unit,"(*(g0))") "this_ref = '", this_ref, "'"
146! write(test%disp%unit,"(*(g0))") "this_str = " , this_int
147! write(test%disp%unit,"(*(g0))") "this = '", this, "'"
148! write(test%disp%unit,"(*(g0))")
149! end if
150! ! LCOV_EXCL_STOP
151! end function test_getStr_IK3_1
152!
153!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
154!
155! function test_getStr_IK3_2() result(assertion)
156! use pm_kind, only: IK => IK3
157! implicit none
158! logical :: assertion
159! character(*), parameter :: this_ref = "0000012345"
160! integer(IK) , parameter :: this_int = 12345_IK
161! character(:), allocatable :: this
162! this = getStr(this_int,"(1I10.10)")
163! assertion = this == this_ref .and. len(this) == len(this_ref)
164! if (test%traceable .and. .not. assertion) then
165! ! LCOV_EXCL_START
166! write(test%disp%unit,"(*(g0))")
167! write(test%disp%unit,"(*(g0))") "this_ref = '", this_ref, "'"
168! write(test%disp%unit,"(*(g0))") "this_str = " , this_int
169! write(test%disp%unit,"(*(g0))") "this = '", this, "'"
170! write(test%disp%unit,"(*(g0))")
171! end if
172! ! LCOV_EXCL_STOP
173! end function test_getStr_IK3_2
174!
175!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176!
177! function test_getStr_IK3_3() result(assertion)
178! use pm_kind, only: IK => IK3
179! implicit none
180! logical :: assertion
181! character(*), parameter :: this_ref = "12345 "
182! integer(IK) , parameter :: this_int = 12345_IK
183! character(:), allocatable :: this
184! this = getStr(this_int,len=10_IK)
185! assertion = this == this_ref .and. len(this) == len(this_ref)
186! if (test%traceable .and. .not. assertion) then
187! ! LCOV_EXCL_START
188! write(test%disp%unit,"(*(g0))")
189! write(test%disp%unit,"(*(g0))") "this_ref = '", this_ref, "'"
190! write(test%disp%unit,"(*(g0))") "this_str = " , this_int
191! write(test%disp%unit,"(*(g0))") "this = '", this, "'"
192! write(test%disp%unit,"(*(g0))")
193! end if
194! ! LCOV_EXCL_STOP
195! end function test_getStr_IK3_3
196!
197!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
198!
199! function test_getStr_IK4_1() result(assertion)
200! use pm_kind, only: IK4
201! logical :: assertion
202! character(*, SK), parameter :: this_ref = "98765432112345"
203! integer(IK4) , parameter :: this_int = 98765432112345_IK4
204! character(:, SK), allocatable :: this
205! this = getStr(this_int)
206! assertion = this == this_ref .and. len(this) == len(this_ref)
207! if (test%traceable .and. .not. assertion) then
208! ! LCOV_EXCL_START
209! write(test%disp%unit,"(*(g0))")
210! write(test%disp%unit,"(*(g0))") "this_ref = '", this_ref, "'"
211! write(test%disp%unit,"(*(g0))") "this_str = " , this_int
212! write(test%disp%unit,"(*(g0))") "this = '", this, "'"
213! write(test%disp%unit,"(*(g0))")
214! end if
215! ! LCOV_EXCL_STOP
216! end function test_getStr_IK4_1
217!
218!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219!
220! function test_getStr_IK4_2() result(assertion)
221! use pm_kind, only: IK4
222! implicit none
223! logical :: assertion
224! character(*, SK), parameter :: this_ref = "00000098765432112345"
225! integer(IK4) , parameter :: this_int = 98765432112345_IK4
226! character(:, SK), allocatable :: this
227! this = getStr(this_int,"(1I20.20)")
228! assertion = this == this_ref .and. len(this) == len(this_ref)
229! if (test%traceable .and. .not. assertion) then
230! ! LCOV_EXCL_START
231! write(test%disp%unit,"(*(g0))")
232! write(test%disp%unit,"(*(g0))") "this_ref = '", this_ref, "'"
233! write(test%disp%unit,"(*(g0))") "this_str = " , this_int
234! write(test%disp%unit,"(*(g0))") "this = '", this, "'"
235! write(test%disp%unit,"(*(g0))")
236! end if
237! ! LCOV_EXCL_STOP
238! end function test_getStr_IK4_2
239!
240!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241!
242! function test_getStr_IK4_3() result(assertion)
243! use pm_kind, only: IK4
244! logical :: assertion
245! character(*, SK), parameter :: this_ref = "98765432112345 "
246! integer(IK4) , parameter :: this_int = 98765432112345_IK4
247! character(:, SK), allocatable :: this
248! this = getStr(this_int,len=20_IK)
249! assertion = this == this_ref .and. len(this) == len(this_ref)
250! if (test%traceable .and. .not. assertion) then
251! ! LCOV_EXCL_START
252! write(test%disp%unit,"(*(g0))")
253! write(test%disp%unit,"(*(g0))") "this_ref = '", this_ref, "'"
254! write(test%disp%unit,"(*(g0))") "this_str = " , this_int
255! write(test%disp%unit,"(*(g0))") "this = '", this, "'"
256! write(test%disp%unit,"(*(g0))")
257! ! LCOV_EXCL_STOP
258! end if
259! end function test_getStr_IK4_3
260!
261!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262!
263! function test_getStr_RK1_1() result(assertion)
264! use pm_kind, only: RK => RK1
265! use pm_str2val, only: real32
266! logical :: assertion
267! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
268! real(RK) :: this
269! this = real32( getStr(this_ref) )
270! assertion = this == this_ref
271! if (test%traceable .and. .not. assertion) then
272! ! LCOV_EXCL_START
273! write(test%disp%unit,"(*(g0))")
274! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
275! write(test%disp%unit,"(*(g0))") "this = ", this
276! write(test%disp%unit,"(*(g0))")
277! ! LCOV_EXCL_STOP
278! end if
279! end function test_getStr_RK1_1
280!
281!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282!
283! function test_getStr_RK1_2() result(assertion)
284! use pm_kind, only: RK => RK1
285! use pm_str2val, only: real32
286! logical :: assertion
287! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
288! real(RK) :: this
289! this = real32( getStr(this_ref,"(g0)") )
290! assertion = this == this_ref
291! if (test%traceable .and. .not. assertion) then
292! ! LCOV_EXCL_START
293! write(test%disp%unit,"(*(g0))")
294! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
295! write(test%disp%unit,"(*(g0))") "this = ", this
296! write(test%disp%unit,"(*(g0))")
297! ! LCOV_EXCL_STOP
298! end if
299! end function test_getStr_RK1_2
300!
301!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302!
303! function test_getStr_RK1_3() result(assertion)
304! use pm_kind, only: RK => RK1
305! use pm_str2val, only: real32
306! implicit none
307! logical :: assertion
308! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
309! real(RK) :: this
310! this = real32( getStr(this_ref,"(g0)",20) )
311! assertion = this == this_ref
312! if (test%traceable .and. .not. assertion) then
313! ! LCOV_EXCL_START
314! write(test%disp%unit,"(*(g0))")
315! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
316! write(test%disp%unit,"(*(g0))") "this = ", this
317! write(test%disp%unit,"(*(g0))")
318! end if
319! ! LCOV_EXCL_STOP
320! end function test_getStr_RK1_3
321!
322!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323!
324! !> \brief
325! !> The input `len` can be larger than the length of the constructed string.
326! function test_getStr_RK1_4() result(assertion)
327! use pm_kind, only: RK => RK1, IK => IK3
328! use pm_str2val, only: real32
329! logical :: assertion
330! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
331! real(RK) :: this
332! this = real32( getStr(this_ref,"(g0)",263_IK) )
333! assertion = this == this_ref
334! if (test%traceable .and. .not. assertion) then
335! ! LCOV_EXCL_START
336! write(test%disp%unit,"(*(g0))")
337! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
338! write(test%disp%unit,"(*(g0))") "this = ", this
339! write(test%disp%unit,"(*(g0))")
340! ! LCOV_EXCL_STOP
341! end if
342! end function test_getStr_RK1_4
343!
344!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
345!
346! function test_getStr_RK2_1() result(assertion)
347! use pm_kind, only: RK => RK2
348! use pm_str2val, only: real64
349! logical :: assertion
350! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
351! real(RK) :: this
352! this = real64( getStr(this_ref) )
353! assertion = this == this_ref
354! if (test%traceable .and. .not. assertion) then
355! ! LCOV_EXCL_START
356! write(test%disp%unit,"(*(g0))")
357! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
358! write(test%disp%unit,"(*(g0))") "this = ", this
359! write(test%disp%unit,"(*(g0))")
360! ! LCOV_EXCL_STOP
361! end if
362! end function test_getStr_RK2_1
363!
364!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
365!
366! function test_getStr_RK2_2() result(assertion)
367! use pm_kind, only: RK => RK2
368! use pm_str2val, only: real64
369! logical :: assertion
370! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
371! real(RK) :: this
372! this = real64( getStr(this_ref,"(g0)") )
373! assertion = this == this_ref
374! if (test%traceable .and. .not. assertion) then
375! ! LCOV_EXCL_START
376! write(test%disp%unit,"(*(g0))")
377! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
378! write(test%disp%unit,"(*(g0))") "this = ", this
379! write(test%disp%unit,"(*(g0))")
380! ! LCOV_EXCL_STOP
381! end if
382! end function test_getStr_RK2_2
383!
384!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
385!
386! function test_getStr_RK2_3() result(assertion)
387! use pm_kind, only: RK => RK2, IK => IK3
388! use pm_str2val, only: real64
389! logical :: assertion
390! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
391! real(RK) :: this
392! this = real64( getStr(this_ref,"(g0)",30_IK) )
393! assertion = this == this_ref
394! if (test%traceable .and. .not. assertion) then
395! ! LCOV_EXCL_START
396! write(test%disp%unit,"(*(g0))")
397! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
398! write(test%disp%unit,"(*(g0))") "this = ", this
399! write(test%disp%unit,"(*(g0))")
400! ! LCOV_EXCL_STOP
401! end if
402! end function test_getStr_RK2_3
403!
404!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405!
406! !> \brief
407! !> The input `len` can be larger than the length of the constructed string.
408! function test_getStr_RK2_4() result(assertion)
409! use pm_kind, only: RK => RK2, IK => IK3
410! use pm_str2val, only: real64
411! logical :: assertion
412! real(RK) , parameter :: this_ref = 1.23456798e-30_RK
413! real(RK) :: this
414! this = real64( getStr(this_ref,"(g0)",263_IK) )
415! assertion = this == this_ref
416! if (test%traceable .and. .not. assertion) then
417! ! LCOV_EXCL_START
418! write(test%disp%unit,"(*(g0))")
419! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
420! write(test%disp%unit,"(*(g0))") "this = ", this
421! write(test%disp%unit,"(*(g0))")
422! ! LCOV_EXCL_STOP
423! end if
424! end function test_getStr_RK2_4
425!
426!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427!
428! function test_getStr_RK2_D1_1() result(assertion)
429! use pm_kind, only: RK => RK2
430! logical :: assertion
431! integer(IK) , parameter :: nthis = 2
432! real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
433! real(RK) :: this(nthis)
434! character(:), allocatable :: string
435! assertion = .true.
436! string = getStr(this_ref)
437! read(string,*) this
438! assertion = all(this == this_ref)
439! if (test%traceable .and. .not. assertion) then
440! ! LCOV_EXCL_START
441! write(test%disp%unit,"(*(g0))")
442! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
443! write(test%disp%unit,"(*(g0))") "this = ", this
444! write(test%disp%unit,"(*(g0))")
445! ! LCOV_EXCL_STOP
446! end if
447! end function test_getStr_RK2_D1_1
448!
449!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450!
451! function test_getStr_RK2_D1_2() result(assertion)
452! use pm_kind, only: RK => RK2
453! logical :: assertion
454! integer(IK) , parameter :: nthis = 2
455! real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
456! real(RK) :: this(nthis)
457! character(:), allocatable :: string
458! assertion = .true.
459! string = getStr(this_ref,"(*(g0,:,' '))")
460! read(string,*) this
461! assertion = all(this == this_ref)
462! if (test%traceable .and. .not. assertion) then
463! ! LCOV_EXCL_START
464! write(test%disp%unit,"(*(g0))")
465! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
466! write(test%disp%unit,"(*(g0))") "this = ", this
467! write(test%disp%unit,"(*(g0))")
468! ! LCOV_EXCL_STOP
469! end if
470! end function test_getStr_RK2_D1_2
471!
472!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473!
474! function test_getStr_RK2_D1_3() result(assertion)
475! use pm_kind, only: RK => RK2, IK => IK3
476! logical :: assertion
477! integer(IK) , parameter :: nthis = 2
478! real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
479! real(RK) :: this(nthis)
480! character(:), allocatable :: string
481! assertion = .true.
482! string = getStr(this_ref,"(*(g0,:,' '))",63_IK)
483! read(string,*) this
484! assertion = all(this == this_ref)
485! if (test%traceable .and. .not. assertion) then
486! ! LCOV_EXCL_START
487! write(test%disp%unit,"(*(g0))")
488! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
489! write(test%disp%unit,"(*(g0))") "this = ", this
490! write(test%disp%unit,"(*(g0))")
491! end if
492! ! LCOV_EXCL_STOP
493! end function test_getStr_RK2_D1_3
494!
495!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
496!
497! !> \brief
498! !> The input `len` can be larger than the length of the constructed string.
499! function test_getStr_RK2_D1_4() result(assertion)
500! use pm_kind, only: RK => RK2, IK => IK3
501! logical :: assertion
502! integer(IK) , parameter :: nthis = 2_IK
503! real(RK) , parameter :: this_ref(nthis) = [1.23456798e-30_RK, 2.32456798e+30_RK]
504! real(RK) :: this(nthis)
505! character(:), allocatable :: string
506! assertion = .true.
507! string = getStr(this_ref,"(*(g0,:,' '))",263_IK)
508! read(string,*) this
509! assertion = all(this == this_ref)
510! if (test%traceable .and. .not. assertion) then
511! ! LCOV_EXCL_START
512! write(test%disp%unit,"(*(g0))")
513! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
514! write(test%disp%unit,"(*(g0))") "this = ", this
515! write(test%disp%unit,"(*(g0))")
516! ! LCOV_EXCL_STOP
517! end if
518! end function test_getStr_RK2_D1_4
519!
520!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
521!
522! function test_getStr_RK2_D2_1() result(assertion)
523! use pm_kind, only: RK => RK2
524! logical :: assertion
525! integer(IK) , parameter :: nthis = 2
526! real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
527! real(RK) :: this(nthis,nthis)
528! character(:), allocatable :: string
529! assertion = .true.
530! string = getStr(this_ref)
531! read(string,*) this
532! assertion = all(this == this_ref)
533! if (test%traceable .and. .not. assertion) then
534! ! LCOV_EXCL_START
535! write(test%disp%unit,"(*(g0))")
536! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
537! write(test%disp%unit,"(*(g0))") "this = ", this
538! write(test%disp%unit,"(*(g0))")
539! ! LCOV_EXCL_STOP
540! end if
541! end function test_getStr_RK2_D2_1
542!
543!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544!
545! function test_getStr_RK2_D2_2() result(assertion)
546! use pm_kind, only: RK => RK2
547! logical :: assertion
548! integer(IK) , parameter :: nthis = 2
549! real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
550! real(RK) :: this(nthis,nthis)
551! character(:), allocatable :: string
552! assertion = .true.
553! string = getStr(this_ref,"(*(g0,:,' '))")
554! read(string,*) this
555! assertion = all(this == this_ref)
556! if (test%traceable .and. .not. assertion) then
557! ! LCOV_EXCL_START
558! write(test%disp%unit,"(*(g0))")
559! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
560! write(test%disp%unit,"(*(g0))") "this = ", this
561! write(test%disp%unit,"(*(g0))")
562! ! LCOV_EXCL_STOP
563! end if
564! end function test_getStr_RK2_D2_2
565!
566!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
567!
568! function test_getStr_RK2_D2_3() result(assertion)
569! use pm_kind, only: RK => RK2, IK => IK3
570! logical :: assertion
571! integer(IK) , parameter :: nthis = 2
572! real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
573! real(RK) :: this(nthis,nthis)
574! character(:), allocatable :: string
575! assertion = .true.
576! string = getStr(this_ref,"(*(g0,:,' '))",128_IK)
577! read(string,*) this
578! assertion = all(this == this_ref)
579! if (test%traceable .and. .not. assertion) then
580! ! LCOV_EXCL_START
581! write(test%disp%unit,"(*(g0))")
582! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
583! write(test%disp%unit,"(*(g0))") "this = ", this
584! write(test%disp%unit,"(*(g0))")
585! ! LCOV_EXCL_STOP
586! end if
587! end function test_getStr_RK2_D2_3
588!
589!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
590!
591! !> \brief
592! !> The input `len` can be larger than the length of the constructed string.
593! function test_getStr_RK2_D2_4() result(assertion)
594! use pm_kind, only: RK => RK2, IK => IK3
595! logical :: assertion
596! integer(IK) , parameter :: nthis = 2
597! real(RK) , parameter :: this_ref(nthis,nthis) = reshape([1.23456798e-30_RK, 2.32456798e+30_RK, 1.23456798e-30_RK, 2.32456798e+30_RK], shape=shape(this_ref))
598! real(RK) :: this(nthis,nthis)
599! character(:), allocatable :: string
600! assertion = .true.
601! string = getStr(this_ref,"(*(g0,:,' '))",256_IK)
602! read(string,*) this
603! assertion = all(this == this_ref)
604! if (test%traceable .and. .not. assertion) then
605! ! LCOV_EXCL_START
606! write(test%disp%unit,"(*(g0))")
607! write(test%disp%unit,"(*(g0))") "this_ref = ", this_ref
608! write(test%disp%unit,"(*(g0))") "this = ", this
609! write(test%disp%unit,"(*(g0))")
610! ! LCOV_EXCL_STOP
611! end if
612! end function test_getStr_RK2_D2_4
613!
614!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615!
616! function test_getStr_LK_1() result(assertion)
617! implicit none
618! logical :: assertion
619! character(:), allocatable :: strout
620! logical :: logic
621! logic = .true.
622! strout = getStr(logic)
623! assertion = strout == "T"
624! if (test%traceable .and. .not. assertion) then
625! ! LCOV_EXCL_START
626! write(test%disp%unit,"(*(g0))")
627! write(test%disp%unit,"(*(g0))") "logic = ", logic
628! write(test%disp%unit,"(*(g0))") "strout = ", strout
629! write(test%disp%unit,"(*(g0))")
630! ! LCOV_EXCL_STOP
631! end if
632! end function
633!
634!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635!
636! function test_getStr_LK_2() result(assertion)
637! implicit none
638! logical :: assertion
639! character(:), allocatable :: strout
640! logical :: logic
641! logic = .false.
642! strout = getStr(logic)
643! assertion = strout == "F"
644! if (test%traceable .and. .not. assertion) then
645! ! LCOV_EXCL_START
646! write(test%disp%unit,"(*(g0))")
647! write(test%disp%unit,"(*(g0))") "logic = ", logic
648! write(test%disp%unit,"(*(g0))") "strout = ", strout
649! write(test%disp%unit,"(*(g0))")
650! ! LCOV_EXCL_STOP
651! end if
652! end function
653!
654!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
655!
656! function test_IntStr_type_1() result(assertion)
657! use pm_kind, only: IK => IK3
658! logical :: assertion
659! type(intStr_type) :: IntStr
660! IntStr%str = getStr(123_IK)
661! assertion = IntStr%str == "123"
662! end function test_IntStr_type_1
663!
664!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
665!
666! function test_IntStr_type_2() result(assertion)
667! use pm_kind, only: IK => IK4
668! logical :: assertion
669! type(intStr_type) :: IntStr
670! IntStr%str = getStr(123_IK)
671! assertion = IntStr%str == "123"
672! end function test_IntStr_type_2
673!
674!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
675!
676! function test_getStr_1() result(assertion)
677! use pm_kind, only: RK => RK1
678! implicit none
679! logical :: assertion
680! type(RealStr_type) :: RealStr
681! RealStr%str = getStr(123._RK,"(F10.4)",15)
682! assertion = RealStr%str == " 123.0000 "
683! if (test%traceable .and. .not. assertion) then
684! ! LCOV_EXCL_START
685! write(test%disp%unit,"(*(g0))")
686! write(test%disp%unit,"(*(g0))") "Number=123_RK1"
687! write(test%disp%unit,"(*(g0))") "RealStr%str = '", RealStr%str, "'"
688! write(test%disp%unit,"(*(g0))")
689! ! LCOV_EXCL_STOP
690! end if
691! end function test_getStr_1
692!
693!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
694!
695! function test_getStr_2() result(assertion)
696! use pm_kind, only: RK => RK2
697! implicit none
698! logical :: assertion
699! type(RealStr_type) :: RealStr
700! RealStr%str = getStr(123._RK,"(F10.4)",15)
701! assertion = RealStr%str == " 123.0000 "
702! if (test%traceable .and. .not. assertion) then
703! ! LCOV_EXCL_START
704! write(test%disp%unit,"(*(g0))")
705! write(test%disp%unit,"(*(g0))") "Number=123_real64"
706! write(test%disp%unit,"(*(g0))") "RealStr%str = '", RealStr%str, "'"
707! write(test%disp%unit,"(*(g0))")
708! ! LCOV_EXCL_STOP
709! end if
710! end function test_getStr_2
711!
712!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713!
714! function test_padVal2Str_1() result(assertion)
715! use pm_kind, only: IK
716! implicit none
717! logical :: assertion
718! integer(IK) , parameter :: paddedLen = 30_IK
719! character(*), parameter :: string_nonPadded = "ParaMonte"
720! character(*), parameter :: stringPadded_ref = "ParaMonte....................."
721! character(*), parameter :: symbol = "."
722! character(:), allocatable :: charPadded
723! charPadded = padChar(string_nonPadded, symbol, paddedLen)
724! assertion = charPadded == stringPadded_ref .and. len(charPadded) == len(stringPadded_ref)
725! if (test%traceable .and. .not. assertion) then
726! ! LCOV_EXCL_START
727! write(test%disp%unit,"(*(g0))")
728! write(test%disp%unit,"(*(g0))") "string_nonPadded : '", string_nonPadded, "'"
729! write(test%disp%unit,"(*(g0))") "stringPadded_ref : '", stringPadded_ref, "'"
730! write(test%disp%unit,"(*(g0))") "charPadded : '", charPadded, "'"
731! write(test%disp%unit,"(*(g0))")
732! end if
733! ! LCOV_EXCL_STOP
734! end function test_padVal2Str_1
735!
736!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
737!
738! function test_padVal2Str_2() result(assertion)
739! use pm_kind, only: IK
740! implicit none
741! logical :: assertion
742! integer(IK) , parameter :: paddedLen = 9_IK
743! character(*), parameter :: string_nonPadded = "ParaMonte"
744! character(*), parameter :: stringPadded_ref = "ParaMonte"
745! character(*), parameter :: symbol = "."
746! character(:), allocatable :: charPadded
747! charPadded = padChar(string_nonPadded, symbol, paddedLen)
748! assertion = charPadded == stringPadded_ref .and. len(charPadded) == len(stringPadded_ref)
749! if (test%traceable .and. .not. assertion) then
750! ! LCOV_EXCL_START
751! write(test%disp%unit,"(*(g0))")
752! write(test%disp%unit,"(*(g0))") "string_nonPadded : '", string_nonPadded, "'"
753! write(test%disp%unit,"(*(g0))") "stringPadded_ref : '", stringPadded_ref, "'"
754! write(test%disp%unit,"(*(g0))") "charPadded : '", charPadded, "'"
755! write(test%disp%unit,"(*(g0))")
756! end if
757! ! LCOV_EXCL_STOP
758! end function test_padVal2Str_2
759!
760!!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
761!
762! !> \brief
763! !> When `len(string) > paddedLen`, the full string must be returned without any padding.
764! function test_padVal2Str_3() result(assertion)
765! use pm_kind, only: IK
766! implicit none
767! logical :: assertion
768! integer(IK) , parameter :: paddedLen = 5_IK
769! character(*), parameter :: string_nonPadded = "ParaMonte"
770! character(*), parameter :: stringPadded_ref = "ParaM"
771! character(*), parameter :: symbol = "."
772! character(:), allocatable :: charPadded
773! charPadded = padChar(string_nonPadded, symbol, paddedLen)
774! assertion = charPadded == stringPadded_ref .and. len(charPadded) == paddedLen .and. charPadded == stringPadded_ref
775! if (test%traceable .and. .not. assertion) then
776! ! LCOV_EXCL_START
777! write(test%disp%unit,"(*(g0))")
778! write(test%disp%unit,"(*(g0))") "string_nonPadded : '", string_nonPadded, "'"
779! write(test%disp%unit,"(*(g0))") "stringPadded_ref : '", stringPadded_ref, "'"
780! write(test%disp%unit,"(*(g0))") "charPadded : '", charPadded, "'"
781! write(test%disp%unit,"(*(g0))")
782! end if
783! ! LCOV_EXCL_STOP
784! end function test_padVal2Str_3
785
786!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
787
788end module test_pm_val2str ! LCOV_EXCL_LINE
This module contains a simple unit-testing framework for the Fortran libraries, including the ParaMon...
Definition: pm_test.F90:42
This module contains the generic procedures for converting values of different types and kinds to For...
Definition: pm_val2str.F90:58
character(*, SK), parameter MODULE_NAME
Definition: pm_val2str.F90:66
This module contains tests of the module pm_val2Str.
subroutine setTest()
type(test_type) test
This is the derived type test_type for generating objects that facilitate testing of a series of proc...
Definition: pm_test.F90:209