Neko  0.8.1
A portable framework for high-order spectral element flow simulations
field_list.f90
Go to the documentation of this file.
1 module field_list
2  use field, only : field_ptr_t, field_t
3  implicit none
4  private
5 
7  type, public :: field_list_t
8  type(field_ptr_t), allocatable :: fields(:)
9  contains
11  procedure, pass(this) :: append => field_list_append
13  procedure, pass(this) :: free => field_list_free
14  end type field_list_t
15 
16 contains
19  subroutine field_list_append(this, f)
20  class(field_list_t), intent(inout) :: this
21  class(field_t), intent(in), target :: f
22  type(field_ptr_t), allocatable :: tmp(:)
23  integer :: len
24 
25  len = size(this%fields)
26 
27  allocate(tmp(len+1))
28  tmp(1:len) = this%fields
29  call move_alloc(tmp, this%fields)
30  this%fields(len+1)%f => f
31 
32  end subroutine field_list_append
33 
35  subroutine field_list_free(this)
36  class(field_list_t), intent(inout) :: this
37  integer :: i, n_fields
38 
39  if (allocated(this%fields)) then
40  n_fields = size(this%fields)
41  do i=1, n_fields
42  call this%fields(i)%f%free()
43  nullify(this%fields(i)%f)
44  end do
45  deallocate(this%fields)
46  end if
47 
48  end subroutine field_list_free
49 
50 
51 
52 end module field_list
subroutine field_list_free(this)
Destructor.
Definition: field_list.f90:36
subroutine field_list_append(this, f)
Append a field to the list.
Definition: field_list.f90:20
Defines a field.
Definition: field.f90:34
field_ptr_t, To easily obtain a pointer to a field
Definition: field.f90:80
field_list_t, To be able to group fields together
Definition: field_list.f90:7