@@ -648,57 +648,45 @@ end subroutine json_file_print_to_string
648
648
! date: 2/3/2014
649
649
!
650
650
! Returns information about a variable in a [[json_file(type)]].
651
+ !
652
+ ! @note If `found` is present, no exceptions will be thrown if an
653
+ ! error occurs. Otherwise, an exception will be thrown if the
654
+ ! variable is not found.
651
655
652
- subroutine json_file_variable_info (me ,path ,found ,var_type ,n_children )
656
+ subroutine json_file_variable_info (me ,path ,found ,var_type ,n_children , name )
653
657
654
658
implicit none
655
659
656
660
class(json_file),intent (inout ) :: me
657
661
character (kind= CK,len=* ),intent (in ) :: path ! ! path to the variable
658
- logical (LK),intent (out ) :: found ! ! the variable exists in the structure
659
- integer (IK),intent (out ) :: var_type ! ! variable type
660
- integer (IK),intent (out ) :: n_children ! ! number of children
661
-
662
- type (json_value),pointer :: p
663
-
664
- ! initialize:
665
- nullify(p)
666
-
667
- ! get a pointer to the variable (if it is there):
668
- call me% get(path,p,found)
669
-
670
- if (found) then
671
-
672
- ! get info:
673
- call me% core% info(p,var_type,n_children)
674
-
675
- else
676
-
677
- ! set to dummy values:
678
- var_type = json_unknown
679
- n_children = 0
680
-
681
- end if
662
+ logical (LK),intent (out ),optional :: found ! ! the variable exists in the structure
663
+ integer (IK),intent (out ),optional :: var_type ! ! variable type
664
+ integer (IK),intent (out ),optional :: n_children ! ! number of children
665
+ character (kind= CK,len= :),allocatable ,intent (out ),optional :: name ! ! variable name
682
666
683
- ! cleanup:
684
- nullify(p)
667
+ call me% core% info(me% p,path,found,var_type,n_children,name)
685
668
686
669
end subroutine json_file_variable_info
687
670
! *****************************************************************************************
688
671
689
672
! *****************************************************************************************
690
673
! >
691
674
! Alternate version of [[json_file_variable_info]], where "path" is kind=CDK.
675
+ !
676
+ ! @note If `found` is present, no exceptions will be thrown if an
677
+ ! error occurs. Otherwise, an exception will be thrown if the
678
+ ! variable is not found.
692
679
693
- subroutine wrap_json_file_variable_info (me ,path ,found ,var_type ,n_children )
680
+ subroutine wrap_json_file_variable_info (me ,path ,found ,var_type ,n_children , name )
694
681
695
682
implicit none
696
683
697
684
class(json_file),intent (inout ) :: me
698
685
character (kind= CDK,len=* ),intent (in ) :: path
699
- logical (LK),intent (out ) :: found
700
- integer (IK),intent (out ) :: var_type
701
- integer (IK),intent (out ) :: n_children
686
+ logical (LK),intent (out ),optional :: found
687
+ integer (IK),intent (out ),optional :: var_type
688
+ integer (IK),intent (out ),optional :: n_children
689
+ character (kind= CK,len= :),allocatable ,intent (out ),optional :: name ! ! variable name
702
690
703
691
call me% info(to_unicode(path),found,var_type,n_children)
704
692
0 commit comments