@@ -21,10 +21,6 @@ multi-threaded way (`executor=ThreadedEx()`, the default), or in a distributed w
2121- `mapping`: a [`ModelMapping`](@ref) between MTG scales and models.
2222- `nsteps`: the number of time-steps to run, only needed if no meteo is given (else it is infered from it).
2323- `outputs`: the outputs to get in dynamic for each node type of the MTG.
24- - `multirate`: experimental feature flag enabling temporal stream-based input resolution for multiscale simulations.
25- Supports `HoldLast`, `Interpolate`, `Integrate`, and `Aggregate` policies.
26- In MTG multi-rate runs, non-sequential executors are currently downgraded to `SequentialEx()` with a warning.
27- Model timesteps shorter than the meteo base step are rejected (sub-step execution is currently unsupported).
2824- `return_requested_outputs`: when `true` in MTG multi-rate runs, return requested resampled outputs directly
2925 as second return value.
3026- `requested_outputs_sink`: sink used to materialize requested outputs when `return_requested_outputs=true`.
@@ -127,14 +123,6 @@ function _all_modellists_collection(object)
127123 return false
128124end
129125
130- function _error_if_multirate_singlescale (multirate)
131- multirate || return nothing
132- error (
133- " `multirate=true` is only supported for MTG-based multiscale runs. " ,
134- " For one scale, build a one-scale MTG and call `run!(mtg, mapping, ...; multirate=true)`."
135- )
136- end
137-
138126_single_scale_runtime_object (object) = object
139127_single_scale_runtime_object (mapping:: ModelMapping ) = _modellist_from_model_mapping (mapping)
140128
@@ -156,7 +144,6 @@ function run!(
156144 tracked_outputs= nothing ,
157145 check= true ,
158146 executor= ThreadedEx (),
159- multirate= false ,
160147 return_requested_outputs= false ,
161148 requested_outputs_sink= DataFrames. DataFrame
162149) where {M<: Union{ModelMapping{SingleScale},ModelList} }
@@ -182,7 +169,6 @@ function run!(
182169 tracked_outputs= nothing ,
183170 check= true ,
184171 executor= ThreadedEx (),
185- multirate= false ,
186172 return_requested_outputs= false ,
187173 requested_outputs_sink= DataFrames. DataFrame
188174)
@@ -200,7 +186,6 @@ function run!(
200186 tracked_outputs= nothing ,
201187 check= true ,
202188 executor= ThreadedEx (),
203- multirate= false ,
204189 return_requested_outputs= false ,
205190 requested_outputs_sink= DataFrames. DataFrame
206191)
@@ -214,7 +199,6 @@ function run!(
214199 tracked_outputs,
215200 check,
216201 executor,
217- multirate,
218202 return_requested_outputs,
219203 requested_outputs_sink
220204 )
@@ -260,11 +244,9 @@ function run!(
260244 tracked_outputs= nothing ,
261245 check= true ,
262246 executor= ThreadedEx (),
263- multirate= false ,
264247 return_requested_outputs= false ,
265248 requested_outputs_sink= DataFrames. DataFrame
266249) where {T<: Union{AbstractArray,AbstractDict} ,A}
267- _error_if_multirate_singlescale (multirate)
268250 if _all_modellists_collection (object)
269251 Base. depwarn (
270252 " `run!` with a collection of `ModelList` is deprecated. Use a collection of `ModelMapping` objects instead." ,
@@ -288,9 +270,9 @@ function run!(
288270 for obj in object
289271
290272 if isa (object, AbstractArray)
291- push! (outputs_collection, run! (obj, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor, multirate = multirate ))
273+ push! (outputs_collection, run! (obj, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor))
292274 else
293- outputs_collection[obj. first] = run! (obj. second, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor, multirate = multirate )
275+ outputs_collection[obj. first] = run! (obj. second, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor)
294276 end
295277
296278 end
@@ -308,11 +290,9 @@ function run!(
308290 tracked_outputs= nothing ,
309291 check= true ,
310292 executor= ThreadedEx (),
311- multirate= false ,
312293 return_requested_outputs= false ,
313294 requested_outputs_sink= DataFrames. DataFrame
314295) where {T<: ModelList }
315- _error_if_multirate_singlescale (multirate)
316296 Base. depwarn (
317297 " `run!(::ModelList, ...)` is deprecated. Use `run!(ModelMapping(...), ...)` instead." ,
318298 :run!
@@ -338,11 +318,9 @@ function run!(
338318 tracked_outputs= nothing ,
339319 check= true ,
340320 executor= ThreadedEx (),
341- multirate= false ,
342321 return_requested_outputs= false ,
343322 requested_outputs_sink= DataFrames. DataFrame
344323) where {T<: ModelMapping{SingleScale} }
345- _error_if_multirate_singlescale (multirate)
346324 model_list = _modellist_from_model_mapping (object)
347325
348326 _run_modellist_singleton (
@@ -461,11 +439,9 @@ function run!(
461439 tracked_outputs= nothing ,
462440 check= true ,
463441 executor= ThreadedEx (),
464- multirate= false ,
465442 return_requested_outputs= false ,
466443 requested_outputs_sink= DataFrames. DataFrame
467444) where {T<: Union{AbstractArray,AbstractDict} }
468- _error_if_multirate_singlescale (multirate)
469445 if _all_modellists_collection (object)
470446 Base. depwarn (
471447 " `run!` with a collection of `ModelList` is deprecated. Use a collection of `ModelMapping` objects instead." ,
@@ -508,9 +484,9 @@ function run!(
508484 # Each object:
509485 for obj in object
510486 if isa (object, AbstractArray)
511- push! (outputs_collection, run! (obj, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor, multirate = multirate ))
487+ push! (outputs_collection, run! (obj, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor))
512488 else
513- outputs_collection[obj. first] = run! (obj. second, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor, multirate = multirate )
489+ outputs_collection[obj. first] = run! (obj. second, meteo, constants, extra, tracked_outputs= tracked_outputs, check= check, executor= executor)
514490 end
515491
516492 end
@@ -675,14 +651,13 @@ function run!(
675651 tracked_outputs= nothing ,
676652 check= true ,
677653 executor= ThreadedEx (),
678- multirate= false ,
679654 return_requested_outputs= false ,
680655 requested_outputs_sink= DataFrames. DataFrame
681656)
682657 _validate_meteo_duration (meteo)
683658 effective_multirate = _effective_multirate (mapping)
684659 isnothing (nsteps) && (nsteps = get_nsteps (meteo))
685- meteo_adjusted = if multirate && meteo isa TimeStepTable{<: Atmosphere }
660+ meteo_adjusted = if effective_multirate && meteo isa TimeStepTable{<: Atmosphere }
686661 # Keep TimeStepTable intact in MTG multi-rate runs so model-clock meteo
687662 # sampling/aggregation can use PlantMeteo sampler APIs.
688663 meteo
@@ -692,8 +667,8 @@ function run!(
692667 adjust_weather_timesteps_to_given_length (nsteps, meteo)
693668 end
694669 status_outputs, output_requests = _multirate_tracked_outputs (tracked_outputs)
695- ! multirate && ! isempty (output_requests) && error (" `OutputRequest` requires ` multirate=true `." )
696- return_requested_outputs && ! multirate && error (" `return_requested_outputs=true` requires ` multirate=true `." )
670+ ! effective_multirate && ! isempty (output_requests) && error (" `OutputRequest` requires a multirate `ModelMapping `." )
671+ return_requested_outputs && ! effective_multirate && error (" `return_requested_outputs=true` requires a multirate `ModelMapping `." )
697672
698673 # NOTE : replace_mapping_status_vectors_with_generated_models is assumed to have already run if used
699674 # otherwise there might be vector length conflicts with timesteps
@@ -705,7 +680,6 @@ function run!(
705680 extra;
706681 check= check,
707682 executor= executor,
708- multirate= multirate,
709683 tracked_outputs= output_requests,
710684 return_requested_outputs= return_requested_outputs,
711685 requested_outputs_sink= requested_outputs_sink
@@ -728,7 +702,6 @@ function run!(
728702 tracked_outputs= nothing ,
729703 check= true ,
730704 executor= ThreadedEx (),
731- multirate= false ,
732705 return_requested_outputs= false ,
733706 requested_outputs_sink= DataFrames. DataFrame
734707)
@@ -746,7 +719,6 @@ function run!(
746719 tracked_outputs= tracked_outputs,
747720 check= check,
748721 executor= executor,
749- multirate= multirate,
750722 return_requested_outputs= return_requested_outputs,
751723 requested_outputs_sink= requested_outputs_sink
752724 )
@@ -761,11 +733,11 @@ function run!(
761733 tracked_outputs= nothing ,
762734 check= true ,
763735 executor= ThreadedEx (),
764- multirate= false ,
765736 return_requested_outputs= false ,
766737 requested_outputs_sink= DataFrames. DataFrame
767738)
768739
740+ effective_multirate = _effective_multirate (object)
769741 dep_graph = object. dependency_graph
770742 models = get_models (object)
771743 _validate_meteo_duration (meteo)
@@ -774,7 +746,7 @@ function run!(
774746 runtime_clock_rows = effective_multirate ? _runtime_clock_rows (object, timeline, dep_graph) : NamedTuple[]
775747 effective_executor = executor
776748 # st = status(object)
777- if multirate
749+ if effective_multirate
778750 if executor != SequentialEx ()
779751 @warn string (
780752 " Multi-rate MTG runs currently execute sequentially. " ,
@@ -789,7 +761,7 @@ function run!(
789761 prepare_output_requests! (object, tracked_outputs, timeline)
790762 configure_temporal_buffers! (object, timeline)
791763 elseif return_requested_outputs
792- error (" `return_requested_outputs=true` requires ` multirate=true `." )
764+ error (" `return_requested_outputs=true` requires a multirate `ModelMapping `." )
793765 end
794766
795767 ! isnothing (extra) && error (" Extra parameters are not allowed for the simulation of an MTG (already used for statuses)." )
@@ -800,17 +772,17 @@ function run!(
800772 if nsteps == 1
801773 roots = collect (dep_graph. roots)
802774 for (process_key, dependency_node) in roots
803- run_node_multiscale! (object, dependency_node, 1 , models, meteo, constants, object, check, effective_executor, multirate , timeline, meteo_sampler)
775+ run_node_multiscale! (object, dependency_node, 1 , models, meteo, constants, object, check, effective_executor, effective_multirate , timeline, meteo_sampler)
804776 end
805- multirate && update_requested_outputs! (object, _time_from_step (1 , timeline))
777+ effective_multirate && update_requested_outputs! (object, _time_from_step (1 , timeline))
806778 save_results! (object, 1 )
807779 else
808780 for (i, meteo_i) in enumerate (Tables. rows (meteo))
809781 roots = collect (dep_graph. roots)
810782 for (process_key, dependency_node) in roots
811- run_node_multiscale! (object, dependency_node, i, models, meteo_i, constants, object, check, effective_executor, multirate , timeline, meteo_sampler)
783+ run_node_multiscale! (object, dependency_node, i, models, meteo_i, constants, object, check, effective_executor, effective_multirate , timeline, meteo_sampler)
812784 end
813- multirate && update_requested_outputs! (object, _time_from_step (i, timeline))
785+ effective_multirate && update_requested_outputs! (object, _time_from_step (i, timeline))
814786 # At the end of the time-step, we save the results of the simulation in the object:
815787 save_results! (object, i)
816788 end
0 commit comments