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 => &
114 integer,
intent(in) :: n
115 character(len=*),
optional,
intent(in) :: name
117 if (this%allocated)
then
118 call neko_error(
"init_register_host_array: " // &
119 "Register entry is already allocated.")
124 allocate(this%host_array_ptr)
125 call this%host_array_ptr%init(n)
127 if (
present(name)) this%name = trim(name)
128 this%type =
'host_array'
129 this%allocated = .true.
136 integer,
intent(in) :: n
137 character(len=*),
optional,
intent(in) :: name
139 if (this%allocated)
then
140 call neko_error(
"init_register_device_array: " // &
141 "Register entry is already allocated.")
146 allocate(this%device_array_ptr)
147 call this%device_array_ptr%init(n)
149 if (
present(name)) this%name = trim(name)
150 this%type =
'device_array'
151 this%allocated = .true.
158 integer,
intent(in) :: n
159 character(len=*),
optional,
intent(in) :: name
161 if (this%allocated)
then
163 //
"Register entry is already allocated.")
168 allocate(this%vector_ptr)
169 call this%vector_ptr%init(n)
171 if (
present(name)) this%name = trim(name)
173 this%allocated = .true.
180 integer,
intent(in) :: nrows, ncols
181 character(len=*),
optional,
intent(in) :: name
183 if (this%allocated)
then
185 //
"Register entry is already allocated.")
190 allocate(this%matrix_ptr)
191 call this%matrix_ptr%init(nrows, ncols)
193 if (
present(name)) this%name = trim(name)
195 this%allocated = .true.
202 integer,
intent(in) :: n, m, l
203 character(len=*),
optional,
intent(in) :: name
205 if (this%allocated)
then
207 //
"Register entry is already allocated.")
212 allocate(this%tensor3_ptr)
213 call this%tensor3_ptr%init(n, m, l)
215 if (
present(name)) this%name = trim(name)
216 this%type =
'tensor3'
217 this%allocated = .true.
224 integer,
intent(in) :: n, m, l, k
225 character(len=*),
optional,
intent(in) :: name
227 if (this%allocated)
then
229 //
"Register entry is already allocated.")
234 allocate(this%tensor4_ptr)
235 call this%tensor4_ptr%init(n, m, l, k)
237 if (
present(name)) this%name = trim(name)
238 this%type =
'tensor4'
239 this%allocated = .true.
246 type(
dofmap_t),
target,
intent(in) :: dof
247 character(len=*),
intent(in) :: name
249 if (this%allocated)
then
251 //
"Register entry is already allocated.")
256 allocate(this%field_ptr)
257 call this%field_ptr%init(dof, trim(name))
259 this%name = trim(name)
261 this%allocated = .true.
268 real(kind=
rp),
intent(in) :: val
269 character(len=*),
optional,
intent(in) :: name
271 if (this%allocated)
then
272 call neko_error(
"init_register_real_scalar: " &
273 //
"Register entry is already allocated.")
278 this%real_scalar = val
280 if (
present(name)) this%name = trim(name)
281 this%type =
'real_scalar'
282 this%allocated = .true.
289 integer,
intent(in) :: val
290 character(len=*),
optional,
intent(in) :: name
292 if (this%allocated)
then
293 call neko_error(
"init_register_integer_scalar: " &
294 //
"Register entry is already allocated.")
299 this%integer_scalar = val
301 if (
present(name)) this%name = trim(name)
302 this%type =
'integer_scalar'
303 this%allocated = .true.
311 if (
associated(this%host_array_ptr))
then
312 call this%host_array_ptr%free()
313 deallocate(this%host_array_ptr)
316 if (
associated(this%device_array_ptr))
then
317 call this%device_array_ptr%free()
318 deallocate(this%device_array_ptr)
321 if (
associated(this%vector_ptr))
then
322 call this%vector_ptr%free()
323 deallocate(this%vector_ptr)
326 if (
associated(this%matrix_ptr))
then
327 call this%matrix_ptr%free()
328 deallocate(this%matrix_ptr)
331 if (
associated(this%tensor3_ptr))
then
332 call this%tensor3_ptr%free()
333 deallocate(this%tensor3_ptr)
336 if (
associated(this%tensor4_ptr))
then
337 call this%tensor4_ptr%free()
338 deallocate(this%tensor4_ptr)
341 if (
associated(this%field_ptr))
then
342 call this%field_ptr%free()
343 deallocate(this%field_ptr)
346 this%real_scalar = 0.0_rp
347 this%integer_scalar = 0
351 this%allocated = .false.
358 character(len=:),
allocatable :: name
359 name = trim(this%name)
365 character(len=:),
allocatable :: type
366 type = trim(this%type)
373 allocated = this%allocated
380 if (this%get_type() .ne.
'host_array')
then
381 call neko_error(
"registry_entry::get_host_array: " &
382 //
"Registry entry is not of type 'host_array'.")
384 host_array_ptr => this%host_array_ptr
391 if (this%get_type() .ne.
'device_array')
then
392 call neko_error(
"registry_entry::get_device_array: " &
393 //
"Registry entry is not of type 'device_array'.")
395 device_array_ptr => this%device_array_ptr
401 type(
vector_t),
pointer :: vector_ptr
402 if (this%get_type() .ne.
'vector')
then
403 call neko_error(
"registry_entry::get_vector: " &
404 //
"Registry entry is not of type 'vector'.")
406 vector_ptr => this%vector_ptr
412 type(
matrix_t),
pointer :: matrix_ptr
413 if (this%get_type() .ne.
'matrix')
then
414 call neko_error(
"registry_entry::get_field: " &
415 //
"Registry entry is not of type 'matrix'.")
417 matrix_ptr => this%matrix_ptr
424 if (this%get_type() .ne.
'tensor3')
then
425 call neko_error(
"registry_entry::get_field: " &
426 //
"Registry entry is not of type 'tensor3'.")
428 tensor3_ptr => this%tensor3_ptr
435 if (this%get_type() .ne.
'tensor4')
then
436 call neko_error(
"registry_entry::get_field: " &
437 //
"Registry entry is not of type 'tensor4'.")
439 tensor4_ptr => this%tensor4_ptr
445 type(
field_t),
pointer :: field_ptr
446 if (this%get_type() .ne.
'field')
then
447 call neko_error(
"registry_entry::get_field: " &
448 //
"Registry entry is not of type 'field'.")
450 field_ptr => this%field_ptr
456 real(kind=
rp),
pointer :: scalar_ptr
457 if (this%get_type() .ne.
'real_scalar')
then
458 call neko_error(
"registry_entry::get_real_scalar: " &
459 //
"Registry entry is not of type 'real_scalar'.")
461 scalar_ptr => this%real_scalar
467 integer,
pointer :: scalar_ptr
468 if (this%get_type() .ne.
'integer_scalar')
then
469 call neko_error(
"registry_entry::get_integer_scalar: " &
470 //
"Registry entry is not of type 'integer_scalar'.")
472 scalar_ptr => this%integer_scalar
480 if (.not. source%is_allocated())
return
483 this%name = source%name
484 this%type = source%type
485 this%allocated = source%allocated
487 select case (trim(this%type))
489 this%real_scalar = source%real_scalar
490 case (
'integer_scalar')
491 this%integer_scalar = source%integer_scalar
493 this%host_array_ptr => source%host_array_ptr
494 nullify(source%host_array_ptr)
495 case (
'device_array')
496 this%device_array_ptr => source%device_array_ptr
497 nullify(source%device_array_ptr)
499 this%vector_ptr => source%vector_ptr
500 nullify(source%vector_ptr)
502 this%matrix_ptr => source%matrix_ptr
503 nullify(source%matrix_ptr)
505 this%tensor3_ptr => source%tensor3_ptr
506 nullify(source%tensor3_ptr)
508 this%tensor4_ptr => source%tensor4_ptr
509 nullify(source%tensor4_ptr)
511 this%field_ptr => source%field_ptr
512 nullify(source%field_ptr)
514 call neko_error(
"move_from_registry_entry: " // &
515 "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.
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.