36 use json_module,
only : json_file, json_value, json_core
74 type(json_file),
intent(inout) :: json
75 character(len=*),
intent(in) :: name
76 real(kind=
sp),
intent(out) ::
value
78 if (.not. json%valid_path(name))
then
79 call neko_error(
"Parameter " // name //
" missing from the case file")
82 call json%get(name,
value)
90 type(json_file),
intent(inout) :: json
91 character(len=*),
intent(in) :: name
92 real(kind=
dp),
intent(out) ::
value
94 if (.not. json%valid_path(name))
then
95 call neko_error(
"Parameter " // name //
" missing from the case file")
98 call json%get(name,
value)
106 type(json_file),
intent(inout) :: json
107 character(len=*),
intent(in) :: name
108 integer,
intent(out) :: value
110 real(kind=
rp) :: test_real
112 if (.not. json%valid_path(name))
then
113 call neko_error(
"Parameter " // name //
" missing from the case file")
116 call json%get(name,
value)
117 call json%get(name, test_real)
120 call neko_error(
"Parameter " // name //
" is not an integer value")
131 type(json_file),
intent(inout) :: json
132 character(len=*),
intent(in) :: name
133 logical,
intent(out) :: value
135 if (.not. json%valid_path(name))
then
136 call neko_error(
"Parameter " // name //
" missing from the case file")
139 call json%get(name,
value)
147 type(json_file),
intent(inout) :: json
148 character(len=*),
intent(in) :: name
149 character(len=:),
allocatable,
intent(out) :: value
151 if (.not. json%valid_path(name))
then
152 call neko_error(
"Parameter " // name //
" missing from the case file")
155 call json%get(name,
value)
163 type(json_file),
intent(inout) :: json
164 character(len=*),
intent(in) :: name
165 real(kind=
sp),
allocatable,
intent(out) :: value(:)
167 if (.not. json%valid_path(name))
then
168 call neko_error(
"Parameter " // name //
" missing from the case file")
171 call json%get(name,
value)
179 type(json_file),
intent(inout) :: json
180 character(len=*),
intent(in) :: name
181 real(kind=
dp),
allocatable,
intent(out) :: value(:)
183 if (.not. json%valid_path(name))
then
184 call neko_error(
"Parameter " // name //
" missing from the case file")
187 call json%get(name,
value)
195 type(json_file),
intent(inout) :: json
196 character(len=*),
intent(in) :: name
197 integer,
allocatable,
intent(out) ::
value(:)
199 real(kind=
rp),
allocatable :: test_real(:)
202 if (.not. json%valid_path(name))
then
203 call neko_error(
"Parameter " // name //
" missing from the case file")
206 call json%get(name,
value)
207 call json%get(name, test_real)
209 do i = 1,
size(
value)
210 if (.not.
abscmp(
real(value(i), kind=
rp), test_real(i)))
then
211 call neko_error(
"Parameter " // name //
" is not an integer array")
221 type(json_file),
intent(inout) :: json
222 character(len=*),
intent(in) :: name
223 logical,
allocatable,
intent(out) ::
value(:)
225 if (.not. json%valid_path(name))
then
226 call neko_error(
"Parameter " // name //
" missing from the case file")
229 call json%get(name,
value)
238 type(json_file),
intent(inout) :: json
239 character(len=*),
intent(in) :: name
240 character(len=*),
allocatable,
intent(out) ::
value(:)
241 character(len=*),
optional,
intent(in) :: filler
243 type(json_value),
pointer :: json_val, val_ptr
244 type(json_core) :: core
245 character(len=:),
allocatable :: string_value
246 integer :: i, n_children
248 if (.not. json%valid_path(name))
then
249 call neko_error(
"Parameter " // name //
" missing from the case file")
251 call json%info(name, n_children = n_children)
253 if (.not.
allocated(
value))
then
254 allocate(value(n_children))
255 else if (len(
value) .lt. n_children)
then
257 allocate(value(n_children))
260 call json%get(name, json_val, found)
261 call json%get_core(core)
264 call core%get_child(json_val, i, val_ptr, found)
265 call core%get(val_ptr, string_value)
267 if (len(string_value) .gt. 0)
then
268 value(i) = string_value
269 else if (
present(filler))
then
278 type(json_file),
intent(inout) :: json
279 character(len=*),
intent(in) :: key
280 type(json_file),
intent(inout) :: output
282 type(json_value),
pointer :: ptr
283 type(json_core) :: core
285 character(len=:),
allocatable :: buffer
287 call json%get_core(core)
288 call json%get(key, ptr, found)
290 if (.not. found)
then
292 trim(key) //
" missing from the case file")
295 call core%print_to_string(ptr,
buffer)
306 type(json_file),
intent(inout) :: json
307 character(len=*),
intent(in) :: name
308 real(kind=
sp),
intent(out) ::
value
309 real(kind=
sp),
intent(in) :: default
312 call json%get(name,
value, found)
316 call json%add(name,
value)
317 else if (.not. found)
then
318 call neko_error(
"Parameter " // name //
" missing from the case file")
328 type(json_file),
intent(inout) :: json
329 character(len=*),
intent(in) :: name
330 real(kind=
dp),
intent(out) ::
value
331 real(kind=
dp),
intent(in) :: default
334 call json%get(name,
value, found)
338 call json%add(name,
value)
339 else if (.not. found)
then
340 call neko_error(
"Parameter " // name //
" missing from the case file")
350 type(json_file),
intent(inout) :: json
351 character(len=*),
intent(in) :: name
352 integer,
intent(out) :: value
353 integer,
intent(in) :: default
356 call json%get(name,
value, found)
360 call json%add(name,
value)
361 else if (.not. found)
then
362 call neko_error(
"Parameter " // name //
" missing from the case file")
372 type(json_file),
intent(inout) :: json
373 character(len=*),
intent(in) :: name
374 logical,
intent(out) :: value
375 logical,
intent(in) :: default
378 call json%get(name,
value, found)
382 call json%add(name,
value)
383 else if (.not. found)
then
384 call neko_error(
"Parameter " // name //
" missing from the case file")
394 type(json_file),
intent(inout) :: json
395 character(len=*),
intent(in) :: name
396 character(len=:),
allocatable,
intent(out) :: value
397 character(len=*),
intent(in) :: default
400 call json%get(name,
value, found)
404 call json%add(name,
value)
405 else if (.not. found)
then
406 call neko_error(
"Parameter " // name //
" missing from the case file")
416 type(json_core),
intent(inout) :: core
417 type(json_value),
pointer,
intent(in) :: array
418 integer,
intent(in) :: i
419 type(json_file),
intent(inout) :: item
420 type(json_value),
pointer :: ptr
422 character(len=:),
allocatable :: buffer
424 call core%get_child(array, i, ptr, found)
425 call core%print_to_string(ptr,
buffer)
426 call item%load_from_string(
buffer)
436 type(json_file),
intent(inout) :: json
437 character(len=*),
intent(in) :: name
438 integer,
intent(in) :: i
439 type(json_file),
intent(out) :: item
441 type(json_core) :: core
442 type(json_value),
pointer :: array
443 type(json_value),
pointer :: ptr
445 character(len=:),
allocatable :: buffer
447 call json%get_core(core)
448 call json%get(name, array, found)
450 if (.not. found)
then
451 call neko_error(
"Parameter " // name //
" missing from the case file")
454 call core%get_child(array, i, ptr, found)
455 call core%print_to_string(ptr,
buffer)
456 call item%load_from_string(
buffer)
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Generic buffer that is extended with buffers of varying rank.
Utilities for retrieving parameters from the case files.
subroutine json_extract_item_from_name(json, name, i, item)
Extract ith item from a JSON array as a separate JSON object.
subroutine json_get_logical(json, name, value)
Retrieves a logical parameter by name or throws an error.
subroutine json_get_or_default_string(json, name, value, default)
Retrieves a string parameter by name or assigns a provided default value. In the latter case also add...
subroutine json_get_real_array(json, name, value)
Retrieves a real array parameter by name or throws an error.
subroutine json_get_subdict(json, key, output)
Extract a sub-object from a json object.
subroutine json_extract_item_from_array(core, array, i, item)
Extract ith item from a JSON array as a separate JSON object.
subroutine json_get_string(json, name, value)
Retrieves a string parameter by name or throws an error.
subroutine json_get_or_default_real(json, name, value, default)
Retrieves a real parameter by name or assigns a provided default value. In the latter case also adds ...
subroutine json_get_or_default_double(json, name, value, default)
Retrieves a real parameter by name or assigns a provided default value. In the latter case also adds ...
subroutine json_get_or_default_logical(json, name, value, default)
Retrieves a logical parameter by name or assigns a provided default value. In the latter case also ad...
subroutine json_get_double_array(json, name, value)
Retrieves a real array parameter by name or throws an error.
subroutine json_get_or_default_integer(json, name, value, default)
Retrieves an integer parameter by name or assigns a provided default value. In the latter case also a...
subroutine json_get_double(json, name, value)
Retrieves a double precision real parameter by name or throws an error.
subroutine json_get_string_array(json, name, value, filler)
Retrieves a string array parameter by name or throws an error.
subroutine json_get_logical_array(json, name, value)
Retrieves a logical array parameter by name or throws an error.
subroutine json_get_real(json, name, value)
Retrieves a real parameter by name or throws an error.
logical, public json_no_defaults
If true, the json_get_or_default routines will not add missing parameters.
subroutine json_get_integer(json, name, value)
Retrieves an integer parameter by name or throws an error.
subroutine json_get_integer_array(json, name, value)
Retrieves a integer array parameter by name or throws an error.
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.