36 use json_module,
only : json_file, json_value, json_core
69 type(json_file),
intent(inout) :: json
70 character(len=*),
intent(in) :: name
71 real(kind=
sp),
intent(out) ::
value
73 if (.not. json%valid_path(name))
then
74 call neko_error(
"Parameter " // name //
" missing from the case file")
77 call json%get(name,
value)
85 type(json_file),
intent(inout) :: json
86 character(len=*),
intent(in) :: name
87 real(kind=
dp),
intent(out) ::
value
89 if (.not. json%valid_path(name))
then
90 call neko_error(
"Parameter " // name //
" missing from the case file")
93 call json%get(name,
value)
101 type(json_file),
intent(inout) :: json
102 character(len=*),
intent(in) :: name
103 integer,
intent(out) :: value
105 if (.not. json%valid_path(name))
then
106 call neko_error(
"Parameter " // name //
" missing from the case file")
109 call json%get(name,
value)
117 type(json_file),
intent(inout) :: json
118 character(len=*),
intent(in) :: name
119 logical,
intent(out) :: value
121 if (.not. json%valid_path(name))
then
122 call neko_error(
"Parameter " // name //
" missing from the case file")
125 call json%get(name,
value)
133 type(json_file),
intent(inout) :: json
134 character(len=*),
intent(in) :: name
135 character(len=:),
allocatable,
intent(out) :: value
137 if (.not. json%valid_path(name))
then
138 call neko_error(
"Parameter " // name //
" missing from the case file")
141 call json%get(name,
value)
149 type(json_file),
intent(inout) :: json
150 character(len=*),
intent(in) :: name
151 real(kind=
sp),
allocatable,
intent(out) :: value(:)
153 if (.not. json%valid_path(name))
then
154 call neko_error(
"Parameter " // name //
" missing from the case file")
157 call json%get(name,
value)
165 type(json_file),
intent(inout) :: json
166 character(len=*),
intent(in) :: name
167 real(kind=
dp),
allocatable,
intent(out) :: value(:)
169 if (.not. json%valid_path(name))
then
170 call neko_error(
"Parameter " // name //
" missing from the case file")
173 call json%get(name,
value)
181 type(json_file),
intent(inout) :: json
182 character(len=*),
intent(in) :: name
183 integer,
allocatable,
intent(out) ::
value(:)
185 if (.not. json%valid_path(name))
then
186 call neko_error(
"Parameter " // name //
" missing from the case file")
189 call json%get(name,
value)
197 type(json_file),
intent(inout) :: json
198 character(len=*),
intent(in) :: name
199 logical,
allocatable,
intent(out) ::
value(:)
201 if (.not. json%valid_path(name))
then
202 call neko_error(
"Parameter " // name //
" missing from the case file")
205 call json%get(name,
value)
214 type(json_file),
intent(inout) :: json
215 character(len=*),
intent(in) :: name
216 character(len=*),
allocatable,
intent(out) ::
value(:)
217 character(len=*),
optional,
intent(in) :: filler
219 type(json_value),
pointer :: json_val, val_ptr
220 type(json_core) :: core
221 character(len=:),
allocatable :: string_value
222 integer :: i, n_children
224 if (.not. json%valid_path(name))
then
225 call neko_error(
"Parameter " // name //
" missing from the case file")
227 call json%info(name, n_children=n_children)
229 if (.not.
allocated(
value))
then
230 allocate(value(n_children))
231 else if (len(
value) .lt. n_children)
then
233 allocate(value(n_children))
236 call json%get(name, json_val, found)
237 call json%get_core(core)
240 call core%get_child(json_val, i, val_ptr, found)
241 call core%get(val_ptr, string_value)
243 if (len(string_value) .gt. 0)
then
244 value(i) = string_value
245 else if(
present(filler))
then
258 type(json_file),
intent(inout) :: json
259 character(len=*),
intent(in) :: name
260 real(kind=
sp),
intent(out) ::
value
261 real(kind=
sp),
intent(in) :: default
264 call json%get(name,
value, found)
266 if (.not. found)
then
268 call json%add(name,
value)
278 type(json_file),
intent(inout) :: json
279 character(len=*),
intent(in) :: name
280 real(kind=
dp),
intent(out) ::
value
281 real(kind=
dp),
intent(in) :: default
284 call json%get(name,
value, found)
286 if (.not. found)
then
288 call json%add(name,
value)
298 type(json_file),
intent(inout) :: json
299 character(len=*),
intent(in) :: name
300 integer,
intent(out) :: value
301 integer,
intent(in) :: default
304 call json%get(name,
value, found)
306 if (.not. found)
then
308 call json%add(name,
value)
318 type(json_file),
intent(inout) :: json
319 character(len=*),
intent(in) :: name
320 logical,
intent(out) :: value
321 logical,
intent(in) :: default
324 call json%get(name,
value, found)
326 if (.not. found)
then
328 call json%add(name,
value)
338 type(json_file),
intent(inout) :: json
339 character(len=*),
intent(in) :: name
340 character(len=:),
allocatable,
intent(out) :: value
341 character(len=*),
intent(in) :: default
344 call json%get(name,
value, found)
346 if (.not. found)
then
348 call json%add(name,
value)
358 type(json_core),
intent(inout) :: core
359 type(json_value),
pointer,
intent(in) :: array
360 integer,
intent(in) :: i
361 type(json_file),
intent(inout) :: item
362 type(json_value),
pointer :: ptr
364 character(len=:),
allocatable :: buffer
366 call core%get_child(array, i, ptr, found)
367 call core%print_to_string(ptr, buffer)
368 call item%load_from_string(buffer)
378 type(json_file),
intent(inout) :: json
379 character(len=*),
intent(in) :: name
380 integer,
intent(in) :: i
381 type(json_file),
intent(out) :: item
383 type(json_core) :: core
384 type(json_value),
pointer :: array
385 type(json_value),
pointer :: ptr
387 character(len=:),
allocatable :: buffer
389 call json%get_core(core)
390 call json%get(name, array, found)
392 if (.not. found)
then
393 call neko_error(
"Parameter " // name //
" missing from the case file")
396 call core%get_child(array, i, ptr, found)
397 call core%print_to_string(ptr, buffer)
398 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.
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_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.