36 use json_module,
only : json_file, json_value, json_core
73 type(json_file),
intent(inout) :: json
74 character(len=*),
intent(in) :: name
75 real(kind=
sp),
intent(out) ::
value
77 if (.not. json%valid_path(name))
then
78 call neko_error(
"Parameter " // name //
" missing from the case file")
81 call json%get(name,
value)
89 type(json_file),
intent(inout) :: json
90 character(len=*),
intent(in) :: name
91 real(kind=
dp),
intent(out) ::
value
93 if (.not. json%valid_path(name))
then
94 call neko_error(
"Parameter " // name //
" missing from the case file")
97 call json%get(name,
value)
105 type(json_file),
intent(inout) :: json
106 character(len=*),
intent(in) :: name
107 integer,
intent(out) :: value
109 if (.not. json%valid_path(name))
then
110 call neko_error(
"Parameter " // name //
" missing from the case file")
113 call json%get(name,
value)
121 type(json_file),
intent(inout) :: json
122 character(len=*),
intent(in) :: name
123 logical,
intent(out) :: value
125 if (.not. json%valid_path(name))
then
126 call neko_error(
"Parameter " // name //
" missing from the case file")
129 call json%get(name,
value)
137 type(json_file),
intent(inout) :: json
138 character(len=*),
intent(in) :: name
139 character(len=:),
allocatable,
intent(out) :: value
141 if (.not. json%valid_path(name))
then
142 call neko_error(
"Parameter " // name //
" missing from the case file")
145 call json%get(name,
value)
153 type(json_file),
intent(inout) :: json
154 character(len=*),
intent(in) :: name
155 real(kind=
sp),
allocatable,
intent(out) :: value(:)
157 if (.not. json%valid_path(name))
then
158 call neko_error(
"Parameter " // name //
" missing from the case file")
161 call json%get(name,
value)
169 type(json_file),
intent(inout) :: json
170 character(len=*),
intent(in) :: name
171 real(kind=
dp),
allocatable,
intent(out) :: value(:)
173 if (.not. json%valid_path(name))
then
174 call neko_error(
"Parameter " // name //
" missing from the case file")
177 call json%get(name,
value)
185 type(json_file),
intent(inout) :: json
186 character(len=*),
intent(in) :: name
187 integer,
allocatable,
intent(out) ::
value(:)
189 if (.not. json%valid_path(name))
then
190 call neko_error(
"Parameter " // name //
" missing from the case file")
193 call json%get(name,
value)
201 type(json_file),
intent(inout) :: json
202 character(len=*),
intent(in) :: name
203 logical,
allocatable,
intent(out) ::
value(:)
205 if (.not. json%valid_path(name))
then
206 call neko_error(
"Parameter " // name //
" missing from the case file")
209 call json%get(name,
value)
218 type(json_file),
intent(inout) :: json
219 character(len=*),
intent(in) :: name
220 character(len=*),
allocatable,
intent(out) ::
value(:)
221 character(len=*),
optional,
intent(in) :: filler
223 type(json_value),
pointer :: json_val, val_ptr
224 type(json_core) :: core
225 character(len=:),
allocatable :: string_value
226 integer :: i, n_children
228 if (.not. json%valid_path(name))
then
229 call neko_error(
"Parameter " // name //
" missing from the case file")
231 call json%info(name, n_children = n_children)
233 if (.not.
allocated(
value))
then
234 allocate(value(n_children))
235 else if (len(
value) .lt. n_children)
then
237 allocate(value(n_children))
240 call json%get(name, json_val, found)
241 call json%get_core(core)
244 call core%get_child(json_val, i, val_ptr, found)
245 call core%get(val_ptr, string_value)
247 if (len(string_value) .gt. 0)
then
248 value(i) = string_value
249 else if (
present(filler))
then
258 type(json_file),
intent(inout) :: json
259 character(len=*),
intent(in) :: key
260 type(json_file),
intent(out) :: output
262 type(json_value),
pointer :: child
266 call json%get(key, child, valid)
267 if (.not. valid)
then
269 trim(key) //
'" missing from the case file')
284 type(json_file),
intent(inout) :: json
285 character(len=*),
intent(in) :: name
286 real(kind=
sp),
intent(out) ::
value
287 real(kind=
sp),
intent(in) :: default
290 call json%get(name,
value, found)
294 call json%add(name,
value)
295 else if (.not. found)
then
296 call neko_error(
"Parameter " // name //
" missing from the case file")
306 type(json_file),
intent(inout) :: json
307 character(len=*),
intent(in) :: name
308 real(kind=
dp),
intent(out) ::
value
309 real(kind=
dp),
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 integer,
intent(out) :: value
331 integer,
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 logical,
intent(out) :: value
353 logical,
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 character(len=:),
allocatable,
intent(out) :: value
375 character(len=*),
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_core),
intent(inout) :: core
395 type(json_value),
pointer,
intent(in) :: array
396 integer,
intent(in) :: i
397 type(json_file),
intent(inout) :: item
398 type(json_value),
pointer :: ptr
400 character(len=:),
allocatable :: buffer
402 call core%get_child(array, i, ptr, found)
403 call core%print_to_string(ptr,
buffer)
404 call item%load_from_string(
buffer)
414 type(json_file),
intent(inout) :: json
415 character(len=*),
intent(in) :: name
416 integer,
intent(in) :: i
417 type(json_file),
intent(out) :: item
419 type(json_core) :: core
420 type(json_value),
pointer :: array
421 type(json_value),
pointer :: ptr
423 character(len=:),
allocatable :: buffer
425 call json%get_core(core)
426 call json%get(name, array, found)
428 if (.not. found)
then
429 call neko_error(
"Parameter " // name //
" missing from the case file")
432 call core%get_child(array, i, ptr, found)
433 call core%print_to_string(ptr,
buffer)
434 call item%load_from_string(
buffer)
443 type(json_file),
intent(inout) :: json
444 character(len=*),
intent(in) :: name
445 type(json_file),
intent(inout) :: object
447 type(json_value),
pointer :: ptr
448 type(json_core) :: core
450 character(len=:),
allocatable ::
buffer
452 call json%get_core(core)
453 call json%get(name, ptr, found)
455 if (.not. found)
then
456 call neko_error(
"Object " // name //
" missing from the case file")
459 call core%print_to_string(ptr,
buffer)
460 call object%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, public json_extract_object(json, name, object)
Extract object as a separate JSON dictionary.
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.