Skip to content

Commit 0d58f6e

Browse files
committed
Silence warnings associated with new test 12
1 parent bc692d7 commit 0d58f6e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/tests/jf_test_12.f90

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module jf_test_12_mod
77

88
character(len=*),parameter :: dir = '../files/outputs/' !! Path to write JSON file to
99
character(len=*),parameter :: file = 'array.json' !! Filename to write
10+
real(wp), parameter :: TOL = 100*epsilon(1.0_wp) !! Tolerance for real comparisons
1011

1112
contains
1213

@@ -81,7 +82,7 @@ subroutine test_12(error_cnt)
8182
call check_errors()
8283

8384
call json_get(root,'$.array data.data(1)',array_element)
84-
call check_errors(array_element == 1.0_wp)
85+
call check_errors(abs(array_element - 1.0_wp) <= TOL)
8586

8687
call json_get(root,'@.array data.shape',fetched_shape)
8788
call check_errors(all(fetched_shape == shape))
@@ -129,14 +130,14 @@ subroutine test_12(error_cnt)
129130
call check_errors()
130131

131132
call json_get(tmp_json_ptr,fetched_array)
132-
call check_errors(all(fetched_array == reshape(raw_array,[size(raw_array)])))
133+
call check_errors(all(abs(fetched_array - reshape(raw_array,[size(raw_array)])) <= TOL))
133134

134135
call json_get(root,'array data.data',fetched_array)
135-
call check_errors(all(fetched_array == reshape(raw_array,[size(raw_array)])))
136+
call check_errors(all(abs(fetched_array - reshape(raw_array,[size(raw_array)])) <= TOL))
136137

137138
raw_array = 0
138139
call json_get(me=root,path='array data.data',array_callback=get_3D_from_array)
139-
call check_errors(all(fetched_array == reshape(raw_array,[size(raw_array)])))
140+
call check_errors(all(abs(fetched_array - reshape(raw_array,[size(raw_array)])) <= TOL))
140141

141142
my_file = json_file(root)
142143

@@ -150,7 +151,7 @@ subroutine test_12(error_cnt)
150151
call check_errors()
151152

152153
call my_file%get('$array data.data',fetched_array)
153-
call check_errors(all(fetched_array == reshape(raw_array,[size(raw_array)])))
154+
call check_errors(all(abs(fetched_array - reshape(raw_array,[size(raw_array)])) <= TOL))
154155

155156
call my_file%get(tmp_json_ptr)
156157
call check_errors(associated(tmp_json_ptr,root))
@@ -169,14 +170,16 @@ subroutine check_errors(assertion)
169170

170171
subroutine get_3D_from_array(element, i, count)
171172
type(json_value), pointer , intent(in) :: element
172-
integer , intent(in) :: i !index
173-
integer , intent(in) :: count !size of array
173+
integer , intent(in) :: i !!index
174+
integer , intent(in) :: count !!size of array
175+
integer :: useless !! assign count to this to silence warnings
174176

175177
! let's pretend we're c programmers!
176178
call json_get( element, raw_array( &
177179
mod(i-1,imx) + 1, & ! i index
178180
mod((i-1)/imx,jmx) + 1, & ! j index
179181
mod((i-1)/imx/jmx,kmx) + 1 ) ) ! k inded
182+
useless = count
180183
end subroutine
181184

182185
end subroutine

0 commit comments

Comments
 (0)