Skip to content

Info #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 26, 2016
Merged

Info #212

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
40bf94b
added additional info routines.
jacobwilliams Jun 13, 2016
499e7c7
updated interface to json_file info routines to match the ones in jso…
jacobwilliams Jun 13, 2016
beefb14
added matrix info routines.
jacobwilliams Jun 14, 2016
06b5f64
Merge branch 'master' of https://github.com/jacobwilliams/json-fortra…
jacobwilliams Jun 14, 2016
b4f3e9a
added tests for new info routines.
jacobwilliams Jun 25, 2016
210f9b2
fixed missing variable output.
jacobwilliams Jun 25, 2016
e417f85
attempted fix for Travis build, which is using older version of gfort…
jacobwilliams Jun 25, 2016
068e193
try gfortran-5 for travis builds.
jacobwilliams Jun 26, 2016
5832f94
try gfortran 5.1 for travis builds.
jacobwilliams Jun 26, 2016
229f3be
try again.
jacobwilliams Jun 26, 2016
d87619d
increasing coverage for info routines.
jacobwilliams Jun 26, 2016
eeedbcf
testing workaround for gfortran bug.
jacobwilliams Jun 26, 2016
4d28c78
increase coverage.
jacobwilliams Jun 26, 2016
986b52c
attempting to change codecov target to 70%
jacobwilliams Jun 26, 2016
35ac449
test with gfortran 4.9 on travis.
jacobwilliams Jun 26, 2016
dd01ba7
attempting 4.9 workaround
jacobwilliams Jun 26, 2016
b7d89d6
see if this helps.
jacobwilliams Jun 26, 2016
9175258
revert workaround and try again.
jacobwilliams Jun 26, 2016
7cb102c
revert previous commit. this workaround is necessary for unicode buil…
jacobwilliams Jun 26, 2016
15b162a
remove comment.
jacobwilliams Jun 26, 2016
9e51a55
added matrix_info routines to json_file class.
jacobwilliams Jun 26, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ coverage:
- doc
status:
patch:
default: {}
default:
target: 70%
project:
default: {}
default:
target: 70%
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #174

116 changes: 85 additions & 31 deletions src/json_file_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ module json_file_module
procedure,public :: destroy => json_file_destroy
procedure,public :: move => json_file_move_pointer
generic,public :: info => MAYBEWRAP(json_file_variable_info)
generic,public :: matrix_info => MAYBEWRAP(json_file_variable_matrix_info)

!error checking:
procedure,public :: failed => json_file_failed
Expand Down Expand Up @@ -125,8 +126,9 @@ module json_file_module
procedure :: initialize_json_core_in_file
procedure :: set_json_core_in_file

!git info:
!get info:
procedure :: MAYBEWRAP(json_file_variable_info)
procedure :: MAYBEWRAP(json_file_variable_matrix_info)

!get:
procedure :: MAYBEWRAP(json_file_get_object)
Expand Down Expand Up @@ -648,61 +650,113 @@ end subroutine json_file_print_to_string
! date: 2/3/2014
!
! Returns information about a variable in a [[json_file(type)]].
!
!@note If `found` is present, no exceptions will be thrown if an
! error occurs. Otherwise, an exception will be thrown if the
! variable is not found.

subroutine json_file_variable_info(me,path,found,var_type,n_children)
subroutine json_file_variable_info(me,path,found,var_type,n_children,name)

implicit none

class(json_file),intent(inout) :: me
character(kind=CK,len=*),intent(in) :: path !! path to the variable
logical(LK),intent(out) :: found !! the variable exists in the structure
integer(IK),intent(out) :: var_type !! variable type
integer(IK),intent(out) :: n_children !! number of children
logical(LK),intent(out),optional :: found !! the variable exists in the structure
integer(IK),intent(out),optional :: var_type !! variable type
integer(IK),intent(out),optional :: n_children !! number of children
character(kind=CK,len=:),allocatable,intent(out),optional :: name !! variable name

type(json_value),pointer :: p
call me%core%info(me%p,path,found,var_type,n_children,name)

!initialize:
nullify(p)
end subroutine json_file_variable_info
!*****************************************************************************************

