51 character(len=80),
private :: name =
""
53 character(len=80),
private ::
type =
""
55 logical,
private :: allocated = .false.
58 real(kind=
rp),
private :: real_scalar = 0.0_rp
59 integer,
private :: integer_scalar = 0
62 type(
vector_t),
private,
pointer :: vector_ptr => null()
63 type(
matrix_t),
private,
pointer :: matrix_ptr => null()
64 type(
field_t),
private,
pointer :: field_ptr => null()
98 integer,
intent(in) :: n
99 character(len=*),
optional,
intent(in) :: name
101 if (this%allocated)
then
102 call neko_error(
"init_register_host_array: " // &
103 "Register entry is already allocated.")
108 allocate(this%host_array_ptr)
109 call this%host_array_ptr%init(n)
111 if (
present(name)) this%name = trim(name)
112 this%type =
'host_array'
113 this%allocated = .true.
120 integer,
intent(in) :: n
121 character(len=*),
optional,
intent(in) :: name
123 if (this%allocated)
then
124 call neko_error(
"init_register_device_array: " // &
125 "Register entry is already allocated.")
130 allocate(this%device_array_ptr)
131 call this%device_array_ptr%init(n)
133 if (
present(name)) this%name = trim(name)
134 this%type =
'device_array'
135 this%allocated = .true.
142 integer,
intent(in) :: n
143 character(len=*),
optional,
intent(in) :: name
145 if (this%allocated)
then
147 //
"Register entry is already allocated.")
152 allocate(this%vector_ptr)
153 call this%vector_ptr%init(n)
155 if (
present(name)) this%name = trim(name)
157 this%allocated = .true.
164 integer,
intent(in) :: nrows, ncols
165 character(len=*),
optional,
intent(in) :: name
167 if (this%allocated)
then
169 //
"Register entry is already allocated.")
174 allocate(this%matrix_ptr)
175 call this%matrix_ptr%init(nrows, ncols)
177 if (
present(name)) this%name = trim(name)
179 this%allocated = .true.
186 type(
dofmap_t),
target,
intent(in) :: dof
187 character(len=*),
intent(in) :: name
189 if (this%allocated)
then
191 //
"Register entry is already allocated.")
196 allocate(this%field_ptr)
197 call this%field_ptr%init(dof, trim(name))
199 this%name = trim(name)
201 this%allocated = .true.
208 real(kind=
rp),
intent(in) :: val
209 character(len=*),
optional,
intent(in) :: name
211 if (this%allocated)
then
212 call neko_error(
"init_register_real_scalar: " &
213 //
"Register entry is already allocated.")
218 this%real_scalar = val
220 if (
present(name)) this%name = trim(name)
221 this%type =
'real_scalar'
222 this%allocated = .true.
229 integer,
intent(in) :: val
230 character(len=*),
optional,
intent(in) :: name
232 if (this%allocated)
then
233 call neko_error(
"init_register_integer_scalar: " &
234 //
"Register entry is already allocated.")
239 this%integer_scalar = val
241 if (
present(name)) this%name = trim(name)
242 this%type =
'integer_scalar'
243 this%allocated = .true.
251 if (
associated(this%host_array_ptr))
then
252 call this%host_array_ptr%free()
253 deallocate(this%host_array_ptr)
256 if (
associated(this%device_array_ptr))
then
257 call this%device_array_ptr%free()
258 deallocate(this%device_array_ptr)
261 if (
associated(this%vector_ptr))
then
262 call this%vector_ptr%free()
263 deallocate(this%vector_ptr)
266 if (
associated(this%matrix_ptr))
then
267 call this%matrix_ptr%free()
268 deallocate(this%matrix_ptr)
271 if (
associated(this%field_ptr))
then
272 call this%field_ptr%free()
273 deallocate(this%field_ptr)
276 this%real_scalar = 0.0_rp
277 this%integer_scalar = 0
281 this%allocated = .false.
288 character(len=:),
allocatable :: name
289 name = trim(this%name)
295 character(len=:),
allocatable :: type
296 type = trim(this%type)
303 allocated = this%allocated
311 if (this%get_type() .ne.
'host_array')
then
312 call neko_error(
"registry_entry::get_host_array: " &
313 //
"Registry entry is not of type 'host_array'.")
315 host_array_ptr => this%host_array_ptr
322 if (this%get_type() .ne.
'device_array')
then
323 call neko_error(
"registry_entry::get_device_array: " &
324 //
"Registry entry is not of type 'device_array'.")
326 device_array_ptr => this%device_array_ptr
332 type(
vector_t),
pointer :: vector_ptr
333 if (this%get_type() .ne.
'vector')
then
334 call neko_error(
"registry_entry::get_vector: " &
335 //
"Registry entry is not of type 'vector'.")
337 vector_ptr => this%vector_ptr
343 type(
matrix_t),
pointer :: matrix_ptr
344 if (this%get_type() .ne.
'matrix')
then
345 call neko_error(
"registry_entry::get_field: " &
346 //
"Registry entry is not of type 'matrix'.")
348 matrix_ptr => this%matrix_ptr
354 type(
field_t),
pointer :: field_ptr
355 if (this%get_type() .ne.
'field')
then
356 call neko_error(
"registry_entry::get_field: " &
357 //
"Registry entry is not of type 'field'.")
359 field_ptr => this%field_ptr
365 real(kind=
rp),
pointer :: scalar_ptr
366 if (this%get_type() .ne.
'real_scalar')
then
367 call neko_error(
"registry_entry::get_real_scalar: " &
368 //
"Registry entry is not of type 'real_scalar'.")
370 scalar_ptr => this%real_scalar
376 integer,
pointer :: scalar_ptr
377 if (this%get_type() .ne.
'integer_scalar')
then
378 call neko_error(
"registry_entry::get_integer_scalar: " &
379 //
"Registry entry is not of type 'integer_scalar'.")
381 scalar_ptr => this%integer_scalar
389 if (.not. source%is_allocated())
return
392 this%name = source%name
393 this%type = source%type
394 this%allocated = source%allocated
396 select case (trim(this%type))
398 this%real_scalar = source%real_scalar
399 case (
'integer_scalar')
400 this%integer_scalar = source%integer_scalar
402 this%host_array_ptr => source%host_array_ptr
403 nullify(source%host_array_ptr)
404 case (
'device_array')
405 this%device_array_ptr => source%device_array_ptr
406 nullify(source%device_array_ptr)
408 this%vector_ptr => source%vector_ptr
409 nullify(source%vector_ptr)
411 this%matrix_ptr => source%matrix_ptr
412 nullify(source%matrix_ptr)
414 this%field_ptr => source%field_ptr
415 nullify(source%field_ptr)
417 call neko_error(
"move_from_registry_entry: " // &
418 "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.
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_device_array(this, n, name)
Initialize by a device array.
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.