@@ -78,6 +78,7 @@ module json_file_module
78
78
procedure ,public :: destroy = > json_file_destroy
79
79
procedure ,public :: move = > json_file_move_pointer
80
80
generic,public :: info = > MAYBEWRAP(json_file_variable_info)
81
+ generic,public :: matrix_info = > MAYBEWRAP(json_file_variable_matrix_info)
81
82
82
83
! error checking:
83
84
procedure ,public :: failed = > json_file_failed
@@ -125,8 +126,9 @@ module json_file_module
125
126
procedure :: initialize_json_core_in_file
126
127
procedure :: set_json_core_in_file
127
128
128
- ! git info:
129
+ ! get info:
129
130
procedure :: MAYBEWRAP(json_file_variable_info)
131
+ procedure :: MAYBEWRAP(json_file_variable_matrix_info)
130
132
131
133
! get:
132
134
procedure :: MAYBEWRAP(json_file_get_object)
@@ -648,61 +650,113 @@ end subroutine json_file_print_to_string
648
650
! date: 2/3/2014
649
651
!
650
652
! Returns information about a variable in a [[json_file(type)]].
653
+ !
654
+ ! @note If `found` is present, no exceptions will be thrown if an
655
+ ! error occurs. Otherwise, an exception will be thrown if the
656
+ ! variable is not found.
651
657
652
- subroutine json_file_variable_info (me ,path ,found ,var_type ,n_children )
658
+ subroutine json_file_variable_info (me ,path ,found ,var_type ,n_children , name )
653
659
654
660
implicit none
655
661
656
662
class(json_file),intent (inout ) :: me
657
663
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
664
+ logical (LK),intent (out ),optional :: found ! ! the variable exists in the structure
665
+ integer (IK),intent (out ),optional :: var_type ! ! variable type
666
+ integer (IK),intent (out ),optional :: n_children ! ! number of children
667
+ character (kind= CK,len= :),allocatable ,intent (out ),optional :: name ! ! variable name
661
668
662
- type (json_value), pointer :: p
669
+ call me % core % info(me % p,path,found,var_type,n_children,name)
663
670
664
- ! initialize:
665
- nullify(p)
671
+ end subroutine json_file_variable_info
672
+ ! *****************************************************************************************
666
673
667
- ! get a pointer to the variable (if it is there):
668
- call me% get(path,p,found)
674
+ ! *****************************************************************************************
675
+ ! >
676
+ ! Alternate version of [[json_file_variable_info]], where "path" is kind=CDK.
677
+ !
678
+ ! @note If `found` is present, no exceptions will be thrown if an
679
+ ! error occurs. Otherwise, an exception will be thrown if the
680
+ ! variable is not found.
669
681
670
- if ( found) then
682
+ subroutine wrap_json_file_variable_info ( me , path , found , var_type , n_children , name )
671
683
672
- ! get info:
673
- call me% core% info(p,var_type,n_children)
684
+ implicit none
674
685
675
- else
686
+ class(json_file),intent (inout ) :: me
687
+ character (kind= CDK,len=* ),intent (in ) :: path
688
+ logical (LK),intent (out ),optional :: found
689
+ integer (IK),intent (out ),optional :: var_type
690
+ integer (IK),intent (out ),optional :: n_children
691
+ character (kind= CK,len= :),allocatable ,intent (out ),optional :: name ! ! variable name
676
692
677
- ! set to dummy values:
678
- var_type = json_unknown
679
- n_children = 0
693
+ call me% info(to_unicode(path),found,var_type,n_children,name)
680
694
681
- end if
695
+ end subroutine wrap_json_file_variable_info
696
+ ! *****************************************************************************************
682
697
683
- ! cleanup:
684
- nullify(p)
698
+ ! *****************************************************************************************
699
+ ! > author: Jacob Williams
700
+ ! date: 6/26/2016
701
+ !
702
+ ! Returns matrix information about a variable in a [[json_file(type)]].
703
+ !
704
+ ! @note If `found` is present, no exceptions will be thrown if an
705
+ ! error occurs. Otherwise, an exception will be thrown if the
706
+ ! variable is not found.
685
707
686
- end subroutine json_file_variable_info
708
+ subroutine json_file_variable_matrix_info (me ,path ,is_matrix ,found ,&
709
+ var_type ,n_sets ,set_size ,name )
710
+
711
+ implicit none
712
+
713
+ class(json_file),intent (inout ) :: me
714
+ character (kind= CK,len=* ),intent (in ) :: path ! ! path to the variable
715
+ logical (LK),intent (out ) :: is_matrix ! ! true if it is a valid matrix
716
+ logical (LK),intent (out ),optional :: found ! ! true if it was found
717
+ integer (IK),intent (out ),optional :: var_type ! ! variable type of data in
718
+ ! ! the matrix (if all elements have
719
+ ! ! the same type)
720
+ integer (IK),intent (out ),optional :: n_sets ! ! number of data sets (i.e., matrix
721
+ ! ! rows if using row-major order)
722
+ integer (IK),intent (out ),optional :: set_size ! ! size of each data set (i.e., matrix
723
+ ! ! cols if using row-major order)
724
+ character (kind= CK,len= :),allocatable ,intent (out ),optional :: name ! ! variable name
725
+
726
+ call me% core% matrix_info(me% p,path,is_matrix,found,var_type,n_sets,set_size,name)
727
+
728
+ end subroutine json_file_variable_matrix_info
687
729
! *****************************************************************************************
688
730
689
731
! *****************************************************************************************
690
732
! >
691
- ! Alternate version of [[json_file_variable_info]], where "path" is kind=CDK.
733
+ ! Alternate version of [[json_file_variable_matrix_info]], where "path" is kind=CDK.
734
+ !
735
+ ! @note If `found` is present, no exceptions will be thrown if an
736
+ ! error occurs. Otherwise, an exception will be thrown if the
737
+ ! variable is not found.
692
738
693
- subroutine wrap_json_file_variable_info (me ,path ,found ,var_type ,n_children )
739
+ subroutine wrap_json_file_variable_matrix_info (me ,path ,is_matrix ,found ,&
740
+ var_type ,n_sets ,set_size ,name )
694
741
695
742
implicit none
696
743
697
744
class(json_file),intent (inout ) :: me
698
- 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
702
-
703
- call me% info(to_unicode(path),found,var_type,n_children)
704
-
705
- end subroutine wrap_json_file_variable_info
745
+ character (kind= CDK,len=* ),intent (in ) :: path ! ! path to the variable
746
+ logical (LK),intent (out ) :: is_matrix ! ! true if it is a valid matrix
747
+ logical (LK),intent (out ),optional :: found ! ! true if it was found
748
+ integer (IK),intent (out ),optional :: var_type ! ! variable type of data in
749
+ ! ! the matrix (if all elements have
750
+ ! ! the same type)
751
+ integer (IK),intent (out ),optional :: n_sets ! ! number of data sets (i.e., matrix
752
+ ! ! rows if using row-major order)
753
+ integer (IK),intent (out ),optional :: set_size ! ! size of each data set (i.e., matrix
754
+ ! ! cols if using row-major order)
755
+ character (kind= CK,len= :),allocatable ,intent (out ),optional :: name ! ! variable name
756
+
757
+ call me% matrix_info(to_unicode(path),is_matrix,found,var_type,n_sets,set_size,name)
758
+
759
+ end subroutine wrap_json_file_variable_matrix_info
706
760
! *****************************************************************************************
707
761
708
762
! *****************************************************************************************
0 commit comments