Skip to content

Commit 8de3655

Browse files
Fixing cases in which the number starts with 0 and is considered base 8
1 parent 0aee2a3 commit 8de3655

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

DATA/production/common/setVarsFromALIEN_PROC_ID.sh

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@
33
# Script to set a couple of variables that depend on ALIEN_PROC_ID.
44
# Since several scripts might need this, it is in a separate script.
55

6-
# let's get the last 10 (for INT) and 5 (for int16) digits of ALIEN_PROC_ID, to be passed to define NUMAID and shm-segment-id via O2JOBID, which are int and int16 respectively. Then we make them an int or int16
7-
ALIEN_PROC_ID_MAX_NDIGITS_INT32=10
8-
ALIEN_PROC_ID_MAX_NDIGITS_INT16=9
9-
ALIEN_PROC_ID_LENTGH=`echo $ALIEN_PROC_ID | wc -l`
10-
ALIEN_PROC_ID_OFFSET_INT32=$((ALIEN_PROC_ID_LENTGH - ALIEN_PROC_ID_MAX_NDIGITS_INT32))
11-
ALIEN_PROC_ID_OFFSET_INT16=$((ALIEN_PROC_ID_LENTGH - ALIEN_PROC_ID_MAX_NDIGITS_INT16))
12-
# lets's take the last 10 (int) or 5 (int16) digits
13-
ALIEN_PROC_ID_OFFSET_INT32=${ALIEN_PROC_ID:$((ALIEN_PROC_ID_OFFSET_INT32))}
14-
ALIEN_PROC_ID_OFFSET_INT16=${ALIEN_PROC_ID:$((ALIEN_PROC_ID_OFFSET_INT16))}
6+
# let's get the last 9 (for int) and 8 (for int16) digits of ALIEN_PROC_ID, to be passed to define NUMAID and shm-segment-id via O2JOBID, which are int and int16 respectively. Then we make them an int or int16
7+
ALIEN_PROC_ID_MAX_NDIGITS_INT32=9
8+
ALIEN_PROC_ID_MAX_NDIGITS_INT16=8
9+
echo "ALIEN_PROC_ID for current job = ${ALIEN_PROC_ID}"
10+
11+
if [[ -n ${ALIEN_JDL_PACKAGES} ]] && [[ ${#ALIEN_PROC_ID} -lt ${ALIEN_PROC_ID_MAX_NDIGITS_INT32} ]]; then # we are on the grid, and we expect to have the PROC_ID
12+
echo "We cannot determine O2JOBID, the job id is too short (${ALIEN_PROC_ID}), we need at least ${ALIEN_PROC_ID_MAX_NDIGITS_INT32} digits, returning error"
13+
exit 2
14+
fi
15+
16+
ALIEN_PROC_ID_OFFSET_INT32=$((10#${ALIEN_PROC_ID: -${ALIEN_PROC_ID_MAX_NDIGITS_INT32}}))
17+
echo "ALIEN_PROC_ID_OFFSET_INT32 = $ALIEN_PROC_ID_OFFSET_INT32"
18+
19+
ALIEN_PROC_ID_OFFSET_INT16=$((10#${ALIEN_PROC_ID: -${ALIEN_PROC_ID_MAX_NDIGITS_INT16}}))
20+
echo "ALIEN_PROC_ID_OFFSET_INT16 = $ALIEN_PROC_ID_OFFSET_INT16"
21+
1522
# let's make them int32 or int16, but not with the max possible value (which would be 0x7fffffff and 0x7fff respectively)
1623
# but a bit less, to allow to add [0, 15] on top afterwards if needed (e.g. we usually add
1724
# the NUMAID), see https://github.com/AliceO2Group/O2DPG/pull/993#pullrequestreview-1393401475
1825
export O2JOBID=$(((ALIEN_PROC_ID_OFFSET_INT32 & 0x7ffffff) * 16))
1926
export O2JOBSHMID=$(((ALIEN_PROC_ID_OFFSET_INT16 & 0x7ff) * 16))
20-
echo "ALIEN_PROC_ID = $ALIEN_PROC_ID, we will set O2JOBID = $O2JOBID, SHMEMID = $SHMEMID"
27+
echo "ALIEN_PROC_ID = $ALIEN_PROC_ID, we will set O2JOBID = $O2JOBID, SHMEMID = $O2JOBSHMID"

0 commit comments

Comments
 (0)