1313from typing import Union , Optional
1414
1515
16+ @add_run_method (DnoraFileType .INPUT )
1617@add_run_method (DnoraFileType .SPECTRA )
1718@add_run_method (DnoraFileType .ICE )
1819@add_run_method (DnoraFileType .WATERLEVEL )
@@ -38,10 +39,14 @@ def _get_default_format(self) -> str:
3839
3940 def __init__ (self , model , include_nest : bool = True ):
4041 self .model = model
41- if include_nest and model .nest () is not None :
42- self ._nest = self .__class__ (model .nest ())
43- else :
44- self ._nest = None
42+ self ._nest = {}
43+ if not self .model .parent ():
44+ msg .header (self , "Initializing model executer..." )
45+ msg .plain (f"Will execute '{ model .grid ().name } '" )
46+ if include_nest and model .nest ():
47+ for name , nest in self .model .nest (get_dict = True ).items ():
48+ msg .plain (f"Will execute '{ name } ' inside '{ model .grid ().name } '" )
49+ self ._nest [name ] = self .__class__ (nest )
4550
4651 def dry_run (self ) -> bool :
4752 return self ._dry_run or self .model .dry_run ()
@@ -118,28 +123,16 @@ def run_model(
118123 ** kwargs ,
119124 ):
120125 """Run the main model. Set post_process=False to disable any post-processing that might be defined."""
121- self ._run (
122- file_type = DnoraFileType .INPUT ,
126+
127+ # Use the method generated by the decorateor, since that will automatically go through all nested grids if present
128+ self .run_input (
123129 model_runner = model_runner ,
124130 model_folder = model_folder ,
125131 post_process = post_process ,
126132 dry_run = dry_run ,
127133 ** kwargs ,
128134 )
129135
130- nest = self ._nest
131-
132- while nest is not None :
133- nest ._run (
134- file_type = DnoraFileType .INPUT ,
135- model_runner = model_runner ,
136- model_folder = model_folder ,
137- post_process = post_process ,
138- dry_run = dry_run ,
139- ** kwargs ,
140- )
141- nest = nest ._nest
142-
143136 def _run (
144137 self ,
145138 file_type : Union [DnoraFileType , str ],
0 commit comments