53 character(len=80),
private :: name =
""
55 character(len=80),
private ::
type =
""
57 logical,
private :: allocated = .false.
60 real(kind=
rp),
private :: real_scalar = 0.0_rp
61 integer,
private :: integer_scalar = 0
68 type(
vector_t),
private,
pointer :: vector_ptr => null()
69 type(
matrix_t),
private,
pointer :: matrix_ptr => null()
70 type(
tensor3_t),
private,
pointer :: tensor3_ptr => null()
71 type(
tensor4_t),
private,
pointer :: tensor4_ptr => null()
74 type(
field_t),
private,
pointer :: field_ptr => null()
79 procedure, pass(this) :: init_integer_scalar => &
115 integer,
intent(in) :: n
116 character(len=*),
optional,
intent(in) :: name
118 if (this%allocated)
then
119 call neko_error(
"init_register_host_array: " // &
120 "Register entry is already allocated.")
125 allocate(this%host_array_ptr)
126 call this%host_array_ptr%init(n)
128 if (
present(name)) this%name = trim(name)
129 this%type =
'host_array'
130 this%allocated = .true.
137 integer,
intent(in) :: n
138 character(len=*),
optional,
intent(in) :: name
140 if (this%allocated)
then
141 call neko_error(
"init_register_device_array: " // &
142 "Register entry is already allocated.")
147 allocate(this%device_array_ptr)
148 call this%device_array_ptr%init(n)
150 if (
present(name)) this%name = trim(name)
151 this%type =
'device_array'
152 this%allocated = .true.
159 integer,
intent(in) :: n
160 character(len=*),
optional,
intent(in) :: name
162 if (this%allocated)
then
164 //
"Register entry is already allocated.")
169 allocate(this%vector_ptr)
170 call this%vector_ptr%init(n)
172 if (
present(name)) this%name = trim(name)
174 this%allocated = .true.
181 integer,
intent(in) :: nrows, ncols
182 character(len=*),
optional,
intent(in) :: name
184 if (this%allocated)
then
186 //
"Register entry is already allocated.")
191 allocate(this%matrix_ptr)
192 call this%matrix_ptr%init(nrows, ncols)
194 if (
present(name)) this%name = trim(name)
196 this%allocated = .true.
203 integer,
intent(in) :: n, m, l
204 character(len=*),
optional,
intent(in) :: name
206 if (this%allocated)
then
208 //
"Register entry is already allocated.")
213 allocate(this%tensor3_ptr)
214 call this%tensor3_ptr%init(n, m, l)
216 if (
present(name)) this%name = trim(name)
217 this%type =
'tensor3'
218 this%allocated = .true.
225 integer,
intent(in) :: n, m, l, k
226 character(len=*),
optional,
intent(in) :: name
228 if (this%allocated)
then
230 //
"Register entry is already allocated.")
235 allocate(this%tensor4_ptr)
236 call this%tensor4_ptr%init(n, m, l, k)
238 if (
present(name)) this%name = trim(name)
239 this%type =
'tensor4'
240 this%allocated = .true.
247 type(
dofmap_t),
target,
intent(in) :: dof
248 character(len=*),
intent(in) :: name
250 if (this%allocated)
then
252 //
"Register entry is already allocated.")
257 allocate(this%field_ptr)
258 call this%field_ptr%init(dof, trim(name))
260 this%name = trim(name)
262 this%allocated = .true.
269 real(kind=
rp),
intent(in) :: val
270 character(len=*),
optional,
intent(in) :: name
272 if (this%allocated)
then
273 call neko_error(
"init_register_real_scalar: " &
274 //
"Register entry is already allocated.")
279 this%real_scalar = val
281 if (
present(name)) this%name = trim(name)
282 this%type =
'real_scalar'
283 this%allocated = .true.
290 integer,
intent(in) :: val
291 character(len=*),
optional,
intent(in) :: name
293 if (this%allocated)
then
294 call neko_error(
"init_register_integer_scalar: " &
295 //
"Register entry is already allocated.")
300 this%integer_scalar = val
302 if (
present(name)) this%name = trim(name)
303 this%type =
'integer_scalar'
304 this%allocated = .true.
312 if (
associated(this%host_array_ptr))
then
313 call this%host_array_ptr%free()
314 deallocate(this%host_array_ptr)
317 if (
associated(this%device_array_ptr))
then
318 call this%device_array_ptr%free()
319 deallocate(this%device_array_ptr)
322 if (
associated(this%vector_ptr))
then
323 call this%vector_ptr%free()
324 deallocate(this%vector_ptr)
327 if (
associated(this%matrix_ptr))
then
328 call this%matrix_ptr%free()
329 deallocate(this%matrix_ptr)
332 if (
associated(this%tensor3_ptr))
then
333 call this%tensor3_ptr%free()
334 deallocate(this%tensor3_ptr)
337 if (
associated(this%tensor4_ptr))
then
338 call this%tensor4_ptr%free()
339 deallocate(this%tensor4_ptr)
342 if (
associated(this%field_ptr))
then
343 call this%field_ptr%free()
344 deallocate(this%field_ptr)
347 this%real_scalar = 0.0_rp
348 this%integer_scalar = 0
352 this%allocated = .false.
359 character(len=:),
allocatable :: name
360 name = trim(this%name)
366 character(len=:),
allocatable :: type
367 type = trim(this%type)
374 allocated = this%allocated
380 character(len=*),
intent(in) :: type_str
381 is_type = trim(this%type) .eq. trim(type_str)
388 if (this%get_type() .ne.
'host_array')
then
389 call neko_error(
"registry_entry::get_host_array: " &
390 //
"Registry entry is not of type 'host_array'.")
392 host_array_ptr => this%host_array_ptr
399 if (this%get_type() .ne.
'device_array')
then
400 call neko_error(
"registry_entry::get_device_array: " &
401 //
"Registry entry is not of type 'device_array'.")
403 device_array_ptr => this%device_array_ptr
409 type(
vector_t),
pointer :: vector_ptr
410 if (this%get_type() .ne.
'vector')
then
411 call neko_error(
"registry_entry::get_vector: " &
412 //
"Registry entry is not of type 'vector'.")
414 vector_ptr => this%vector_ptr
420 type(
matrix_t),
pointer :: matrix_ptr
421 if (this%get_type() .ne.
'matrix')
then
422 call neko_error(
"registry_entry::get_field: " &
423 //
"Registry entry is not of type 'matrix'.")
425 matrix_ptr => this%matrix_ptr
432 if (this%get_type() .ne.
'tensor3')
then
433 call neko_error(
"registry_entry::get_field: " &
434 //
"Registry entry is not of type 'tensor3'.")
436 tensor3_ptr => this%tensor3_ptr
443 if (this%get_type() .ne.
'tensor4')
then
444 call neko_error(
"registry_entry::get_field: " &
445 //
"Registry entry is not of type 'tensor4'.")
447 tensor4_ptr => this%tensor4_ptr
453 type(
field_t),
pointer :: field_ptr
454 if (this%get_type() .ne.
'field')
then
455 call neko_error(
"registry_entry::get_field: " &
456 //
"Registry entry is not of type 'field'.")
458 field_ptr => this%field_ptr
464 real(kind=
rp),
pointer :: scalar_ptr
465 if (this%get_type() .ne.
'real_scalar')
then
466 call neko_error(
"registry_entry::get_real_scalar: " &
467 //
"Registry entry is not of type 'real_scalar'.")
469 scalar_ptr => this%real_scalar
475 integer,
pointer :: scalar_ptr
476 if (this%get_type() .ne.
'integer_scalar')
then
477 call neko_error(
"registry_entry::get_integer_scalar: " &
478 //
"Registry entry is not of type 'integer_scalar'.")
480 scalar_ptr => this%integer_scalar
488 if (.not. source%is_allocated())
return
491 this%name = source%name
492 this%type = source%type
493 this%allocated = source%allocated
495 select case (trim(this%type))
497 this%real_scalar = source%real_scalar
498 case (
'integer_scalar')
499 this%integer_scalar = source%integer_scalar
501 this%host_array_ptr => source%host_array_ptr
502 nullify(source%host_array_ptr)
503 case (
'device_array')
504 this%device_array_ptr => source%device_array_ptr
505 nullify(source%device_array_ptr)
507 this%vector_ptr => source%vector_ptr
508 nullify(source%vector_ptr)
510 this%matrix_ptr => source%matrix_ptr
511 nullify(source%matrix_ptr)
513 this%tensor3_ptr => source%tensor3_ptr
514 nullify(source%tensor3_ptr)
516 this%tensor4_ptr => source%tensor4_ptr
517 nullify(source%tensor4_ptr)
519 this%field_ptr => source%field_ptr
520 nullify(source%field_ptr)
522 call neko_error(
"move_from_registry_entry: " // &
523 "Unsupported registry entry type: " // trim(this%type))
Module containing device only array type.
Defines a mapping of the degrees of freedom.
Module containing host-only array type.
integer, parameter, public rp
Global precision used in computations.
Defines a registry entry for storing and requesting temporary objects This is used in the registries ...
real(kind=rp) function, pointer get_real_scalar(this)
Get the real scalar pointer of the registry entry.
subroutine init_register_field(this, dof, name)
Initialize a register entry.
type(tensor3_t) function, pointer get_tensor3(this)
Get the tensor3 pointer of the registry entry.
subroutine init_register_host_array(this, n, name)
Initialize by a host array.
pure character(len=:) function, allocatable get_name(this)
Get the name of the registry entry.
subroutine init_register_tensor4(this, n, m, l, k, name)
Initialize a register entry.
subroutine init_register_device_array(this, n, name)
Initialize by a device array.
type(tensor4_t) function, pointer get_tensor4(this)
Get the tensor4 pointer of the registry entry.
subroutine init_register_tensor3(this, n, m, l, name)
Initialize a register entry.
subroutine init_register_real_scalar(this, val, name)
Initialize a scalar register entry.
subroutine init_register_matrix(this, nrows, ncols, name)
Initialize a register entry.
type(device_array_t) function, pointer get_device_array(this)
Get the device_array pointer of the registry entry.
pure logical function is_type(this, type_str)
Check if the registry entry is of a specific type.
subroutine init_register_vector(this, n, name)
Initialize a register entry.
subroutine init_register_integer_scalar(this, val, name)
Initialize an integer scalar register entry.
subroutine move_from_registry_entry(this, source)
Move a registry entry from another entry.
type(field_t) function, pointer get_field(this)
Get the field pointer of the registry entry.
subroutine free_register(this)
Free a register entry.
type(host_array_t) function, pointer get_host_array(this)
Get the host array pointer of the registry entry.
pure logical function is_allocated(this)
Check if the registry entry is allocated.
type(vector_t) function, pointer get_vector(this)
Get the vector pointer of the registry entry.
type(matrix_t) function, pointer get_matrix(this)
Get the matrix pointer of the registry entry.
pure character(len=:) function, allocatable get_type(this)
Get the type of the registry entry.
integer function, pointer get_integer_scalar(this)
Get the integer scalar pointer of the registry entry.
Device-only temporary array.
Host-only temporary array.