-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathTest_MpiFormatter.pf
110 lines (76 loc) · 2.74 KB
/
Test_MpiFormatter.pf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
module Test_MpiFormatter
use funit
use PFL_MpiFormatter
use PFL_LogRecord
use PFL_SeverityLevels
implicit none
contains
@test
subroutine test_no_reference()
use mpi
type (MpiFormatter) :: f
type (LogRecord) :: rec
integer :: comm ! not really used due to mock
call initLogRecord(rec, 'A', INFO, 'message')
f = MpiFormatter(fmt='%(message)a', comm=comm)
@assertEqual('message', f%format(rec))
call verify()
end subroutine test_no_reference
@test
subroutine test_one_comm()
use mpi
type (MpiFormatter) :: f
type (LogRecord) :: rec
integer :: comm = 1 ! not really used due to mock
call initLogRecord(rec, 'A', INFO, 'message')
call set_mpi_rank(2)
call set_mpi_size(5)
f = MpiFormatter(fmt='%(message)a %(mpi_rank)i2.2 %(mpi_size)i2.2', comm=comm)
@assertEqual('message 02 05', f%format(rec))
call verify()
end subroutine test_one_comm
@test
subroutine test_multi_comm()
use mpi
type (MpiFormatter) :: f
type (LogRecord) :: rec
integer :: comm = 1 ! not really used due to mock
call initLogRecord(rec, 'A', INFO, 'message')
call set_mpi_rank(2)
call set_mpi_size(5)
f = MpiFormatter(fmt='%(message)a %(mpi_rank_1)i2.2 %(mpi_size_2)i2.2', comms=[comm,comm])
@assertEqual('message 02 05', f%format(rec))
call verify()
end subroutine test_multi_comm
@test
subroutine test_multi_comm_default_fmt()
use mpi
type (MpiFormatter) :: f
type (LogRecord) :: rec
integer :: comm = 1 ! not really used due to mock
call initLogRecord(rec, 'A', INFO, 'message')
call set_mpi_rank(2)
call set_mpi_size(5)
f = MpiFormatter(comms=[comm,comm,comm])
@assertEqual('pe=(2,2,2): message', f%format(rec))
call verify()
end subroutine test_multi_comm_default_fmt
@test
subroutine test_alt_names()
use mpi
type (MpiFormatter) :: f
type (LogRecord) :: rec
character(len=:), allocatable :: fmt
integer :: comm = 1 ! not really used due to mock
call initLogRecord(rec, 'A', INFO, 'message')
call set_mpi_rank(2)
call set_mpi_size(5)
fmt = '%(message)a %(p)i2.2 %(np)i2.2'
f = MpiFormatter(fmt=fmt, comm=comm, rank_keyword='p', size_keyword='np')
@assertEqual('message 02 05', f%format(rec))
fmt = '%(message)a %(p_1)i2.2 %(p_2)i2.2 %(np_1)i2.2 %(np_2)i2.2'
f = MpiFormatter(fmt=fmt, comms=[comm,comm], rank_prefix='p', size_prefix='np')
@assertEqual('message 02 02 05 05', f%format(rec))
call verify()
end subroutine test_alt_names
end module Test_MpiFormatter