38  use json_module, 
only : json_file
 
   58     integer, 
private :: n_simcomps
 
   62     logical, 
private :: finalized = .false.
 
 
   93    type(
case_t), 
target, 
intent(inout) :: case
 
   94    character(len=*), 
optional, 
intent(in) :: simcomp_root
 
   95    integer :: n_simcomps, i
 
   96    type(json_file) :: comp_subdict
 
   99    logical, 
allocatable :: mask(:)
 
  101    integer, 
allocatable :: read_order(:), order(:)
 
  105    character(len=:), 
allocatable :: root_name, comp_type
 
  111    if (
present(simcomp_root)) 
then 
  112       root_name = simcomp_root
 
  114       root_name = 
'case.simulation_components' 
  118    if (.not. (root_name .in. 
case%params)) 
return 
  119    call neko_log%section(
'Initialize simcomp')
 
  122    call case%params%info(root_name, n_children = n_simcomps)
 
  123    this%n_simcomps = n_simcomps
 
  124    allocate(this%simcomps(n_simcomps))
 
  125    allocate(order(n_simcomps))
 
  126    allocate(read_order(n_simcomps))
 
  127    allocate(
mask(n_simcomps), source = .true.)
 
  137       if (read_order(i) .gt. max_order) 
then 
  138          max_order = read_order(i)
 
  145       if (read_order(i) == -1) 
then 
  146          max_order = max_order + 1
 
  147          read_order(i) = max_order
 
  155       loc = minloc(read_order, 
mask = 
mask)
 
  165       call json_get(comp_subdict, 
"type", comp_type)
 
  166       call neko_log%message(
'- ' // trim(comp_type))
 
  168       call simulation_component_factory(this%simcomps(i)%simcomp, &
 
  174    deallocate(read_order)
 
 
  185    if (
allocated(this%simcomps)) 
then 
  186       do i = 1, this%n_simcomps
 
  187          call this%simcomps(i)%simcomp%free
 
  189       deallocate(this%simcomps)
 
 
  199    type(json_file), 
intent(inout), 
optional :: settings
 
  202    integer :: i, position
 
  206    do i = 1, this%n_simcomps
 
  207       if (.not. 
allocated(this%simcomps(i)%simcomp)) 
then 
  214    if (position .eq. 0) 
then 
  215       if (this%n_simcomps .gt. 0) 
call move_alloc(this%simcomps, tmp_simcomps)
 
  216       allocate(this%simcomps(this%n_simcomps + 1))
 
  218       if (
allocated(tmp_simcomps)) 
then 
  219          do i = 1, this%n_simcomps
 
  220             call move_alloc(tmp_simcomps(i)%simcomp, this%simcomps(i)%simcomp)
 
  224       this%n_simcomps = this%n_simcomps + 1
 
  225       position = this%n_simcomps
 
  227       if (
allocated(tmp_simcomps)) 
deallocate(tmp_simcomps)
 
  230    this%simcomps(position)%simcomp = object
 
  231    if (
present(settings)) 
then 
  232       call this%simcomps(position)%simcomp%init(settings, this%case)
 
  235    this%finalized = .false.
 
 
  245    integer :: i, order, max_order
 
  246    logical :: order_found, previous_found
 
  249    integer, 
allocatable :: order_list(:)
 
  252    do i = 1, this%n_simcomps
 
  253       if (.not. 
allocated(this%simcomps(i)%simcomp)) 
then 
  254          call neko_error(
"Simulation component not initialized.")
 
  259    previous_found = .true.
 
  260    do order = 1, this%n_simcomps
 
  261       order_found = .false.
 
  262       do i = 1, this%n_simcomps
 
  263          if (this%simcomps(i)%simcomp%order == order .and. order_found) 
then 
  264             call neko_error(
"Simulation component order must be unique.")
 
  265          else if (this%simcomps(i)%simcomp%order == order) 
then 
  269       if (order_found .and. .not. previous_found) 
then 
  270          call neko_error(
"Simulation component order must be contiguous " // &
 
  273       previous_found = order_found
 
  276    allocate(order_list(this%n_simcomps))
 
  279    do i = 1, this%n_simcomps
 
  280       order_list(i) = this%simcomps(i)%simcomp%order
 
  281       if (order_list(i) .gt. max_order) 
then 
  282          max_order = order_list(i)
 
  286    do i = 1, this%n_simcomps
 
  287       if (order_list(i) .eq. -1) 
then 
  288          order_list(i) = max_order + 1
 
  289          max_order = max_order + 1
 
  294    do i = 1, this%n_simcomps
 
  295       if (order_list(i) .gt. this%n_simcomps) 
then 
  296          deallocate(order_list)
 
  297          call neko_error(
"Simulation component order is out of bounds.")
 
  302    call move_alloc(this%simcomps, tmp_simcomps)
 
  303    allocate(this%simcomps(this%n_simcomps))
 
  304    do i = 1, this%n_simcomps
 
  305       order = order_list(i)
 
  306       call move_alloc(tmp_simcomps(i)%simcomp, this%simcomps(order)%simcomp)
 
  309    if (
allocated(tmp_simcomps)) 
then 
  310       deallocate(tmp_simcomps)
 
  312    if (
allocated(order_list)) 
then 
  313       deallocate(order_list)
 
  316    this%finalized = .true.
 
 
  326    if (.not. this%finalized) 
call this%finalize()
 
  328    if (
allocated(this%simcomps)) 
then 
  329       do i = 1, 
size(this%simcomps)
 
  330          call this%simcomps(i)%simcomp%preprocess(time)
 
 
  343    if (.not. this%finalized) 
call this%finalize()
 
  345    if (
allocated(this%simcomps)) 
then 
  346       do i = 1, this%n_simcomps
 
  347          call this%simcomps(i)%simcomp%compute(time)
 
 
  360    if (
allocated(this%simcomps)) 
then 
  361       do i = 1, this%n_simcomps
 
  362          call this%simcomps(i)%simcomp%restart(time)
 
 
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
 
Retrieves a parameter by name or throws an error.
 
Defines a simulation case.
 
Utilities for retrieving parameters from the case files.
 
type(log_t), public neko_log
Global log stream.
 
Object for handling masks in Neko.
 
integer, parameter, public rp
Global precision used in computations.
 
Contains the simcomp_executor_t type.
 
subroutine simcomp_executor_restart(this, time)
Execute restart for all simcomps.
 
subroutine simcomp_executor_add(this, object, settings)
Appending a new simcomp to the executor.
 
subroutine simcomp_executor_compute(this, time)
Execute compute_ for all simcomps.
 
type(simcomp_executor_t), target, public neko_simcomps
Global variable for the simulation component driver.
 
subroutine simcomp_executor_finalize(this)
Finalize the initialization. Sorts the simcomps based on the order property. Additionally we check th...
 
subroutine simcomp_executor_init(this, case, simcomp_root)
Constructor.
 
pure integer function simcomp_executor_get_n(this)
Get the number of simcomps.
 
subroutine simcomp_executor_preprocess(this, time)
Execute preprocess_ for all simcomps.
 
subroutine simcomp_executor_free(this)
Destructor.
 
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
 
Module with things related to the simulation time.
 
Singleton type that serves as a driver for the simulation components. Stores all the components in th...
 
Base abstract class for simulation components.
 
A helper type that is needed to have an array of polymorphic objects.
 
A struct that contains all info about the time, expand as needed.