# Wall Time ignored - I think I have a fix

**URL:** <https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378>\
**Category:** Atmosphere\
**Created:** [27 January 2023 02:38 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378 "2023-01-27T02:38:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![holger](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/holger/32/320_2.png) [@holger](https://forum.access-hive.org.au/u/holger)\
**Post date:** [27 January 2023 02:38 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/1 "2023-01-27T02:38:36Z")

</div>

Many versions of the ACCESS system using rose/cylc on gadi have an issue with the walltime. The Wallclock time in the rose interface expects an [ISO8601 Duration](https://en.wikipedia.org//wiki/ISO_8601#Durations) and will fail if it doesn’t receive this.

On the other hand, Gadi’s PBS system doesn’t understand this. This has lead to the workaround that the walltime is hardcoded in `site/nci_gadi.rc` and the Wallclock time setting being ignored. This is confusing.

I have tested adding this macro to the top of the `site/nci_gadi.rc` file:

```plaintext
{% macro evalclock(iso8601duration) -%}
     {% set hoursminssecs = iso8601duration.split("T")[1] -%}
     {% set hours = hoursminssecs.split("H")[0] | int -%}
     {% set mins = hoursminssecs.split("H")[1].split("M")[0] | int -%}
     {% set secs = hoursminssecs.split("H")[1].split("M")[1] | int -%}
     {{ [hours, mins, secs] | join(":") }}
{%- endmacro -%}

```

Then, in the section `[[ATMOS_RESOURCE]]` → `[[[directives]]]` I’ve added this line:

```plaintext
-l walltime = {{ evalclock(MAIN_CLOCK) }}

```

If you notice, it will ignore any value that refers to days or larger, but I haven’t seen any job requesting more than one day.

What do you think? Is there a better way? I’m a total newbie with jinja2

Holger

---

<div class="post-metadata">

**Author:** ![Aidan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/aidan/32/42_2.png) [@Aidan](https://forum.access-hive.org.au/u/Aidan)\
**Post date:** [27 January 2023 03:12 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/2 "2023-01-27T03:12:11Z")

</div>

> [@holger](#):
>
> What do you think? Is there a better way? I’m a total newbie with jinja2

Seems like a great idea @holger. I wonder if this (and other macros?) could be put in macro library in a public repo with some unit CI testing using something like [GitHub - cfpb/macropolo](https://github.com/cfpb/macropolo).

That would help with testing new functionality too.

---

<div class="post-metadata">

**Author:** ![holger](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/holger/32/320_2.png) [@holger](https://forum.access-hive.org.au/u/holger)\
**Post date:** [27 January 2023 04:28 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/3 "2023-01-27T04:28:26Z")

</div>

I just found a bug in this. If you don’t specify minutes, for example `PT2H` then it breaks. Back to the drawing board.

---

<div class="post-metadata">

**Author:** ![holger](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/holger/32/320_2.png) [@holger](https://forum.access-hive.org.au/u/holger)\
**Post date:** [27 January 2023 06:18 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/4 "2023-01-27T06:18:29Z")

</div>

My new version is more flexible, but very much longer. There must be a better way, but I don’t find a lot of documentation on jinja2, particularly on how to slice and dice strings. Anyway, here’s my new version, for who is interested. (Mind you, you still have to add the `-l walltime = {{ evalclock(MAIN_CLOCK) }}` in the relevant section:

```plaintext
{% macro evalclock(iso8601duration) -%}
    {% set duration = iso8601duration.split("P")[1] -%}
    {% set totalseconds = 0 -%}
    {% if "T" in duration -%}
        {% set days_and_more, hours_and_less = duration.split("T") -%}
        {% if "H" in hours_and_less -%}
            {% set hours, minutes_and_less = hours_and_less.split("H") -%}
            {% set totalseconds = (hours | int) * 60 * 60 -%}
        {% else -%}
            {% set minutes_and_less = hours_and_less -%}
        {% endif -%}
        {% if "M" in minutes_and_less -%}
            {% set minutes, seconds = minutes_and_less.split("M") -%}
            {% set totalseconds = totalseconds + (( minutes | int ) * 60 ) -%}
        {% else -%}
            {% set seconds = minutes_and_less -%}
        {% endif -%}
        {% if "S" in seconds -%}
            {% set totalseconds = totalseconds + ( seconds.split("S")[0] | int ) -%}
        {% endif -%}
    {% else -%}
        {% set days_and_more = duration -%}
    {% endif -%}
        {% if "W" in days_and_more -%}
        {% set totalseconds = (days_and_more.split("W")[0] | int) * 7 * 24 * 60 * 60 -%}
    {% else -%}
        {% if "Y" in days_and_more -%}
            {% set years, months_and_less = days_and_more.split("Y") -%}
            {% set totalseconds = totalseconds + ((years | int) * 365 * 24 * 60 * 60 ) -%}
        {% else -%}
            {% set months_and_less = days_and_more -%}
        {% endif -%}
        {% if "M" in months_and_less -%}
            {% set monts, days = months_and_less.split("M") -%}
            {% set totalseconds = totalseconds + (( months | int ) * 30 * 24 * 60 * 60 ) -%}
        {% else -%}
            {% set days = months_and_less -%}
        {% endif -%}
        {% if "D" in days -%}
            {% set totalseconds = totalseconds + (( days.split("D")[0] | int ) * 24 * 60 * 60 ) -%}
        {% endif -%}
    {% endif -%}
    {{ totalseconds }}

```

---

<div class="post-metadata">

**Author:** ![clairecarouge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/clairecarouge/32/380_2.png) [@clairecarouge](https://forum.access-hive.org.au/u/clairecarouge)\
**Post date:** [29 January 2023 21:41 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/5 "2023-01-29T21:41:42Z")

</div>

> [@holger](#):
>
> ```auto
> {% set monts, days = months_and_less.split("M") -%}
> 
> ```

Just replying to highlight a typo, it should be `set months` not `set monts`

---

<div class="post-metadata">

**Author:** ![Scott](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/scott/32/37_2.png) [@Scott](https://forum.access-hive.org.au/u/Scott)\
**Post date:** [29 January 2023 22:26 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/6 "2023-01-29T22:26:21Z")

</div>

If you give an ISO duration to [execution time limit](https://cylc.github.io/cylc-doc/7.9.3/html/appendices/suiterc-config-ref.html#runtime-name-job-execution-time-limit) then it will get automatically passed to `-l walltime` as a duration in seconds

---

<div class="post-metadata">

**Author:** ![holger](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.access-hive.org.au/holger/32/320_2.png) [@holger](https://forum.access-hive.org.au/u/holger)\
**Post date:** [30 January 2023 03:34 UTC](https://forum.access-hive.org.au/t/wall-time-ignored-i-think-i-have-a-fix/378/7 "2023-01-30T03:34:49Z")

</div>

@Scott It was more complex than that. That was the first thing I tried. But after your comment, I went back and tried one more thing:

I had seen that the section `[[HPC]]` → `[[[directives]]]` contained a setting

```plaintext
-l walltime = 1:00:00

```

and when I commented out that setting, the execution time limit was correctly set. No question that is much easier than my convoluted jinja2 macro.

Thank you for letting me check twice.

Cheers  
Holger