!get a pointer to the variable (if it is there):
call me%get(path,p,found)
!*****************************************************************************************
!>
! Alternate version of [[json_file_variable_info]], where "path" is kind=CDK.
!
!@note If `found` is present, no exceptions will be thrown if an
! error occurs. Otherwise, an exception will be thrown if the
! variable is not found.

if (found) then
subroutine wrap_json_file_variable_info(me,path,found,var_type,n_children,name)

!get info:
call me%core%info(p,var_type,n_children)
implicit none

else
class(json_file),intent(inout) :: me
character(kind=CDK,len=*),intent(in) :: path
logical(LK),intent(out),optional :: found
integer(IK),intent(out),optional :: var_type
integer(IK),intent(out),optional :: n_children
character(kind=CK,len=:),allocatable,intent(out),optional :: name !! variable name

!set to dummy values:
var_type = json_unknown
n_children = 0
call me%info(to_unicode(path),found,var_type,n_children,name)

end if
end subroutine wrap_json_file_variable_info
!*****************************************************************************************

!cleanup:
nullify(p)
!*****************************************************************************************
!> author: Jacob Williams
! date: 6/26/2016
!
! Returns matrix information about a variable in a [[json_file(type)]].
!
!@note If `found` is present, no exceptions will be thrown if an
! error occurs. Otherwise, an exception will be thrown if the
! variable is not found.

end subroutine json_file_variable_info
subroutine json_file_variable_matrix_info(me,path,is_matrix,found,&
var_type,n_sets,set_size,name)

implicit none

class(json_file),intent(inout) :: me
character(kind=CK,len=*),intent(in) :: path !! path to the variable
logical(LK),intent(out) :: is_matrix !! true if it is a valid matrix
logical(LK),intent(out),optional :: found !! true if it was found
integer(IK),intent(out),optional :: var_type !! variable type of data in
!! the matrix (if all elements have
!! the same type)
integer(IK),intent(out),optional :: n_sets !! number of data sets (i.e., matrix
!! rows if using row-major order)
integer(IK),intent(out),optional :: set_size !! size of each data set (i.e., matrix
!! cols if using row-major order)
character(kind=CK,len=:),allocatable,intent(out),optional :: name !! variable name

call me%core%matrix_info(me%p,path,is_matrix,found,var_type,n_sets,set_size,name)

end subroutine json_file_variable_matrix_info
!*****************************************************************************************

!*****************************************************************************************
!>
! Alternate version of [[json_file_variable_info]], where "path" is kind=CDK.
! Alternate version of [[json_file_variable_matrix_info]], where "path" is kind=CDK.
!
!@note If `found` is present, no exceptions will be thrown if an
! error occurs. Otherwise, an exception will be thrown if the
! variable is not found.

subroutine wrap_json_file_variable_info(me,path,found,var_type,n_children)
subroutine wrap_json_file_variable_matrix_info(me,path,is_matrix,found,&
var_type,n_sets,set_size,name)

implicit none

class(json_file),intent(inout) :: me
character(kind=CDK,len=*),intent(in) :: path
logical(LK),intent(out) :: found
integer(IK),intent(out) :: var_type
integer(IK),intent(out) :: n_children

call me%info(to_unicode(path),found,var_type,n_children)

end subroutine wrap_json_file_variable_info
character(kind=CDK,len=*),intent(in) :: path !! path to the variable
logical(LK),intent(out) :: is_matrix !! true if it is a valid matrix
logical(LK),intent(out),optional :: found !! true if it was found
integer(IK),intent(out),optional :: var_type !! variable type of data in
!! the matrix (if all elements have
!! the same type)
integer(IK),intent(out),optional :: n_sets !! number of data sets (i.e., matrix
!! rows if using row-major order)
integer(IK),intent(out),optional :: set_size !! size of each data set (i.e., matrix
!! cols if using row-major order)
character(kind=CK,len=:),allocatable,intent(out),optional :: name !! variable name

call me%matrix_info(to_unicode(path),is_matrix,found,var_type,n_sets,set_size,name)

end subroutine wrap_json_file_variable_matrix_info
!*****************************************************************************************

!*****************************************************************************************
Expand Down
Loading