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
253 if (
associated( this%current) ) pdict => this%current%next
255 do while (
associated( pdict ) )
257 if ( pdict%key .strequal. skey )
exit
260 this%current => pdict
264 if (.not.
associated( pdict ) ) &
265 call warn( smessage=
"Failed to find another dictionary entry with a key value of "//
dquote(skey), &
282 if (
associated( this%current) )
then
283 pdict => this%current%next
284 this%current => this%current%next
287 if (.not.
associated( pdict ) ) &
288 call warn( smessage=
"Reached end of dictionary.", &
299 character (len=*),
intent(in) :: skey
303 integer (c_int) :: iindex
305 this%current => this%first
307 do while (
associated(this%current ) )
309 if ( this%current%key .containssimilar. skey ) &
310 call slstring%append(this%current%key)
312 this%current => this%current%next
316 if ( slstring%get(1) ==
'<NA>' ) &
317 call warn(smessage=
"Failed to find a dictionary entry associated with a key value of " &
327 character (len=*),
intent(in) :: skey
328 logical (c_bool) :: in_use
331 integer (c_int) :: iindex
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
371 integer (c_int) :: iindex
374 this%current => this%first
376 do while (
associated(this%current ) )
382 if (this%current%key .strapprox. ssearchkey )
then
384 pdict => this%current
389 this%current => this%current%next
400 type (DICT_ENTRY_T),
pointer :: dict_entry
402 type (DICT_ENTRY_T),
pointer :: temp_dict_entry
403 integer (c_int) :: iIndex
405 temp_dict_entry => null()
407 if (
associated(dict_entry) )
then
409 temp_dict_entry => this%find_dict_entry( dict_entry%key )
413 if (
associated( temp_dict_entry ) )
then
415 do iindex=1, dict_entry%sl%count
417 call temp_dict_entry%sl%append( dict_entry%sl%get( iindex ) )
421 temp_dict_entry => null()
425 this%count = this%count + 1
427 if (
associated( this%last) )
then
431 dict_entry%previous => this%last
432 dict_entry%next => null()
433 this%last%next => dict_entry
434 this%last => dict_entry
435 this%current => dict_entry
439 this%first => dict_entry
440 this%last => dict_entry
441 this%current => dict_entry
442 dict_entry%previous => null()
443 dict_entry%next => null()
451 call warn( smessage=
"Internal programming error: dictionary entry is null", &
452 smodule=__file__, iline=__line__ )
463 character (len=*),
intent(in) :: sKey
466 type (DICT_ENTRY_T),
pointer :: pTarget
467 type (DICT_ENTRY_T),
pointer :: pTemp
469 ptarget => this%get_entry(skey)
471 if (
associated( ptarget ) )
then
474 ptemp => ptarget%previous
476 if (
associated( ptemp) )
then
478 ptemp%next => ptarget%next
479 ptarget%next%previous => ptemp
483 ptemp => ptarget%next
489 this%current => ptemp
491 call ptarget%sl%clear()
502 character (len=*) :: sKey
503 integer (c_int),
allocatable,
intent(out) :: iValues(:)
504 logical (c_bool),
optional :: is_fatal
507 type (DICT_ENTRY_T),
pointer :: pTarget
508 integer (c_int) :: iStat
509 logical (c_bool) :: is_fatal_l
510 logical (c_bool) :: empty_entries
512 if (
present( is_fatal ) )
then
513 is_fatal_l = is_fatal
518 ptarget => this%get_entry(skey)
520 if (
associated( ptarget ) )
then
522 if ( is_fatal_l )
then
523 empty_entries = ptarget%sl%empty_entries_present()
524 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
525 //
" with the key value of "//
dquote(skey), &
529 ivalues = ptarget%sl%get_integer()
533 allocate(ivalues(1), stat=istat)
534 call assert(istat == 0,
"Failed to allocate memory to iValues array", &
537 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
538 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
551 character (len=*) :: sKey
552 logical (c_bool),
allocatable,
intent(out) :: lValues(:)
553 logical (c_bool),
optional :: is_fatal
556 type (DICT_ENTRY_T),
pointer :: pTarget
557 integer (c_int) :: iStat
558 logical (c_bool) :: is_fatal_l
559 logical (c_bool) :: empty_entries
561 if (
present( is_fatal ) )
then
562 is_fatal_l = is_fatal
567 ptarget => this%get_entry(skey)
569 if (
associated( ptarget ) )
then
571 if ( is_fatal_l )
then
572 empty_entries = ptarget%sl%empty_entries_present()
573 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
574 //
" with the key value of "//
dquote(skey), &
578 lvalues = ptarget%sl%get_logical()
582 allocate(lvalues(1), stat=istat)
583 call assert(istat == 0,
"Failed to allocate memory to lValues array", &
586 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
587 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
609 type (FSTRING_LIST_T) :: slKeys
610 logical (c_bool),
allocatable,
intent(out) :: lValues(:)
611 logical (c_bool),
optional :: is_fatal
614 type (DICT_ENTRY_T),
pointer :: pTarget
615 integer (c_int) :: iStat
616 integer (c_int) :: iCount
617 character (len=:),
allocatable :: sText
618 logical (c_bool) :: is_fatal_l
619 logical (c_bool) :: empty_entries
621 if (
present( is_fatal ) )
then
622 is_fatal_l = is_fatal
629 do while ( icount < slkeys%count )
633 stext = slkeys%get( icount)
635 ptarget => this%get_entry( stext )
637 if (
associated( ptarget ) )
exit
641 if (
associated( ptarget ) )
then
643 if ( is_fatal_l )
then
644 empty_entries = ptarget%sl%empty_entries_present()
645 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
646 //
" with the key values of "//slkeys%list_all(), &
650 lvalues = ptarget%sl%get_logical()
654 allocate(lvalues(1), stat=istat)
655 call assert(istat == 0,
"Failed to allocate memory to lValues array", &
658 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
659 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
672 type (FSTRING_LIST_T) :: slKeys
673 type ( FSTRING_LIST_T ),
intent(out) :: slString
674 logical (c_bool),
optional :: is_fatal
677 type (DICT_ENTRY_T),
pointer :: pTarget
678 integer (c_int) :: iStat
679 integer (c_int) :: iCount
680 character (len=:),
allocatable :: sText
681 logical (c_bool) :: is_fatal_l
682 logical (c_bool) :: empty_entries
684 if (
present( is_fatal ) )
then
685 is_fatal_l = is_fatal
692 do while ( icount < slkeys%count )
696 stext = slkeys%get( icount)
698 ptarget => this%get_entry( stext )
700 if (
associated( ptarget ) )
exit
704 if (
associated( ptarget ) )
then
706 if ( is_fatal_l )
then
707 empty_entries = ptarget%sl%empty_entries_present()
708 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
709 //
" with the key values of "//slkeys%list_all(), &
713 slstring = ptarget%sl
717 call slstring%append(
"<NA>")
718 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
719 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
730 character(len=:),
allocatable,
intent(out) :: sText
731 character (len=*),
intent(in),
optional :: sKey
732 integer (c_int),
intent(in),
optional :: iIndex
733 logical (c_bool),
optional :: is_fatal
736 type (DICT_ENTRY_T),
pointer :: pTarget
737 integer (c_int) :: iStat
738 logical (c_bool) :: is_fatal_l
739 logical (c_bool) :: empty_entries
741 if (
present( is_fatal ) )
then
742 is_fatal_l = is_fatal
747 if (
present( skey ) ) this%current => this%get_entry(skey)
749 if (
present( iindex ) ) this%current => this%get_entry( iindex )
751 if (
associated( this%current ) )
then
753 stext = this%current%sl%get( 1, this%current%sl%count )
768 character (len=*),
intent(in) :: sKey
769 type (FSTRING_LIST_T),
intent(out) :: slString
770 logical (c_bool),
optional :: is_fatal
773 type (DICT_ENTRY_T),
pointer :: pTarget
774 integer (c_int) :: iStat
775 logical (c_bool) :: is_fatal_l
776 logical (c_bool) :: empty_entries
778 ptarget => this%get_entry(skey)
780 if (
present(is_fatal) )
then
781 is_fatal_l = is_fatal
786 if (
associated( ptarget ) )
then
788 if ( is_fatal_l )
then
789 empty_entries = ptarget%sl%empty_entries_present()
790 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
791 //
" with the key value of "//
dquote(skey), &
795 slstring = ptarget%sl
799 call slstring%append(
"<NA>")
800 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
801 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
822 type (FSTRING_LIST_T) :: slKeys
823 integer (c_int),
allocatable,
intent(out) :: iValues(:)
824 logical (c_bool),
optional :: is_fatal
827 type (DICT_ENTRY_T),
pointer :: pTarget
828 integer (c_int) :: iStat
829 integer (c_int) :: iCount
830 character (len=256) :: sText
831 logical (c_bool) :: is_fatal_l
832 logical (c_bool) :: empty_entries
834 if (
present( is_fatal ) )
then
835 is_fatal_l = is_fatal
844 do while ( icount < slkeys%count )
848 stext = slkeys%get( icount)
850 ptarget => this%get_entry( stext )
852 if (
associated( ptarget ) )
exit
856 if (
associated( ptarget ) )
then
858 if ( is_fatal_l )
then
859 empty_entries = ptarget%sl%empty_entries_present()
860 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
861 //
" with the key values of "//slkeys%list_all(), &
865 ivalues = ptarget%sl%get_integer()
869 allocate(ivalues(1), stat=istat)
870 call assert(istat == 0,
"Failed to allocate memory to iValues array", &
873 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
874 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
896 type (FSTRING_LIST_T) :: slKeys
897 real (c_float),
allocatable,
intent(out) :: fValues(:)
898 logical (c_bool),
optional :: is_fatal
901 type (DICT_ENTRY_T),
pointer :: pTarget
902 integer (c_int) :: iStat
903 integer (c_int) :: iCount
904 character (len=:),
allocatable :: sText
905 logical (c_bool) :: is_fatal_l
906 logical (c_bool) :: empty_entries
908 if (
present( is_fatal ) )
then
909 is_fatal_l = is_fatal
917 do while ( icount < slkeys%count )
921 stext = slkeys%get( icount)
923 ptarget => this%get_entry( stext )
925 if (
associated( ptarget ) )
exit
929 if (
associated( ptarget ) )
then
931 if ( is_fatal_l )
then
932 empty_entries = ptarget%sl%empty_entries_present()
933 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
934 //
" with the key values of "//slkeys%list_all(), &
938 fvalues = ptarget%sl%get_float()
942 allocate(fvalues(1), stat=istat)
943 call assert(istat == 0,
"Failed to allocate memory to fValues array", &
946 call warn(smessage=
"Failed to find a dictionary entry associated with key value(s) of: "//
dquote(slkeys%list_all()), &
947 smodule=__file__, iline=__line__, iloglevel=
log_debug, lecho=
false)
962 character (len=*),
intent(in) :: sKey
963 real (c_float),
allocatable,
intent(out) :: fValues(:)
964 logical (c_bool),
optional :: is_fatal
967 type (DICT_ENTRY_T),
pointer :: pTarget
968 integer (c_int) :: iStat
969 logical (c_bool) :: is_fatal_l
970 logical (c_bool) :: empty_entries
972 if (
present( is_fatal ) )
then
973 is_fatal_l = is_fatal
978 ptarget => this%get_entry(skey)
980 if (
associated( ptarget ) )
then
982 if ( is_fatal_l )
then
983 empty_entries = ptarget%sl%empty_entries_present()
984 if( empty_entries )
call warn(smessage=
"There are missing values associated" &
985 //
" with the key value of "//
dquote(skey), &
989 fvalues = ptarget%sl%get_float()
993 allocate(fvalues(1), stat=istat)
994 call assert(istat == 0,
"Failed to allocate memory to iValues array", &
997 call warn(smessage=
"Failed to find a dictionary entry associated with key value of "//
dquote(skey), &
998 smodule=__file__, iline=__line__, iloglevel=
log_debug , lecho=
false)
1011 integer (c_int),
intent(in),
optional :: iLogLevel
1012 character (len=*),
intent(in),
optional :: sDescription
1013 logical (c_bool),
intent(in),
optional :: lEcho
1016 type (DICT_ENTRY_T),
pointer :: current
1017 character (len=512) :: sTempBuf
1018 character (len=:),
allocatable :: sDescription_
1019 integer (c_int) :: iCount
1020 integer (c_int) :: iIndex
1021 integer (c_int) :: iLogLevel_l
1022 logical (c_bool) :: lEcho_l
1024 if (
present( iloglevel ) )
then
1025 iloglevel_l = iloglevel
1027 iloglevel_l =
logs%iLogLevel
1030 if (
present( lecho ) )
then
1036 if (
present( sdescription ) )
then
1037 sdescription_ = trim(sdescription)
1039 sdescription_ =
"dictionary data structure"
1042 current => this%first
1045 call logs%write(
"### Summary of all items stored in "//trim(sdescription_), &
1046 iloglevel=iloglevel_l, lecho=lecho_l )
1048 do while (
associated( current ) )
1051 stempbuf = current%key
1054 iloglevel=iloglevel_l, lecho=lecho_l, itab=2, ilinesbefore=1, ilinesafter=1 )
1056 select case ( iloglevel_l )
1075 if ( lecho_l )
call current%sl%print()
1077 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