53 module subroutine json_get_or_lookup_real(json, name, val)
54 type(json_file),
intent(inout) :: json
55 character(len=*),
intent(in) :: name
56 real(kind=
sp),
intent(out) :: val
58 character(len=:),
allocatable :: reg_name
62 call json%info(name, found = found, var_type = var_type)
63 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
64 call neko_error(
"Parameter " // name // &
65 " is neither a real nor a string.")
69 call json%get(name, val, found)
74 call json_get(json, name, reg_name)
78 end subroutine json_get_or_lookup_real
84 module subroutine json_get_or_lookup_double(json, name, val)
85 type(json_file),
intent(inout) :: json
86 character(len=*),
intent(in) :: name
87 real(kind=
dp),
intent(out) :: val
89 character(len=:),
allocatable :: reg_name
93 call json%info(name, found = found, var_type = var_type)
94 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
95 call neko_error(
"Parameter " // name // &
96 " is neither a real nor a string.")
100 call json%get(name, val, found)
105 call json_get(json, name, reg_name)
109 end subroutine json_get_or_lookup_double
121 module subroutine json_get_or_lookup_integer(json, name, val)
122 type(json_file),
intent(inout) :: json
123 character(len=*),
intent(in) :: name
124 integer,
intent(out) :: val
126 character(len=:),
allocatable :: reg_name
130 call json%info(name, found = found, var_type = var_type)
131 if (found .and. (var_type .ne. 5) .and. (var_type .ne. 7))
then
132 call neko_error(
"Parameter " // name // &
133 " is neither an integer nor a string.")
137 call json%get(name, val, found)
142 call json_get(json, name, reg_name)
146 end subroutine json_get_or_lookup_integer
159 module subroutine json_get_or_lookup_or_default_real(json, name,&
161 type(json_file),
intent(inout) :: json
162 character(len=*),
intent(in) :: name
163 real(kind=
sp),
intent(out) :: val
164 real(kind=
sp),
intent(in) :: default
166 character(len=:),
allocatable :: reg_name
170 call json%info(name, found = found, var_type = var_type)
171 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
172 call neko_error(
"Parameter " // name // &
173 " is neither a real nor a string.")
176 call json%get(name, val, found)
181 call json%get(name, reg_name, found)
182 if (.not. found)
then
185 call json_get_or_default(json, name, val, default)
190 end subroutine json_get_or_lookup_or_default_real
197 module subroutine json_get_or_lookup_or_default_double(json, name, &
199 type(json_file),
intent(inout) :: json
200 character(len=*),
intent(in) :: name
201 real(kind=
dp),
intent(out) :: val
202 real(kind=
dp),
intent(in) :: default
204 character(len=:),
allocatable :: reg_name
208 call json%info(name, found = found, var_type = var_type)
209 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
210 call neko_error(
"Parameter " // name // &
211 " is neither a real nor a string.")
214 call json%get(name, val, found)
219 call json%get(name, reg_name, found)
220 if (.not. found)
then
223 call json_get_or_default(json, name, val, default)
228 end subroutine json_get_or_lookup_or_default_double
242 module subroutine json_get_or_lookup_or_default_integer(json, &
244 type(json_file),
intent(inout) :: json
245 character(len=*),
intent(in) :: name
246 integer,
intent(out) :: val
247 integer,
intent(in) :: default
249 character(len=:),
allocatable :: reg_name
253 call json%info(name, found = found, var_type = var_type)
254 if (found .and. (var_type .ne. 5) .and. (var_type .ne. 7))
then
255 call neko_error(
"Parameter " // name // &
256 " is neither an integer nor a string.")
259 call json%get(name, val, found)
264 call json%get(name, reg_name, found)
265 if (.not. found)
then
268 call json_get_or_default(json, name, val, default)
273 end subroutine json_get_or_lookup_or_default_integer
284 module subroutine json_get_or_lookup_real_array(json, name, val)
285 type(json_file),
intent(inout) :: json
286 character(len=*),
intent(in) :: name
287 real(kind=
sp),
allocatable,
intent(inout) :: val(:)
289 type(vector_t),
pointer :: vec_ptr
291 character(len=:),
allocatable :: reg_name
294 call json%info(name, found = found, var_type = var_type)
295 if (found .and. (var_type .ne. 3) .and. (var_type .ne. 7))
then
296 call neko_error(
"Parameter " // name // &
297 " is neither an array nor a string.")
301 call json%get(name, val, found)
307 call json%info(name, found = found, var_type = var_type)
308 if (found .and. (var_type .ne. 7))
then
309 call neko_error(
"Parameter " // name // &
310 " is neither a real array nor a string.")
314 call json_get(json, name, reg_name)
318 val =
real(vec_ptr%x, kind=
sp)
319 end subroutine json_get_or_lookup_real_array
325 module subroutine json_get_or_lookup_double_array(json, name, val)
326 type(json_file),
intent(inout) :: json
327 character(len=*),
intent(in) :: name
328 real(kind=
dp),
allocatable,
intent(inout) :: val(:)
330 type(vector_t),
pointer :: vec_ptr
332 character(len=:),
allocatable :: reg_name
336 call json%get(name, val, found)
342 call json%info(name, found = found, var_type = var_type)
343 if (found .and. (var_type .ne. 7))
then
344 call neko_error(
"Parameter " // name // &
345 " is neither a real array nor a string.")
349 call json_get(json, name, reg_name)
353 val =
real(vec_ptr%x, kind=
dp)
354 end subroutine json_get_or_lookup_double_array
365 module subroutine json_get_or_lookup_integer_array(json, name, &
367 type(json_file),
intent(inout) :: json
368 character(len=*),
intent(in) :: name
369 integer,
allocatable,
intent(inout) :: val(:)
371 type(vector_t),
pointer :: vec_ptr
373 character(len=:),
allocatable :: reg_name
378 call json%get(name, val, found)
384 call json%info(name, found = found, var_type = var_type)
385 if (found .and. (var_type .ne. 7))
then
386 call neko_error(
"Parameter " // name // &
387 " is neither an integer array nor a string.")
391 call json_get(json, name, reg_name)
398 if (.not.
abscmp(
real(val(i), kind=
rp), vec_ptr%x(i)))
then
399 call neko_error(
"json_get_or_lookup_integer_array: " &
400 //
"Value retrieved from registry entry '" // reg_name &
401 //
"' is not an integer array.")
404 end subroutine json_get_or_lookup_integer_array
406end submodule case_file_utils
Utilities for retrieving parameters from the case files.
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
Defines a registry for storing solution fields.
type(registry_t), target, public neko_const_registry
This registry is used to store user-defined scalars and vectors, provided under the constants section...