3 use iso_c_binding,
only : c_int, c_float, c_double, c_bool
16 character (len=:),
allocatable :: key
17 character (len=:),
allocatable :: secondary_key
46 integer (c_int) :: count = 0
113 character (len=*),
intent(in) :: sKey
115 this%key = trim(skey)
124 character (len=*),
intent(in) :: sValue
126 call this%sl%append(svalue)
135 real (c_float),
intent(in) :: fValue
146 integer (c_int),
intent(in) :: iValue
157 real (c_double),
intent(in) :: dValue
168 logical (c_bool),
intent(in) :: lValue
184 character (len=*),
intent(in) :: skey
187 this%current => this%first
189 do while (
associated( this%current ) )
191 if ( this%current%key .strapprox. skey )
exit
193 this%current => this%current%next
197 if (.not.
associated( this%current ) ) &
198 call warn( smessage=
"Failed to find a dictionary entry with a key value of "//
dquote(skey), &
202 pdict => this%current
211 integer (c_int),
intent(in) :: iindex
215 integer (c_int) :: icurrentindex
219 this%current => this%first
223 if ( .not.
associated( this%current ) )
exit
225 if ( icurrentindex == iindex )
exit
227 this%current => this%current%next
229 icurrentindex = icurrentindex + 1
233 if (.not.
associated( this%current ) ) &
234 call warn( smessage=
"Failed to find a dictionary entry with a index value of " &
239 pdict => this%current
248 character (len=*),
intent(in) :: skey
255 if (
associated( this%current) ) pdict => this%current%next
257 do while (
associated( pdict ) )
259 if ( pdict%key .strequal. skey )
exit
262 this%current => pdict
266 if (.not.
associated( pdict ) ) &
267 call warn( smessage=
"Failed to find another dictionary entry with a key value of "//
dquote(skey), &
284 if (
associated( this%current) )
then
285 pdict => this%current%next
286 this%current => this%current%next
289 if (.not.
associated( pdict ) ) &
290 call warn( smessage=
"Reached end of dictionary.", &
301 character (len=*),
intent(in) :: skey
306 this%current => this%first
308 do while (
associated(this%current ) )
310 if ( this%current%key .containssimilar. skey ) &
311 call slstring%append(this%current%key)
313 this%current => this%current%next
317 if ( slstring%get(1) ==
'<NA>' ) &
318 call warn(smessage=
"Failed to find a dictionary entry associated with a key value of " &
328 character (len=*),
intent(in) :: skey
329 logical (c_bool) :: in_use
332 integer (c_int) :: icount
334 this%current => this%first
337 do while (
associated(this%current ) )
343 if ( this%current%key .strapprox. skey ) icount = icount + 1
345 this%current => this%current%next
349 if ( icount == 0 )
then
367 character (len=*),
intent(in) :: ssearchkey
373 this%current => this%first
375 do while (
associated(this%current ) )
381 if (this%current%key .strapprox. ssearchkey )
then
383 pdict => this%current
388 this%current => this%current%next
399 type (DICT_ENTRY_T),
pointer :: dict_entry
401 type (DICT_ENTRY_T),
pointer :: temp_dict_entry
402 integer (c_int) :: iIndex
404 temp_dict_entry => null()
406 if (
associated(dict_entry) )
then
408 temp_dict_entry => this%find_dict_entry( dict_entry%key )
412 if (
associated( temp_dict_entry ) )
then
414 do iindex=1, dict_entry%sl%count
416 call temp_dict_entry%sl%append( dict_entry%sl%get( iindex ) )
420 temp_dict_entry => null()
424 this%count = this%count + 1
426 if (
associated( this%last) )
then
430 dict_entry%previous => this%last
431 dict_entry%next => null()
432 this%last%next => dict_entry
433 this%last => dict_entry
434 this%current => dict_entry
438 this%first => dict_entry
439 this%last => dict_entry
440 this%current => dict_entry
441 dict_entry%previous => null()
442 dict_entry%next => null()
450 call warn( smessage=
"Internal programming error: dictionary entry is null", &
451 smodule=__file__, iline=__line__ )
462 character (len=*),
intent(in) :: sKey
465 type (DICT_ENTRY_T),
pointer :: pTarget
466 type (DICT_ENTRY_T),
pointer :: pTemp
468 ptarget => this%get_entry(skey)
470 if (
associated( ptarget ) )
then
473 ptemp => ptarget%previous
475 if (
associated( ptemp) )
then
477 ptemp%next => ptarget%next
478 ptarget%next%previous => ptemp
482 ptemp => ptarget%next
488 this%current => ptemp
490 call ptarget%sl%clear()
501 character (len=*) :: sKey
502 integer (c_int),
allocatable,
intent(out) :: iValues(:)
503 logical (c_bool),
optional :: is_fatal
506 type (DICT_ENTRY_T),
pointer :: pTarget
507 integer (c_int) :: iStat
508 logical (c_bool) :: is_fatal_l
509 logical (c_bool) :: empty_entries
511 if (
present( is_fatal ) )
then
512 is_fatal_l = is_fatal
517 ptarget => this%get_entry(skey)
519 if (
associated( ptarget ) )
then
521 if ( is_fatal_l )
then
522 empty_entries = ptarget%sl%empty_entries_present()
523 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
524 //
" with the key value of "//
dquote(skey), &
528 ivalues = ptarget%sl%get_integer()
532 allocate(ivalues(1), stat=istat)
533 call assert(istat == 0,
"Failed to allocate memory to iValues array", &
536 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
537 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
550 character (len=*) :: sKey
551 logical (c_bool),
allocatable,
intent(out) :: lValues(:)
552 logical (c_bool),
optional :: is_fatal
555 type (DICT_ENTRY_T),
pointer :: pTarget
556 integer (c_int) :: iStat
557 logical (c_bool) :: is_fatal_l
558 logical (c_bool) :: empty_entries
560 if (
present( is_fatal ) )
then
561 is_fatal_l = is_fatal
566 ptarget => this%get_entry(skey)
568 if (
associated( ptarget ) )
then
570 if ( is_fatal_l )
then
571 empty_entries = ptarget%sl%empty_entries_present()
572 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
573 //
" with the key value of "//
dquote(skey), &
577 lvalues = ptarget%sl%get_logical()
581 allocate(lvalues(1), stat=istat)
582 call assert(istat == 0,
"Failed to allocate memory to lValues array", &
585 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
586 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
608 type (FSTRING_LIST_T) :: slKeys
609 logical (c_bool),
allocatable,
intent(out) :: lValues(:)
610 logical (c_bool),
optional :: is_fatal
613 type (DICT_ENTRY_T),
pointer :: pTarget
614 integer (c_int) :: iStat
615 integer (c_int) :: iCount
616 character (len=:),
allocatable :: sText
617 logical (c_bool) :: is_fatal_l
618 logical (c_bool) :: empty_entries
620 if (
present( is_fatal ) )
then
621 is_fatal_l = is_fatal
628 do while ( icount < slkeys%count )
632 stext = slkeys%get( icount)
634 ptarget => this%get_entry( stext )
636 if (
associated( ptarget ) )
exit
640 if (
associated( ptarget ) )
then
642 if ( is_fatal_l )
then
643 empty_entries = ptarget%sl%empty_entries_present()
644 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
645 //
" with the key values of "//slkeys%list_all(), &
649 lvalues = ptarget%sl%get_logical()
653 allocate(lvalues(1), stat=istat)
654 call assert(istat == 0,
"Failed to allocate memory to lValues array", &
657 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
658 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
671 type (FSTRING_LIST_T) :: slKeys
672 type ( FSTRING_LIST_T ),
intent(out) :: slString
673 logical (c_bool),
optional :: is_fatal
676 type (DICT_ENTRY_T),
pointer :: pTarget
677 integer (c_int) :: iCount
678 character (len=:),
allocatable :: sText
679 logical (c_bool) :: is_fatal_l
680 logical (c_bool) :: empty_entries
682 if (
present( is_fatal ) )
then
683 is_fatal_l = is_fatal
690 do while ( icount < slkeys%count )
694 stext = slkeys%get( icount)
696 ptarget => this%get_entry( stext )
698 if (
associated( ptarget ) )
exit
702 if (
associated( ptarget ) )
then
704 if ( is_fatal_l )
then
705 empty_entries = ptarget%sl%empty_entries_present()
706 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
707 //
" with the key values of "//slkeys%list_all(), &
711 slstring = ptarget%sl
715 call slstring%append(
"<NA>")
716 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
717 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
728 character(len=:),
allocatable,
intent(out) :: sText
729 character (len=*),
intent(in),
optional :: sKey
730 integer (c_int),
intent(in),
optional :: iIndex
731 logical (c_bool),
optional :: is_fatal
734 logical (c_bool) :: is_fatal_l
736 if (
present( is_fatal ) )
then
737 is_fatal_l = is_fatal
742 if (
present( skey ) ) this%current => this%get_entry(skey)
744 if (
present( iindex ) ) this%current => this%get_entry( iindex )
746 if (
associated( this%current ) )
then
748 stext = this%current%sl%get( 1, this%current%sl%count )
763 character (len=*),
intent(in) :: sKey
764 type (FSTRING_LIST_T),
intent(out) :: slString
765 logical (c_bool),
optional :: is_fatal
768 type (DICT_ENTRY_T),
pointer :: pTarget
769 logical (c_bool) :: is_fatal_l
770 logical (c_bool) :: empty_entries
772 ptarget => this%get_entry(skey)
774 if (
present(is_fatal) )
then
775 is_fatal_l = is_fatal
780 if (
associated( ptarget ) )
then
782 if ( is_fatal_l )
then
783 empty_entries = ptarget%sl%empty_entries_present()
784 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
785 //
" with the key value of "//
dquote(skey), &
789 slstring = ptarget%sl
793 call slstring%append(
"<NA>")
794 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
795 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
816 type (FSTRING_LIST_T) :: slKeys
817 integer (c_int),
allocatable,
intent(out) :: iValues(:)
818 logical (c_bool),
optional :: is_fatal
821 type (DICT_ENTRY_T),
pointer :: pTarget
822 integer (c_int) :: iStat
823 integer (c_int) :: iCount
824 character (len=256) :: sText
825 logical (c_bool) :: is_fatal_l
826 logical (c_bool) :: empty_entries
828 if (
present( is_fatal ) )
then
829 is_fatal_l = is_fatal
838 do while ( icount < slkeys%count )
842 stext = slkeys%get( icount)
844 ptarget => this%get_entry( stext )
846 if (
associated( ptarget ) )
exit
850 if (
associated( ptarget ) )
then
852 if ( is_fatal_l )
then
853 empty_entries = ptarget%sl%empty_entries_present()
854 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
855 //
" with the key values of "//slkeys%list_all(), &
859 ivalues = ptarget%sl%get_integer()
863 allocate(ivalues(1), stat=istat)
864 call assert(istat == 0,
"Failed to allocate memory to iValues array", &
867 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
868 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
890 type (FSTRING_LIST_T) :: slKeys
891 real (c_float),
allocatable,
intent(out) :: fValues(:)
892 logical (c_bool),
optional :: is_fatal
895 type (DICT_ENTRY_T),
pointer :: pTarget
896 integer (c_int) :: iStat
897 integer (c_int) :: iCount
898 character (len=:),
allocatable :: sText
899 logical (c_bool) :: is_fatal_l
900 logical (c_bool) :: empty_entries
902 if (
present( is_fatal ) )
then
903 is_fatal_l = is_fatal
911 do while ( icount < slkeys%count )
915 stext = slkeys%get( icount)
917 ptarget => this%get_entry( stext )
919 if (
associated( ptarget ) )
exit
923 if (
associated( ptarget ) )
then
925 if ( is_fatal_l )
then
926 empty_entries = ptarget%sl%empty_entries_present()
927 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
928 //
" with the key values of "//slkeys%list_all(), &
932 fvalues = ptarget%sl%get_float()
936 allocate(fvalues(1), stat=istat)
937 call assert(istat == 0,
"Failed to allocate memory to fValues array", &
940 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
941 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
956 character (len=*),
intent(in) :: sKey
957 real (c_float),
allocatable,
intent(out) :: fValues(:)
958 logical (c_bool),
optional :: is_fatal
961 type (DICT_ENTRY_T),
pointer :: pTarget
962 integer (c_int) :: iStat
963 logical (c_bool) :: is_fatal_l
964 logical (c_bool) :: empty_entries
966 if (
present( is_fatal ) )
then
967 is_fatal_l = is_fatal
972 ptarget => this%get_entry(skey)
974 if (
associated( ptarget ) )
then
976 if ( is_fatal_l )
then
977 empty_entries = ptarget%sl%empty_entries_present()
978 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
979 //
" with the key value of "//
dquote(skey), &
983 fvalues = ptarget%sl%get_float()
987 allocate(fvalues(1), stat=istat)
988 call assert(istat == 0,
"Failed to allocate memory to iValues array", &
991 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
992 smodule=__file__, iline=__line__, iloglevel=
log_debug , lecho=
false)
1005 integer (c_int),
intent(in),
optional :: iLogLevel
1006 character (len=*),
intent(in),
optional :: sDescription
1007 logical (c_bool),
intent(in),
optional :: lEcho
1010 type (DICT_ENTRY_T),
pointer :: current
1011 character (len=512) :: sTempBuf
1012 character (len=:),
allocatable :: sDescription_
1013 integer (c_int) :: iCount
1014 integer (c_int) :: iLogLevel_l
1015 logical (c_bool) :: lEcho_l
1017 if (
present( iloglevel ) )
then
1018 iloglevel_l = iloglevel
1020 iloglevel_l =
logs%iLogLevel
1023 if (
present( lecho ) )
then
1029 if (
present( sdescription ) )
then
1030 sdescription_ = trim(sdescription)
1032 sdescription_ =
"dictionary data structure"
1035 current => this%first
1038 call logs%write(
"### Summary of all items stored in "//trim(sdescription_), &
1039 iloglevel=iloglevel_l, lecho=lecho_l )
1041 do while (
associated( current ) )
1044 stempbuf = current%key
1047 iloglevel=iloglevel_l, lecho=lecho_l, itab=2, ilinesbefore=1, ilinesafter=1 )
1049 select case ( iloglevel_l )
1068 if ( lecho_l )
call current%sl%print()
1070 current => current%next
This module contains physical constants and convenience functions aimed at performing unit conversion...
logical(c_bool), parameter, public true
logical(c_bool), parameter, public false
real(c_float), parameter ftinyval
integer(c_int), parameter, public itinyval
subroutine get_values_as_string_list_sub(this, skey, slstring, is_fatal)
type(dict_entry_t) function, pointer get_entry_by_key_fn(this, skey)
type(dict_entry_t) function, pointer get_next_entry_by_key_fn(this, skey)
subroutine add_key_sub(this, skey)
subroutine get_values_as_float_given_list_of_keys_sub(this, slkeys, fvalues, is_fatal)
Search through keys for a match; return float values.
type(dict_entry_t) function, pointer get_entry_by_index_fn(this, iindex)
subroutine add_integer_sub(this, ivalue)
subroutine get_values_as_logical_given_list_of_keys_sub(this, slkeys, lvalues, is_fatal)
Search through keys for a match; return logical values.
type(dict_entry_t), pointer, public cf_entry
subroutine print_all_dictionary_entries_sub(this, iloglevel, sdescription, lecho)
subroutine get_values_as_int_given_list_of_keys_sub(this, slkeys, ivalues, is_fatal)
Search through keys for a match; return integer values.
type(dict_entry_t) function, pointer get_next_entry_fn(this)
type(dict_t), public cf_dict
logical(c_bool) function key_name_already_in_use_fn(this, skey)
subroutine delete_entry_by_key_sub(this, skey)
subroutine get_values_as_int_sub(this, skey, ivalues, is_fatal)
subroutine add_double_sub(this, dvalue)
subroutine get_value_as_string_sub(this, stext, skey, iindex, is_fatal)
type(dict_entry_t) function, pointer find_dict_entry_fn(this, ssearchkey)
subroutine get_values_as_string_list_given_list_of_keys_sub(this, slkeys, slstring, is_fatal)
type(fstring_list_t) function grep_dictionary_key_names_fn(this, skey)
subroutine add_entry_to_dict_sub(this, dict_entry)
subroutine add_float_sub(this, fvalue)
subroutine get_values_as_float_sub(this, skey, fvalues, is_fatal)
subroutine add_logical_sub(this, lvalue)
subroutine add_string_sub(this, svalue)
subroutine get_values_as_logical_sub(this, skey, lvalues, is_fatal)
subroutine, public warn(smessage, smodule, iline, shints, lfatal, iloglevel, lecho)
type(logfile_t), public logs