@@ -78,6 +78,7 @@ module json_file_module
7878 procedure ,public :: destroy = > json_file_destroy
7979 procedure ,public :: move = > json_file_move_pointer
8080 generic,public :: info = > MAYBEWRAP(json_file_variable_info)
81+ generic,public :: matrix_info = > MAYBEWRAP(json_file_variable_matrix_info)
8182
8283 ! error checking:
8384 procedure ,public :: failed = > json_file_failed
@@ -125,8 +126,9 @@ module json_file_module
125126 procedure :: initialize_json_core_in_file
126127 procedure :: set_json_core_in_file
127128
128- ! git info:
129+ ! get info:
129130 procedure :: MAYBEWRAP(json_file_variable_info)
131+ procedure :: MAYBEWRAP(json_file_variable_matrix_info)
130132
131133 ! get:
132134 procedure :: MAYBEWRAP(json_file_get_object)
@@ -648,61 +650,113 @@ end subroutine json_file_print_to_string
648650! date: 2/3/2014
649651!
650652! 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.
651657
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 )
653659
654660 implicit none
655661
656662 class(json_file),intent (inout ) :: me
657663 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
661668
662- type (json_value), pointer :: p
669+ call me % core % info(me % p,path,found,var_type,n_children,name)
663670
664- ! initialize:
665- nullify(p)
671+ end subroutine json_file_variable_info
672+ ! *****************************************************************************************
666673
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.
669681
670- if ( found) then
682+ subroutine wrap_json_file_variable_info ( me , path , found , var_type , n_children , name )
671683
672- ! get info:
673- call me% core% info(p,var_type,n_children)
684+ implicit none
674685
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
676692
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)
680694
681- end if
695+ end subroutine wrap_json_file_variable_info
696+ ! *****************************************************************************************
682697
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.
685707
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
687729! *****************************************************************************************
688730
689731! *****************************************************************************************
690732! >
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.
692738
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 )
694741
695742 implicit none
696743
697744 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
706760! *****************************************************************************************
707761
708762! *****************************************************************************************
0 commit comments