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()
69 procedure, pass(this) :: init_integer_scalar => &
99 integer,
intent(in) :: n
100 character(len=*),
optional,
intent(in) :: name
102 if (this%allocated)
then
103 call neko_error(
"init_register_host_array: " // &
104 "Register entry is already allocated.")
109 allocate(this%host_array_ptr)
110 call this%host_array_ptr%init(n)
112 if (
present(name)) this%name = trim(name)
113 this%type =
'host_array'
114 this%allocated = .true.
121 integer,
intent(in) :: n
122 character(len=*),
optional,
intent(in) :: name
124 if (this%allocated)
then
125 call neko_error(
"init_register_device_array: " // &
126 "Register entry is already allocated.")
131 allocate(this%device_array_ptr)
132 call this%device_array_ptr%init(n)
134 if (
present(name)) this%name = trim(name)
135 this%type =
'device_array'
136 this%allocated = .true.
143 integer,
intent(in) :: n
144 character(len=*),
optional,
intent(in) :: name
146 if (this%allocated)
then
148 //
"Register entry is already allocated.")
153 allocate(this%vector_ptr)
154 call this%vector_ptr%init(n)
156 if (
present(name)) this%name = trim(name)
158 this%allocated = .true.
165 integer,
intent(in) :: nrows, ncols
166 character(len=*),
optional,
intent(in) :: name
168 if (this%allocated)
then
170 //
"Register entry is already allocated.")
175 allocate(this%matrix_ptr)
176 call this%matrix_ptr%init(nrows, ncols)
178 if (
present(name)) this%name = trim(name)
180 this%allocated = .true.
187 type(
dofmap_t),
target,
intent(in) :: dof
188 character(len=*),
intent(in) :: name
190 if (this%allocated)
then
192 //
"Register entry is already allocated.")
197 allocate(this%field_ptr)
198 call this%field_ptr%init(dof, trim(name))
200 this%name = trim(name)
202 this%allocated = .true.
209 real(kind=
rp),
intent(in) :: val
210 character(len=*),
optional,
intent(in) :: name
212 if (this%allocated)
then
213 call neko_error(
"init_register_real_scalar: " &
214 //
"Register entry is already allocated.")
219 this%real_scalar = val
221 if (
present(name)) this%name = trim(name)
222 this%type =
'real_scalar'
223 this%allocated = .true.
230 integer,
intent(in) :: val
231 character(len=*),
optional,
intent(in) :: name
233 if (this%allocated)
then
234 call neko_error(
"init_register_integer_scalar: " &
235 //
"Register entry is already allocated.")
240 this%integer_scalar = val
242 if (
present(name)) this%name = trim(name)
243 this%type =
'integer_scalar'
244 this%allocated = .true.
252 if (
associated(this%host_array_ptr))
then
253 call this%host_array_ptr%free()
254 deallocate(this%host_array_ptr)
257 if (
associated(this%device_array_ptr))
then
258 call this%device_array_ptr%free()
259 deallocate(this%device_array_ptr)
262 if (
associated(this%vector_ptr))
then
263 call this%vector_ptr%free()
264 deallocate(this%vector_ptr)
267 if (
associated(this%matrix_ptr))
then
268 call this%matrix_ptr%free()
269 deallocate(this%matrix_ptr)
272 if (
associated(this%field_ptr))
then
273 call this%field_ptr%free()
274 deallocate(this%field_ptr)
277 this%real_scalar = 0.0_rp
278 this%integer_scalar = 0
282 this%allocated = .false.
289 character(len=:),
allocatable :: name
290 name = trim(this%name)
296 character(len=:),
allocatable :: type
297 type = trim(this%type)
304 allocated = this%allocated
312 if (this%get_type() .ne.
'host_array')
then
313 call neko_error(
"registry_entry::get_host_array: " &
314 //
"Registry entry is not of type 'host_array'.")
316 host_array_ptr => this%host_array_ptr
323 if (this%get_type() .ne.
'device_array')
then
324 call neko_error(
"registry_entry::get_device_array: " &
325 //
"Registry entry is not of type 'device_array'.")
327 device_array_ptr => this%device_array_ptr
333 type(
vector_t),
pointer :: vector_ptr
334 if (this%get_type() .ne.
'vector')
then
335 call neko_error(
"registry_entry::get_vector: " &
336 //
"Registry entry is not of type 'vector'.")
338 vector_ptr => this%vector_ptr
344 type(
matrix_t),
pointer :: matrix_ptr
345 if (this%get_type() .ne.
'matrix')
then
346 call neko_error(
"registry_entry::get_field: " &
347 //
"Registry entry is not of type 'matrix'.")
349 matrix_ptr => this%matrix_ptr
355 type(
field_t),
pointer :: field_ptr
356 if (this%get_type() .ne.
'field')
then
357 call neko_error(
"registry_entry::get_field: " &
358 //
"Registry entry is not of type 'field'.")
360 field_ptr => this%field_ptr
366 real(kind=
rp),
pointer :: scalar_ptr
367 if (this%get_type() .ne.
'real_scalar')
then
368 call neko_error(
"registry_entry::get_real_scalar: " &
369 //
"Registry entry is not of type 'real_scalar'.")
371 scalar_ptr => this%real_scalar
377 integer,
pointer :: scalar_ptr
378 if (this%get_type() .ne.
'integer_scalar')
then
379 call neko_error(
"registry_entry::get_integer_scalar: " &
380 //
"Registry entry is not of type 'integer_scalar'.")
382 scalar_ptr => this%integer_scalar
390 if (.not. source%is_allocated())
return
393 this%name = source%name
394 this%type = source%type
395 this%allocated = source%allocated
397 select case (trim(this%type))
399 this%real_scalar = source%real_scalar
400 case (
'integer_scalar')
401 this%integer_scalar = source%integer_scalar
403 this%host_array_ptr => source%host_array_ptr
404 nullify(source%host_array_ptr)
405 case (
'device_array')
406 this%device_array_ptr => source%device_array_ptr
407 nullify(source%device_array_ptr)
409 this%vector_ptr => source%vector_ptr
410 nullify(source%vector_ptr)
412 this%matrix_ptr => source%matrix_ptr
413 nullify(source%matrix_ptr)
415 this%field_ptr => source%field_ptr
416 nullify(source%field_ptr)
418 call neko_error(
"move_from_registry_entry: " // &
419 "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.