36 use json_module,
only : json_file, json_value, json_core
70 type(json_file),
intent(inout) :: json
71 character(len=*),
intent(in) :: name
72 real(kind=
sp),
intent(out) ::
value
74 if (.not. json%valid_path(name))
then
75 call neko_error(
"Parameter " // name //
" missing from the case file")
78 call json%get(name,
value)
86 type(json_file),
intent(inout) :: json
87 character(len=*),
intent(in) :: name
88 real(kind=
dp),
intent(out) ::
value
90 if (.not. json%valid_path(name))
then
91 call neko_error(
"Parameter " // name //
" missing from the case file")
94 call json%get(name,
value)
102 type(json_file),
intent(inout) :: json
103 character(len=*),
intent(in) :: name
104 integer,
intent(out) :: value
106 if (.not. json%valid_path(name))
then
107 call neko_error(
"Parameter " // name //
" missing from the case file")
110 call json%get(name,
value)
118 type(json_file),
intent(inout) :: json
119 character(len=*),
intent(in) :: name
120 logical,
intent(out) :: value
122 if (.not. json%valid_path(name))
then
123 call neko_error(
"Parameter " // name //
" missing from the case file")
126 call json%get(name,
value)
134 type(json_file),
intent(inout) :: json
135 character(len=*),
intent(in) :: name
136 character(len=:),
allocatable,
intent(out) :: value
138 if (.not. json%valid_path(name))
then
139 call neko_error(
"Parameter " // name //
" missing from the case file")
142 call json%get(name,
value)
150 type(json_file),
intent(inout) :: json
151 character(len=*),
intent(in) :: name
152 real(kind=
sp),
allocatable,
intent(out) :: value(:)
154 if (.not. json%valid_path(name))
then
155 call neko_error(
"Parameter " // name //
" missing from the case file")
158 call json%get(name,
value)
166 type(json_file),
intent(inout) :: json
167 character(len=*),
intent(in) :: name
168 real(kind=
dp),
allocatable,
intent(out) :: value(:)
170 if (.not. json%valid_path(name))
then
171 call neko_error(
"Parameter " // name //
" missing from the case file")
174 call json%get(name,
value)
182 type(json_file),
intent(inout) :: json
183 character(len=*),
intent(in) :: name
184 integer,
allocatable,
intent(out) ::
value(:)
186 if (.not. json%valid_path(name))
then
187 call neko_error(
"Parameter " // name //
" missing from the case file")
190 call json%get(name,
value)
198 type(json_file),
intent(inout) :: json
199 character(len=*),
intent(in) :: name
200 logical,
allocatable,
intent(out) ::
value(:)
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)
215 type(json_file),
intent(inout) :: json
216 character(len=*),
intent(in) :: name
217 character(len=*),
allocatable,
intent(out) ::
value(:)
218 character(len=*),
optional,
intent(in) :: filler
220 type(json_value),
pointer :: json_val, val_ptr
221 type(json_core) :: core
222 character(len=:),
allocatable :: string_value
223 integer :: i, n_children
225 if (.not. json%valid_path(name))
then
226 call neko_error(
"Parameter " // name //
" missing from the case file")
228 call json%info(name, n_children = n_children)
230 if (.not.
allocated(
value))
then
231 allocate(value(n_children))
232 else if (len(
value) .lt. n_children)
then
234 allocate(value(n_children))
237 call json%get(name, json_val, found)
238 call json%get_core(core)
241 call core%get_child(json_val, i, val_ptr, found)
242 call core%get(val_ptr, string_value)
244 if (len(string_value) .gt. 0)
then
245 value(i) = string_value
246 else if (
present(filler))
then
255 type(json_file),
intent(inout) :: json
256 character(len=*),
intent(in) :: key
257 type(json_file),
intent(out) :: output
259 type(json_value),
pointer :: child
263 call json%get(key, child, valid)
264 if (.not. valid)
then
266 trim(key) //
'" missing from the case file')
281 type(json_file),
intent(inout) :: json
282 character(len=*),
intent(in) :: name
283 real(kind=
sp),
intent(out) ::
value
284 real(kind=
sp),
intent(in) :: default
287 call json%get(name,
value, found)
289 if (.not. found)
then
291 call json%add(name,
value)
301 type(json_file),
intent(inout) :: json
302 character(len=*),
intent(in) :: name
303 real(kind=
dp),
intent(out) ::
value
304 real(kind=
dp),
intent(in) :: default
307 call json%get(name,
value, found)
309 if (.not. found)
then
311 call json%add(name,
value)
321 type(json_file),
intent(inout) :: json
322 character(len=*),
intent(in) :: name
323 integer,
intent(out) :: value
324 integer,
intent(in) :: default
327 call json%get(name,
value, found)
329 if (.not. found)
then
331 call json%add(name,
value)
341 type(json_file),
intent(inout) :: json
342 character(len=*),
intent(in) :: name
343 logical,
intent(out) :: value
344 logical,
intent(in) :: default
347 call json%get(name,
value, found)
349 if (.not. found)
then
351 call json%add(name,
value)
361 type(json_file),
intent(inout) :: json
362 character(len=*),
intent(in) :: name
363 character(len=:),
allocatable,
intent(out) :: value
364 character(len=*),
intent(in) :: default
367 call json%get(name,
value, found)
369 if (.not. found)
then
371 call json%add(name,
value)
381 type(json_core),
intent(inout) :: core
382 type(json_value),
pointer,
intent(in) :: array
383 integer,
intent(in) :: i
384 type(json_file),
intent(inout) :: item
385 type(json_value),
pointer :: ptr
387 character(len=:),
allocatable :: buffer
389 call core%get_child(array, i, ptr, found)
390 call core%print_to_string(ptr, buffer)
391 call item%load_from_string(buffer)
401 type(json_file),
intent(inout) :: json
402 character(len=*),
intent(in) :: name
403 integer,
intent(in) :: i
404 type(json_file),
intent(out) :: item
406 type(json_core) :: core
407 type(json_value),
pointer :: array
408 type(json_value),
pointer :: ptr
410 character(len=:),
allocatable :: buffer
412 call json%get_core(core)
413 call json%get(name, array, found)
415 if (.not. found)
then
416 call neko_error(
"Parameter " // name //
" missing from the case file")
419 call core%get_child(array, i, ptr, found)
420 call core%print_to_string(ptr, buffer)
421 call item%load_from_string(buffer)
430 type(json_file),
intent(inout) :: json
431 character(len=*),
intent(in) :: name
432 type(json_file),
intent(inout) :: object
434 type(json_value),
pointer :: ptr
435 type(json_core) :: core
437 character(len=:),
allocatable :: buffer
439 call json%get_core(core)
440 call json%get(name, ptr, found)
442 if (.not. found)
then
443 call neko_error(
"Object " // name //
" missing from the case file")
446 call core%print_to_string(ptr, buffer)
447 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.
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.
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.