Skip to content

Commit 9e51a55

Browse files
committed
added matrix_info routines to json_file class.
1 parent 15b162a commit 9e51a55

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

src/json_file_module.F90

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -693,6 +695,70 @@ subroutine wrap_json_file_variable_info(me,path,found,var_type,n_children,name)
693695
end subroutine wrap_json_file_variable_info
694696
!*****************************************************************************************
695697

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.
707+
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
729+
!*****************************************************************************************
730+
731+
!*****************************************************************************************
732+
!>
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.
738+
739+
subroutine wrap_json_file_variable_matrix_info(me,path,is_matrix,found,&
740+
var_type,n_sets,set_size,name)
741+
742+
implicit none
743+
744+
class(json_file),intent(inout) :: me
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
760+
!*****************************************************************************************
761+
696762
!*****************************************************************************************
697763
!> author: Izaak Beekman
698764
! date: 7/23/2015

0 commit comments

Comments
 (0)