@@ -18,7 +18,7 @@ module PFL_Config
18
18
use PFL_Formatter
19
19
use PFL_Filterer
20
20
use PFL_FileHandler
21
-
21
+
22
22
use gFTL2_StringUnlimitedMap
23
23
use PFL_Filter
24
24
use PFL_StringUtilities, only: to_lower_case
@@ -77,7 +77,7 @@ subroutine build_formatters(this, cfg, unusable, extra, rc)
77
77
class(NodeIterator), allocatable :: iter
78
78
class (Formatter), allocatable :: f
79
79
character (:), allocatable :: formatter_name
80
-
80
+
81
81
integer :: status
82
82
83
83
_ASSERT(cfg% is_mapping(), " PFL::Config::build_formatters() - input cfg not a mapping" , rc)
@@ -123,7 +123,7 @@ subroutine build_formatter(fmtr, cfg, unusable, extra, global_communicator, rc)
123
123
select case (class_name)
124
124
case (' Formatter' )
125
125
call build_basic_formatter(fmtr, cfg, _RC)
126
- #ifdef _LOGGER_USE_MPI
126
+ #ifdef _LOGGER_USE_MPI
127
127
case (' MpiFormatter' )
128
128
if (present (extra)) then
129
129
extra_ = extra
@@ -287,7 +287,7 @@ subroutine build_mpi_formatter(fmtr, cfg, unusable, extra, rc)
287
287
_RETURN(_SUCCESS,rc)
288
288
end subroutine build_mpi_formatter
289
289
#endif
290
-
290
+
291
291
subroutine build_locks (this , cfg , unusable , extra , rc )
292
292
use PFL_AbstractLock
293
293
#ifdef _LOGGER_USE_MPI
@@ -304,7 +304,7 @@ subroutine build_locks(this, cfg, unusable, extra, rc)
304
304
character (:), allocatable :: lock_name
305
305
class (AbstractLock), allocatable :: lock
306
306
integer :: status
307
-
307
+
308
308
_ASSERT(cfg% is_mapping(), " PFL::Config::build_locks() - input cfg not a mapping" , rc)
309
309
310
310
associate (b = > cfg% begin(), e = > cfg% end ())
@@ -313,7 +313,9 @@ subroutine build_locks(this, cfg, unusable, extra, rc)
313
313
314
314
lock_name = to_string(iter% first(), _RC)
315
315
subcfg = > iter% second()
316
- lock = build_lock(subcfg, extra= extra, _RC)
316
+ ! lock = build_lock(subcfg, extra=extra, _RC)
317
+ allocate (lock, source= build_lock(subcfg, extra= extra, rc= status))
318
+ _VERIFY(status,' ' ,rc)
317
319
call this% locks% insert(lock_name, lock)
318
320
call iter% next()
319
321
end do
@@ -376,7 +378,7 @@ subroutine build_filters(this, cfg, unusable, extra, rc)
376
378
377
379
associate (b = > cfg% begin(), e = > cfg% end ())
378
380
iter = b
379
-
381
+
380
382
do while (iter /= e)
381
383
382
384
filter_name = to_string(iter% first(), _RC)
@@ -407,7 +409,7 @@ function build_filter(cfg, unusable, extra, rc) result(f)
407
409
408
410
character (len= :), allocatable :: class_name
409
411
integer :: status
410
-
412
+
411
413
_ASSERT(cfg% is_mapping(), " PFL::Config::build_formatter() - input cfg not a mapping" , rc)
412
414
413
415
if (cfg% has(' class' )) then
@@ -420,12 +422,12 @@ function build_filter(cfg, unusable, extra, rc) result(f)
420
422
case (' filter' )
421
423
allocate (f, source= build_basic_filter(cfg, rc= status))
422
424
_VERIFY(status, ' ' , rc)
423
-
425
+
424
426
case (' levelfilter' )
425
427
allocate (f, source= build_LevelFilter(cfg, rc= status))
426
428
_VERIFY(status, ' ' , rc)
427
-
428
- #ifdef _LOGGER_USE_MPI
429
+
430
+ #ifdef _LOGGER_USE_MPI
429
431
case (' mpifilter' )
430
432
allocate (f, source= build_MpiFilter(cfg, extra= extra, rc= status))
431
433
_VERIFY(status, ' ' , rc)
@@ -443,7 +445,7 @@ function build_basic_filter(cfg, rc) result(f)
443
445
type (Filter) :: f
444
446
class(YAML_Node), intent (in ) :: cfg
445
447
integer , optional , intent (out ) :: rc
446
-
448
+
447
449
character (len= :), allocatable :: name
448
450
integer :: status
449
451
@@ -461,18 +463,18 @@ function build_LevelFilter(cfg, rc) result(f)
461
463
type (LevelFilter) :: f
462
464
class(YAML_Node), intent (in ) :: cfg
463
465
integer , optional , intent (out ) :: rc
464
-
466
+
465
467
integer :: min_level, max_level
466
468
integer :: status
467
469
468
470
min_level = get_level(' min_level' , _RC)
469
471
max_level = get_level(' max_level' , _RC)
470
-
472
+
471
473
f = LevelFilter(min_level, max_level)
472
-
474
+
473
475
_RETURN(_SUCCESS,rc)
474
476
contains
475
-
477
+
476
478
integer function get_level (key , rc ) result(level)
477
479
character (len=* ), intent (in ) :: key
478
480
integer , optional , intent (out ) :: rc
@@ -493,7 +495,7 @@ integer function get_level(key, rc) result(level)
493
495
494
496
_RETURN(_SUCCESS,rc)
495
497
end function get_level
496
-
498
+
497
499
end function build_LevelFilter
498
500
499
501
#ifdef _LOGGER_USE_MPI
@@ -504,7 +506,7 @@ function build_MpiFilter(cfg, unusable, extra, rc) result(f)
504
506
class (KeywordEnforcer), optional , intent (in ) :: unusable
505
507
type (StringUnlimitedMap), optional , intent (in ) :: extra
506
508
integer , optional , intent (out ) :: rc
507
-
509
+
508
510
character (len= :), allocatable :: comm_name
509
511
integer :: comm
510
512
integer :: rank, root, ierror
@@ -528,7 +530,7 @@ function build_MpiFilter(cfg, unusable, extra, rc) result(f)
528
530
_UNUSED_DUMMY(unusable)
529
531
end function build_MpiFilter
530
532
#endif
531
-
533
+
532
534
533
535
subroutine build_handlers (this , cfg , unusable , extra , rc )
534
536
class (ConfigElements), intent (inout ) :: this
@@ -558,7 +560,7 @@ subroutine build_handlers(this, cfg, unusable, extra, rc)
558
560
559
561
_RETURN(_SUCCESS,rc)
560
562
end subroutine build_handlers
561
-
563
+
562
564
subroutine build_handler (h , cfg , elements , unusable , extra , rc )
563
565
class (AbstractHandler), allocatable , intent (out ) :: h
564
566
class(YAML_Node), intent (inout ) :: cfg
@@ -568,7 +570,7 @@ subroutine build_handler(h, cfg, elements, unusable, extra, rc)
568
570
integer , optional , intent (out ) :: rc
569
571
570
572
integer :: status
571
-
573
+
572
574
call allocate_concrete_handler(h, cfg, _RC)
573
575
call set_handler_level(h, cfg, _RC)
574
576
call set_handler_formatter(h, cfg, elements% formatters, _RC)
@@ -600,11 +602,11 @@ subroutine allocate_concrete_handler(h, cfg, rc)
600
602
case (' filehandler' )
601
603
call build_filehandler(fh, cfg)
602
604
allocate (h, source= fh)
603
- #ifdef _LOGGER_USE_MPI
605
+ #ifdef _LOGGER_USE_MPI
604
606
case (' mpifilehandler' )
605
607
call build_mpifilehandler(fh, cfg)
606
608
allocate (h, source= fh)
607
- #endif
609
+ #endif
608
610
case default
609
611
_ASSERT(.false. , " PFL::Config::build_handler() - unsupported class: '" // class_name // " '." , rc)
610
612
end select
@@ -614,7 +616,7 @@ end subroutine allocate_concrete_handler
614
616
subroutine set_handler_level (h , cfg , rc )
615
617
class (AbstractHandler), intent (inout ) :: h
616
618
class(YAML_Node), intent (in ) :: cfg
617
- integer , optional , intent (out ) :: rc
619
+ integer , optional , intent (out ) :: rc
618
620
619
621
character (len= :), allocatable :: level_name
620
622
integer :: level
@@ -638,7 +640,7 @@ subroutine set_handler_level(h, cfg, rc)
638
640
639
641
_RETURN(_SUCCESS,rc)
640
642
end subroutine set_handler_level
641
-
643
+
642
644
643
645
subroutine set_handler_formatter (h , cfg , formatters , rc )
644
646
use PFL_Formatter
@@ -726,7 +728,7 @@ subroutine set_handler_lock(h, cfg, locks, rc)
726
728
end if
727
729
_RETURN(_SUCCESS,rc)
728
730
end subroutine set_handler_lock
729
-
731
+
730
732
731
733
end subroutine build_handler
732
734
@@ -893,8 +895,8 @@ subroutine build_mpifilehandler(h, cfg, unusable, extra, rc)
893
895
end if
894
896
895
897
h = FileHandler(fileName, delay= delay)
896
-
897
- _RETURN(_SUCCESS,rc)
898
+
899
+ _RETURN(_SUCCESS,rc)
898
900
end subroutine build_mpifilehandler
899
901
#endif
900
902
@@ -990,7 +992,7 @@ subroutine set_logger_propagate(lgr, cfg, rc)
990
992
991
993
_RETURN(_SUCCESS,rc)
992
994
end subroutine set_logger_propagate
993
-
995
+
994
996
995
997
subroutine set_logger_filters (lgr , cfg , filters , unusable , extra , rc )
996
998
class (Logger), intent (inout ) :: lgr
@@ -1034,15 +1036,15 @@ subroutine set_logger_handlers(lgr, cfg, handlers, unusable, extra, rc)
1034
1036
type (StringUnlimitedMap), optional , intent (in ) :: extra
1035
1037
integer , optional , intent (out ) :: rc
1036
1038
1037
- character (len= :), allocatable :: handler_name
1039
+ character (len= :), allocatable :: handler_name
1038
1040
class(YAML_Node), pointer :: subcfg
1039
1041
integer :: i
1040
1042
integer :: status
1041
1043
1042
1044
if (cfg% has(' handlers' )) then
1043
1045
subcfg = > cfg% of(' handlers' )
1044
1046
_ASSERT(cfg% has(' handlers' ), " PFL::Config::set_logger_handlers() - expected sequence for 'handlers' key." , rc)
1045
-
1047
+
1046
1048
do i = 1 , subcfg% size ()
1047
1049
call subcfg% get(handler_name, i, _RC)
1048
1050
@@ -1145,7 +1147,7 @@ subroutine set_global_communicator(this, comm)
1145
1147
class (ConfigElements), intent (inout ) :: this
1146
1148
integer , optional , intent (in ) :: comm
1147
1149
1148
- #ifdef _LOGGER_USE_MPI
1150
+ #ifdef _LOGGER_USE_MPI
1149
1151
if (present (comm)) then
1150
1152
this% global_communicator = comm
1151
1153
else
0 commit comments