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)
321 end subroutine json_get_or_lookup_real_array
327 module subroutine json_get_or_lookup_double_array(json, name, val)
328 type(json_file),
intent(inout) :: json
329 character(len=*),
intent(in) :: name
330 real(kind=
dp),
allocatable,
intent(inout) :: val(:)
332 type(vector_t),
pointer :: vec_ptr
334 character(len=:),
allocatable :: reg_name
338 call json%get(name, val, found)
344 call json%info(name, found = found, var_type = var_type)
345 if (found .and. (var_type .ne. 7))
then
346 call neko_error(
"Parameter " // name // &
347 " is neither a real array nor a string.")
351 call json_get(json, name, reg_name)
355 val =
real(vec_ptr%x, kind=
dp)
358 end subroutine json_get_or_lookup_double_array
369 module subroutine json_get_or_lookup_integer_array(json, name, &
371 type(json_file),
intent(inout) :: json
372 character(len=*),
intent(in) :: name
373 integer,
allocatable,
intent(inout) :: val(:)
375 type(vector_t),
pointer :: vec_ptr
377 character(len=:),
allocatable :: reg_name
382 call json%get(name, val, found)
388 call json%info(name, found = found, var_type = var_type)
389 if (found .and. (var_type .ne. 7))
then
390 call neko_error(
"Parameter " // name // &
391 " is neither an integer array nor a string.")
395 call json_get(json, name, reg_name)
402 if (.not.
abscmp(
real(val(i), kind=
rp), vec_ptr%x(i)))
then
403 call neko_error(
"json_get_or_lookup_integer_array: " &
404 //
"Value retrieved from registry entry '" // reg_name &
405 //
"' is not an integer array.")
409 end subroutine json_get_or_lookup_integer_array
411end 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...