51 module subroutine json_get_or_lookup_real(json, name, val)
52 type(json_file),
intent(inout) :: json
53 character(len=*),
intent(in) :: name
54 real(kind=sp),
intent(out) :: val
56 character(len=:),
allocatable :: reg_name
60 call json%info(name, found = found, var_type = var_type)
61 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
62 call neko_error(
"Parameter " // name // &
63 " is neither a real nor a string.")
67 call json%get(name, val, found)
72 call json_get(json, name, reg_name)
76 end subroutine json_get_or_lookup_real
82 module subroutine json_get_or_lookup_double(json, name, val)
83 type(json_file),
intent(inout) :: json
84 character(len=*),
intent(in) :: name
85 real(kind=dp),
intent(out) :: val
87 character(len=:),
allocatable :: reg_name
91 call json%info(name, found = found, var_type = var_type)
92 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
93 call neko_error(
"Parameter " // name // &
94 " is neither a real nor a string.")
98 call json%get(name, val, found)
103 call json_get(json, name, reg_name)
107 end subroutine json_get_or_lookup_double
119 module subroutine json_get_or_lookup_integer(json, name, val)
120 type(json_file),
intent(inout) :: json
121 character(len=*),
intent(in) :: name
122 integer,
intent(out) :: val
124 character(len=:),
allocatable :: reg_name
128 call json%info(name, found = found, var_type = var_type)
129 if (found .and. (var_type .ne. 5) .and. (var_type .ne. 7))
then
130 call neko_error(
"Parameter " // name // &
131 " is neither an integer nor a string.")
135 call json%get(name, val, found)
140 call json_get(json, name, reg_name)
144 end subroutine json_get_or_lookup_integer
157 module subroutine json_get_or_lookup_or_default_real(json, name,&
159 type(json_file),
intent(inout) :: json
160 character(len=*),
intent(in) :: name
161 real(kind=sp),
intent(out) :: val
162 real(kind=sp),
intent(in) :: default
164 character(len=:),
allocatable :: reg_name
168 call json%info(name, found = found, var_type = var_type)
169 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
170 call neko_error(
"Parameter " // name // &
171 " is neither a real nor a string.")
174 call json%get(name, val, found)
179 call json%get(name, reg_name, found)
180 if (.not. found)
then
183 call json_get_or_default(json, name, val, default)
188 end subroutine json_get_or_lookup_or_default_real
195 module subroutine json_get_or_lookup_or_default_double(json, name, &
197 type(json_file),
intent(inout) :: json
198 character(len=*),
intent(in) :: name
199 real(kind=dp),
intent(out) :: val
200 real(kind=dp),
intent(in) :: default
202 character(len=:),
allocatable :: reg_name
206 call json%info(name, found = found, var_type = var_type)
207 if (found .and. (var_type .ne. 6) .and. (var_type .ne. 7))
then
208 call neko_error(
"Parameter " // name // &
209 " is neither a real nor a string.")
212 call json%get(name, val, found)
217 call json%get(name, reg_name, found)
218 if (.not. found)
then
221 call json_get_or_default(json, name, val, default)
226 end subroutine json_get_or_lookup_or_default_double
240 module subroutine json_get_or_lookup_or_default_integer(json, &
242 type(json_file),
intent(inout) :: json
243 character(len=*),
intent(in) :: name
244 integer,
intent(out) :: val
245 integer,
intent(in) :: default
247 character(len=:),
allocatable :: reg_name
251 call json%info(name, found = found, var_type = var_type)
252 if (found .and. (var_type .ne. 5) .and. (var_type .ne. 7))
then
253 call neko_error(
"Parameter " // name // &
254 " is neither an integer nor a string.")
257 call json%get(name, val, found)
262 call json%get(name, reg_name, found)
263 if (.not. found)
then
266 call json_get_or_default(json, name, val, default)
271 end subroutine json_get_or_lookup_or_default_integer
282 module subroutine json_get_or_lookup_real_array(json, name, val)
283 type(json_file),
intent(inout) :: json
284 character(len=*),
intent(in) :: name
285 real(kind=sp),
allocatable,
intent(inout) :: val(:)
287 type(vector_t),
pointer :: vec_ptr
289 character(len=:),
allocatable :: reg_name
292 call json%info(name, found = found, var_type = var_type)
293 if (found .and. (var_type .ne. 3) .and. (var_type .ne. 7))
then
294 call neko_error(
"Parameter " // name // &
295 " is neither an array nor a string.")
299 call json%get(name, val, found)
305 call json%info(name, found = found, var_type = var_type)
306 if (found .and. (var_type .ne. 7))
then
307 call neko_error(
"Parameter " // name // &
308 " is neither a real array nor a string.")
312 call json_get(json, name, reg_name)
316 val =
real(vec_ptr%x, kind=sp)
317 end subroutine json_get_or_lookup_real_array
323 module subroutine json_get_or_lookup_double_array(json, name, val)
324 type(json_file),
intent(inout) :: json
325 character(len=*),
intent(in) :: name
326 real(kind=dp),
allocatable,
intent(inout) :: val(:)
328 type(vector_t),
pointer :: vec_ptr
330 character(len=:),
allocatable :: reg_name
334 call json%get(name, val, found)
340 call json%info(name, found = found, var_type = var_type)
341 if (found .and. (var_type .ne. 7))
then
342 call neko_error(
"Parameter " // name // &
343 " is neither a real array nor a string.")
347 call json_get(json, name, reg_name)
351 val =
real(vec_ptr%x, kind=dp)
352 end subroutine json_get_or_lookup_double_array
363 module subroutine json_get_or_lookup_integer_array(json, name, &
365 type(json_file),
intent(inout) :: json
366 character(len=*),
intent(in) :: name
367 integer,
allocatable,
intent(inout) :: val(:)
369 type(vector_t),
pointer :: vec_ptr
371 character(len=:),
allocatable :: reg_name
376 call json%get(name, val, found)
382 call json%info(name, found = found, var_type = var_type)
383 if (found .and. (var_type .ne. 7))
then
384 call neko_error(
"Parameter " // name // &
385 " is neither an integer array nor a string.")
389 call json_get(json, name, reg_name)
396 if (.not. abscmp(
real(val(i), kind=rp), vec_ptr%x(i)))
then
397 call neko_error(
"json_get_or_lookup_integer_array: " &
398 //
"Value retrieved from registry entry '" // reg_name &
399 //
"' is not an integer array.")
402 end subroutine json_get_or_lookup_integer_array
404end submodule case_file_utils
Utilities for retrieving parameters from the case files.
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...