Opened 3 months ago

Closed 3 months ago

#3440 closed help (answered)

Cylc broadcast with random seed

Reported by: luciana Owned by: um_support
Component: Rose/Cylc Keywords: cylc broadcast, random seed
Cc: Platform: JASMIN
UM Version:

Description

Hello!

Happy new year! :)

I'm having a weird situation that I've seen before when using parallel programming. Because I'm not used to working with it, the answer might be simple, but I needed to ask.

Here is my suite:

—-
[scheduling]

initial cycle point = 20200810T00
final cycle point = 20200812T00

[ [dependencies] ]

[ [ [T00] ] ]

graph = """

broadcast-test ⇒ test

"""

[runtime]

[ [broadcast-test] ]

script = """

BROADCAST=$(($RANDOM%2))
echo "BROADCAST=$BROADCAST"
if [ [ $BROADCAST == 0 ] ]; then

cylc broadcast -n 'test' -s "[environment]VAR=0" "${CYLC_SUITE_NAME}"

else

cylc broadcast -n 'test' -s "[environment]VAR=1" "${CYLC_SUITE_NAME}"

fi

"""

[ [test] ]

script = "echo VAR = $VAR"

[ [ [environment] ] ]

VAR = 2

—-

I was expecting the variable VAR with the same value of the variable BROADCAST, but that doesn't happen. It seems that the current value of the variable BROADCAST is being used in the variable VAR when the task is called. That's not the behaviour that I was intending to achieve.

This example is in my directory, in /home/users/lucy/puma/random-test. The test /home/users/lucy/cylc-run/r2 shows something as follows:

—-
[lucy@cylc1 r2]$ cylc cat-log r2 broadcast-test.20200811T0000Z
Suite : r2
Task Job : 20200811T0000Z/broadcast-test/01 (try 1)
User@Host: lucy@…

BROADCAST=0
2021-01-02T01:09:14Z INFO - started
Broadcast set:
+ [test.*] [environment]VAR=0
2021-01-02T01:09:15Z INFO - succeeded
[lucy@cylc1 r2]$ cylc cat-log r2 test.20200811T0000Z
Suite : r2
Task Job : 20200811T0000Z/test/01 (try 1)
User@Host: lucy@…

VAR = 1
2021-01-02T01:09:18Z INFO - started
2021-01-02T01:09:19Z INFO - succeeded
—-

If this is the intended behaviour of the system, what do I have to do to achieve what I want?

Kind regards.

Luciana.

Change History (4)

comment:1 Changed 3 months ago by ros

Hi Luciana,

I think this might be because you've not set the suite to finish one cycle before the next starts.

When I set the graph to the following it works fine for me:

     [[[T00]]]
      graph = """
        broadcast-test => test
        test[-P1D] => broadcast-test
              """

My suite is: /home/users/rshatcher/cylc-suites/random-test

My output:

rshatcher@cylc1$ cylc cat-log -o random-test broadcast-test.20200810T0000Z
Suite    : random-test
Task Job : 20200810T0000Z/broadcast-test/01 (try 1)
User@Host: rshatcher@cylc1.jasmin.ac.uk

BROADCAST=1
BROADCAST is 1
2021-01-04T11:36:54Z INFO - started
Broadcast set:
+ [test.*] [environment]VAR=1
2021-01-04T11:36:55Z INFO - succeeded

rshatcher@cylc1$ cylc cat-log -o random-test test.20200810T0000Z
Suite    : random-test
Task Job : 20200810T0000Z/test/01 (try 1)
User@Host: rshatcher@cylc1.jasmin.ac.uk

RSH VAR = 1
2021-01-04T11:36:59Z INFO - started
2021-01-04T11:37:00Z INFO - succeeded

rshatcher@cylc1$ cylc cat-log -o random-test broadcast-test.20200811T0000Z
Suite    : random-test
Task Job : 20200811T0000Z/broadcast-test/01 (try 1)
User@Host: rshatcher@cylc1.jasmin.ac.uk

BROADCAST=0
BROADCAST is 0
2021-01-04T11:37:03Z INFO - started
Broadcast set:
+ [test.*] [environment]VAR=0
2021-01-04T11:37:04Z INFO - succeeded

rshatcher@cylc1$ cylc cat-log -o random-test test.20200811T0000Z
Suite    : random-test
Task Job : 20200811T0000Z/test/01 (try 1)
User@Host: rshatcher@cylc1.jasmin.ac.uk

RSH VAR = 0
2021-01-04T11:37:08Z INFO - started
2021-01-04T11:37:09Z INFO - succeeded

Regards,
Ros.

comment:2 Changed 3 months ago by ros

Just to add, broadcast by default broadcasts to all cycles.

If you need to be able to run multiple cycles concurrently, then you will have to specify the cycle in the broadcast command.

comment:3 Changed 3 months ago by luciana

Hi Ros.

Thank you for the quick (and simple!) answer. Your suggestion will do the job perfectly. :)

Kind regards.

Luciana.

comment:4 Changed 3 months ago by luciana

  • Resolution set to answered
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.