optimize order of execution/read-in for memory
The order of execution for each effective parameter and thus its input fields needs to be optimized for memory. The possibility of having "intermediate" effective parameters (e.g. van Genuchten parameters) needs to be taken into account. The implementation needs to iterate over effective parameters in the optimal order and read the input fields only when needed (and optionally release them from memory asap).
The way to do it, is to assign a reference counter and its total references to each input_field and effective_parameter. Once the type is referenced in a transfer function, the counter is increased. If the counter reaches the total, the type may be deallocated from memory.
To do this, implement #3 (closed) first.
The order of execution of the effective parameters in the main loop needs to be determined by a path walk along the dependency trajectories:
- for each input_field and effective_parameter, set a total_refs and ref_counter to 0,
- init eff_param_index_list, eff_param_counter, current_param
- use an effective parameter only dependent on input_fields as current_param, loop over all eff_param
- add current_param to eff_param_index_list
- increment each parents ref counter, set used_since in each parent and self to eff_param_counter
- for each parent, check if ref counter equals total_refs, set used_until to eff_param_counter
- init n_remain_param_depend, n_remain_param_depend, additional_parents_needed
- search next remaining effparam, loop over them
- if param has same or subset of dependencies: set as current_param, increment eff_param_counter and cycle main loop
- else: set n_remain_param_depend to additional_parents_needed
- if self has a child: then use this as new current_param, increment eff_param_counter and cycle main loop
- else: use effparam with lowest n_remain_param_depend as new current_param, increment eff_param_counter