The problem is, your TOTAL_MPI_TASKS is not defined as a Jinaj2 variable, it’s just a plain Cylc config item. So Jinja2 does not know about it when you try to print it out for the --ntasks bit.
Just as assign it to a Jinja2 variable, and and have Jinja2 print it to the file in both places,e.g.:
(Remember Jinja2 is a template processor. All the Jinja2 code in your flow.cylc has to “process out” first thing, to generate the actual valid Cylc workflow configuration. )
You can use Jinja2 to programmatically generate any text and print it anywhere in the file - so long as the resulting file (with Jinja2 processed out) is valid Cylc syntax.
Oh, hang on, I just saw that the value of CORES_PER_NUMA_REGION is a shell expression.
This is very different to Jinja2 code. Jinja2 code gets processed at start-up, when the flow.cylc is parsed.
Shell expressions are not processed at all by Cylc. They are printed verbatim to the job file, to be evaluated in the job environment at job run time!
If the final values you need are available at start-up (when flow.cylc is parsed) it’s probably better to use Jinja2, then you don’t have to wait till that particular job runs to find out if you got it wrong because the job environment is not what you thought.
ok cool, i think i get it! as this workflow progresses (it’s a beta climate LFRic one) there’ll be more stuff in the rose-suite.conf file to prevent having to do this anyway!