<span class="target" id="index-0"></span><div class="section" id="operational-suite-solution">
<span id="operational-suite-soln"></span>
<p>One possible solution:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/env python2.7</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">ecflow</span>
<span class="n">defs</span> <span class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Defs</span><span class="p">()</span>
<span class="n">suite</span> <span class="o">=</span> <span class="n">defs</span><span class="o">.</span><span class="n">add_suite</span><span class="p">(</span><span class="s">"operation_suite"</span><span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_repeat</span><span class="p">(</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">RepeatDay</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_HOME"</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course"</span><span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_INCLUDE"</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course"</span><span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_FILES"</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course/oper"</span><span class="p">)</span>
<span class="c"># Defines the triggers for the first cycle</span>
<span class="n">cycle_triggers</span> <span class="o">=</span> <span class="s">"1"</span>
<span class="k">for</span> <span class="n">cycle</span> <span class="ow">in</span> <span class="p">(</span> <span class="mi">0</span> <span class="p">,</span> <span class="mi">12</span> <span class="p">):</span>
<span class="k">if</span> <span class="n">cycle</span> <span class="o">==</span> <span class="mi">12</span> <span class="p">:</span>
<span class="n">last_step</span> <span class="o">=</span> <span class="mi">240</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">last_step</span> <span class="o">=</span> <span class="mi">24</span>
<span class="n">fcycle_fam</span> <span class="o">=</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">cycle</span><span class="p">))</span>
<span class="n">fcycle_fam</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"CYCLE"</span><span class="p">,</span> <span class="n">cycle</span><span class="p">)</span>
<span class="n">fcycle_fam</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"LAST_STEP"</span><span class="p">,</span> <span class="n">last_step</span><span class="p">)</span>
<span class="k">if</span> <span class="n">cycle_triggers</span> <span class="o">!=</span> <span class="s">"1"</span> <span class="p">:</span>
<span class="n">fcycle_fam</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="n">cycle_triggers</span><span class="p">)</span>
<span class="n">analysis_fam</span> <span class="o">=</span> <span class="n">fcycle_fam</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span><span class="s">"analysis"</span><span class="p">)</span>
<span class="n">analysis_fam</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"get_observations"</span><span class="p">)</span>
<span class="n">analysis_fam</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"run_analysis"</span><span class="p">)</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"get_observations == complete"</span><span class="p">)</span>
<span class="n">analysis_fam</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"post_processing"</span><span class="p">)</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"run_analysis == complete"</span><span class="p">)</span>
<span class="n">forecast_fam</span> <span class="o">=</span> <span class="n">fcycle_fam</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span><span class="s">"forecast"</span><span class="p">)</span>
<span class="n">forecast_fam</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"analysis == complete"</span><span class="p">)</span>
<span class="n">forecast_fam</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"get_input_data"</span><span class="p">)</span>
<span class="n">run_forecast_task</span> <span class="o">=</span> <span class="n">forecast_fam</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"run_forecast"</span><span class="p">)</span>
<span class="n">run_forecast_task</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"get_input_data == complete"</span><span class="p">)</span>
<span class="n">run_forecast_task</span><span class="o">.</span><span class="n">add_meter</span><span class="p">(</span><span class="s">"step"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">last_step</span><span class="p">,</span> <span class="n">last_step</span><span class="p">)</span>
<span class="n">archive_fam</span> <span class="o">=</span> <span class="n">fcycle_fam</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span><span class="s">"archive"</span><span class="p">)</span>
<span class="n">fam_analsis</span> <span class="o">=</span> <span class="n">archive_fam</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span><span class="s">"analysis"</span><span class="p">)</span>
<span class="n">fam_analsis</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"TYPE"</span><span class="p">,</span><span class="s">"analysis"</span><span class="p">)</span>
<span class="n">fam_analsis</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"STEP"</span><span class="p">,</span><span class="s">"0"</span><span class="p">)</span>
<span class="n">fam_analsis</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"../analysis/run_analysis == complete"</span><span class="p">)</span>
<span class="n">fam_analsis</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"save"</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">6</span><span class="p">,</span> <span class="n">last_step</span><span class="p">,</span> <span class="mi">6</span><span class="p">):</span>
<span class="n">step_fam</span> <span class="o">=</span> <span class="n">fam_analsis</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span><span class="s">"step_"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
<span class="n">step_fam</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"TYPE"</span><span class="p">,</span> <span class="s">"forecast"</span><span class="p">)</span>
<span class="n">step_fam</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"STEP"</span><span class="p">,</span> <span class="n">i</span><span class="p">)</span>
<span class="n">step_fam</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"../../forecast/run_forecast:step ge "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
<span class="n">step_fam</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"save"</span><span class="p">)</span>
<span class="c"># Defines the triggers for the next cycle</span>
<span class="n">cycle_triggers</span> <span class="o">=</span> <span class="s">"./"</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">cycle</span><span class="p">)</span> <span class="o">+</span> <span class="s">" == complete"</span>
</pre></div>
</div>
</div>
|